summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/simpleini/SimpleIni.h46
-rw-r--r--src/CBot/CBotString.cpp21
-rw-r--r--src/CMakeLists.txt198
-rw-r--r--src/app/app.cpp541
-rw-r--r--src/app/app.h171
-rw-r--r--src/app/main.cpp7
-rw-r--r--src/app/system_windows.h8
-rw-r--r--src/common/error_ids.h5
-rw-r--r--src/common/event.cpp10
-rw-r--r--src/common/event.h196
-rw-r--r--src/common/event_ids.h8
-rw-r--r--src/common/global.h141
-rw-r--r--src/common/image.cpp142
-rw-r--r--src/common/image.h22
-rw-r--r--src/common/iman.cpp136
-rw-r--r--src/common/iman.h108
-rw-r--r--src/common/ioutils.h5
-rw-r--r--src/common/key.h26
-rw-r--r--src/common/language.h54
-rw-r--r--src/common/logger.h14
-rw-r--r--src/common/metafile.cpp28
-rw-r--r--src/common/misc.cpp332
-rw-r--r--src/common/misc.h71
-rw-r--r--src/common/profile.cpp5
-rw-r--r--src/common/profile.h19
-rw-r--r--src/common/restext.cpp89
-rw-r--r--src/common/restext.h32
-rw-r--r--src/common/restext_ids.h3
-rw-r--r--src/common/restext_strings.c63
-rw-r--r--src/common/singleton.h5
-rw-r--r--src/common/stringutils.h5
-rw-r--r--src/common/struct.h54
-rw-r--r--src/common/test/CMakeLists.txt2
-rw-r--r--src/common/test/image_test.cpp23
-rw-r--r--src/graphics/core/light.h1
-rw-r--r--src/graphics/engine/camera.cpp100
-rw-r--r--src/graphics/engine/camera.h6
-rw-r--r--src/graphics/engine/engine.cpp197
-rw-r--r--src/graphics/engine/engine.h21
-rw-r--r--src/graphics/engine/lightning.h2
-rw-r--r--src/graphics/engine/particle.cpp2
-rw-r--r--src/graphics/engine/particle.h2
-rw-r--r--src/graphics/engine/pyro.h3
-rw-r--r--src/graphics/engine/text.cpp14
-rw-r--r--src/graphics/opengl/gldevice.cpp65
-rw-r--r--src/math/all.h2
-rw-r--r--src/math/const.h1
-rw-r--r--src/math/conv.h39
-rw-r--r--src/math/geometry.h176
-rw-r--r--src/math/matrix.h73
-rw-r--r--src/math/point.h16
-rw-r--r--src/math/test/CMakeLists.txt40
-rw-r--r--src/math/test/geometry_test.cpp84
-rw-r--r--src/math/test/matrix_test.cpp124
-rw-r--r--src/math/test/vector_test.cpp76
-rw-r--r--src/math/vector.h45
-rw-r--r--src/object/auto/auto.cpp125
-rw-r--r--src/object/auto/auto.h75
-rw-r--r--src/object/auto/autobase.cpp299
-rw-r--r--src/object/auto/autobase.h27
-rw-r--r--src/object/auto/autoconvert.cpp76
-rw-r--r--src/object/auto/autoconvert.h5
-rw-r--r--src/object/auto/autoderrick.cpp134
-rw-r--r--src/object/auto/autoderrick.h5
-rw-r--r--src/object/auto/autodestroyer.cpp64
-rw-r--r--src/object/auto/autodestroyer.h5
-rw-r--r--src/object/auto/autoegg.cpp40
-rw-r--r--src/object/auto/autoegg.h3
-rw-r--r--src/object/auto/autoenergy.cpp141
-rw-r--r--src/object/auto/autoenergy.h5
-rw-r--r--src/object/auto/autofactory.cpp146
-rw-r--r--src/object/auto/autofactory.h5
-rw-r--r--src/object/auto/autoflag.cpp19
-rw-r--r--src/object/auto/autoflag.h3
-rw-r--r--src/object/auto/autohuston.cpp63
-rw-r--r--src/object/auto/autohuston.h15
-rw-r--r--src/object/auto/autoinfo.cpp94
-rw-r--r--src/object/auto/autoinfo.h5
-rw-r--r--src/object/auto/autojostle.cpp11
-rw-r--r--src/object/auto/autojostle.h3
-rw-r--r--src/object/auto/autokid.cpp46
-rw-r--r--src/object/auto/autokid.h5
-rw-r--r--src/object/auto/autolabo.cpp109
-rw-r--r--src/object/auto/autolabo.h13
-rw-r--r--src/object/auto/automush.cpp49
-rw-r--r--src/object/auto/automush.h5
-rw-r--r--src/object/auto/autonest.cpp38
-rw-r--r--src/object/auto/autonest.h7
-rw-r--r--src/object/auto/autonuclear.cpp79
-rw-r--r--src/object/auto/autonuclear.h5
-rw-r--r--src/object/auto/autopara.cpp73
-rw-r--r--src/object/auto/autopara.h9
-rw-r--r--src/object/auto/autoportico.cpp64
-rw-r--r--src/object/auto/autoportico.h5
-rw-r--r--src/object/auto/autoradar.cpp61
-rw-r--r--src/object/auto/autoradar.h5
-rw-r--r--src/object/auto/autorepair.cpp58
-rw-r--r--src/object/auto/autorepair.h5
-rw-r--r--src/object/auto/autoresearch.cpp126
-rw-r--r--src/object/auto/autoresearch.h13
-rw-r--r--src/object/auto/autoroot.cpp28
-rw-r--r--src/object/auto/autoroot.h5
-rw-r--r--src/object/auto/autosafe.cpp106
-rw-r--r--src/object/auto/autosafe.h5
-rw-r--r--src/object/auto/autostation.cpp89
-rw-r--r--src/object/auto/autostation.h5
-rw-r--r--src/object/auto/autotower.cpp103
-rw-r--r--src/object/auto/autotower.h5
-rw-r--r--src/object/brain.cpp590
-rw-r--r--src/object/brain.h169
-rw-r--r--src/object/mainmovie.cpp34
-rw-r--r--src/object/mainmovie.h39
-rw-r--r--src/object/motion/motion.cpp49
-rw-r--r--src/object/motion/motion.h74
-rw-r--r--src/object/motion/motionant.cpp146
-rw-r--r--src/object/motion/motionant.h2
-rw-r--r--src/object/motion/motionbee.cpp94
-rw-r--r--src/object/motion/motionhuman.cpp315
-rw-r--r--src/object/motion/motionmother.cpp72
-rw-r--r--src/object/motion/motionspider.cpp128
-rw-r--r--src/object/motion/motionspider.h2
-rw-r--r--src/object/motion/motiontoto.cpp120
-rw-r--r--src/object/motion/motiontoto.h2
-rw-r--r--src/object/motion/motionvehicle.cpp354
-rw-r--r--src/object/motion/motionvehicle.h6
-rw-r--r--src/object/motion/motionworm.cpp68
-rw-r--r--src/object/motion/motionworm.h4
-rw-r--r--src/object/object.cpp1418
-rw-r--r--src/object/object.h132
-rw-r--r--src/object/robotmain.cpp5287
-rw-r--r--src/object/robotmain.h423
-rw-r--r--src/object/task/task.cpp26
-rw-r--r--src/object/task/task.h53
-rw-r--r--src/object/task/taskadvance.cpp19
-rw-r--r--src/object/task/taskbuild.cpp210
-rw-r--r--src/object/task/taskbuild.h36
-rw-r--r--src/object/task/taskfire.cpp77
-rw-r--r--src/object/task/taskfire.h2
-rw-r--r--src/object/task/taskfireant.cpp35
-rw-r--r--src/object/task/taskfireant.h2
-rw-r--r--src/object/task/taskflag.cpp80
-rw-r--r--src/object/task/taskgoto.cpp453
-rw-r--r--src/object/task/taskgungoal.cpp19
-rw-r--r--src/object/task/taskinfo.cpp57
-rw-r--r--src/object/task/taskinfo.h2
-rw-r--r--src/object/task/taskmanager.cpp44
-rw-r--r--src/object/task/taskmanager.h2
-rw-r--r--src/object/task/taskmanip.cpp255
-rw-r--r--src/object/task/taskpen.cpp49
-rw-r--r--src/object/task/taskpen.h4
-rw-r--r--src/object/task/taskrecover.cpp74
-rw-r--r--src/object/task/taskrecover.h4
-rw-r--r--src/object/task/taskreset.cpp57
-rw-r--r--src/object/task/taskreset.h2
-rw-r--r--src/object/task/tasksearch.cpp69
-rw-r--r--src/object/task/tasksearch.h2
-rw-r--r--src/object/task/taskshield.cpp171
-rw-r--r--src/object/task/taskshield.h6
-rw-r--r--src/object/task/taskspiderexplo.cpp19
-rw-r--r--src/object/task/tasktake.cpp127
-rw-r--r--src/object/task/tasktake.h3
-rw-r--r--src/object/task/taskterraform.cpp90
-rw-r--r--src/object/task/taskterraform.h4
-rw-r--r--src/object/task/taskturn.cpp21
-rw-r--r--src/object/task/taskwait.cpp13
-rw-r--r--src/physics/physics.cpp826
-rw-r--r--src/physics/physics.h59
-rw-r--r--src/plugins/plugininterface.h8
-rw-r--r--src/po/de.po101
-rw-r--r--src/po/fr.po101
-rw-r--r--src/po/pl.po114
-rw-r--r--src/script/cbottoken.cpp23
-rw-r--r--src/script/cbottoken.h10
-rw-r--r--src/script/cmdtoken.cpp161
-rw-r--r--src/script/cmdtoken.h56
-rw-r--r--src/script/script.cpp1221
-rw-r--r--src/script/script.h178
-rw-r--r--src/sound/sound.h70
-rw-r--r--src/ui/button.cpp94
-rw-r--r--src/ui/button.h45
-rw-r--r--src/ui/check.cpp54
-rw-r--r--src/ui/check.h32
-rw-r--r--src/ui/color.cpp137
-rw-r--r--src/ui/color.h49
-rw-r--r--src/ui/compass.cpp109
-rw-r--r--src/ui/compass.h38
-rw-r--r--src/ui/control.cpp475
-rw-r--r--src/ui/control.h241
-rw-r--r--src/ui/displayinfo.cpp467
-rw-r--r--src/ui/displayinfo.h137
-rw-r--r--src/ui/displaytext.cpp190
-rw-r--r--src/ui/displaytext.h45
-rw-r--r--src/ui/edit.cpp763
-rw-r--r--src/ui/edit.h149
-rw-r--r--src/ui/editvalue.cpp117
-rw-r--r--src/ui/editvalue.h41
-rw-r--r--src/ui/gauge.cpp72
-rw-r--r--src/ui/gauge.h33
-rw-r--r--src/ui/group.cpp487
-rw-r--r--src/ui/group.h13
-rw-r--r--src/ui/image.cpp58
-rw-r--r--src/ui/image.h17
-rw-r--r--src/ui/interface.cpp543
-rw-r--r--src/ui/interface.h133
-rw-r--r--src/ui/key.cpp195
-rw-r--r--src/ui/key.h39
-rw-r--r--src/ui/label.cpp45
-rw-r--r--src/ui/label.h25
-rw-r--r--src/ui/list.cpp664
-rw-r--r--src/ui/list.h122
-rw-r--r--src/ui/maindialog.cpp1768
-rw-r--r--src/ui/maindialog.h123
-rw-r--r--src/ui/mainmap.cpp261
-rw-r--r--src/ui/mainmap.h72
-rw-r--r--src/ui/mainshort.cpp92
-rw-r--r--src/ui/mainshort.h63
-rw-r--r--src/ui/map.cpp432
-rw-r--r--src/ui/map.h160
-rw-r--r--src/ui/scroll.cpp108
-rw-r--r--src/ui/scroll.h70
-rw-r--r--src/ui/shortcut.cpp70
-rw-r--r--src/ui/shortcut.h28
-rw-r--r--src/ui/slider.cpp115
-rw-r--r--src/ui/slider.h75
-rw-r--r--src/ui/studio.cpp585
-rw-r--r--src/ui/studio.h144
-rw-r--r--src/ui/target.cpp80
-rw-r--r--src/ui/target.h33
-rw-r--r--src/ui/window.cpp393
-rw-r--r--src/ui/window.h123
230 files changed, 15088 insertions, 16047 deletions
diff --git a/lib/simpleini/SimpleIni.h b/lib/simpleini/SimpleIni.h
index f9f36bb..c75408e 100644
--- a/lib/simpleini/SimpleIni.h
+++ b/lib/simpleini/SimpleIni.h
@@ -422,7 +422,7 @@ public:
}
bool ConvertToStore(const SI_CHAR * a_pszString) {
size_t uLen = SizeToStore(a_pszString);
- if (uLen == (size_t)(-1)) {
+ if (uLen == static_cast<size_t>(-1)) {
return false;
}
while (uLen > m_scratch.size()) {
@@ -1360,7 +1360,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadFile(
}
fseek(a_fpFile, 0, SEEK_SET);
size_t uRead = fread(pData, sizeof(char), lSize, a_fpFile);
- if (uRead != (size_t) lSize) {
+ if (uRead != static_cast<size_t>(lSize)) {
delete[] pData;
return SI_FILE;
}
@@ -1394,7 +1394,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadData(
// determine the length of the converted data
size_t uLen = converter.SizeFromStore(a_pData, a_uDataLen);
- if (uLen == (size_t)(-1)) {
+ if (uLen == static_cast<size_t>(-1)) {
return SI_FAIL;
}
@@ -1753,7 +1753,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadMultiLineText(
// move this line down to the location that it should be if necessary
if (pDataLine < pCurrLine) {
- size_t nLen = (size_t) (a_pData - pCurrLine);
+ size_t nLen = static_cast<size_t> (a_pData - pCurrLine);
memmove(pDataLine, pCurrLine, nLen * sizeof(SI_CHAR));
pDataLine[nLen] = '\0';
}
@@ -1816,10 +1816,10 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::CopyString(
{
size_t uLen = 0;
if (sizeof(SI_CHAR) == sizeof(char)) {
- uLen = strlen((const char *)a_pString);
+ uLen = strlen(static_cast<const char *>(a_pString));
}
else if (sizeof(SI_CHAR) == sizeof(wchar_t)) {
- uLen = wcslen((const wchar_t *)a_pString);
+ uLen = wcslen(reinterpret_cast<const wchar_t *>(a_pString));
}
else {
for ( ; a_pString[uLen]; ++uLen) /*loop*/ ;
@@ -2225,7 +2225,7 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::GetSectionSize(
// if multi-key isn't permitted then the section size is
// the number of keys that we have.
if (!m_bAllowMultiKey || section.empty()) {
- return (int) section.size();
+ return static_cast<int> (section.size());
}
// otherwise we need to count them
@@ -2626,7 +2626,7 @@ struct SI_GenericCase {
bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const {
long cmp;
for ( ;*pLeft && *pRight; ++pLeft, ++pRight) {
- cmp = (long) *pLeft - (long) *pRight;
+ cmp = static_cast<long> (*pLeft) - static_cast<long> (*pRight);
if (cmp != 0) {
return cmp < 0;
}
@@ -2649,7 +2649,7 @@ struct SI_GenericNoCase {
bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const {
long cmp;
for ( ;*pLeft && *pRight; ++pLeft, ++pRight) {
- cmp = (long) locase(*pLeft) - (long) locase(*pRight);
+ cmp = static_cast<long> (locase(*pLeft)) - static_cast<long> (locase(*pRight));
if (cmp != 0) {
return cmp < 0;
}
@@ -2741,7 +2741,7 @@ public:
const SI_CHAR * a_pInputData)
{
// ASCII/MBCS/UTF-8 needs no conversion
- return strlen((const char *)a_pInputData) + 1;
+ return strlen(static_cast<const char *>(a_pInputData)) + 1;
}
/** Convert the input string to the storage format of this data.
@@ -2763,7 +2763,7 @@ public:
size_t a_uOutputDataSize)
{
// calc input string length (SI_CHAR type and size independent)
- size_t uInputLen = strlen((const char *)a_pInputData) + 1;
+ size_t uInputLen = strlen(static_cast<const char *>(a_pInputData)) + 1;
if (uInputLen > a_uOutputDataSize) {
return false;
}
@@ -3195,12 +3195,12 @@ template<class SI_CHAR>
struct SI_NoCase {
bool operator()(const SI_CHAR * pLeft, const SI_CHAR * pRight) const {
if (sizeof(SI_CHAR) == sizeof(char)) {
- return _mbsicmp((const unsigned char *)pLeft,
- (const unsigned char *)pRight) < 0;
+ return _mbsicmp(reinterpret_cast<const unsigned char *>(pLeft),
+ reinterpret_cast<const unsigned char *>(pRight)) < 0;
}
if (sizeof(SI_CHAR) == sizeof(wchar_t)) {
- return _wcsicmp((const wchar_t *)pLeft,
- (const wchar_t *)pRight) < 0;
+ return _wcsicmp(reinterpret_cast<const wchar_t *>(pLeft),
+ reinterpret_cast<const wchar_t *>(pRight)) < 0;
}
return SI_GenericNoCase<SI_CHAR>()(pLeft, pRight);
}
@@ -3251,9 +3251,9 @@ public:
int retval = MultiByteToWideChar(
m_uCodePage, 0,
- a_pInputData, (int) a_uInputDataLen,
+ a_pInputData, static_cast<int> (a_uInputDataLen),
0, 0);
- return (size_t)(retval > 0 ? retval : -1);
+ return static_cast<size_t>(retval > 0 ? retval : -1);
}
/** Convert the input string from the storage format to SI_CHAR.
@@ -3277,8 +3277,8 @@ public:
{
int nSize = MultiByteToWideChar(
m_uCodePage, 0,
- a_pInputData, (int) a_uInputDataLen,
- (wchar_t *) a_pOutputData, (int) a_uOutputDataSize);
+ a_pInputData, static_cast<int> (a_uInputDataLen),
+ static_cast<wchar_t *> (a_pOutputData), static_cast<int> (a_uOutputDataSize));
return (nSize > 0);
}
@@ -3297,9 +3297,9 @@ public:
{
int retval = WideCharToMultiByte(
m_uCodePage, 0,
- (const wchar_t *) a_pInputData, -1,
+ static_cast<const wchar_t *> (a_pInputData), -1,
0, 0, 0, 0);
- return (size_t) (retval > 0 ? retval : -1);
+ return static_cast<size_t> (retval > 0 ? retval : -1);
}
/** Convert the input string to the storage format of this data.
@@ -3322,8 +3322,8 @@ public:
{
int retval = WideCharToMultiByte(
m_uCodePage, 0,
- (const wchar_t *) a_pInputData, -1,
- a_pOutputData, (int) a_uOutputDataSize, 0, 0);
+ static_cast<const wchar_t *> (a_pInputData), -1,
+ a_pOutputData, static_cast<int> (a_uOutputDataSize), 0, 0);
return retval > 0;
}
};
diff --git a/src/CBot/CBotString.cpp b/src/CBot/CBotString.cpp
index 7223e6f..84f9ca2 100644
--- a/src/CBot/CBotString.cpp
+++ b/src/CBot/CBotString.cpp
@@ -597,18 +597,6 @@ static void DestructElements(CBotString* pOldData, int nCount)
}
}
-static void CopyElements(CBotString* pDest, CBotString* pSrc, int nCount)
-{
- while (nCount--)
- {
- *pDest = *pSrc;
- ++pDest;
- ++pSrc;
- }
-}
-
-
-
// set the array size
void CBotStringArray::SetSize(int nNewSize)
@@ -618,15 +606,14 @@ void CBotStringArray::SetSize(int nNewSize)
// shrink to nothing
DestructElements(m_pData, m_nSize);
-// delete[] static_cast<unsigned char *>(m_pData);
- delete[] (unsigned char *)m_pData;
+ delete[] reinterpret_cast<unsigned char *>(m_pData);
m_pData = NULL;
m_nSize = m_nMaxSize = 0;
}
else if (m_pData == NULL)
{
// create one with exact size
- m_pData = (CBotString*) new unsigned char[nNewSize * sizeof(CBotString)];
+ m_pData = reinterpret_cast<CBotString*> (new unsigned char[nNewSize * sizeof(CBotString)]);
ConstructElements(m_pData, nNewSize);
@@ -663,7 +650,7 @@ void CBotStringArray::SetSize(int nNewSize)
else
nNewMax = nNewSize; // no slush
- CBotString* pNewData = (CBotString*) new unsigned char[nNewMax * sizeof(CBotString)];
+ CBotString* pNewData = reinterpret_cast<CBotString*> (new unsigned char[nNewMax * sizeof(CBotString)]);
// copy new data from old
memcpy(pNewData, m_pData, m_nSize * sizeof(CBotString));
@@ -673,7 +660,7 @@ void CBotStringArray::SetSize(int nNewSize)
// Get rid of old stuff (note: no destructors called)
- delete[] (unsigned char *)m_pData;
+ delete[] reinterpret_cast<unsigned char *>(m_pData);
m_pData = pNewData;
m_nSize = nNewSize;
m_nMaxSize = nNewMax;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index dc003b9..197438c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,6 +6,7 @@ add_subdirectory(tools)
# Tests
add_subdirectory(graphics/engine/test)
+add_subdirectory(math/test)
# Configure options
@@ -17,6 +18,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(PLATFORM_WINDOWS 1)
set(PLATFORM_LINUX 0)
set(PLATFORM_OTHER 0)
+ set(PLATFORM_LIBS "-lintl")
# On Windows, GLEW is required
if (${USE_GLEW} MATCHES "auto")
set(USE_GLEW 1)
@@ -64,12 +66,11 @@ app/main.cpp
app/system.cpp
common/event.cpp
common/image.cpp
-common/logger.cpp
common/iman.cpp
-# common/metafile.cpp
-# common/misc.cpp
-# common/modfile.cpp
-# common/profile.cpp
+common/logger.cpp
+common/metafile.cpp
+common/misc.cpp
+common/profile.cpp
common/restext.cpp
common/restext_strings.c
common/stringutils.cpp
@@ -87,97 +88,96 @@ graphics/engine/terrain.cpp
graphics/engine/text.cpp
graphics/engine/water.cpp
graphics/opengl/gldevice.cpp
-# object/auto/auto.cpp
-# object/auto/autobase.cpp
-# object/auto/autoconvert.cpp
-# object/auto/autoderrick.cpp
-# object/auto/autodestroyer.cpp
-# object/auto/autoegg.cpp
-# object/auto/autoenergy.cpp
-# object/auto/autofactory.cpp
-# object/auto/autoflag.cpp
-# object/auto/autohuston.cpp
-# object/auto/autoinfo.cpp
-# object/auto/autojostle.cpp
-# object/auto/autokid.cpp
-# object/auto/autolabo.cpp
-# object/auto/automush.cpp
-# object/auto/autonest.cpp
-# object/auto/autonuclear.cpp
-# object/auto/autopara.cpp
-# object/auto/autoportico.cpp
-# object/auto/autoradar.cpp
-# object/auto/autorepair.cpp
-# object/auto/autoresearch.cpp
-# object/auto/autoroot.cpp
-# object/auto/autosafe.cpp
-# object/auto/autostation.cpp
-# object/auto/autotower.cpp
-# object/brain.cpp
-# object/mainmovie.cpp
-# object/motion/motion.cpp
-# object/motion/motionant.cpp
-# object/motion/motionbee.cpp
-# object/motion/motionhuman.cpp
-# object/motion/motionmother.cpp
-# object/motion/motionspider.cpp
-# object/motion/motiontoto.cpp
-# object/motion/motionvehicle.cpp
-# object/motion/motionworm.cpp
-# object/object.cpp
-# object/robotmain.cpp
-# object/task/task.cpp
-# object/task/taskadvance.cpp
-# object/task/taskbuild.cpp
-# object/task/taskfire.cpp
-# object/task/taskfireant.cpp
-# object/task/taskflag.cpp
-# object/task/taskgoto.cpp
-# object/task/taskgungoal.cpp
-# object/task/taskinfo.cpp
-# object/task/taskmanager.cpp
-# object/task/taskmanip.cpp
-# object/task/taskpen.cpp
-# object/task/taskrecover.cpp
-# object/task/taskreset.cpp
-# object/task/tasksearch.cpp
-# object/task/taskshield.cpp
-# object/task/taskspiderexplo.cpp
-# object/task/tasktake.cpp
-# object/task/taskterraform.cpp
-# object/task/taskturn.cpp
-# object/task/taskwait.cpp
-# physics/physics.cpp
-# script/cbottoken.cpp
-# script/cmdtoken.cpp
-# script/script.cpp
-# sound/sound.cpp
-# ui/button.cpp
-# ui/check.cpp
-# ui/color.cpp
-# ui/compass.cpp
-# ui/control.cpp
-# ui/displayinfo.cpp
-# ui/displaytext.cpp
-# ui/edit.cpp
-# ui/editvalue.cpp
-# ui/gauge.cpp
-# ui/group.cpp
-# ui/image.cpp
-# ui/interface.cpp
-# ui/key.cpp
-# ui/label.cpp
-# ui/list.cpp
-# ui/maindialog.cpp
-# ui/mainmap.cpp
-# ui/mainshort.cpp
-# ui/map.cpp
-# ui/scroll.cpp
-# ui/shortcut.cpp
-# ui/slider.cpp
-# ui/studio.cpp
-# ui/target.cpp
-# ui/window.cpp
+object/auto/auto.cpp
+object/auto/autobase.cpp
+object/auto/autoconvert.cpp
+object/auto/autoderrick.cpp
+object/auto/autodestroyer.cpp
+object/auto/autoegg.cpp
+object/auto/autoenergy.cpp
+object/auto/autofactory.cpp
+object/auto/autoflag.cpp
+object/auto/autohuston.cpp
+object/auto/autoinfo.cpp
+object/auto/autojostle.cpp
+object/auto/autokid.cpp
+object/auto/autolabo.cpp
+object/auto/automush.cpp
+object/auto/autonest.cpp
+object/auto/autonuclear.cpp
+object/auto/autopara.cpp
+object/auto/autoportico.cpp
+object/auto/autoradar.cpp
+object/auto/autorepair.cpp
+object/auto/autoresearch.cpp
+object/auto/autoroot.cpp
+object/auto/autosafe.cpp
+object/auto/autostation.cpp
+object/auto/autotower.cpp
+object/brain.cpp
+object/mainmovie.cpp
+object/motion/motion.cpp
+object/motion/motionant.cpp
+object/motion/motionbee.cpp
+object/motion/motionhuman.cpp
+object/motion/motionmother.cpp
+object/motion/motionspider.cpp
+object/motion/motiontoto.cpp
+object/motion/motionvehicle.cpp
+object/motion/motionworm.cpp
+object/object.cpp
+object/robotmain.cpp
+object/task/task.cpp
+object/task/taskadvance.cpp
+object/task/taskbuild.cpp
+object/task/taskfire.cpp
+object/task/taskfireant.cpp
+object/task/taskflag.cpp
+object/task/taskgoto.cpp
+object/task/taskgungoal.cpp
+object/task/taskinfo.cpp
+object/task/taskmanager.cpp
+object/task/taskmanip.cpp
+object/task/taskpen.cpp
+object/task/taskrecover.cpp
+object/task/taskreset.cpp
+object/task/tasksearch.cpp
+object/task/taskshield.cpp
+object/task/taskspiderexplo.cpp
+object/task/tasktake.cpp
+object/task/taskterraform.cpp
+object/task/taskturn.cpp
+object/task/taskwait.cpp
+physics/physics.cpp
+script/cbottoken.cpp
+script/cmdtoken.cpp
+script/script.cpp
+ui/button.cpp
+ui/check.cpp
+ui/color.cpp
+ui/compass.cpp
+ui/control.cpp
+ui/displayinfo.cpp
+ui/displaytext.cpp
+ui/edit.cpp
+ui/editvalue.cpp
+ui/gauge.cpp
+ui/group.cpp
+ui/image.cpp
+ui/interface.cpp
+ui/key.cpp
+ui/label.cpp
+ui/list.cpp
+ui/maindialog.cpp
+ui/mainmap.cpp
+ui/mainshort.cpp
+ui/map.cpp
+ui/scroll.cpp
+ui/shortcut.cpp
+ui/slider.cpp
+ui/studio.cpp
+ui/target.cpp
+ui/window.cpp
)
set(LIBS
@@ -191,12 +191,16 @@ ${PLATFORM_LIBS}
CBot
)
-include_directories(. ${CMAKE_CURRENT_BINARY_DIR}
+include_directories(
+.
+..
+${CMAKE_CURRENT_BINARY_DIR}
${SDL_INCLUDE_DIR}
${SDL_IMAGE_INCLUDE_DIR}
${SDLTTF_INCLUDE_DIR}
${PNG_INCLUDE_DIRS}
${OPTIONAL_INCLUDE_DIRS}
+..
)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 00cd13d..23e6d9f 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -23,16 +23,24 @@
#include "common/logger.h"
#include "common/iman.h"
#include "common/image.h"
+#include "common/key.h"
#include "graphics/opengl/gldevice.h"
+#include "object/robotmain.h"
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
-#include <stdio.h>
+#include <fstream>
+#include <stdlib.h>
+#include <libintl.h>
-template<> CApplication* CSingleton<CApplication>::mInstance = NULL;
+
+template<> CApplication* CSingleton<CApplication>::mInstance = nullptr;
+
+//! Static buffer for putenv locale
+static char S_LANGUAGE[50] = { 0 };
//! Interval of timer called to update joystick state
@@ -62,8 +70,8 @@ struct ApplicationPrivate
ApplicationPrivate()
{
memset(&currentEvent, 0, sizeof(SDL_Event));
- surface = NULL;
- joystick = NULL;
+ surface = nullptr;
+ joystick = nullptr;
joystickTimer = 0;
}
};
@@ -76,14 +84,10 @@ CApplication::CApplication()
m_iMan = new CInstanceManager();
m_eventQueue = new CEventQueue(m_iMan);
- m_engine = NULL;
- m_device = NULL;
- m_robotMain = NULL;
- m_sound = NULL;
-
- m_keyState = 0;
- m_axeKey = Math::Vector(0.0f, 0.0f, 0.0f);
- m_axeJoy = Math::Vector(0.0f, 0.0f, 0.0f);
+ m_engine = nullptr;
+ m_device = nullptr;
+ m_robotMain = nullptr;
+ m_sound = nullptr;
m_exitCode = 0;
m_active = false;
@@ -91,29 +95,57 @@ CApplication::CApplication()
m_windowTitle = "COLOBOT";
+ m_simulationSuspended = false;
+
+ m_simulationSpeed = 1.0f;
+
+ m_realAbsTimeBase = 0LL;
+ m_realAbsTime = 0LL;
+ m_realRelTime = 0LL;
+
+ m_absTimeBase = 0LL;
+ m_exactAbsTime = 0LL;
+ m_exactRelTime = 0LL;
+
+ m_absTime = 0.0f;
+ m_relTime = 0.0f;
+
+ m_baseTimeStamp = CreateTimeStamp();
+ m_curTimeStamp = CreateTimeStamp();
+ m_lastTimeStamp = CreateTimeStamp();
+
m_joystickEnabled = false;
+ m_kmodState = 0;
+ m_mouseButtonsState = 0;
+ m_trackedKeys = 0;
+
m_dataPath = "./data";
- ResetKey();
+ m_language = LANG_ENGLISH;
}
CApplication::~CApplication()
{
delete m_private;
- m_private = NULL;
+ m_private = nullptr;
delete m_eventQueue;
- m_eventQueue = NULL;
+ m_eventQueue = nullptr;
delete m_iMan;
- m_iMan = NULL;
+ m_iMan = nullptr;
+
+ DestroyTimeStamp(m_baseTimeStamp);
+ DestroyTimeStamp(m_curTimeStamp);
+ DestroyTimeStamp(m_lastTimeStamp);
}
-bool CApplication::ParseArguments(int argc, char *argv[])
+ParseArgsStatus CApplication::ParseArguments(int argc, char *argv[])
{
bool waitDataDir = false;
bool waitLogLevel = false;
+ bool waitLanguage = false;
for (int i = 1; i < argc; ++i)
{
@@ -123,6 +155,7 @@ bool CApplication::ParseArguments(int argc, char *argv[])
{
waitDataDir = false;
m_dataPath = arg;
+ GetLogger()->Info("Using custom data dir: '%s'\n", m_dataPath.c_str());
continue;
}
@@ -142,7 +175,23 @@ bool CApplication::ParseArguments(int argc, char *argv[])
else if (arg == "none")
GetLogger()->SetLogLevel(LOG_NONE);
else
- return false;
+ return PARSE_ARGS_FAIL;
+ continue;
+ }
+
+ if (waitLanguage)
+ {
+ waitLanguage = false;
+ if (arg == "en")
+ m_language = LANG_ENGLISH;
+ else if (arg == "de")
+ m_language = LANG_GERMAN;
+ else if (arg == "fr")
+ m_language = LANG_FRENCH;
+ else if (arg == "pl")
+ m_language = LANG_POLISH;
+ else
+ return PARSE_ARGS_FAIL;
continue;
}
@@ -158,34 +207,95 @@ bool CApplication::ParseArguments(int argc, char *argv[])
{
waitDataDir = true;
}
+ else if (arg == "-language")
+ {
+ waitLanguage = true;
+ }
+ else if (arg == "-help")
+ {
+ GetLogger()->Message("\n");
+ GetLogger()->Message("COLOBOT GOLD pre-alpha\n");
+ GetLogger()->Message("\n");
+ GetLogger()->Message("List of available options:\n");
+ GetLogger()->Message(" -help this help\n");
+ GetLogger()->Message(" -datadir path set custom data directory path\n");
+ GetLogger()->Message(" -debug enable debug mode (more info printed in logs)\n");
+ GetLogger()->Message(" -loglevel level set log level to level (one of: trace, debug, info, warn, error, none)\n");
+ GetLogger()->Message(" -language lang set language (one of: en, de, fr, pl)\n");
+ return PARSE_ARGS_HELP;
+ }
else
{
m_exitCode = 1;
- return false;
+ return PARSE_ARGS_FAIL;
}
}
// Args not given?
- if (waitDataDir || waitLogLevel)
- return false;
+ if (waitDataDir || waitLogLevel || waitLanguage)
+ return PARSE_ARGS_FAIL;
- return true;
+ return PARSE_ARGS_OK;
}
bool CApplication::Create()
{
GetLogger()->Info("Creating CApplication\n");
- // TODO: verify that data directory exists
+ // I know, a primitive way to check for dir, but works
+ std::string readmePath = m_dataPath + "/README.txt";
+ std::ifstream testReadme;
+ testReadme.open(readmePath.c_str(), std::ios_base::in);
+ if (!testReadme.good())
+ {
+ GetLogger()->Error("Could not open test file in data dir: '%s'\n", readmePath.c_str());
+ m_errorMessage = std::string("Could not read from data directory:\n") +
+ std::string("'") + m_dataPath + std::string("'\n") +
+ std::string("Please check your installation, or supply a valid data directory by -datadir option.");
+ m_exitCode = 1;
+ return false;
+ }
+
+ /* Gettext initialization */
+
+ std::string locale = "C";
+ switch (m_language)
+ {
+ case LANG_ENGLISH:
+ locale = "en_US.utf8";
+ break;
+
+ case LANG_GERMAN:
+ locale = "de_DE.utf8";
+ break;
+
+ case LANG_FRENCH:
+ locale = "fr_FR.utf8";
+ break;
+
+ case LANG_POLISH:
+ locale = "pl_PL.utf8";
+ break;
+ }
+
+ std::string langStr = "LANGUAGE=";
+ langStr += locale;
+ strcpy(S_LANGUAGE, langStr.c_str());
+ putenv(S_LANGUAGE);
+ setlocale(LC_ALL, locale.c_str());
+
+ std::string trPath = m_dataPath + std::string("/i18n");
+ bindtextdomain("colobot", trPath.c_str());
+ bind_textdomain_codeset("colobot", "UTF-8");
+ textdomain("colobot");
+
+ GetLogger()->Debug("Testing gettext translation: '%s'\n", gettext("Colobot rules!"));
// Temporarily -- only in windowed mode
m_deviceConfig.fullScreen = false;
-/* // Create the sound instance.
- m_sound = new CSound(m_iMan);
-
- // Create the robot application.
- m_robotMain = new CRobotMain(m_iMan); */
+ // Create the sound instance.
+ m_sound = new CSoundInterface();
std::string standardInfoMessage =
@@ -218,7 +328,7 @@ bool CApplication::Create()
if (! CreateVideoSurface())
return false; // dialog is in function
- if (m_private->surface == NULL)
+ if (m_private->surface == nullptr)
{
m_errorMessage = std::string("SDL error while setting video mode:\n") +
std::string(SDL_GetError());
@@ -261,6 +371,11 @@ bool CApplication::Create()
return false;
}
+ // Create the robot application.
+ m_robotMain = new CRobotMain(m_iMan, this);
+
+ m_robotMain->ChangePhase(PHASE_WELCOME1);
+
GetLogger()->Info("CApplication created successfully\n");
return true;
@@ -269,7 +384,7 @@ bool CApplication::Create()
bool CApplication::CreateVideoSurface()
{
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
- if (videoInfo == NULL)
+ if (videoInfo == nullptr)
{
m_errorMessage = std::string("SDL error while getting video info:\n ") +
std::string(SDL_GetError());
@@ -321,44 +436,46 @@ bool CApplication::CreateVideoSurface()
void CApplication::Destroy()
{
- /*if (m_robotMain != NULL)
+ m_joystickEnabled = false;
+
+ if (m_robotMain != nullptr)
{
delete m_robotMain;
- m_robotMain = NULL;
+ m_robotMain = nullptr;
}
- if (m_sound != NULL)
+ if (m_sound != nullptr)
{
delete m_sound;
- m_sound = NULL;
- }*/
+ m_sound = nullptr;
+ }
- if (m_engine != NULL)
+ if (m_engine != nullptr)
{
m_engine->Destroy();
delete m_engine;
- m_engine = NULL;
+ m_engine = nullptr;
}
- if (m_device != NULL)
+ if (m_device != nullptr)
{
m_device->Destroy();
delete m_device;
- m_device = NULL;
+ m_device = nullptr;
}
- if (m_private->joystick != NULL)
+ if (m_private->joystick != nullptr)
{
SDL_JoystickClose(m_private->joystick);
- m_private->joystick = NULL;
+ m_private->joystick = nullptr;
}
- if (m_private->surface != NULL)
+ if (m_private->surface != nullptr)
{
SDL_FreeSurface(m_private->surface);
- m_private->surface = NULL;
+ m_private->surface = nullptr;
}
IMG_Quit();
@@ -383,7 +500,7 @@ bool CApplication::ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig)
return false;
}
- if (m_private->surface == NULL)
+ if (m_private->surface == nullptr)
{
if (! restore)
{
@@ -426,7 +543,7 @@ bool CApplication::OpenJoystick()
return false;
m_private->joystick = SDL_JoystickOpen(m_joystick.index);
- if (m_private->joystick == NULL)
+ if (m_private->joystick == nullptr)
return false;
m_joystick.axisCount = SDL_JoystickNumAxes(m_private->joystick);
@@ -437,7 +554,7 @@ bool CApplication::OpenJoystick()
m_joyButtonState = std::vector<bool>(m_joystick.buttonCount, false);
// Create a timer for polling joystick state
- m_private->joystickTimer = SDL_AddTimer(JOYSTICK_TIMER_INTERVAL, JoystickTimerCallback, NULL);
+ m_private->joystickTimer = SDL_AddTimer(JOYSTICK_TIMER_INTERVAL, JoystickTimerCallback, nullptr);
return true;
}
@@ -447,7 +564,7 @@ void CApplication::CloseJoystick()
// Timer will remove itself automatically
SDL_JoystickClose(m_private->joystick);
- m_private->joystick = NULL;
+ m_private->joystick = nullptr;
}
bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick)
@@ -455,7 +572,7 @@ bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick)
if ( (newJoystick.index < 0) || (newJoystick.index >= SDL_NumJoysticks()) )
return false;
- if (m_private->joystick != NULL)
+ if (m_private->joystick != nullptr)
CloseJoystick();
return OpenJoystick();
@@ -464,7 +581,7 @@ bool CApplication::ChangeJoystick(const JoystickDevice &newJoystick)
Uint32 JoystickTimerCallback(Uint32 interval, void *)
{
CApplication *app = CApplication::GetInstancePointer();
- if ((app == NULL) || (! app->GetJoystickEnabled()))
+ if ((app == nullptr) || (! app->GetJoystickEnabled()))
return 0; // don't run the timer again
app->UpdateJoystick();
@@ -540,6 +657,10 @@ int CApplication::Run()
{
m_active = true;
+ GetCurrentTimeStamp(m_baseTimeStamp);
+ GetCurrentTimeStamp(m_lastTimeStamp);
+ GetCurrentTimeStamp(m_curTimeStamp);
+
while (true)
{
// To be sure no old event remains
@@ -577,12 +698,24 @@ int CApplication::Run()
{
bool passOn = ProcessEvent(event);
- if (m_engine != NULL && passOn)
+ if (m_engine != nullptr && passOn)
passOn = m_engine->ProcessEvent(event);
if (passOn)
m_eventQueue->AddEvent(event);
}
+
+ Event virtualEvent = CreateVirtualEvent(event);
+ if (virtualEvent.type != EVENT_NULL)
+ {
+ bool passOn = ProcessEvent(virtualEvent);
+
+ if (m_engine != nullptr && passOn)
+ passOn = m_engine->ProcessEvent(virtualEvent);
+
+ if (passOn)
+ m_eventQueue->AddEvent(virtualEvent);
+ }
}
}
@@ -602,12 +735,12 @@ int CApplication::Run()
{
passOn = ProcessEvent(event);
- if (passOn && m_engine != NULL)
+ if (passOn && m_engine != nullptr)
passOn = m_engine->ProcessEvent(event);
}
- /*if (passOn && m_robotMain != NULL)
- m_robotMain->ProcessEvent(event); */
+ if (passOn && m_robotMain != nullptr)
+ m_robotMain->EventProcess(event);
}
/* Update mouse position explicitly right before rendering
@@ -616,6 +749,9 @@ int CApplication::Run()
// Update game and render a frame during idle time (no messages are waiting)
Render();
+
+ // Update simulation state
+ StepSimulation();
}
}
@@ -664,6 +800,7 @@ Event CApplication::ParseEvent()
else
event.type = EVENT_KEY_UP;
+ event.key.virt = false;
event.key.key = m_private->currentEvent.key.keysym.sym;
event.key.mod = m_private->currentEvent.key.keysym.mod;
event.key.state = TranslatePressState(m_private->currentEvent.key.state);
@@ -672,15 +809,32 @@ Event CApplication::ParseEvent()
else if ( (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) ||
(m_private->currentEvent.type == SDL_MOUSEBUTTONUP) )
{
- if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN)
- event.type = EVENT_MOUSE_BUTTON_DOWN;
+ if ((m_private->currentEvent.button.button == SDL_BUTTON_WHEELUP) ||
+ (m_private->currentEvent.button.button == SDL_BUTTON_WHEELDOWN))
+ {
+ if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN) // ignore the following up event
+ {
+ event.type = EVENT_MOUSE_WHEEL;
+ if (m_private->currentEvent.button.button == SDL_BUTTON_WHEELDOWN)
+ event.mouseWheel.dir = WHEEL_DOWN;
+ else
+ event.mouseWheel.dir = WHEEL_UP;
+ event.mouseWheel.pos = m_engine->WindowToInterfaceCoords(
+ Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
+ }
+ }
else
- event.type = EVENT_MOUSE_BUTTON_UP;
+ {
+ if (m_private->currentEvent.type == SDL_MOUSEBUTTONDOWN)
+ event.type = EVENT_MOUSE_BUTTON_DOWN;
+ else
+ event.type = EVENT_MOUSE_BUTTON_UP;
- event.mouseButton.button = m_private->currentEvent.button.button;
- event.mouseButton.state = TranslatePressState(m_private->currentEvent.button.state);
- event.mouseButton.pos = m_engine->WindowToInterfaceCoords(
- Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
+ event.mouseButton.button = m_private->currentEvent.button.button;
+ event.mouseButton.state = TranslatePressState(m_private->currentEvent.button.state);
+ event.mouseButton.pos = m_engine->WindowToInterfaceCoords(
+ Math::IntPoint(m_private->currentEvent.button.x, m_private->currentEvent.button.y));
+ }
}
else if (m_private->currentEvent.type == SDL_MOUSEMOTION)
{
@@ -725,18 +879,93 @@ Event CApplication::ParseEvent()
return event;
}
-/** Processes incoming events. It is the first function called after an event is captures.
- Function returns \c true if the event is to be passed on to other processing functions
- or \c false if not. */
-bool CApplication::ProcessEvent(const Event &event)
+/**
+ * Processes incoming events. It is the first function called after an event is captured.
+ * Event is modified, updating its tracked keys state and mouse position to current values.
+ * Function returns \c true if the event is to be passed on to other processing functions
+ * or \c false if not. */
+bool CApplication::ProcessEvent(Event &event)
{
CLogger *l = GetLogger();
+ event.trackedKeys = m_trackedKeys;
+ if (GetSystemMouseVisibile())
+ event.mousePos = m_systemMousePos;
+ else
+ event.mousePos = m_engine->GetMousePos();
+
if (event.type == EVENT_ACTIVE)
{
- m_active = event.active.gain;
if (m_debugMode)
- l->Info("Focus change: active = %s\n", m_active ? "true" : "false");
+ l->Info("Focus change: active = %s\n", event.active.gain ? "true" : "false");
+
+ /*if (m_active != event.active.gain)
+ {
+ m_active = event.active.gain;
+
+ if (m_active)
+ ResumeSimulation();
+ else
+ SuspendSimulation();
+ }*/
+ }
+ else if (event.type == EVENT_KEY_DOWN)
+ {
+ m_kmodState = event.key.mod;
+
+ if ((m_kmodState & KEY_MOD(SHIFT)) != 0)
+ m_trackedKeys |= TRKEY_SHIFT;
+ else if ((m_kmodState & KEY_MOD(CTRL)) != 0)
+ m_trackedKeys |= TRKEY_CONTROL;
+ else if (event.key.key == KEY(KP8))
+ m_trackedKeys |= TRKEY_NUM_UP;
+ else if (event.key.key == KEY(KP2))
+ m_trackedKeys |= TRKEY_NUM_DOWN;
+ else if (event.key.key == KEY(KP4))
+ m_trackedKeys |= TRKEY_NUM_LEFT;
+ else if (event.key.key == KEY(KP6))
+ m_trackedKeys |= TRKEY_NUM_RIGHT;
+ else if (event.key.key == KEY(KP_PLUS))
+ m_trackedKeys |= TRKEY_NUM_PLUS;
+ else if (event.key.key == KEY(KP_MINUS))
+ m_trackedKeys |= TRKEY_NUM_MINUS;
+ else if (event.key.key == KEY(PAGEUP))
+ m_trackedKeys |= TRKEY_PAGE_UP;
+ else if (event.key.key == KEY(PAGEDOWN))
+ m_trackedKeys |= TRKEY_PAGE_DOWN;
+ }
+ else if (event.type == EVENT_KEY_UP)
+ {
+ m_kmodState = event.key.mod;
+
+ if ((m_kmodState & KEY_MOD(SHIFT)) != 0)
+ m_trackedKeys &= ~TRKEY_SHIFT;
+ else if ((m_kmodState & KEY_MOD(CTRL)) != 0)
+ m_trackedKeys &= ~TRKEY_CONTROL;
+ else if (event.key.key == KEY(KP8))
+ m_trackedKeys &= ~TRKEY_NUM_UP;
+ else if (event.key.key == KEY(KP2))
+ m_trackedKeys &= ~TRKEY_NUM_DOWN;
+ else if (event.key.key == KEY(KP4))
+ m_trackedKeys &= ~TRKEY_NUM_LEFT;
+ else if (event.key.key == KEY(KP6))
+ m_trackedKeys &= ~TRKEY_NUM_RIGHT;
+ else if (event.key.key == KEY(KP_PLUS))
+ m_trackedKeys &= ~TRKEY_NUM_PLUS;
+ else if (event.key.key == KEY(KP_MINUS))
+ m_trackedKeys &= ~TRKEY_NUM_MINUS;
+ else if (event.key.key == KEY(PAGEUP))
+ m_trackedKeys &= ~TRKEY_PAGE_UP;
+ else if (event.key.key == KEY(PAGEDOWN))
+ m_trackedKeys &= ~TRKEY_PAGE_DOWN;
+ }
+ else if (event.type == EVENT_MOUSE_BUTTON_DOWN)
+ {
+ m_mouseButtonsState |= 1 << event.mouseButton.button;
+ }
+ else if (event.type == EVENT_MOUSE_BUTTON_UP)
+ {
+ m_mouseButtonsState &= ~(1 << event.mouseButton.button);
}
// Print the events in debug mode to test the code
@@ -747,6 +976,7 @@ bool CApplication::ProcessEvent(const Event &event)
case EVENT_KEY_DOWN:
case EVENT_KEY_UP:
l->Info("EVENT_KEY_%s:\n", (event.type == EVENT_KEY_DOWN) ? "DOWN" : "UP");
+ l->Info(" virt = %s\n", (event.key.virt) ? "true" : "false");
l->Info(" key = %4x\n", event.key.key);
l->Info(" state = %s\n", (event.key.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
l->Info(" mod = %4x\n", event.key.mod);
@@ -764,6 +994,11 @@ bool CApplication::ProcessEvent(const Event &event)
l->Info(" state = %s\n", (event.mouseButton.state == STATE_PRESSED) ? "STATE_PRESSED" : "STATE_RELEASED");
l->Info(" pos = (%f, %f)\n", event.mouseButton.pos.x, event.mouseButton.pos.y);
break;
+ case EVENT_MOUSE_WHEEL:
+ l->Info("EVENT_MOUSE_WHEEL:\n");
+ l->Info(" dir = %s\n", (event.mouseWheel.dir == WHEEL_DOWN) ? "WHEEL_DOWN" : "WHEEL_UP");
+ l->Info(" pos = (%f, %f)\n", event.mouseWheel.pos.x, event.mouseWheel.pos.y);
+ break;
case EVENT_JOY_AXIS:
l->Info("EVENT_JOY_AXIS:\n");
l->Info(" axis = %d\n", event.joyAxis.axis);
@@ -789,6 +1024,48 @@ bool CApplication::ProcessEvent(const Event &event)
return true;
}
+
+Event CApplication::CreateVirtualEvent(const Event& sourceEvent)
+{
+ Event virtualEvent;
+ virtualEvent.systemEvent = true;
+
+ if ((sourceEvent.type == EVENT_KEY_DOWN) || (sourceEvent.type == EVENT_KEY_UP))
+ {
+ virtualEvent.type = sourceEvent.type;
+ virtualEvent.key = sourceEvent.key;
+ virtualEvent.key.virt = true;
+
+ if (sourceEvent.key.key == KEY(LCTRL) || sourceEvent.key.key == KEY(RCTRL))
+ virtualEvent.key.key = VIRTUAL_KMOD(CTRL);
+ else if (sourceEvent.key.key == KEY(LSHIFT) || sourceEvent.key.key == KEY(RSHIFT))
+ virtualEvent.key.key = VIRTUAL_KMOD(SHIFT);
+ else if (sourceEvent.key.key == KEY(LALT) || sourceEvent.key.key == KEY(RALT))
+ virtualEvent.key.key = VIRTUAL_KMOD(ALT);
+ else if (sourceEvent.key.key == KEY(LMETA) || sourceEvent.key.key == KEY(RMETA))
+ virtualEvent.key.key = VIRTUAL_KMOD(META);
+ else
+ virtualEvent.type = EVENT_NULL;
+ }
+ else if ((sourceEvent.type == EVENT_JOY_BUTTON_DOWN) || (sourceEvent.type == EVENT_JOY_BUTTON_UP))
+ {
+ if (sourceEvent.type == EVENT_JOY_BUTTON_DOWN)
+ virtualEvent.type = EVENT_KEY_DOWN;
+ else
+ virtualEvent.type = EVENT_KEY_UP;
+ virtualEvent.key.virt = true;
+ virtualEvent.key.key = VIRTUAL_JOY(sourceEvent.joyButton.button);
+ virtualEvent.key.mod = 0;
+ virtualEvent.key.unicode = 0;
+ }
+ else
+ {
+ virtualEvent.type = EVENT_NULL;
+ }
+
+ return virtualEvent;
+}
+
/** Renders the frame and swaps buffers as necessary */
void CApplication::Render()
{
@@ -798,9 +1075,101 @@ void CApplication::Render()
SDL_GL_SwapBuffers();
}
-void CApplication::StepSimulation(float rTime)
+void CApplication::SuspendSimulation()
{
- // TODO
+ m_simulationSuspended = true;
+ GetLogger()->Info("Suspend simulation\n");
+}
+
+void CApplication::ResumeSimulation()
+{
+ m_simulationSuspended = false;
+
+ GetCurrentTimeStamp(m_baseTimeStamp);
+ CopyTimeStamp(m_curTimeStamp, m_baseTimeStamp);
+ m_realAbsTimeBase = m_realAbsTime;
+ m_absTimeBase = m_exactAbsTime;
+
+ GetLogger()->Info("Resume simulation\n");
+}
+
+bool CApplication::GetSimulationSuspended()
+{
+ return m_simulationSuspended;
+}
+
+void CApplication::SetSimulationSpeed(float speed)
+{
+ m_simulationSpeed = speed;
+
+ GetCurrentTimeStamp(m_baseTimeStamp);
+ m_realAbsTimeBase = m_realAbsTime;
+ m_absTimeBase = m_exactAbsTime;
+
+ GetLogger()->Info("Simulation speed = %.2f\n", speed);
+}
+
+void CApplication::StepSimulation()
+{
+ if (m_simulationSuspended)
+ return;
+
+ CopyTimeStamp(m_lastTimeStamp, m_curTimeStamp);
+ GetCurrentTimeStamp(m_curTimeStamp);
+
+ long long absDiff = TimeStampExactDiff(m_baseTimeStamp, m_curTimeStamp);
+ m_realAbsTime = m_realAbsTimeBase + absDiff;
+ // m_baseTimeStamp is updated on simulation speed change, so this is OK
+ m_exactAbsTime = m_absTimeBase + m_simulationSpeed * absDiff;
+ m_absTime = (m_absTimeBase + m_simulationSpeed * absDiff) / 1e9f;
+
+ m_realRelTime = TimeStampExactDiff(m_lastTimeStamp, m_curTimeStamp);
+ m_exactRelTime = m_simulationSpeed * m_realRelTime;
+ m_relTime = (m_simulationSpeed * m_realRelTime) / 1e9f;
+
+
+ m_engine->FrameUpdate();
+ m_sound->FrameMove(m_relTime);
+
+
+ Event frameEvent(EVENT_FRAME);
+ frameEvent.rTime = m_relTime;
+ m_eventQueue->AddEvent(frameEvent);
+}
+
+float CApplication::GetSimulationSpeed()
+{
+ return m_simulationSpeed;
+}
+
+float CApplication::GetAbsTime()
+{
+ return m_absTime;
+}
+
+long long CApplication::GetExactAbsTime()
+{
+ return m_exactAbsTime;
+}
+
+long long CApplication::GetRealAbsTime()
+{
+ return m_realAbsTime;
+}
+
+float CApplication::GetRelTime()
+{
+ return m_relTime;
+}
+
+long long CApplication::GetExactRelTime()
+{
+ return m_exactRelTime;
+}
+
+long long CApplication::GetRealRelTime()
+{
+ return m_realRelTime;
}
Gfx::GLDeviceConfig CApplication::GetVideoConfig()
@@ -814,7 +1183,7 @@ VideoQueryResult CApplication::GetVideoResolutionList(std::vector<Math::IntPoint
resolutions.clear();
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
- if (videoInfo == NULL)
+ if (videoInfo == nullptr)
return VIDEO_QUERY_ERROR;
Uint32 videoFlags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER | SDL_HWPALETTE;
@@ -861,25 +1230,31 @@ bool CApplication::GetDebugMode()
return m_debugMode;
}
-void CApplication::FlushPressKey()
+int CApplication::GetKmods()
{
- // TODO
+ return m_kmodState;
}
-void CApplication::ResetKey()
+bool CApplication::GetKmodState(int kmod)
{
- // TODO
+ return (m_kmodState & kmod) != 0;
}
-void CApplication::SetKey(int keyRank, int option, int key)
+bool CApplication::GetTrackedKeyState(TrackedKey key)
{
- // TODO
+ return (m_trackedKeys & key) != 0;
}
-int CApplication::GetKey(int keyRank, int option)
+bool CApplication::GetMouseButtonState(int index)
{
- // TODO
- return 0;
+ return (m_mouseButtonsState & (1<<index)) != 0;
+}
+
+void CApplication::ResetKeyStates()
+{
+ m_trackedKeys = 0;
+ m_kmodState = 0;
+ m_robotMain->ResetKeyStates();
}
void CApplication::SetGrabInput(bool grab)
@@ -964,3 +1339,13 @@ std::string CApplication::GetDataFilePath(const std::string& dirName, const std:
{
return m_dataPath + "/" + dirName + "/" + fileName;
}
+
+Language CApplication::GetLanguage()
+{
+ return m_language;
+}
+
+void CApplication::SetLanguage(Language language)
+{
+ m_language = language;
+}
diff --git a/src/app/app.h b/src/app/app.h
index 7991177..33be5a5 100644
--- a/src/app/app.h
+++ b/src/app/app.h
@@ -22,8 +22,7 @@
#pragma once
-
-#include "common/misc.h"
+#include "common/global.h"
#include "common/singleton.h"
#include "graphics/core/device.h"
#include "graphics/engine/engine.h"
@@ -36,11 +35,12 @@
class CInstanceManager;
class CEvent;
class CRobotMain;
-class CSound;
+class CSoundInterface;
/**
- \struct JoystickDevice
- \brief Information about a joystick device */
+ * \struct JoystickDevice
+ * \brief Information about a joystick device
+ */
struct JoystickDevice
{
//! Device index (-1 = invalid device)
@@ -57,8 +57,9 @@ struct JoystickDevice
};
/**
- \enum VideoQueryResult
- \brief Result of querying for available video resolutions */
+ * \enum VideoQueryResult
+ * \brief Result of querying for available video resolutions
+ */
enum VideoQueryResult
{
VIDEO_QUERY_ERROR,
@@ -68,6 +69,35 @@ enum VideoQueryResult
};
+/**
+ * \enum TrackedKeys
+ * \brief Keys (or kmods) whose state (pressed/released) is tracked by CApplication
+ */
+enum TrackedKey
+{
+ TRKEY_SHIFT = (1<<0),
+ TRKEY_CONTROL = (1<<1),
+ TRKEY_NUM_UP = (1<<2),
+ TRKEY_NUM_DOWN = (1<<3),
+ TRKEY_NUM_LEFT = (1<<4),
+ TRKEY_NUM_RIGHT = (1<<5),
+ TRKEY_NUM_PLUS = (1<<6),
+ TRKEY_NUM_MINUS = (1<<7),
+ TRKEY_PAGE_UP = (1<<8),
+ TRKEY_PAGE_DOWN = (1<<9)
+};
+
+/**
+ * \enum ParseArgsStatus
+ * \brief State of parsing commandline arguments
+ */
+enum ParseArgsStatus
+{
+ PARSE_ARGS_OK = 1, //! < all ok
+ PARSE_ARGS_FAIL = 2, //! < invalid syntax
+ PARSE_ARGS_HELP = 3 //! < -help requested
+};
+
struct ApplicationPrivate;
/**
@@ -82,7 +112,7 @@ struct ApplicationPrivate;
* \section Creation Creation of other main objects
*
* The class creates the only instance of CInstanceManager, CEventQueue, CEngine,
- * CRobotMain and CSound classes.
+ * CRobotMain and CSoundInterface classes.
*
* \section Window Window management
*
@@ -123,7 +153,7 @@ public:
public:
//! Parses commandline arguments
- bool ParseArguments(int argc, char *argv[]);
+ ParseArgsStatus ParseArguments(int argc, char *argv[]);
//! Initializes the application
bool Create();
//! Main event loop
@@ -147,8 +177,37 @@ public:
//! Change the video mode to given mode
bool ChangeVideoConfig(const Gfx::GLDeviceConfig &newConfig);
+ //! Suspends animation (time will not be updated)
+ void SuspendSimulation();
+ //! Resumes animation
+ void ResumeSimulation();
+ //! Returns whether simulation is suspended
+ bool GetSimulationSuspended();
+
//! Updates the simulation state
- void StepSimulation(float rTime);
+ void StepSimulation();
+
+ //@{
+ //! Management of simulation speed
+ void SetSimulationSpeed(float speed);
+ float GetSimulationSpeed();
+ //@}
+
+ //! Returns the absolute time counter [seconds]
+ float GetAbsTime();
+ //! Returns the exact absolute time counter [nanoseconds]
+ long long GetExactAbsTime();
+
+ //! Returns the exact absolute time counter disregarding speed setting [nanoseconds]
+ long long GetRealAbsTime();
+
+ //! Returns the relative time since last update [seconds]
+ float GetRelTime();
+ //! Returns the exact realative time since last update [nanoseconds]
+ long long GetExactRelTime();
+
+ //! Returns the exact relative time since last update disregarding speed setting [nanoseconds]
+ long long GetRealRelTime();
//! Returns a list of available joystick devices
std::vector<JoystickDevice> GetJoystickList();
@@ -159,10 +218,11 @@ public:
//! Change the current joystick device
bool ChangeJoystick(const JoystickDevice &newJoystick);
- //! Enables/disables joystick
+ //! Management of joystick enable state
+ //@{
void SetJoystickEnabled(bool enable);
- //! Returns whether joystick is enabled
bool GetJoystickEnabled();
+ //@}
//! Polls the state of joystick axes and buttons
void UpdateJoystick();
@@ -170,42 +230,63 @@ public:
//! Updates the mouse position explicitly
void UpdateMouse();
- void FlushPressKey();
- void ResetKey();
- void SetKey(int keyRank, int option, int key);
- int GetKey(int keyRank, int option);
+ //! Returns the current key modifiers
+ int GetKmods();
+ //! Returns whether the given kmod is active
+ bool GetKmodState(int kmod);
+
+ //! Returns whether the tracked key is pressed
+ bool GetTrackedKeyState(TrackedKey key);
- //! Sets the grab mode for input (keyboard & mouse)
+ //! Returns whether the mouse button is pressed
+ bool GetMouseButtonState(int index);
+
+ //! Resets tracked key states and modifiers
+ void ResetKeyStates();
+
+ //! Management of the grab mode for input (keyboard & mouse)
+ //@{
void SetGrabInput(bool grab);
- //! Returns the grab mode
bool GetGrabInput();
+ //@}
- //! Sets the visiblity of system mouse cursor
+ //! Management of the visiblity of system mouse cursor
+ //@{
void SetSystemMouseVisible(bool visible);
- //! Returns the visiblity of system mouse cursor
bool GetSystemMouseVisibile();
+ //@}
- //! Sets the position of system mouse cursor (in interface coords)
+ //! Management of the position of system mouse cursor (in interface coords)
+ //@{
void SetSystemMousePos(Math::Point pos);
- //! Returns the position of system mouse cursor (in interface coords)
Math::Point GetSystemMousePos();
+ //@}
- //! Enables/disables debug mode (prints more info in logger)
+ //! Management of debug mode (prints more info in logger)
+ //@{
void SetDebugMode(bool mode);
- //! Returns whether debug mode is enabled
bool GetDebugMode();
+ //@}
//! Returns the full path to a file in data directory
std::string GetDataFilePath(const std::string &dirName, const std::string &fileName);
+ //! Management of language
+ //@{
+ Language GetLanguage();
+ void SetLanguage(Language language);
+ //@}
+
protected:
//! Creates the window's SDL_Surface
bool CreateVideoSurface();
//! Processes the captured SDL event to Event struct
Event ParseEvent();
+ //! If applicable, creates a virtual event to match the changed state as of new event
+ Event CreateVirtualEvent(const Event& sourceEvent);
//! Handles some incoming events
- bool ProcessEvent(const Event &event);
+ bool ProcessEvent(Event &event);
//! Renders the image in window
void Render();
@@ -226,7 +307,7 @@ protected:
//! Graphics device
Gfx::CDevice* m_device;
//! Sound subsystem
- CSound* m_sound;
+ CSoundInterface* m_sound;
//! Main class of the proper game engine
CRobotMain* m_robotMain;
@@ -248,13 +329,36 @@ protected:
//! Text set as window title
std::string m_windowTitle;
- int m_keyState;
- Math::Vector m_axeKey;
- Math::Vector m_axeJoy;
- Math::Point m_systemMousePos;
- long m_mouseWheel;
+ //! Animation time stamps, etc.
+ //@{
+ SystemTimeStamp* m_baseTimeStamp;
+ SystemTimeStamp* m_lastTimeStamp;
+ SystemTimeStamp* m_curTimeStamp;
- long m_key[50][2];
+ long long m_realAbsTimeBase;
+ long long m_realAbsTime;
+ long long m_realRelTime;
+
+ long long m_absTimeBase;
+ long long m_exactAbsTime;
+ long long m_exactRelTime;
+
+ float m_absTime;
+ float m_relTime;
+
+ float m_simulationSpeed;
+ bool m_simulationSuspended;
+ //@}
+
+ //! Current state of key modifiers (mask of SDLMod)
+ unsigned int m_kmodState;
+ //! Current state of some tracked keys (mask of TrackedKey)
+ unsigned int m_trackedKeys;
+ //! Current state of mouse buttons (mask of button indexes)
+ unsigned int m_mouseButtonsState;
+
+ //! Current system mouse position
+ Math::Point m_systemMousePos;
//! Info about current joystick device
JoystickDevice m_joystick;
@@ -267,5 +371,8 @@ protected:
//! Path to directory with data files
std::string m_dataPath;
+
+ //! Application language
+ Language m_language;
};
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 0d885f7..084ca30 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -78,11 +78,16 @@ int main(int argc, char *argv[])
CApplication app; // single instance of the application
- if (! app.ParseArguments(argc, argv))
+ ParseArgsStatus status = app.ParseArguments(argc, argv);
+ if (status == PARSE_ARGS_FAIL)
{
SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
return app.GetExitCode();
}
+ else if (status == PARSE_ARGS_HELP)
+ {
+ return app.GetExitCode();
+ }
int code = 0;
diff --git a/src/app/system_windows.h b/src/app/system_windows.h
index 72d9f88..c9743e6 100644
--- a/src/app/system_windows.h
+++ b/src/app/system_windows.h
@@ -48,18 +48,18 @@ struct SystemTimeStamp
// Convert a wide Unicode string to an UTF8 string
std::string UTF8_Encode_Windows(const std::wstring &wstr)
{
- int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
+ int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), NULL, 0, NULL, NULL);
std::string strTo(size_needed, 0);
- WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
+ WideCharToMultiByte(CP_UTF8, 0, &wstr[0], static_cast<int>(wstr.size()), &strTo[0], size_needed, NULL, NULL);
return strTo;
}
// Convert an UTF8 string to a wide Unicode String
std::wstring UTF8_Decode_Windows(const std::string &str)
{
- int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
+ int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), NULL, 0);
std::wstring wstrTo(size_needed, 0);
- MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
+ MultiByteToWideChar(CP_UTF8, 0, &str[0], static_cast<int>(str.size()), &wstrTo[0], size_needed);
return wstrTo;
}
diff --git a/src/common/error_ids.h b/src/common/error_ids.h
index b17a018..fc1f7d6 100644
--- a/src/common/error_ids.h
+++ b/src/common/error_ids.h
@@ -14,6 +14,9 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// TODO: move to global.h after restext rewrite
+
#pragma once
enum Error
@@ -23,8 +26,6 @@ enum Error
ERR_CONTINUE = 2, // continues
ERR_STOP = 3, // stops
ERR_CMD = 4, // unknown command
- ERR_INSTALL = 20, // incorrectly installed program
- ERR_NOCD = 21, // CD not found
ERR_MANIP_VEH = 100, // inappropriate vehicle
ERR_MANIP_FLY = 101, // impossible in flight
ERR_MANIP_BUSY = 102, // taking: hands already occupied
diff --git a/src/common/event.cpp b/src/common/event.cpp
index 6a5f4d3..87c8a5c 100644
--- a/src/common/event.cpp
+++ b/src/common/event.cpp
@@ -19,6 +19,16 @@
#include "common/event.h"
#include "common/iman.h"
+static EventType g_uniqueEventType = EVENT_USER;
+
+
+EventType GetUniqueEventType()
+{
+ int i = static_cast<int>(g_uniqueEventType+1);
+ g_uniqueEventType = static_cast<EventType>(i);
+ return g_uniqueEventType;
+}
+
CEventQueue::CEventQueue(CInstanceManager* iMan)
diff --git a/src/common/event.h b/src/common/event.h
index 3192931..378960c 100644
--- a/src/common/event.h
+++ b/src/common/event.h
@@ -14,23 +14,26 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// event.h
+/**
+ * \file common/event.h
+ * \brief Event types, structs and event queue
+ */
#pragma once
-#include <common/key.h>
-#include <common/event_ids.h>
-#include <math/point.h>
-
-#include <string.h>
-
+#include "common/key.h"
+#include "common/event_ids.h"
+#include "math/point.h"
+#include "math/vector.h"
class CInstanceManager;
-/** \enum PressState
- \brief State of key/mouse button */
+/**
+ * \enum PressState
+ * \brief State of key/mouse button
+ */
enum PressState
{
STATE_PRESSED,
@@ -38,21 +41,22 @@ enum PressState
};
-/** \struct KeyEventData
- \brief Additional data for keyboard event */
+/**
+ * \struct KeyEventData
+ * \brief Additional data for keyboard event
+ */
struct KeyEventData
{
//! STATE_PRESSED or STATE_RELEASED */
PressState state;
- //! Key symbol: KEY(...) macro value (from common/key.h)
+ //! If true, the key is a virtual code generated by key modifier press or joystick button press
+ bool virt;
+ //! Key symbol: KEY(...) macro value or virtual key VIRTUAL_... (from common/key.h)
unsigned int key;
//! Keyboard modifiers: a bitmask made of KEY_MOD(...) macro values (from common/key.h)
unsigned int mod;
//! Unicode character
unsigned int unicode;
-
- KeyEventData()
- : state(STATE_PRESSED), key(0), mod(0), unicode(0) {}
};
/** \struct MouseMotionEventData
@@ -60,16 +64,15 @@ struct KeyEventData
struct MouseMoveEventData
{
//! Current button state
- unsigned char state;
+ PressState state;
//! Position of mouse in normalized coordinates (0..1)
Math::Point pos;
-
- MouseMoveEventData()
- : state(STATE_PRESSED) {}
};
-/** \struct MouseButtonEventData
- \brief Additional data mouse button event */
+/**
+ * \struct MouseButtonEventData
+ * \brief Additional data mouse button event
+ */
struct MouseButtonEventData
{
//! The mouse button index
@@ -78,39 +81,58 @@ struct MouseButtonEventData
PressState state;
//! Position of mouse in normalized coordinates (0..1)
Math::Point pos;
+};
+
+/**
+ * \enum WheelDirection
+ * \brief Direction of mouse wheel movement
+ */
+enum WheelDirection
+{
+ WHEEL_UP,
+ WHEEL_DOWN
+};
- MouseButtonEventData()
- : button(0), state(STATE_PRESSED) {}
+/**
+ * \enum MouseWheelEventData
+ * \brief Additional data for mouse wheel event.
+ */
+struct MouseWheelEventData
+{
+ //! Wheel direction
+ WheelDirection dir;
+ //! Position of mouse in normalized coordinates (0..1)
+ Math::Point pos;
};
-/** \struct JoyAxisEventData
- \brief Additional data for joystick axis event */
+/**
+ * \struct JoyAxisEventData
+ * \brief Additional data for joystick axis event
+ */
struct JoyAxisEventData
{
//! The joystick axis index
unsigned char axis;
//! The axis value (range: -32768 to 32767)
int value;
-
- JoyAxisEventData()
- : axis(axis), value(value) {}
};
-/** \struct JoyButtonEventData
- \brief Additional data for joystick button event */
+/**
+ * \struct JoyButtonEventData
+ * \brief Additional data for joystick button event
+ */
struct JoyButtonEventData
{
//! The joystick button index
unsigned char button;
//! STATE_PRESSED or STATE_RELEASED
PressState state;
-
- JoyButtonEventData()
- : button(0), state(STATE_PRESSED) {}
};
-/** \enum ActiveEventFlags
- \brief Type of focus gained/lost */
+/**
+ * \enum ActiveEventFlags
+ * \brief Type of focus gained/lost
+ */
enum ActiveEventFlags
{
//! Application window focus
@@ -122,30 +144,29 @@ enum ActiveEventFlags
};
-/** \struct ActiveEventData
- \brief Additional data for active event */
+/**
+ * \struct ActiveEventData
+ * \brief Additional data for active event
+ */
struct ActiveEventData
{
//! Flags (bitmask of enum values ActiveEventFlags)
unsigned char flags;
//! True if the focus was gained; false otherwise
bool gain;
-
- ActiveEventData()
- : flags(0), gain(false) {}
};
/**
- \struct Event
- \brief Event sent by system, interface or game
-
- Event is described by its type (EventType) and the union
- \a data contains additional data about the event.
- Different members of the union are filled with different event types.
- With some events, nothing is filled (it's zeroed out).
- The union contains roughly the same information as SDL_Event struct
- but packaged to independent structs and fields.
+ * \struct Event
+ * \brief Event sent by system, interface or game
+ *
+ * Event is described by its type (EventType) and the union
+ * \a data contains additional data about the event.
+ * Different members of the union are filled with different event types.
+ * With some events, nothing is filled (it's zeroed out).
+ * The union contains roughly the same information as SDL_Event struct
+ * but packaged to independent structs and fields.
**/
struct Event
{
@@ -163,6 +184,8 @@ struct Event
MouseButtonEventData mouseButton;
//! Additional data for EVENT_MOUSE_MOVE
MouseMoveEventData mouseMove;
+ //! Additional data for EVENT_MOUSE_WHEEL
+ MouseWheelEventData mouseWheel;
//! Additional data for EVENT_JOY
JoyAxisEventData joyAxis;
//! Additional data for EVENT_JOY_AXIS
@@ -171,70 +194,49 @@ struct Event
ActiveEventData active;
};
- // TODO: refactor/rewrite
+ //! State of tracked keys (mask of TrackedKey enum values)
+ unsigned int trackedKeys;
+
+ //! Mouse position is provided also for other types of events besides mouse events
+ Math::Point mousePos;
+
+ //! Motion vector set by keyboard or joystick
+ Math::Vector motionInput;
+
+ // TODO: remove and replace references with trackedKeys
+ short keyState;
+
+ // TODO: remove and replace references with mousePos
+ Math::Point pos;
+
+ // TODO: remove
long param; // parameter
- Math::Point pos; // mouse position (0 .. 1)
- float axeX; // control the X axis (-1 .. 1)
- float axeY; // control of the Y axis (-1 .. 1)
- float axeZ; // control the Z axis (-1 .. 1)
- short keyState; // state of the keyboard (KS_ *)
+
+ // TODO: remove in longer term (use CApplication's new time functions instead)
float rTime; // relative time
Event(EventType aType = EVENT_NULL)
{
type = aType;
systemEvent = false;
+ trackedKeys = 0;
param = 0;
- axeX = axeY = axeZ = 0.0f;
- keyState = 0;
rTime = 0.0f;
}
};
-/**
- \enum KeyRank
- \brief Slots for key assignment of user controls
- */
-
-// TODO: move to global.h ?
-
-enum KeyRank
-{
- KEYRANK_LEFT = 0,
- KEYRANK_RIGHT = 1,
- KEYRANK_UP = 2,
- KEYRANK_DOWN = 3,
- KEYRANK_GUP = 4,
- KEYRANK_GDOWN = 5,
- KEYRANK_CAMERA = 6,
- KEYRANK_DESEL = 7,
- KEYRANK_ACTION = 8,
- KEYRANK_NEAR = 9,
- KEYRANK_AWAY = 10,
- KEYRANK_NEXT = 11,
- KEYRANK_HUMAN = 12,
- KEYRANK_QUIT = 13,
- KEYRANK_HELP = 14,
- KEYRANK_PROG = 15,
- KEYRANK_VISIT = 16,
- KEYRANK_SPEED10 = 17,
- KEYRANK_SPEED15 = 18,
- KEYRANK_SPEED20 = 19,
- KEYRANK_SPEED30 = 20,
- KEYRANK_AIMUP = 21,
- KEYRANK_AIMDOWN = 22,
- KEYRANK_CBOT = 23,
-};
+//! Returns an unique event type (above the standard IDs)
+EventType GetUniqueEventType();
/**
- \class CEventQueue
- \brief Global event queue
-
- Provides an interface to a global FIFO queue with events (both system- and user-generated).
- The queue has a fixed maximum size but it should not be a problem.
+ * \class CEventQueue
+ * \brief Global event queue
+ *
+ * Provides an interface to a global FIFO queue with events (both system- and user-generated).
+ * The queue has a fixed maximum size but it should not be a problem.
*/
class CEventQueue
{
@@ -261,5 +263,3 @@ protected:
int m_tail;
int m_total;
};
-
-
diff --git a/src/common/event_ids.h b/src/common/event_ids.h
index ab235d5..9cbbf94 100644
--- a/src/common/event_ids.h
+++ b/src/common/event_ids.h
@@ -14,6 +14,9 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// TODO: move to event.h after restext rewrite
+
#pragma once
/**
@@ -38,6 +41,8 @@ enum EventType
EVENT_MOUSE_BUTTON_DOWN = 3,
//! Event sent after releasing a mouse button
EVENT_MOUSE_BUTTON_UP = 4,
+ //! Event sent after moving mouse wheel up or down
+ EVENT_MOUSE_WHEEL = 5,
//! Event sent after moving the mouse
EVENT_MOUSE_MOVE = 7,
//! Event sent after pressing a key
@@ -48,9 +53,6 @@ enum EventType
//! Event sent when application window loses/gains focus
EVENT_ACTIVE = 10,
- //? EVENT_CHAR = 10,
- //? EVENT_FOCUS = 11,
-
//! Event sent after moving joystick axes
EVENT_JOY_AXIS = 12,
//! Event sent after pressing a joystick button
diff --git a/src/common/global.h b/src/common/global.h
index 670c578..3433aeb 100644
--- a/src/common/global.h
+++ b/src/common/global.h
@@ -14,53 +14,124 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// global.h
+/**
+ * \file common/global.h
+ * \brief Some common, global definitions
+ */
#pragma once
+#include "error_ids.h"
-enum BuildType
+/**
+ * \enum Language
+ * \brief Application language
+ */
+enum Language
{
- BUILD_FACTORY = (1<<0), // factory
- BUILD_DERRICK = (1<<1), // derrick
- BUILD_CONVERT = (1<<2), // converter
- BUILD_RADAR = (1<<3), // radar
- BUILD_ENERGY = (1<<4), // factory of cells
- BUILD_NUCLEAR = (1<<5), // nuclear power plant
- BUILD_STATION = (1<<6), // base station
- BUILD_REPAIR = (1<<7), // repair center
- BUILD_TOWER = (1<<8), // defense tower
- BUILD_RESEARCH = (1<<9), // research center
- BUILD_LABO = (1<<10), // laboratory
- BUILD_PARA = (1<<11), // lightning protection
- BUILD_INFO = (1<<12), // information terminal
- BUILD_GFLAT = (1<<16), // flat floor
- BUILD_FLAG = (1<<17) // puts / removes colored flag
+ LANG_ENGLISH = 0,
+ LANG_FRENCH = 1,
+ LANG_GERMAN = 2,
+ LANG_POLISH = 3
};
+/**
+ * \enum BuildType
+ * \brief Construction actions (buildings, etc.) available to user
+ *
+ * TODO: refactor
+ */
+enum BuildType
+{
+ BUILD_FACTORY = (1<<0), //! < factory
+ BUILD_DERRICK = (1<<1), //! < derrick
+ BUILD_CONVERT = (1<<2), //! < converter
+ BUILD_RADAR = (1<<3), //! < radar
+ BUILD_ENERGY = (1<<4), //! < factory of cells
+ BUILD_NUCLEAR = (1<<5), //! < nuclear power plant
+ BUILD_STATION = (1<<6), //! < base station
+ BUILD_REPAIR = (1<<7), //! < repair center
+ BUILD_TOWER = (1<<8), //! < defense tower
+ BUILD_RESEARCH = (1<<9), //! < research center
+ BUILD_LABO = (1<<10), //! < laboratory
+ BUILD_PARA = (1<<11), //! < lightning protection
+ BUILD_INFO = (1<<12), //! < information terminal
+ BUILD_GFLAT = (1<<16), //! < flat floor
+ BUILD_FLAG = (1<<17) //! < puts / removes colored flag
+};
-// Do not change values ​​was because of backups (bits = ...).
+/**
+ * \enum ResearchType
+ * \brief Research actions available to user
+ */
enum ResearchType
{
- RESEARCH_TANK = (1<<0), // caterpillars
- RESEARCH_FLY = (1<<1), // wings
- RESEARCH_CANON = (1<<2), // cannon
- RESEARCH_TOWER = (1<<3), // defense tower
- RESEARCH_ATOMIC = (1<<4), // nuclear
- RESEARCH_THUMP = (1<<5), // thumper
- RESEARCH_SHIELD = (1<<6), // shield
- RESEARCH_PHAZER = (1<<7), // phazer gun
- RESEARCH_iPAW = (1<<8), // legs of insects
- RESEARCH_iGUN = (1<<9), // cannon of insects
- RESEARCH_RECYCLER = (1<<10), // recycler
- RESEARCH_SUBM = (1<<11), // submarine
- RESEARCH_SNIFFER = (1<<12) // sniffer
+ RESEARCH_TANK = (1<<0), //! < caterpillars
+ RESEARCH_FLY = (1<<1), //! < wings
+ RESEARCH_CANON = (1<<2), //! < cannon
+ RESEARCH_TOWER = (1<<3), //! < defense tower
+ RESEARCH_ATOMIC = (1<<4), //! < nuclear
+ RESEARCH_THUMP = (1<<5), //! < thumper
+ RESEARCH_SHIELD = (1<<6), //! < shield
+ RESEARCH_PHAZER = (1<<7), //! < phazer gun
+ RESEARCH_iPAW = (1<<8), //! < legs of insects
+ RESEARCH_iGUN = (1<<9), //! < cannon of insects
+ RESEARCH_RECYCLER = (1<<10), //! < recycler
+ RESEARCH_SUBM = (1<<11), //! < submarine
+ RESEARCH_SNIFFER = (1<<12) //! < sniffer
+};
+
+/**
+ * \enum InputSlot
+ * \brief Available slots for input bindings
+ */
+enum InputSlot
+{
+ INPUT_SLOT_LEFT = 0,
+ INPUT_SLOT_RIGHT = 1,
+ INPUT_SLOT_UP = 2,
+ INPUT_SLOT_DOWN = 3,
+ INPUT_SLOT_GUP = 4,
+ INPUT_SLOT_GDOWN = 5,
+ INPUT_SLOT_CAMERA = 6,
+ INPUT_SLOT_DESEL = 7,
+ INPUT_SLOT_ACTION = 8,
+ INPUT_SLOT_NEAR = 9,
+ INPUT_SLOT_AWAY = 10,
+ INPUT_SLOT_NEXT = 11,
+ INPUT_SLOT_HUMAN = 12,
+ INPUT_SLOT_QUIT = 13,
+ INPUT_SLOT_HELP = 14,
+ INPUT_SLOT_PROG = 15,
+ INPUT_SLOT_VISIT = 16,
+ INPUT_SLOT_SPEED10 = 17,
+ INPUT_SLOT_SPEED15 = 18,
+ INPUT_SLOT_SPEED20 = 19,
+ INPUT_SLOT_SPEED30 = 20,
+ INPUT_SLOT_AIMUP = 21,
+ INPUT_SLOT_AIMDOWN = 22,
+ INPUT_SLOT_CBOT = 23,
+
+ INPUT_SLOT_MAX
};
+/**
+ * \enum JoyAxisSlot
+ * \brief Slots for joystick axes inputs
+ */
+enum JoyAxisSlot
+{
+ JOY_AXIS_SLOT_X,
+ JOY_AXIS_SLOT_Y,
+ JOY_AXIS_SLOT_Z,
+
+ JOY_AXIS_SLOT_MAX
+};
+
+
+// TODO: move to CRobotMain
extern long g_id; // unique identifier
-extern long g_build; // constructible buildings
-extern long g_researchDone; // research done
+extern int g_build; // constructible buildings
+extern int g_researchDone; // research done
extern long g_researchEnable; // research available
extern float g_unit; // conversion factor
-
-
diff --git a/src/common/image.cpp b/src/common/image.cpp
index 3d64377..50f6eee 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -21,6 +21,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <assert.h>
+
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <png.h>
@@ -88,21 +90,21 @@ bool PNGSaveSurface(const char *filename, SDL_Surface *surf)
/* Opening output file */
fp = fopen(filename, "wb");
- if (fp == NULL)
+ if (fp == nullptr)
{
PNG_ERROR = std::string("Could not open file '") + std::string(filename) + std::string("' for saving");
return false;
}
/* Initializing png structures and callbacks */
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, PNGUserError, NULL);
- if (png_ptr == NULL)
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, PNGUserError, nullptr);
+ if (png_ptr == nullptr)
return false;
info_ptr = png_create_info_struct(png_ptr);
- if (info_ptr == NULL)
+ if (info_ptr == nullptr)
{
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(NULL));
+ png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
PNG_ERROR = "png_create_info_struct() error!";
return false;
}
@@ -142,7 +144,7 @@ bool PNGSaveSurface(const char *filename, SDL_Surface *surf)
CImage::CImage()
{
- m_data = NULL;
+ m_data = nullptr;
}
CImage::~CImage()
@@ -150,22 +152,22 @@ CImage::~CImage()
Free();
}
-bool CImage::IsEmpty()
+bool CImage::IsEmpty() const
{
- return m_data == NULL;
+ return m_data == nullptr;
}
void CImage::Free()
{
- if (m_data != NULL)
+ if (m_data != nullptr)
{
- if (m_data->surface != NULL)
+ if (m_data->surface != nullptr)
{
SDL_FreeSurface(m_data->surface);
- m_data->surface = NULL;
+ m_data->surface = nullptr;
}
delete m_data;
- m_data = NULL;
+ m_data = nullptr;
}
}
@@ -174,6 +176,118 @@ ImageData* CImage::GetData()
return m_data;
}
+Math::IntPoint CImage::GetSize() const
+{
+ if (m_data == nullptr)
+ return Math::IntPoint();
+
+ return Math::IntPoint(m_data->surface->w, m_data->surface->h);
+}
+
+/**
+ * Image must be valid and pixel coords in valid range.
+ *
+ * \param pixel pixel coords (range x: 0..width-1 y: 0..height-1)
+ * \returns color
+ */
+Gfx::Color CImage::GetPixel(Math::IntPoint pixel)
+{
+ assert(m_data != nullptr);
+ assert(pixel.x >= 0 || pixel.x <= m_data->surface->w);
+ assert(pixel.y >= 0 || pixel.y <= m_data->surface->h);
+
+ int bpp = m_data->surface->format->BytesPerPixel;
+ int index = pixel.y * m_data->surface->pitch + pixel.x * bpp;
+ Uint8* p = &static_cast<Uint8*>(m_data->surface->pixels)[index];
+
+ Uint32 u = 0;
+ switch (bpp)
+ {
+ case 1:
+ u = *p;
+ break;
+
+ case 2:
+ u = *reinterpret_cast<Uint16*>(p);
+ break;
+
+ case 3:
+ if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
+ u = (p[0] << 16) | (p[1] << 8) | p[2];
+ else
+ u = p[0] | (p[1] << 8) | (p[2] << 16);
+ break;
+
+ case 4:
+ u = *reinterpret_cast<Uint32*>(p);
+ break;
+
+ default:
+ assert(false);
+ }
+
+ Uint8 r = 0, g = 0, b = 0, a = 0;
+ SDL_GetRGBA(u, m_data->surface->format, &r, &g, &b, &a);
+
+ return Gfx::Color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
+}
+
+/**
+ * Image must be valid and pixel coords in valid range.
+ *
+ * \param pixel pixel coords (range x: 0..width-1 y: 0..height-1)
+ * \param color color
+ */
+void CImage::SetPixel(Math::IntPoint pixel, Gfx::Color color)
+{
+ assert(m_data != nullptr);
+ assert(pixel.x >= 0 || pixel.x <= m_data->surface->w);
+ assert(pixel.y >= 0 || pixel.y <= m_data->surface->h);
+
+ int bpp = m_data->surface->format->BytesPerPixel;
+ int index = pixel.y * m_data->surface->pitch + pixel.x * bpp;
+ Uint8* p = &static_cast<Uint8*>(m_data->surface->pixels)[index];
+
+ Uint8 r = static_cast<Uint8>(color.r * 255.0f);
+ Uint8 g = static_cast<Uint8>(color.g * 255.0f);
+ Uint8 b = static_cast<Uint8>(color.b * 255.0f);
+ Uint8 a = static_cast<Uint8>(color.a * 255.0f);
+ Uint32 u = SDL_MapRGBA(m_data->surface->format, r, g, b, a);
+
+ switch(bpp)
+ {
+ case 1:
+ *p = u;
+ break;
+
+ case 2:
+ *reinterpret_cast<Uint16*>(p) = u;
+ break;
+
+ case 3:
+ if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
+ {
+ p[0] = (u >> 16) & 0xFF;
+ p[1] = (u >> 8) & 0xFF;
+ p[2] = u & 0xFF;
+ }
+ else
+ {
+ p[0] = u & 0xFF;
+ p[1] = (u >> 8) & 0xFF;
+ p[2] = (u >> 16) & 0xFF;
+ }
+ break;
+
+ case 4:
+ *reinterpret_cast<Uint32*>(p) = u;
+ break;
+
+ default:
+ assert(false);
+ }
+}
+
std::string CImage::GetError()
{
return m_error;
@@ -189,10 +303,10 @@ bool CImage::Load(const std::string& fileName)
m_error = "";
m_data->surface = IMG_Load(fileName.c_str());
- if (m_data->surface == NULL)
+ if (m_data->surface == nullptr)
{
delete m_data;
- m_data = NULL;
+ m_data = nullptr;
m_error = std::string(IMG_GetError());
return false;
diff --git a/src/common/image.h b/src/common/image.h
index 4d86d31..93c7cab 100644
--- a/src/common/image.h
+++ b/src/common/image.h
@@ -14,10 +14,15 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// image.h
+/**
+ * \file common/image.h
+ * \brief Class for loading and saving images
+ */
#pragma once
+#include "graphics/core/color.h"
+#include "math/intpoint.h"
#include <stddef.h>
#include <string>
@@ -61,12 +66,21 @@ public:
//! Frees the allocated image data
void Free();
- //! Returns whether the image is empty (has NULL data)
- bool IsEmpty();
+ //! Returns whether the image is empty (has null data)
+ bool IsEmpty() const;
- //! Returns the image data; if empty - returns NULL
+ //! Returns the image data; if empty - returns nullptr
ImageData* GetData();
+ //! Returns the image size
+ Math::IntPoint GetSize() const;
+
+ //! Sets the color at given pixel
+ void SetPixel(Math::IntPoint pixel, Gfx::Color color);
+
+ //! Returns the color at given pixel
+ Gfx::Color GetPixel(Math::IntPoint pixel);
+
//! Loads an image from the specified file
bool Load(const std::string &fileName);
diff --git a/src/common/iman.cpp b/src/common/iman.cpp
index 4b89ecf..e59afb1 100644
--- a/src/common/iman.cpp
+++ b/src/common/iman.cpp
@@ -16,12 +16,10 @@
// iman.cpp
-
-#include <stdio.h>
-
-#include "common/struct.h"
#include "common/iman.h"
+#include <cassert>
+
template<> CInstanceManager* CSingleton<CInstanceManager>::mInstance = nullptr;
@@ -39,139 +37,91 @@ CInstanceManager* CInstanceManager::GetInstancePointer()
return mInstance;
}
-
-// Object's constructor.
-
CInstanceManager::CInstanceManager()
{
- int i;
-
- for ( i=0 ; i<CLASS_MAX ; i++ )
+ for (int i = 0; i < CLASS_MAX; i++)
{
- m_table[i].totalPossible = 0;
- m_table[i].totalUsed = 0;
- m_table[i].classPointer = 0;
+ m_table[i].maxCount = 0;
+ m_table[i].usedCount = 0;
+ m_table[i].instances = nullptr;
}
}
-// Object's destructor.
-
CInstanceManager::~CInstanceManager()
{
- int i;
-
- for ( i=0 ; i<CLASS_MAX ; i++ )
- {
- if ( m_table[i].classPointer != 0 )
- {
- free(m_table[i].classPointer);
- }
- }
+ Flush();
}
-
-// Empty the list of all classes.
-
void CInstanceManager::Flush()
{
- int i;
-
- for ( i=0 ; i<CLASS_MAX ; i++ )
+ for (int i = 0; i < CLASS_MAX; i++)
{
- if ( m_table[i].classPointer != 0 )
- {
- free(m_table[i].classPointer);
- }
- m_table[i].classPointer = 0;
+ if (m_table[i].instances != nullptr)
+ delete[] m_table[i].instances;
+
+ m_table[i].instances = nullptr;
}
}
-// Empty all instances of a given class.
-
-void CInstanceManager::Flush(ClassType classType)
+void CInstanceManager::Flush(ManagedClassType classType)
{
- if ( classType < 0 || classType >= CLASS_MAX ) return;
- if ( m_table[classType].classPointer == 0 ) return;
+ if (classType < 0 || classType >= CLASS_MAX) return;
+ if (m_table[classType].instances == nullptr) return;
- free(m_table[classType].classPointer);
- m_table[classType].classPointer = 0;
+ delete[] m_table[classType].instances;
+ m_table[classType].instances = nullptr;
}
-
-// Adds a new instance of a class.
-
-bool CInstanceManager::AddInstance(ClassType classType, void* pointer, int max)
+bool CInstanceManager::AddInstance(ManagedClassType classType, void* instance, int max)
{
- int i;
+ if (classType < 0 || classType >= CLASS_MAX) return false;
- if ( classType < 0 || classType >= CLASS_MAX ) return false;
-
- if ( m_table[classType].classPointer == 0 )
+ if (m_table[classType].instances == nullptr)
{
- m_table[classType].classPointer = static_cast<void**>( malloc(max*sizeof(void*)) );
- m_table[classType].totalPossible = max;
- m_table[classType].totalUsed = 0;
+ m_table[classType].instances = new void*[max];
+ m_table[classType].maxCount = max;
+ m_table[classType].usedCount = 0;
}
- if ( m_table[classType].totalUsed >= m_table[classType].totalPossible ) return false;
+ if (m_table[classType].usedCount >= m_table[classType].maxCount) return false;
- i = m_table[classType].totalUsed++;
- m_table[classType].classPointer[i] = pointer;
+ int i = m_table[classType].usedCount++;
+ m_table[classType].instances[i] = instance;
return true;
}
-// Deletes an instance of a class.
-
-bool CInstanceManager::DeleteInstance(ClassType classType, void* pointer)
+bool CInstanceManager::DeleteInstance(ManagedClassType classType, void* instance)
{
- int i;
-
- if ( classType < 0 || classType >= CLASS_MAX ) return false;
+ if (classType < 0 || classType >= CLASS_MAX) return false;
- for ( i=0 ; i<m_table[classType].totalUsed ; i++ )
+ for (int i = 0; i < m_table[classType].usedCount; i++)
{
- if ( m_table[classType].classPointer[i] == pointer )
- {
- m_table[classType].classPointer[i] = 0;
- }
+ if (m_table[classType].instances[i] == instance)
+ m_table[classType].instances[i] = nullptr;
}
Compress(classType);
return true;
}
-// Seeking an existing instance. Returns 0 if it does not exist.
-// Must be super fast!
-
-void* CInstanceManager::SearchInstance(ClassType classType, int rank)
+void* CInstanceManager::SearchInstance(ManagedClassType classType, int rank)
{
-#if _DEBUG
- if ( classType < 0 || classType >= CLASS_MAX ) return 0;
- if ( m_table[classType].classPointer == 0 ) return 0;
-#endif
- if ( rank >= m_table[classType].totalUsed ) return 0;
+ if (classType < 0 || classType >= CLASS_MAX) return nullptr;
+ if (m_table[classType].instances == nullptr) return nullptr;
+ if (rank >= m_table[classType].usedCount) return nullptr;
- return m_table[classType].classPointer[rank];
+ return m_table[classType].instances[rank];
}
-
-// Fills holes in a table.
-
-void CInstanceManager::Compress(ClassType classType)
+void CInstanceManager::Compress(ManagedClassType classType)
{
- int i, j;
+ if (classType < 0 || classType >= CLASS_MAX) return;
- if ( classType < 0 || classType >= CLASS_MAX ) return;
-
- j = 0;
- for ( i=0 ; i<m_table[classType].totalUsed ; i++ )
+ int j = 0;
+ for (int i = 0; i < m_table[classType].usedCount; i++)
{
- if ( m_table[classType].classPointer[i] != 0 )
- {
- m_table[classType].classPointer[j++] = m_table[classType].classPointer[i];
- }
+ if (m_table[classType].instances[i] != nullptr)
+ m_table[classType].instances[j++] = m_table[classType].instances[i];
}
- m_table[classType].totalUsed = j;
+ m_table[classType].usedCount = j;
}
-
-
diff --git a/src/common/iman.h b/src/common/iman.h
index 89b5206..44f143a 100644
--- a/src/common/iman.h
+++ b/src/common/iman.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// iman.h
+/**
+ * \file iman.h
+ * \brief Instance manager for managed classes
+ */
#pragma once
@@ -22,36 +25,119 @@
#include <common/misc.h>
+/**
+ * \enum ManagedClassType
+ * \brief Type of class managed by CInstanceManager
+ */
-struct BaseClass
+// TODO: remove unnecessary, refactor to singletons, move to CRobotMain, keep others?
+
+enum ManagedClassType
{
- int totalPossible;
- int totalUsed;
- void** classPointer;
+ //! CEventQueue
+ CLASS_EVENT = 1,
+ //! Ui::CInterface
+ CLASS_INTERFACE = 2,
+ //! CRobotMain
+ CLASS_MAIN = 3,
+ //! Gfx::CEngine
+ CLASS_ENGINE = 4,
+ //! Gfx::CTerrain
+ CLASS_TERRAIN = 5,
+ //! CObject
+ CLASS_OBJECT = 6,
+ //! CPhysics
+ CLASS_PHYSICS = 7,
+ //! CBrain
+ CLASS_BRAIN = 8,
+ //! Gfx::CCamera
+ CLASS_CAMERA = 9,
+ //! Gfx::CLightManager
+ CLASS_LIGHT = 10,
+ //! Gfx::CParticle
+ CLASS_PARTICULE = 11,
+ //! CAuto; TODO: remove (unused)
+ CLASS_AUTO = 12,
+ //! Ui::CDisplayText
+ CLASS_DISPLAYTEXT = 13,
+ //! Gfx::CPyro
+ CLASS_PYRO = 14,
+ //! Ui::CScript; TODO: remove (unused)
+ CLASS_SCRIPT = 15,
+ //! Gfx::CText
+ CLASS_TEXT = 16,
+ //! Ui::CStudio, Ui::CDisplayText; TODO: remove (unused)
+ CLASS_STUDIO = 17,
+ //! Gfx::CWater
+ CLASS_WATER = 18,
+ //! Gfx::CCloud; TODO: remove (unused)
+ CLASS_CLOUD = 19,
+ //! CMotion; TODO: remove (unused)
+ CLASS_MOTION = 20,
+ //! CSoundInterface
+ CLASS_SOUND = 21,
+ //! Gfx::CPlanet
+ CLASS_PLANET = 22,
+ //! CTaskManager; TODO: remove (unused)
+ CLASS_TASKMANAGER = 23,
+ //! Ui::CMainDialog; TODO: remove (unused)
+ CLASS_DIALOG = 24,
+ //! Ui::CMainMap; TODO: remove (unused)
+ CLASS_MAP = 25,
+ //! Ui::CMainShort, CMainMovie; TODO: remove (unused)
+ CLASS_SHORT = 26,
+ //! Gfx::CLightning; TODO: remove (unused)
+ CLASS_BLITZ = 27,
+
+ //! Maximum (number of managed classes)
+ CLASS_MAX = 30
};
+/**
+ * \enum ManagedClassInstances
+ * \brief Instances of class managed by CInstanceManager
+ */
+struct ManagedClassInstances
+{
+ int maxCount;
+ int usedCount;
+ void** instances;
+};
+/**
+ * \class CInstanceManager
+ * \brief Manager for instances of certain classes
+ *
+ * Instance manager (often shortened to iMan) allows to register instances of
+ * classes and search them.
+ */
class CInstanceManager : public CSingleton<CInstanceManager>
{
public:
CInstanceManager();
~CInstanceManager();
+ //! Remove all managed instances
void Flush();
- void Flush(ClassType classType);
- bool AddInstance(ClassType classType, void* pointer, int max=1);
- bool DeleteInstance(ClassType classType, void* pointer);
- void* SearchInstance(ClassType classType, int rank=0);
+ //! Removes instances of one type of class
+ void Flush(ManagedClassType classType);
+ //! Registers new instance of class type
+ bool AddInstance(ManagedClassType classType, void* instance, int max=1);
+ //! Deletes the registered instance of class type
+ bool DeleteInstance(ManagedClassType classType, void* instance);
+ //! Seeks a class instance of given type
+ void* SearchInstance(ManagedClassType classType, int rank=0);
static CInstanceManager& GetInstance();
static CInstanceManager* GetInstancePointer();
protected:
- void Compress(ClassType classType);
+ //! Fills holes in instance table
+ void Compress(ManagedClassType classType);
protected:
- BaseClass m_table[CLASS_MAX];
+ ManagedClassInstances m_table[CLASS_MAX];
};
diff --git a/src/common/ioutils.h b/src/common/ioutils.h
index 2a542c6..e7668eb 100644
--- a/src/common/ioutils.h
+++ b/src/common/ioutils.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// ioutils.h
+/**
+ * \file ioutils.h
+ * \brief Functions for binary I/O
+ */
#pragma once
diff --git a/src/common/key.h b/src/common/key.h
index de31c09..11076a3 100644
--- a/src/common/key.h
+++ b/src/common/key.h
@@ -29,6 +29,32 @@
// If need arises, it can be changed to custom function or anything else
#define KEY(x) SDLK_ ## x
+
// Key modifier defined as concatenation to KMOD_...
// If need arises, it can be changed to custom function or anything else
#define KEY_MOD(x) KMOD_ ## x
+
+/**
+ * \enum VirtualKmod
+ * \brief Virtual key codes generated on kmod presses
+ *
+ * These are provided here because left and right pair of keys generate different codes.
+ */
+enum VirtualKmod
+{
+ VIRTUAL_KMOD_CTRL = SDLK_LAST + 100, //! < control (left or right)
+ VIRTUAL_KMOD_SHIFT = SDLK_LAST + 101, //! < shift (left or right)
+ VIRTUAL_KMOD_ALT = SDLK_LAST + 102, //! < alt (left or right)
+ VIRTUAL_KMOD_META = SDLK_LAST + 103 //! < win key (left or right)
+};
+
+// Just syntax sugar
+// So it is the same as other macros
+#define VIRTUAL_KMOD(x) VIRTUAL_KMOD_ ## x
+
+// Virtual key code generated on joystick button presses
+// num is number of joystick button
+#define VIRTUAL_JOY(num) (SDLK_LAST + 200 + num)
+
+//! Special value for invalid key bindings
+const unsigned int KEY_INVALID = SDLK_LAST + 1000;
diff --git a/src/common/language.h b/src/common/language.h
deleted file mode 100644
index 82a7235..0000000
--- a/src/common/language.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// * 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/.
-
-// language.h
-
-#pragma once
-
-
-#define _FULL true // CoLoBoT
-#define _SCHOOL false // CeeBot-A or Teen
- #define _TEEN false // false for CeeBot-A, true for CeeBot-Teen
- #define _EDU false
- #define _PERSO false
- #define _CEEBOTDEMO false
-#define _NET false
-#define _DEMO false // DEMO only CoLoBoT (with _Full = false)!
-
-#define _FRENCH false
-#define _ENGLISH true
-#define _GERMAN false
-#define _WG false
-#define _POLISH false
-
-#define _NEWLOOK false // false for CoLoBoT, true for all CeeBot
-#define _SOUNDTRACKS false // always false since InitAudioTrackVolume crop in Vista
-
-
-// Verifications
-
-#if !_FULL & !_SCHOOL & !_NET & !_DEMO
--> no version chosen!
-#endif
-
-#if _SCHOOL
-#if !_EDU & !_PERSO & !_CEEBOTDEMO
--> EDU or PERSO or CEEBOTDEMO?
-#endif
-#if _EDU & _PERSO & _CEEBOTDEMO
--> EDU and PERSO and CEEBOTDEMO not at the same time!!!
-#endif
-#endif
diff --git a/src/common/logger.h b/src/common/logger.h
index fc43735..dfeeb98 100644
--- a/src/common/logger.h
+++ b/src/common/logger.h
@@ -14,22 +14,20 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// logger.h
+/**
+ * \file common/logger.h
+ * \brief Class for logging information to file or console
+ */
#pragma once
+#include "common/singleton.h"
+
#include <string>
#include <cstdarg>
#include <cstdio>
-#include <common/singleton.h>
-
-/**
- * @file common/logger.h
- * @brief Class for loggin information to file or console
- */
-
/**
* \public
diff --git a/src/common/metafile.cpp b/src/common/metafile.cpp
index 9d54f78..4e7e916 100644
--- a/src/common/metafile.cpp
+++ b/src/common/metafile.cpp
@@ -16,17 +16,15 @@
// metafile.cpp
-
-#include <windows.h>
-#include <stdio.h>
-
-#include "common/language.h"
#include "common/metafile.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
-#if _FULL | _NET
+//#if _FULL | _NET
static unsigned char table_codec[23] =
{
0x85, 0x91, 0x73, 0xcf, 0xa2, 0xbb, 0xf4, 0x77,
@@ -36,7 +34,7 @@ static unsigned char table_codec[23] =
void Codec(void* buffer, int len, int start)
{
- unsigned char *b = (unsigned char*)buffer;
+ unsigned char *b = static_cast<unsigned char*>(buffer);
int i;
for ( i=0 ; i<len ; i++ )
@@ -44,9 +42,9 @@ void Codec(void* buffer, int len, int start)
b[i] ^= table_codec[(start++)%23];
}
}
-#endif
+//#endif
-#if _SCHOOL
+/*#if _SCHOOL
#if _CEEBOTDEMO
static unsigned char table_codec[136] =
{
@@ -99,9 +97,9 @@ void Codec(void* buffer, int len, int start)
}
}
#endif
-#endif
+#endif*/
-#if _DEMO
+/*#if _DEMO
static unsigned char table_codec[27] =
{
0x85, 0x91, 0x77, 0xcf, 0xa3, 0xbb, 0xf4, 0x77,
@@ -120,7 +118,7 @@ void Codec(void* buffer, int len, int start)
b[i] ^= table_codec[(start++)%27];
}
}
-#endif
+#endif*/
@@ -286,7 +284,7 @@ int CMetaFile::Read(void *buffer, int size)
int CMetaFile::GetByte()
{
- BYTE b;
+ int b;
if ( !m_bOpen ) return 1;
@@ -303,7 +301,7 @@ int CMetaFile::GetByte()
int CMetaFile::GetWord()
{
- WORD w;
+ int w;
if ( !m_bOpen ) return 1;
@@ -352,7 +350,7 @@ int CMetaFile::MetaOpen(char *metaname)
strcpy(m_list[i].name, metaname); // memorized the name
fread(&m_list[i].total, sizeof(int), 1, m_list[i].stream);
- m_list[i].headers = (MetaHeader*)malloc(sizeof(MetaHeader)*m_list[i].total);
+ m_list[i].headers = static_cast<MetaHeader*>(malloc(sizeof(MetaHeader)*m_list[i].total));
offset = 4;
for ( j=0 ; j<m_list[i].total ; j++ )
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index 2427356..2ed6e2c 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -17,195 +17,171 @@
// misc.cpp
+#include "common/misc.h"
+
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <ctype.h>
-#include <direct.h>
#include <time.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "old/d3dutil.h"
-#include "common/language.h"
-#include "common/event.h"
-#include "common/misc.h"
-
-
-CMetaFile g_metafile;
-static EventMsg g_uniqueEventMsg = EVENT_USER;
static bool g_bUserDir = false;
static char g_userDir[100] = "";
-
-// Gives a single user event.
-
-EventMsg GetUniqueEventMsg()
-{
- int i;
-
- i = (int)g_uniqueEventMsg+1;
- g_uniqueEventMsg = (EventMsg)i;
- return g_uniqueEventMsg;
-}
-
-
-
// Returns a non-accented letter.
-char RetNoAccent(char letter)
+char GetNoAccent(char letter)
{
+ /*
if ( letter < 0 )
{
- if ( letter == 'á' ||
- letter == 'à' ||
- letter == 'â' ||
- letter == 'ä' ||
- letter == 'ã' ) return 'a';
-
- if ( letter == 'é' ||
- letter == 'è' ||
- letter == 'ê' ||
- letter == 'ë' ) return 'e';
-
- if ( letter == 'í' ||
- letter == 'ì' ||
- letter == 'î' ||
- letter == 'ï' ) return 'i';
-
- if ( letter == 'ó' ||
- letter == 'ò' ||
- letter == 'ô' ||
- letter == 'ö' ||
- letter == 'õ' ) return 'o';
-
- if ( letter == 'ú' ||
- letter == 'ù' ||
- letter == 'û' ||
- letter == 'ü' ) return 'u';
-
- if ( letter == 'ç' ) return 'c';
-
- if ( letter == 'ñ' ) return 'n';
-
- if ( letter == 'Á' ||
- letter == 'À' ||
- letter == 'Â' ||
- letter == 'Ä' ||
- letter == 'Ã' ) return 'A';
-
- if ( letter == 'É' ||
- letter == 'È' ||
- letter == 'Ê' ||
- letter == 'Ë' ) return 'E';
-
- if ( letter == 'Í' ||
- letter == 'Ì' ||
- letter == 'Î' ||
- letter == 'Ï' ) return 'I';
-
- if ( letter == 'Ó' ||
- letter == 'Ò' ||
- letter == 'Ô' ||
- letter == 'Ö' ||
- letter == 'Õ' ) return 'O';
-
- if ( letter == 'Ú' ||
- letter == 'Ù' ||
- letter == 'Û' ||
- letter == 'Ü' ) return 'U';
-
- if ( letter == 'Ç' ) return 'C';
-
- if ( letter == 'Ñ' ) return 'N';
- }
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'a';
+
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'e';
+
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'i';
+
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'o';
+
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'u';
+
+ if ( letter == '�' ) return 'c';
+
+ if ( letter == '�' ) return 'n';
+
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'A';
+
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'E';
+
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'I';
+
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'O';
+
+ if ( letter == '�' ||
+ letter == '�' ||
+ letter == '�' ||
+ letter == '�' ) return 'U';
+
+ if ( letter == '�' ) return 'C';
+
+ if ( letter == '�' ) return 'N';
+ }*/
return letter;
}
// Returns an uppercase letter.
-char RetToUpper(char letter)
+char GetToUpper(char letter)
{
- if ( letter < 0 )
+ /*if ( letter < 0 )
{
- if ( letter == 'á' ) return 'Á';
- if ( letter == 'à' ) return 'À';
- if ( letter == 'â' ) return 'Â';
- if ( letter == 'ä' ) return 'Ä';
- if ( letter == 'ã' ) return 'Ã';
-
- if ( letter == 'é' ) return 'É';
- if ( letter == 'è' ) return 'È';
- if ( letter == 'ê' ) return 'Ê';
- if ( letter == 'ë' ) return 'Ë';
-
- if ( letter == 'í' ) return 'Í';
- if ( letter == 'ì' ) return 'Ì';
- if ( letter == 'î' ) return 'Î';
- if ( letter == 'ï' ) return 'Ï';
-
- if ( letter == 'ó' ) return 'Ó';
- if ( letter == 'ò' ) return 'Ò';
- if ( letter == 'ô' ) return 'Ô';
- if ( letter == 'ö' ) return 'Ö';
- if ( letter == 'õ' ) return 'Õ';
-
- if ( letter == 'ú' ) return 'Ú';
- if ( letter == 'ù' ) return 'Ù';
- if ( letter == 'û' ) return 'Û';
- if ( letter == 'ü' ) return 'Ü';
-
- if ( letter == 'ç' ) return 'Ç';
-
- if ( letter == 'ñ' ) return 'Ñ';
- }
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ }*/
return toupper(letter);
}
// Returns a lowercase letter.
-char RetToLower(char letter)
+char GetToLower(char letter)
{
- if ( letter < 0 )
+ /*if ( letter < 0 )
{
- if ( letter == 'Á' ) return 'á';
- if ( letter == 'À' ) return 'à';
- if ( letter == 'Â' ) return 'â';
- if ( letter == 'Ä' ) return 'ä';
- if ( letter == 'Ã' ) return 'ã';
-
- if ( letter == 'É' ) return 'é';
- if ( letter == 'È' ) return 'è';
- if ( letter == 'Ê' ) return 'ê';
- if ( letter == 'Ë' ) return 'ë';
-
- if ( letter == 'Í' ) return 'í';
- if ( letter == 'Ì' ) return 'ì';
- if ( letter == 'Î' ) return 'î';
- if ( letter == 'Ï' ) return 'ï';
-
- if ( letter == 'Ó' ) return 'ó';
- if ( letter == 'Ò' ) return 'ò';
- if ( letter == 'Ô' ) return 'ô';
- if ( letter == 'Ö' ) return 'ö';
- if ( letter == 'Õ' ) return 'õ';
-
- if ( letter == 'Ú' ) return 'ú';
- if ( letter == 'Ù' ) return 'ù';
- if ( letter == 'Û' ) return 'û';
- if ( letter == 'Ü' ) return 'ü';
-
- if ( letter == 'Ç' ) return 'ç';
-
- if ( letter == 'Ñ' ) return 'ñ';
- }
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+
+ if ( letter == '�' ) return '�';
+ }*/
return tolower(letter);
}
@@ -222,6 +198,7 @@ void TimeToAscii(time_t time, char *buffer)
year = when.tm_year+1900;
if ( year < 2000 ) year -= 1900;
else year -= 2000;
+/* TODO
#if _FRENCH
sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
when.tm_mday, when.tm_mon+1, year,
@@ -232,7 +209,7 @@ void TimeToAscii(time_t time, char *buffer)
when.tm_mday, when.tm_mon+1, year,
when.tm_hour, when.tm_min);
#endif
-#if _ENGLISH
+#if _ENGLISH*/
char format[10];
int hour;
@@ -251,12 +228,12 @@ void TimeToAscii(time_t time, char *buffer)
sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d %s",
when.tm_mon+1, when.tm_mday, year,
hour, when.tm_min, format);
-#endif
+/*#endif
#if _POLISH
sprintf(buffer, "%.2d.%.2d.%.2d %.2d:%.2d",
when.tm_mday, when.tm_mon+1, year,
when.tm_hour, when.tm_min);
-#endif
+#endif*/
}
@@ -281,7 +258,7 @@ bool Xfer(char* src, char* dst)
return false;
}
- buffer = (char*)malloc(10000);
+ buffer = static_cast<char*>(malloc(10000));
while ( true )
{
@@ -311,7 +288,9 @@ bool CopyFileToTemp(char* filename)
UserDir(dst, filename, "textures");
strcpy(g_userDir, save);
- _mkdir("temp");
+ //_mkdir("temp");
+ system("mkdir temp");
+
if ( !Xfer(src, dst) ) return false;
strcpy(filename, dst);
@@ -359,7 +338,7 @@ bool CopyFileListToTemp(char* filename, int* list, int total)
// Adds an extension to file, if doesn't already one.
-void AddExt(char* filename, char* ext)
+void AddExt(char* filename, const char* ext)
{
if ( strchr(filename, '.') != 0 ) return; // already an extension?
strcat(filename, ext);
@@ -368,7 +347,7 @@ void AddExt(char* filename, char* ext)
// Specifies the user folder.
-void UserDir(bool bUser, char* dir)
+void UserDir(bool bUser, const char* dir)
{
g_bUserDir = bUser;
strcpy(g_userDir, dir);
@@ -379,10 +358,10 @@ void UserDir(bool bUser, char* dir)
// def = "abc\"
// out: buffer = "abc\toto.txt"
-void UserDir(char* buffer, char* dir, char* def)
+void UserDir(char* buffer, const char* dir, const char* def)
{
char ddir[100];
- char* add;
+ const char* add;
if ( strstr(dir, "\\") == 0 && def[0] != 0 )
{
@@ -418,24 +397,3 @@ void UserDir(char* buffer, char* dir, char* def)
}
*buffer = 0;
}
-
-
-// Returns the letter corresponding to the language.
-
-char RetLanguageLetter()
-{
-#if _FRENCH
- return 'F';
-#endif
-#if _ENGLISH
- return 'E';
-#endif
-#if _GERMAN | _WG
- return 'D';
-#endif
-#if _POLISH
- return 'P';
-#endif
- return 'X';
-}
-
diff --git a/src/common/misc.h b/src/common/misc.h
index dca801f..f6fd609 100644
--- a/src/common/misc.h
+++ b/src/common/misc.h
@@ -22,55 +22,7 @@
#include <time.h>
-#include "common/metafile.h"
-#include "common/event.h"
-#include "common/error_ids.h"
-
-
-extern CMetaFile g_metafile;
-
-
-
-// Existing classes.
-
-enum ClassType
-{
- CLASS_EVENT = 1,
- CLASS_INTERFACE = 2,
- CLASS_MAIN = 3,
- CLASS_ENGINE = 4,
- CLASS_TERRAIN = 5,
- CLASS_OBJECT = 6,
- CLASS_PHYSICS = 7,
- CLASS_BRAIN = 8,
- CLASS_CAMERA = 9,
- CLASS_LIGHT = 10,
- CLASS_PARTICULE = 11,
- CLASS_AUTO = 12,
- CLASS_DISPLAYTEXT = 13,
- CLASS_PYRO = 14,
- CLASS_SCRIPT = 15,
- CLASS_TEXT = 16,
- CLASS_STUDIO = 17,
- CLASS_WATER = 18,
- CLASS_CLOUD = 19,
- CLASS_MOTION = 20,
- CLASS_SOUND = 21,
- CLASS_PLANET = 22,
- CLASS_TASKMANAGER = 23,
- CLASS_DIALOG = 24,
- CLASS_MAP = 25,
- CLASS_SHORT = 26,
- CLASS_BLITZ = 27,
-};
-
-const int CLASS_MAX = 30;
-
-
-
-
-// Keyboard state.
-
+// TODO: to be removed (replaced by TrackedKey enum and mouse states in app.h)
const int KS_PAGEUP = (1<<4);
const int KS_PAGEDOWN = (1<<5);
const int KS_SHIFT = (1<<6);
@@ -84,23 +36,16 @@ const int KS_NUMRIGHT = (1<<13);
const int KS_NUMPLUS = (1<<14);
const int KS_NUMMINUS = (1<<15);
+// TODO: rewrite/refactor or remove
-// Procedures.
-
-extern EventType GetUniqueEventType();
-
-extern char RetNoAccent(char letter);
-extern char RetToUpper(char letter);
-extern char RetToLower(char letter);
+extern char GetNoAccent(char letter);
+extern char GetToUpper(char letter);
+extern char GetToLower(char letter);
extern void TimeToAscii(time_t time, char *buffer);
extern bool CopyFileToTemp(char* filename);
extern bool CopyFileListToTemp(char* filename, int* list, int total);
-extern void AddExt(char* filename, char* ext);
-extern void UserDir(bool bUser, char* dir);
-extern void UserDir(char* buffer, char* dir, char* def);
-
-extern char RetLanguageLetter();
-
-
+extern void AddExt(char* filename, const char* ext);
+extern void UserDir(bool bUser, const char* dir);
+extern void UserDir(char* buffer, const char* dir, const char* def);
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index 29a68e1..efcfa66 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -17,7 +17,10 @@
// profile.cpp
-#include <common/profile.h>
+#include "common/profile.h"
+
+#include <utility>
+#include <cstring>
template<> CProfile* CSingleton<CProfile>::mInstance = nullptr;
diff --git a/src/common/profile.h b/src/common/profile.h
index 0886522..7a23d94 100644
--- a/src/common/profile.h
+++ b/src/common/profile.h
@@ -14,22 +14,19 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// profile.h
+/**
+ * \file common/profile.h
+ * \brief Class for loading profile (currently for loading ini config file)
+ */
#pragma once
-#include <cstdlib>
-#include <vector>
-#include <utility>
-
-#include <lib/simpleini/SimpleIni.h>
+#include "lib/simpleini/SimpleIni.h"
-#include <common/singleton.h>
+#include "common/singleton.h"
-/**
- * @file common/profile.h
- * @brief Class for loading profile (currently for loading ini config file)
- */
+#include <string>
+#include <vector>
/**
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index 487d1a6..40d11b7 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -14,29 +14,21 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.// restext.cpp
-#include <libintl.h>
-#include <SDL/SDL_keyboard.h>
-#include "common/struct.h"
-#include "common/language.h"
-#include "common/misc.h"
+#include "common/restext.h"
+
+#include "common/global.h"
#include "common/event.h"
-#include "object/object.h"
+#include "common/logger.h"
#include "CBot/resource.h"
-#include "common/restext.h"
+#include "object/object.h"
+#include "object/robotmain.h"
+#include <libintl.h>
+#include <SDL/SDL_keyboard.h>
-// Gives the pointer to the engine.
-static CD3DEngine* g_engine;
static char g_gamerName[100];
-void SetEngine(CD3DEngine *engine)
-{
- g_engine = engine;
-}
-
-// Give the player's name.
-
void SetGlobalGamerName(char *name)
{
strcpy(g_gamerName, name);
@@ -46,39 +38,38 @@ void SetGlobalGamerName(char *name)
struct KeyDesc
{
- KeyRank key;
+ InputSlot key;
char name[20];
};
static KeyDesc keyTable[22] =
{
- { KEYRANK_LEFT, "left;" },
- { KEYRANK_RIGHT, "right;" },
- { KEYRANK_UP, "up;" },
- { KEYRANK_DOWN, "down;" },
- { KEYRANK_GUP, "gup;" },
- { KEYRANK_GDOWN, "gdown;" },
- { KEYRANK_CAMERA, "camera;" },
- { KEYRANK_DESEL, "desel;" },
- { KEYRANK_ACTION, "action;" },
- { KEYRANK_NEAR, "near;" },
- { KEYRANK_AWAY, "away;" },
- { KEYRANK_NEXT, "next;" },
- { KEYRANK_HUMAN, "human;" },
- { KEYRANK_QUIT, "quit;" },
- { KEYRANK_HELP, "help;" },
- { KEYRANK_PROG, "prog;" },
- { KEYRANK_CBOT, "cbot;" },
- { KEYRANK_VISIT, "visit;" },
- { KEYRANK_SPEED10, "speed10;" },
- { KEYRANK_SPEED15, "speed15;" },
- { KEYRANK_SPEED20, "speed20;" },
- { KEYRANK_SPEED30, "speed30;" },
+ { INPUT_SLOT_LEFT, "left;" },
+ { INPUT_SLOT_RIGHT, "right;" },
+ { INPUT_SLOT_UP, "up;" },
+ { INPUT_SLOT_DOWN, "down;" },
+ { INPUT_SLOT_GUP, "gup;" },
+ { INPUT_SLOT_GDOWN, "gdown;" },
+ { INPUT_SLOT_CAMERA, "camera;" },
+ { INPUT_SLOT_DESEL, "desel;" },
+ { INPUT_SLOT_ACTION, "action;" },
+ { INPUT_SLOT_NEAR, "near;" },
+ { INPUT_SLOT_AWAY, "away;" },
+ { INPUT_SLOT_NEXT, "next;" },
+ { INPUT_SLOT_HUMAN, "human;" },
+ { INPUT_SLOT_QUIT, "quit;" },
+ { INPUT_SLOT_HELP, "help;" },
+ { INPUT_SLOT_PROG, "prog;" },
+ { INPUT_SLOT_CBOT, "cbot;" },
+ { INPUT_SLOT_VISIT, "visit;" },
+ { INPUT_SLOT_SPEED10, "speed10;" },
+ { INPUT_SLOT_SPEED15, "speed15;" },
+ { INPUT_SLOT_SPEED20, "speed20;" }
};
// Seeks a key.
-bool SearchKey(const char *cmd, KeyRank &key)
+bool SearchKey(const char *cmd, InputSlot &key)
{
int i;
@@ -97,9 +88,10 @@ bool SearchKey(const char *cmd, KeyRank &key)
static void PutKeyName(char* dst, const char* src)
{
- KeyRank key;
+ InputSlot key;
char name[50];
- int s, d, n, res;
+ int s, d, n;
+ unsigned int res;
s = d = 0;
while ( src[s] != 0 )
@@ -112,9 +104,8 @@ static void PutKeyName(char* dst, const char* src)
{
if ( SearchKey(src+s+5, key) )
{
- // FIXME: res = g_engine->RetKey(key, 0);
- res = 0;
- if ( res != 0 )
+ res = CRobotMain::GetInstancePointer()->GetInputBinding(key).key;
+ if (res != KEY_INVALID)
{
if ( GetResource(RES_KEY, res, name) )
{
@@ -150,7 +141,12 @@ static const char* GetResourceBase(ResType type, int num)
str = strings_text[num];
break;
case RES_EVENT:
- assert(num < strings_event_len);
+ // assert(num < strings_event_len);
+ if (num >= strings_event_len)
+ {
+ GetLogger()->Warn("GetResource invalid event num: %d\n", num);
+ return "";
+ }
str = strings_event[num];
break;
case RES_OBJECT:
@@ -169,6 +165,7 @@ static const char* GetResourceBase(ResType type, int num)
break;
case RES_KEY:
assert(num < SDLK_LAST);
+ // TODO: virtual keys
str = SDL_GetKeyName(static_cast<SDLKey>(num));
break;
default:
diff --git a/src/common/restext.h b/src/common/restext.h
index 624803b..6abb7f5 100644
--- a/src/common/restext.h
+++ b/src/common/restext.h
@@ -14,32 +14,36 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// restext.h
+/**
+ * \file common/restext.h
+ * \brief Translation and string resource utilities
+ */
#pragma once
+#include "common/global.h"
#include "common/restext_ids.h"
-
-class CD3DEngine;
-
-// Possible types of the text resources.
-
+/**
+ * \enum ResType
+ * \brief Types of text resources
+ */
enum ResType
{
- RES_TEXT = 0, // RT_*
- RES_EVENT = 1, // EVENT_* (EventMsg)
- RES_OBJECT = 2, // OBJECT_* (ObjectType)
- RES_ERR = 3, // ERR_* (Error)
- RES_KEY = 4, // VK_* (keys)
- RES_CBOT = 5, // TX_* (cbot.dll)
+ RES_TEXT = 0, //! < RT_*
+ RES_EVENT = 1, //! < EVENT_* (EventMsg)
+ RES_OBJECT = 2, //! < OBJECT_* (ObjectType)
+ RES_ERR = 3, //! < ERR_* (Error)
+ RES_KEY = 4, //! < KEY() (keys)
+ RES_CBOT = 5, //! < TX_* (CBot)
};
-extern void SetEngine(CD3DEngine *engine);
+// TODO: move to CRobotMain
+
extern void SetGlobalGamerName(char *name);
-extern bool SearchKey(char *cmd, KeyRank &key);
+extern bool SearchKey(const char *cmd, InputSlot& slot);
extern bool GetResource(ResType type, int num, char* text);
extern const char * const strings_text[];
diff --git a/src/common/restext_ids.h b/src/common/restext_ids.h
index bee8620..4223a1c 100644
--- a/src/common/restext_ids.h
+++ b/src/common/restext_ids.h
@@ -14,6 +14,9 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
+
+// TODO: move to restext.h after restext rewrite
+
#pragma once
enum ResTextType
diff --git a/src/common/restext_strings.c b/src/common/restext_strings.c
index 8e9471b..d041a28 100644
--- a/src/common/restext_strings.c
+++ b/src/common/restext_strings.c
@@ -22,36 +22,8 @@
const char * const strings_text[] =
{
-#if _FULL
- [RT_VERSION_ID] = "1.18 /e",
-#endif
-#if _NET
- [RT_VERSION_ID] = "CeeBot-A 1.18",
-#endif
-#if _SCHOOL & _EDU
-#if _TEEN
- [RT_VERSION_ID] = "CeeBot-Teen EDU 1.18",
-#else
- [RT_VERSION_ID] = "CeeBot-A EDU 1.18",
-#endif
-#endif
-#if _SCHOOL & _PERSO
-#if _TEEN
- [RT_VERSION_ID] = "CeeBot-Teen PERSO 1.18",
-#else
- [RT_VERSION_ID] = "CeeBot-A PERSO 1.18",
-#endif
-#endif
-#if _SCHOOL & _CEEBOTDEMO
-#if _TEEN
- [RT_VERSION_ID] = "CeeBot-Teen DEMO 1.18",
-#else
- [RT_VERSION_ID] = "CeeBot-A DEMO 1.18",
-#endif
-#endif
-#if _DEMO
- [RT_VERSION_ID] = "Demo 1.18 /e",
-#endif
+ [RT_VERSION_ID] = "Colobot Gold",
+
[RT_DISINFO_TITLE] = "SatCom",
[RT_WINDOW_MAXIMIZED] = "Maximize",
[RT_WINDOW_MINIMIZED] = "Minimize",
@@ -64,13 +36,8 @@ const char * const strings_text[] =
[RT_IO_NEW] = "New ...",
[RT_KEY_OR] = " or ",
-#if _NEWLOOK
- [RT_TITLE_BASE] = "CeeBot",
- [RT_TITLE_INIT] = "CeeBot",
-#else
[RT_TITLE_BASE] = "COLOBOT",
[RT_TITLE_INIT] = "COLOBOT",
-#endif
[RT_TITLE_TRAINER] = "Programming exercises",
[RT_TITLE_DEFI] = "Challenges",
[RT_TITLE_MISSION] = "Missions",
@@ -111,15 +78,9 @@ const char * const strings_text[] =
[RT_PERSO_COMBI] = "Suit color:",
[RT_PERSO_BAND] = "Strip color:",
-#if _NEWLOOK
- [RT_DIALOG_QUIT] = "Do you want to quit CeeBot ?",
- [RT_DIALOG_TITLE] = "CeeBot",
- [RT_DIALOG_YESQUIT] = "Quit\\Quit CeeBot",
-#else
[RT_DIALOG_QUIT] = "Do you want to quit COLOBOT ?",
[RT_DIALOG_TITLE] = "COLOBOT",
[RT_DIALOG_YESQUIT] = "Quit\\Quit COLOBOT",
-#endif
[RT_DIALOG_ABORT] = "Quit the mission?",
[RT_DIALOG_YES] = "Abort\\Abort the current mission",
[RT_DIALOG_NO] = "Continue\\Continue the current mission",
@@ -182,13 +143,8 @@ const char * const strings_event[] =
[EVENT_INTERFACE_AGAIN] = "Restart\\Restart the mission from the beginning",
[EVENT_INTERFACE_WRITE] = "Save\\Save the current mission ",
[EVENT_INTERFACE_READ] = "Load\\Load a saved mission",
-#if _NEWLOOK
- [EVENT_INTERFACE_ABORT] = "\\Return to CeeBot",
- [EVENT_INTERFACE_QUIT] = "Quit\\Quit CeeBot",
-#else
[EVENT_INTERFACE_ABORT] = "\\Return to COLOBOT",
[EVENT_INTERFACE_QUIT] = "Quit\\Quit COLOBOT",
-#endif
[EVENT_INTERFACE_BACK] = "<< Back \\Back to the previous screen",
[EVENT_INTERFACE_PLAY] = "Play\\Start mission!",
[EVENT_INTERFACE_SETUPd] = "Device\\Driver and resolution settings",
@@ -432,11 +388,7 @@ const char * const strings_event[] =
[EVENT_HYPER_SIZE4] = "Size 4",
[EVENT_HYPER_SIZE5] = "Size 5",
[EVENT_SATCOM_HUSTON] = "Instructions from Houston",
-#if _TEEN
- [EVENT_SATCOM_SAT] = "Dictionnary",
-#else
[EVENT_SATCOM_SAT] = "Satellite report",
-#endif
[EVENT_SATCOM_LOADING] = "Programs dispatched by Houston",
[EVENT_SATCOM_OBJECT] = "List of objects",
[EVENT_SATCOM_PROG] = "Programming help",
@@ -475,11 +427,7 @@ const char * const strings_object[] =
[OBJECT_RESEARCH] = "Research center",
[OBJECT_RADAR] = "Radar station",
[OBJECT_INFO] = "Information exchange post",
-#if _TEEN
- [OBJECT_ENERGY] = "Disintegrator",
-#else
[OBJECT_ENERGY] = "Power cell factory",
-#endif
[OBJECT_LABO] = "Autolab",
[OBJECT_NUCLEAR] = "Nuclear power station",
[OBJECT_PARA] = "Lightning conductor",
@@ -574,13 +522,6 @@ const char * const strings_object[] =
const char * const strings_err[] =
{
[ERR_CMD] = "Unknown command",
-#if _NEWLOOK
- [ERR_INSTALL] = "CeeBot not installed.",
- [ERR_NOCD] = "Please insert the CeeBot CD\nand re-run the game.",
-#else
- [ERR_INSTALL] = "COLOBOT not installed.",
- [ERR_NOCD] = "Please insert the COLOBOT CD\nand re-run the game.",
-#endif
[ERR_MANIP_VEH] = "Inappropriate bot",
[ERR_MANIP_FLY] = "Impossible when flying",
[ERR_MANIP_BUSY] = "Already carrying something",
diff --git a/src/common/singleton.h b/src/common/singleton.h
index f631ed4..7407504 100644
--- a/src/common/singleton.h
+++ b/src/common/singleton.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// singleton.h
+/**
+ * \file common/singleton.h
+ * \brief CSingleton base class for singletons
+ */
#pragma once
diff --git a/src/common/stringutils.h b/src/common/stringutils.h
index a0cae70..064351d 100644
--- a/src/common/stringutils.h
+++ b/src/common/stringutils.h
@@ -14,7 +14,10 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// stringutils.h
+/**
+ * \file common/stringutils.h
+ * \brief Some useful string operations
+ */
#pragma once
diff --git a/src/common/struct.h b/src/common/struct.h
deleted file mode 100644
index 45ac314..0000000
--- a/src/common/struct.h
+++ /dev/null
@@ -1,54 +0,0 @@
-// * 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/.
-
-// struct.h
-
-#pragma once
-
-
-#include <math/vector.h>
-
-
-#define D3DFVF_VERTEX2 (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX2)
-
-struct D3DVERTEX2
-{
- float x,y,z;
- float nx,ny,nz;
- float tu, tv;
- float tu2, tv2;
-
- D3DVERTEX2() { }
- D3DVERTEX2(const Math::Vector& _v, const Math::Vector& _n, float _tu=0.0f, float _tv=0.0f, float _tu2=0.0f, float _tv2=0.0f)
- {
- x = _v.x;
- y = _v.y;
- z = _v.z;
- nx = _n.x;
- ny = _n.y;
- nz = _n.z;
- tu = _tu;
- tv = _tv;
- tu2 = _tu2;
- tv2 = _tv2;
- }
-};
-
-
-struct ColorHSV
-{
- float h,s,v;
-}; \ No newline at end of file
diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt
index d81acab..a1a7a50 100644
--- a/src/common/test/CMakeLists.txt
+++ b/src/common/test/CMakeLists.txt
@@ -7,6 +7,8 @@ include_directories("../../")
include_directories("../../../")
add_executable(image_test ../image.cpp image_test.cpp)
+target_link_libraries(image_test -lpng -lSDL -lSDL_image)
+
add_executable(profile_test ../profile.cpp profile_test.cpp)
add_test(profile_test ./profile_test)
diff --git a/src/common/test/image_test.cpp b/src/common/test/image_test.cpp
index 0ad1ee2..a98c9cc 100644
--- a/src/common/test/image_test.cpp
+++ b/src/common/test/image_test.cpp
@@ -22,6 +22,29 @@ int main(int argc, char *argv[])
printf("Error loading '%s': %s\n", err.c_str());
return 1;
}
+ Gfx::Color color;
+ std::string str;
+
+ color = image.GetPixel(Math::IntPoint(0, 0));
+ str = color.ToString();
+ printf("pixel @ (0,0): %s\n", str.c_str());
+
+ color = image.GetPixel(Math::IntPoint(0, 1));
+ str = color.ToString();
+ printf("pixel @ (0,1): %s\n", str.c_str());
+
+ color = image.GetPixel(Math::IntPoint(1, 0));
+ str = color.ToString();
+ printf("pixel @ (1,0): %s\n", str.c_str());
+
+ color = image.GetPixel(Math::IntPoint(1, 1));
+ str = color.ToString();
+ printf("pixel @ (1,1): %s\n", str.c_str());
+
+ image.SetPixel(Math::IntPoint(0, 0), Gfx::Color(0.1f, 0.2f, 0.3f, 0.0f));
+ image.SetPixel(Math::IntPoint(1, 0), Gfx::Color(0.3f, 0.2f, 0.1f, 1.0f));
+ image.SetPixel(Math::IntPoint(0, 1), Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f));
+ image.SetPixel(Math::IntPoint(1, 1), Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f));
if (! image.SavePNG(argv[2]))
{
diff --git a/src/graphics/core/light.h b/src/graphics/core/light.h
index a39d1f5..0601c5b 100644
--- a/src/graphics/core/light.h
+++ b/src/graphics/core/light.h
@@ -66,6 +66,7 @@ struct Light
float attenuation2;
//! Angle of spotlight cone (0-90 degrees)
float spotAngle;
+
//! Intensity of spotlight (0 = uniform; 128 = most intense)
float spotIntensity;
diff --git a/src/graphics/engine/camera.cpp b/src/graphics/engine/camera.cpp
index f077fff..cd7e307 100644
--- a/src/graphics/engine/camera.cpp
+++ b/src/graphics/engine/camera.cpp
@@ -28,67 +28,6 @@
#include "object/object.h"
#include "physics/physics.h"
-
-// TODO temporary stubs for CObject and CPhysics
-
-void CObject::SetTransparency(float)
-{
-}
-
-CObject* CObject::GetFret()
-{
- return nullptr;
-}
-
-CObject* CObject::GetPower()
-{
- return nullptr;
-}
-
-CObject* CObject::GetTruck()
-{
- return nullptr;
-}
-
-ObjectType CObject::GetType()
-{
- return OBJECT_NULL;
-}
-
-void CObject::SetGunGoalH(float)
-{
-}
-
-void CObject::GetGlobalSphere(Math::Vector &pos, float &radius)
-{
-}
-
-float CObject::GetAngleY(int)
-{
- return 0.0f;
-}
-
-Math::Vector CObject::GetPosition(int)
-{
- return Math::Vector();
-}
-
-void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
- Math::Vector &lookat, Math::Vector &upVec,
- Gfx::CameraType type)
-{
-}
-
-CPhysics* CObject::GetPhysics()
-{
- return nullptr;
-}
-
-bool CPhysics::GetLand()
-{
- return false;
-}
-
//! Changes the level of transparency of an object and objects transported (battery & cargo)
void SetTransparency(CObject* obj, float value)
{
@@ -263,12 +202,12 @@ void Gfx::CCamera::Init(Math::Vector eye, Math::Vector lookat, float delay)
}
-void Gfx::CCamera::SetObject(CObject* object)
+void Gfx::CCamera::SetControllingObject(CObject* object)
{
m_cameraObj = object;
}
-CObject* Gfx::CCamera::GetObject()
+CObject* Gfx::CCamera::GetControllingObject()
{
return m_cameraObj;
}
@@ -1063,11 +1002,9 @@ bool Gfx::CCamera::EventProcess(const Event &event)
EventMouseMove(event);
break;
- // TODO: mouse wheel event
- /*case EVENT_KEY_DOWN:
- if ( event.param == VK_WHEELUP ) EventMouseWheel(+1);
- if ( event.param == VK_WHEELDOWN ) EventMouseWheel(-1);
- break;*/
+ case EVENT_MOUSE_WHEEL:
+ EventMouseWheel(event.mouseWheel.dir);
+ break;
default:
break;
@@ -1081,17 +1018,17 @@ bool Gfx::CCamera::EventMouseMove(const Event &event)
return true;
}
-void Gfx::CCamera::EventMouseWheel(int dir)
+void Gfx::CCamera::EventMouseWheel(WheelDirection dir)
{
if (m_type == Gfx::CAM_TYPE_BACK)
{
- if (dir > 0)
+ if (dir == WHEEL_UP)
{
m_backDist -= 8.0f;
if (m_backDist < m_backMin)
m_backDist = m_backMin;
}
- if (dir < 0)
+ else if (dir == WHEEL_DOWN)
{
m_backDist += 8.0f;
if (m_backDist > 200.0f)
@@ -1102,13 +1039,13 @@ void Gfx::CCamera::EventMouseWheel(int dir)
if ( m_type == Gfx::CAM_TYPE_FIX ||
m_type == Gfx::CAM_TYPE_PLANE )
{
- if (dir > 0)
+ if (dir == WHEEL_UP)
{
m_fixDist -= 8.0f;
if (m_fixDist < 10.0f)
m_fixDist = 10.0f;
}
- if (dir < 0)
+ else if (dir == WHEEL_DOWN)
{
m_fixDist += 8.0f;
if (m_fixDist > 200.0f)
@@ -1118,13 +1055,13 @@ void Gfx::CCamera::EventMouseWheel(int dir)
if ( m_type == Gfx::CAM_TYPE_VISIT )
{
- if (dir > 0)
+ if (dir == WHEEL_UP)
{
m_visitDist -= 8.0f;
if (m_visitDist < 20.0f)
m_visitDist = 20.0f;
}
- if (dir < 0)
+ else if (dir == WHEEL_DOWN)
{
m_visitDist += 8.0f;
if (m_visitDist > 200.0f)
@@ -1245,19 +1182,19 @@ bool Gfx::CCamera::EventFrameFree(const Event &event)
m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, m_mouseDirV * event.rTime * factor * m_speed);
// Up/Down
- m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, event.axeY * event.rTime * factor * m_speed);
+ m_eyePt = Math::LookatPoint(m_eyePt, m_directionH, m_directionV, event.motionInput.y * event.rTime * factor * m_speed);
// Left/Right
if ( event.keyState & KS_CONTROL )
{
- if ( event.axeX < 0.0f )
- m_eyePt = Math::LookatPoint(m_eyePt, m_directionH + Math::PI / 2.0f, m_directionV, -event.axeX * event.rTime * factor * m_speed);
- if ( event.axeX > 0.0f )
- m_eyePt = Math::LookatPoint(m_eyePt, m_directionH - Math::PI / 2.0f, m_directionV, event.axeX * event.rTime * factor * m_speed);
+ if ( event.motionInput.x < 0.0f )
+ m_eyePt = Math::LookatPoint(m_eyePt, m_directionH + Math::PI / 2.0f, m_directionV, -event.motionInput.x * event.rTime * factor * m_speed);
+ if ( event.motionInput.x > 0.0f )
+ m_eyePt = Math::LookatPoint(m_eyePt, m_directionH - Math::PI / 2.0f, m_directionV, event.motionInput.x * event.rTime * factor * m_speed);
}
else
{
- m_directionH -= event.axeX * event.rTime * 0.7f * m_speed;
+ m_directionH -= event.motionInput.x * event.rTime * 0.7f * m_speed;
}
// PageUp/PageDown
@@ -1719,3 +1656,4 @@ Math::Vector Gfx::CCamera::ExcludeObject(Math::Vector eye, Math::Vector lookat,
return eye;*/
}
+
diff --git a/src/graphics/engine/camera.h b/src/graphics/engine/camera.h
index 1a82f9f..7a7350f 100644
--- a/src/graphics/engine/camera.h
+++ b/src/graphics/engine/camera.h
@@ -136,8 +136,8 @@ class CCamera {
void Init(Math::Vector eye, Math::Vector lookat, float delay);
//! Sets the object controlling the camera
- void SetObject(CObject* object);
- CObject* GetObject();
+ void SetControllingObject(CObject* object);
+ CObject* GetControllingObject();
//! Change the type of camera
void SetType(Gfx::CameraType type);
@@ -208,7 +208,7 @@ protected:
//! Changes the camera according to the mouse moved
bool EventMouseMove(const Event &event);
//! Mouse wheel operation
- void EventMouseWheel(int dir);
+ void EventMouseWheel(WheelDirection dir);
//! Changes the camera according to the time elapsed
bool EventFrame(const Event &event);
//! Moves the point of view
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index 068687a..bd5f60f 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -37,6 +37,7 @@
#include "graphics/engine/water.h"
#include "math/geometry.h"
#include "sound/sound.h"
+#include "ui/interface.h"
// Initial size of various vectors
@@ -87,15 +88,6 @@ Gfx::EngineObjLevel4::EngineObjLevel4(bool used, Gfx::EngineTriangleType type, c
vertices.reserve(LEVEL4_VERTEX_PREALLOCATE_COUNT);
}
-
-
-// TODO: temporary stub for CInterface
-class CInterface
-{
-public:
- void Draw() {}
-};
-
Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
{
m_iMan = iMan;
@@ -147,7 +139,7 @@ Gfx::CEngine::CEngine(CInstanceManager *iMan, CApplication *app)
m_backgroundCloudUp = Gfx::Color();
m_backgroundCloudDown = Gfx::Color();
m_backgroundFull = false;
- m_backgroundQuarter = false;
+ m_backgroundScale = Math::Point(1.0f, 1.0f);
m_overFront = true;
m_overColor = Gfx::Color();
m_overMode = ENG_RSTATE_TCOLOR_BLACK;
@@ -338,41 +330,23 @@ bool Gfx::CEngine::ProcessEvent(const Event &event)
int index = static_cast<int>(m_mouseType);
m_mouseType = static_cast<Gfx::EngineMouseType>( (index + 1) % Gfx::ENG_MOUSE_COUNT );
}
- else if (event.key.key == KEY(F3))
- {
- bool bq = !m_backgroundQuarter;
- SetBackground(bq ? "geneda.png" : "", Gfx::Color(), Gfx::Color(), Gfx::Color(), Gfx::Color(), true, bq);
- }
- else if (event.key.key == KEY(F4))
- {
- m_skyMode = !m_skyMode;
- if (! m_skyMode)
- {
- m_backgroundColorDown = Gfx::Color(0.2f, 0.2f, 0.2f);
- m_backgroundColorUp = Gfx::Color(0.8f, 0.8f, 0.8f);
- }
- else
- {
- m_backgroundColorDown = m_backgroundColorUp = Gfx::Color(0.0f, 0.0f, 0.0f);
- }
- }
- }
- else if (event.type == EVENT_FRAME)
- {
- m_highlightTime += event.rTime;
}
// By default, pass on all events
return true;
}
-void Gfx::CEngine::FrameMove(float rTime)
+void Gfx::CEngine::FrameUpdate()
{
+ float rTime = m_app->GetRelTime();
+
m_lightMan->UpdateProgression(rTime);
m_particle->FrameParticle(rTime);
ComputeDistance();
UpdateGeometry();
+ m_highlightTime = m_app->GetAbsTime();
+
if (m_groundMark.draw)
{
if (m_groundMark.phase == Gfx::ENG_GR_MARK_PHASE_INC) // growing?
@@ -402,16 +376,6 @@ void Gfx::CEngine::FrameMove(float rTime)
}
}
}
-
- if (m_sound == nullptr)
- m_sound = static_cast<CSoundInterface*>( m_iMan->SearchInstance(CLASS_SOUND) );
-
- m_sound->FrameMove(rTime);
-}
-
-void Gfx::CEngine::StepSimulation(float rTime)
-{
- m_app->StepSimulation(rTime);
}
bool Gfx::CEngine::WriteScreenShot(const std::string& fileName, int width, int height)
@@ -2166,26 +2130,10 @@ bool Gfx::CEngine::LoadAllTextures()
LoadTexture("effect02.png");
LoadTexture("map.png");
- if (m_backgroundQuarter) // image into 4 pieces?
- {
- if (! m_backgroundName.empty())
- {
- for (int i = 0; i < 4; i++)
- m_backgroundQuarterTexs[i] = LoadTexture(m_backgroundQuarterNames[i]);
- }
- else
- {
- for (int i = 0; i < 4; i++)
- m_backgroundQuarterTexs[i].SetInvalid();
- }
- }
+ if (! m_backgroundName.empty())
+ m_backgroundTex = LoadTexture(m_backgroundName);
else
- {
- if (! m_backgroundName.empty())
- m_backgroundFullTex = LoadTexture(m_backgroundName);
- else
- m_backgroundFullTex.SetInvalid();
- }
+ m_backgroundTex.SetInvalid();
if (! m_foregroundName.empty())
m_foregroundTex = LoadTexture(m_foregroundName);
@@ -2464,29 +2412,14 @@ float Gfx::CEngine::GetFogStart(int rank)
return m_fogStart[rank];
}
-std::string QuarterName(const std::string& name, int quarter)
-{
- size_t pos = name.find('.');
- if (pos == std::string::npos)
- return name;
-
- return name.substr(0, pos) + std::string(1, static_cast<char>('a' + quarter)) + name.substr(pos);
-}
-
void Gfx::CEngine::SetBackground(const std::string& name, Gfx::Color up, Gfx::Color down,
Gfx::Color cloudUp, Gfx::Color cloudDown,
- bool full, bool quarter)
+ bool full, Math::Point scale)
{
- if (m_backgroundFullTex.Valid())
+ if (m_backgroundTex.Valid())
{
- DeleteTexture(m_backgroundFullTex);
- m_backgroundFullTex.SetInvalid();
- }
-
- for (int i = 0; i < 4; i++)
- {
- DeleteTexture(m_backgroundQuarterTexs[i]);
- m_backgroundQuarterTexs[i].SetInvalid();
+ DeleteTexture(m_backgroundTex);
+ m_backgroundTex.SetInvalid();
}
m_backgroundName = name;
@@ -2495,28 +2428,15 @@ void Gfx::CEngine::SetBackground(const std::string& name, Gfx::Color up, Gfx::Co
m_backgroundCloudUp = cloudUp;
m_backgroundCloudDown = cloudDown;
m_backgroundFull = full;
- m_backgroundQuarter = quarter;
+ m_backgroundScale = scale;
if (! m_backgroundName.empty())
- {
- if (m_backgroundQuarter)
- {
- for (int i = 0; i < 4; i++)
- {
- m_backgroundQuarterNames[i] = QuarterName(name, i);
- m_backgroundQuarterTexs[i] = LoadTexture(m_backgroundQuarterNames[i]);
- }
- }
- else
- {
- m_backgroundFullTex = LoadTexture(m_backgroundName);
- }
- }
+ m_backgroundTex = LoadTexture(m_backgroundName);
}
void Gfx::CEngine::GetBackground(std::string& name, Gfx::Color& up, Gfx::Color& down,
Gfx::Color& cloudUp, Gfx::Color& cloudDown,
- bool &full, bool &quarter)
+ bool &full, Math::Point& scale)
{
name = m_backgroundName;
up = m_backgroundColorUp;
@@ -2524,7 +2444,7 @@ void Gfx::CEngine::GetBackground(std::string& name, Gfx::Color& up, Gfx::Color&
cloudUp = m_backgroundCloudUp;
cloudDown = m_backgroundCloudDown;
full = m_backgroundFull;
- quarter = m_backgroundQuarter;
+ scale = m_backgroundScale;
}
void Gfx::CEngine::SetForegroundName(const std::string& name)
@@ -2726,16 +2646,6 @@ int Gfx::CEngine::GetEditIndentValue()
return m_editIndentValue;
}
-void Gfx::CEngine::SetSpeed(float speed)
-{
- m_speed = speed;
-}
-
-float Gfx::CEngine::GetSpeed()
-{
- return m_speed;
-}
-
void Gfx::CEngine::SetTracePrecision(float factor)
{
m_tracePrecision = factor;
@@ -3144,7 +3054,7 @@ void Gfx::CEngine::DrawInterface()
m_device->SetTransform(Gfx::TRANSFORM_WORLD, m_matWorldInterface);
// Draw the entire interface
- CInterface* interface = static_cast<CInterface*>( m_iMan->SearchInstance(CLASS_INTERFACE) );
+ Ui::CInterface* interface = static_cast<Ui::CInterface*>( m_iMan->SearchInstance(CLASS_INTERFACE) );
if (interface != nullptr)
interface->Draw();
@@ -3505,10 +3415,16 @@ void Gfx::CEngine::DrawBackgroundGradient(const Gfx::Color& up, const Gfx::Color
AddStatisticTriangle(2);
}
-// Status: PART_TESTED
-void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, const Gfx::Texture &tex)
+// Status: TESTED, VERIFIED
+void Gfx::CEngine::DrawBackgroundImage()
{
- Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
+ Math::Point p1, p2;
+ p1.x = 0.0f;
+ p1.y = 0.0f;
+ p2.x = 1.0f;
+ p2.y = 1.0f;
+
+Math::Vector n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
float u1, u2, v1, v2;
if (m_backgroundFull)
@@ -3517,14 +3433,6 @@ void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, co
v1 = 0.0f;
u2 = 1.0f;
v2 = 1.0f;
-
- if (m_backgroundQuarter)
- {
- u1 += 0.5f/512.0f;
- v1 += 0.5f/384.0f;
- u2 -= 0.5f/512.0f;
- v2 -= 0.5f/384.0f;
- }
}
else
{
@@ -3541,7 +3449,10 @@ void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, co
v2 = v1+h;
}
- SetTexture(tex);
+ u2 *= m_backgroundScale.x;
+ v2 *= m_backgroundScale.y;
+
+ SetTexture(m_backgroundTex);
SetState(Gfx::ENG_RSTATE_OPAQUE_TEXTURE | Gfx::ENG_RSTATE_WRAP);
m_device->SetTransform(Gfx::TRANSFORM_VIEW, m_matViewInterface);
@@ -3560,48 +3471,6 @@ void Gfx::CEngine::DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, co
AddStatisticTriangle(2);
}
-// Status: TESTED, VERIFIED
-void Gfx::CEngine::DrawBackgroundImage()
-{
- Math::Point p1, p2;
- std::string name;
-
- if (m_backgroundQuarter)
- {
- p1.x = 0.0f;
- p1.y = 0.5f;
- p2.x = 0.5f;
- p2.y = 1.0f;
- DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[0]);
-
- p1.x = 0.5f;
- p1.y = 0.5f;
- p2.x = 1.0f;
- p2.y = 1.0f;
- DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[1]);
-
- p1.x = 0.0f;
- p1.y = 0.0f;
- p2.x = 0.5f;
- p2.y = 0.5f;
- DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[2]);
-
- p1.x = 0.5f;
- p1.y = 0.0f;
- p2.x = 1.0f;
- p2.y = 0.5f;
- DrawBackgroundImageQuarter(p1, p2, m_backgroundQuarterTexs[3]);
- }
- else
- {
- p1.x = 0.0f;
- p1.y = 0.0f;
- p2.x = 1.0f;
- p2.y = 1.0f;
- DrawBackgroundImageQuarter(p1, p2, m_backgroundFullTex);
- }
-}
-
void Gfx::CEngine::DrawPlanet()
{
if (! m_planet->PlanetExist()) return;
@@ -3854,6 +3723,8 @@ void Gfx::CEngine::DrawMouseSprite(Math::Point pos, Math::Point size, int icon)
Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), normal, Math::Point(u2, v1))
};
+ m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_TEST, false);
+ m_device->SetRenderState(Gfx::RENDER_STATE_DEPTH_WRITE, false);
m_device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
AddStatisticTriangle(2);
}
diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h
index 705c83a..01a1dee 100644
--- a/src/graphics/engine/engine.h
+++ b/src/graphics/engine/engine.h
@@ -664,9 +664,7 @@ public:
bool ProcessEvent(const Event& event);
//! Called once per frame, the call is the entry point for animating the scene
- void FrameMove(float rTime);
- //! Evolved throughout the game
- void StepSimulation(float rTime);
+ void FrameUpdate();
//! Writes a screenshot containing the current frame
@@ -993,10 +991,10 @@ public:
//! Management of the background image to use
void SetBackground(const std::string& name, Gfx::Color up = Gfx::Color(), Gfx::Color down = Gfx::Color(),
Gfx::Color cloudUp = Gfx::Color(), Gfx::Color cloudDown = Gfx::Color(),
- bool full = false, bool quarter = false);
+ bool full = false, Math::Point scale = Math::Point(1.0f, 1.0f));
void GetBackground(std::string& name, Gfx::Color& up, Gfx::Color& down,
Gfx::Color& cloudUp, Gfx::Color& cloudDown,
- bool& full, bool& quarter);
+ bool& full, Math::Point& scale);
//@}
//! Specifies the name of foreground texture
@@ -1099,11 +1097,6 @@ public:
//@}
//@{
- //! Management of game speed
- void SetSpeed(float speed);
- float GetSpeed();
-
- //@{
//! Management of precision of robot tracks
void SetTracePrecision(float factor);
float GetTracePrecision();
@@ -1161,8 +1154,6 @@ protected:
void DrawBackground();
//! Draws the gradient background
void DrawBackgroundGradient(const Gfx::Color& up, const Gfx::Color& down);
- //! Draws a portion of the image background
- void DrawBackgroundImageQuarter(Math::Point p1, Math::Point p2, const Gfx::Texture &tex);
//! Draws the image background
void DrawBackgroundImage();
//! Draws all the planets
@@ -1297,11 +1288,9 @@ protected:
bool m_firstGroundSpot;
int m_secondTexNum;
bool m_backgroundFull;
- bool m_backgroundQuarter;
+ Math::Point m_backgroundScale;
std::string m_backgroundName;
- std::string m_backgroundQuarterNames[4];
- Gfx::Texture m_backgroundFullTex;
- Gfx::Texture m_backgroundQuarterTexs[4];
+ Gfx::Texture m_backgroundTex;
Gfx::Color m_backgroundColorUp;
Gfx::Color m_backgroundColorDown;
Gfx::Color m_backgroundCloudUp;
diff --git a/src/graphics/engine/lightning.h b/src/graphics/engine/lightning.h
index e34eb3b..af389f2 100644
--- a/src/graphics/engine/lightning.h
+++ b/src/graphics/engine/lightning.h
@@ -22,7 +22,7 @@
#pragma once
-#include "common/misc.h"
+#include "common/event.h"
#include "math/vector.h"
diff --git a/src/graphics/engine/particle.cpp b/src/graphics/engine/particle.cpp
index 37a3975..c177deb 100644
--- a/src/graphics/engine/particle.cpp
+++ b/src/graphics/engine/particle.cpp
@@ -200,7 +200,7 @@ void Gfx::CParticle::DrawParticle(int sheet)
// TODO!
}
-bool Gfx::CParticle::WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur)
+bool Gfx::CParticle::WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur)
{
GetLogger()->Trace("CParticle::WriteWheelTrace() stub!\n");
// TODO!
diff --git a/src/graphics/engine/particle.h b/src/graphics/engine/particle.h
index c53aea5..f78e242 100644
--- a/src/graphics/engine/particle.h
+++ b/src/graphics/engine/particle.h
@@ -306,7 +306,7 @@ public:
void FrameParticle(float rTime);
void DrawParticle(int sheet);
- bool WriteWheelTrace(char *filename, int width, int height, Math::Vector dl, Math::Vector ur);
+ bool WriteWheelTrace(const char *filename, int width, int height, Math::Vector dl, Math::Vector ur);
protected:
void DeleteRank(int rank);
diff --git a/src/graphics/engine/pyro.h b/src/graphics/engine/pyro.h
index 5d2ca63..c0c0144 100644
--- a/src/graphics/engine/pyro.h
+++ b/src/graphics/engine/pyro.h
@@ -22,7 +22,8 @@
#pragma once
-#include "common/misc.h"
+#include "common/event.h"
+#include "common/global.h"
#include "graphics/engine/engine.h"
#include "object/object.h"
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 19ef57b..8fc8709 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -785,18 +785,20 @@ Gfx::CharTexture Gfx::CText::CreateCharTexture(Gfx::UTF8Char ch, Gfx::CachedFont
data.surface = nullptr;
- SDL_FreeSurface(textSurface);
- SDL_FreeSurface(textureSurface);
-
if (! tex.Valid())
{
m_error = "Texture create error";
return texture;
}
+ else
+ {
+ texture.id = tex.id;
+ texture.texSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textureSurface->w, textureSurface->h));
+ texture.charSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textSurface->w, textSurface->h));
+ }
- texture.id = tex.id;
- texture.texSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textureSurface->w, textureSurface->h));
- texture.charSize = m_engine->WindowToInterfaceSize(Math::IntPoint(textSurface->w, textSurface->h));
+ SDL_FreeSurface(textSurface);
+ SDL_FreeSurface(textureSurface);
return texture;
}
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index a779a5f..416b506 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -129,9 +129,11 @@ bool Gfx::CGLDevice::Create()
glViewport(0, 0, m_config.size.x, m_config.size.y);
+ int numLights = 0;
+ glGetIntegerv(GL_MAX_LIGHTS, &numLights);
- m_lights = std::vector<Gfx::Light>(GL_MAX_LIGHTS, Gfx::Light());
- m_lightsEnabled = std::vector<bool> (GL_MAX_LIGHTS, false);
+ m_lights = std::vector<Gfx::Light>(numLights, Gfx::Light());
+ m_lightsEnabled = std::vector<bool> (numLights, false);
int maxTextures = 0;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTextures);
@@ -182,7 +184,6 @@ void Gfx::CGLDevice::BeginScene()
void Gfx::CGLDevice::EndScene()
{
- glFlush();
}
void Gfx::CGLDevice::Clear()
@@ -434,7 +435,10 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr
else
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);
+
+ bool convert = false;
GLenum sourceFormat = 0;
+
if (params.format == Gfx::TEX_IMG_RGB)
{
sourceFormat = GL_RGB;
@@ -459,26 +463,26 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr
{
if (data->surface->format->Amask != 0)
{
- if ((data->surface->format->Rmask == 0xFF000000) &&
- (data->surface->format->Gmask == 0x00FF0000) &&
- (data->surface->format->Bmask == 0x0000FF00) &&
- (data->surface->format->Amask == 0x000000FF))
+ if ((data->surface->format->Amask == 0xFF000000) &&
+ (data->surface->format->Rmask == 0x00FF0000) &&
+ (data->surface->format->Gmask == 0x0000FF00) &&
+ (data->surface->format->Bmask == 0x000000FF))
{
sourceFormat = GL_BGRA;
result.alpha = true;
}
- else if ((data->surface->format->Bmask == 0xFF000000) &&
- (data->surface->format->Gmask == 0x00FF0000) &&
- (data->surface->format->Rmask == 0x0000FF00) &&
- (data->surface->format->Amask == 0x000000FF))
+ else if ((data->surface->format->Amask == 0xFF000000) &&
+ (data->surface->format->Bmask == 0x00FF0000) &&
+ (data->surface->format->Gmask == 0x0000FF00) &&
+ (data->surface->format->Rmask == 0x000000FF))
{
sourceFormat = GL_RGBA;
result.alpha = true;
}
else
{
- GetLogger()->Error("Auto texture format failed\n");
- return Gfx::Texture(); // other format?
+ sourceFormat = GL_RGBA;
+ convert = true;
}
}
else
@@ -499,16 +503,43 @@ Gfx::Texture Gfx::CGLDevice::CreateTexture(ImageData *data, const Gfx::TextureCr
}
else
{
- GetLogger()->Error("Auto texture format failed\n");
- return Gfx::Texture(); // other format?
+ sourceFormat = GL_RGBA;
+ convert = true;
}
}
}
else
assert(false);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data->surface->w, data->surface->h,
- 0, sourceFormat, GL_UNSIGNED_BYTE, data->surface->pixels);
+ SDL_Surface* actualSurface = data->surface;
+ SDL_Surface* convertedSurface = nullptr;
+
+ if (convert)
+ {
+ SDL_PixelFormat format;
+ format.BytesPerPixel = 4;
+ format.BitsPerPixel = 32;
+ format.alpha = 0;
+ format.colorkey = 0;
+ format.Aloss = format.Bloss = format.Gloss = format.Rloss = 0;
+ format.Amask = 0xFF000000;
+ format.Ashift = 24;
+ format.Bmask = 0x00FF0000;
+ format.Bshift = 16;
+ format.Gmask = 0x0000FF00;
+ format.Gshift = 8;
+ format.Rmask = 0x000000FF;
+ format.Rshift = 0;
+ format.palette = nullptr;
+ convertedSurface = SDL_ConvertSurface(data->surface, &format, SDL_SWSURFACE);
+ if (convertedSurface != nullptr)
+ actualSurface = convertedSurface;
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, actualSurface->w, actualSurface->h,
+ 0, sourceFormat, GL_UNSIGNED_BYTE, actualSurface->pixels);
+
+ SDL_FreeSurface(convertedSurface);
// Restore the previous state of 1st stage
diff --git a/src/math/all.h b/src/math/all.h
index 4ac9d55..0d067d3 100644
--- a/src/math/all.h
+++ b/src/math/all.h
@@ -27,5 +27,3 @@
#include "vector.h"
#include "matrix.h"
#include "geometry.h"
-
-#include "conv.h"
diff --git a/src/math/const.h b/src/math/const.h
index 0b6f971..3f85fee 100644
--- a/src/math/const.h
+++ b/src/math/const.h
@@ -51,4 +51,3 @@ const float RAD_TO_DEG = 57.29577951308232286465f;
const float LOG_2 = log(2.0f);
}; // namespace Math
-
diff --git a/src/math/conv.h b/src/math/conv.h
deleted file mode 100644
index 43e6fbd..0000000
--- a/src/math/conv.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* math/conv.h
-
- Temporary conversion functions for D3DVECTOR and D3DMATRIX */
-
-#pragma once
-
-#include <d3d.h>
-
-#include "vector.h"
-#include "matrix.h"
-
-inline D3DVECTOR VEC_TO_D3DVEC(Math::Vector vec)
-{
- return D3DVECTOR(vec.x, vec.y, vec.z);
-}
-
-inline Math::Vector D3DVEC_TO_VEC(D3DVECTOR vec)
-{
- return Math::Vector(vec.x, vec.y, vec.z);
-}
-
-inline D3DMATRIX MAT_TO_D3DMAT(Math::Matrix mat)
-{
- D3DMATRIX result;
- mat.Transpose();
- for (int r = 0; r < 4; ++r)
- {
- for (int c = 0; c < 16; ++c)
- result.m[r][c] = mat.m[4*c+r];
- }
- return result;
-}
-
-inline Math::Matrix D3DMAT_TO_MAT(D3DMATRIX mat)
-{
- Math::Matrix result(mat.m);
- result.Transpose();
- return result;
-}
diff --git a/src/math/geometry.h b/src/math/geometry.h
index 1c5f60f..55bc745 100644
--- a/src/math/geometry.h
+++ b/src/math/geometry.h
@@ -76,9 +76,11 @@ inline bool IsInsideTriangle(Math::Point a, Math::Point b, Math::Point c, Math::
}
//! Rotates a point around a center
-/** \a center center of rotation
- \a angle angle is in radians (positive is counterclockwise (CCW) )
- \a p the point */
+/**
+ * \param center center of rotation
+ * \param angle angle [radians] (positive is CCW)
+ * \param p the point to be rotated
+ */
inline Math::Point RotatePoint(const Math::Point &center, float angle, const Math::Point &p)
{
Math::Point a;
@@ -96,8 +98,10 @@ inline Math::Point RotatePoint(const Math::Point &center, float angle, const Mat
}
//! Rotates a point around the origin (0,0)
-/** \a angle angle in radians (positive is counterclockwise (CCW) )
- \a p the point */
+/**
+ * \param angle angle [radians] (positive is CCW)
+ * \param p the point to be rotated
+ */
inline Math::Point RotatePoint(float angle, const Math::Point &p)
{
float x = p.x*cosf(angle) - p.y*sinf(angle);
@@ -106,9 +110,11 @@ inline Math::Point RotatePoint(float angle, const Math::Point &p)
return Math::Point(x, y);
}
-//! Rotates a vector (dist, 0).
-/** \a angle angle is in radians (positive is counterclockwise (CCW) )
- \a dist distance to origin */
+//! Rotates a vector (dist, 0)
+/**
+ * \param angle angle [radians] (positive is CCW)
+ * \param dist distance to origin
+ */
inline Math::Point RotatePoint(float angle, float dist)
{
float x = dist*cosf(angle);
@@ -117,7 +123,12 @@ inline Math::Point RotatePoint(float angle, float dist)
return Math::Point(x, y);
}
-//! TODO documentation
+//! Rotates a point around a center on 2D plane
+/**
+ * \param cx,cy center of rotation
+ * \param angle angle of rotation [radians] (positive is CCW)
+ * \param px,py point coordinates to rotate
+ */
inline void RotatePoint(float cx, float cy, float angle, float &px, float &py)
{
float ax, ay;
@@ -132,11 +143,14 @@ inline void RotatePoint(float cx, float cy, float angle, float &px, float &py)
py = cy+ay;
}
-//! Rotates a point around a center in space.
-/** \a center center of rotation
- \a angleH,angleV rotation angles in radians (positive is counterclockwise (CCW) ) )
- \a p the point
- \returns the rotated point */
+//! Rotates a point around a center in space
+/**
+ * \a angleH is rotation along Y axis (heading) while \a angleV is rotation along X axis (TODO: ?).
+ *
+ * \param center center of rotation
+ * \param angleH,angleV rotation angles [radians] (positive is CCW)
+ * \param p the point to be rotated
+ */
inline void RotatePoint(const Math::Vector &center, float angleH, float angleV, Math::Vector &p)
{
p.x -= center.x;
@@ -151,11 +165,14 @@ inline void RotatePoint(const Math::Vector &center, float angleH, float angleV,
p = center + b;
}
-//! Rotates a point around a center in space.
-/** \a center center of rotation
- \a angleH,angleV rotation angles in radians (positive is counterclockwise (CCW) ) )
- \a p the point
- \returns the rotated point */
+//! Rotates a point around a center in space
+/**
+ * The rotation is performed first along Y axis (\a angleH) and then along X axis (\a angleV).
+ *
+ * \param center center of rotation
+ * \param angleH,angleV rotation angles [radians] (positive is CCW)
+ * \param p the point to be rotated
+ */
inline void RotatePoint2(const Math::Vector center, float angleH, float angleV, Math::Vector &p)
{
p.x -= center.x;
@@ -189,10 +206,12 @@ inline float RotateAngle(float x, float y)
return -atan + 0.5f*PI;
}
-//! Calculates the angle between two points and one center
-/** \a center the center point
- \a p1,p2 the two points
- \returns The angle in radians (positive is counterclockwise (CCW) ) */
+//! Calculates the angle between two points and a center
+/**
+ * \param center the center point
+ * \param p1,p2 the two points
+ * \returns the angle [radians] (positive is CCW)
+ */
inline float RotateAngle(const Math::Point &center, const Math::Point &p1, const Math::Point &p2)
{
if (PointsEqual(p1, center))
@@ -215,9 +234,11 @@ inline float RotateAngle(const Math::Point &center, const Math::Point &p1, const
}
//! Loads view matrix from the given vectors
-/** \a from origin
- \a at view direction
- \a worldUp up vector */
+/**
+ * \param from origin
+ * \param at view direction
+ * \param worldUp up vector
+ */
inline void LoadViewMatrix(Math::Matrix &mat, const Math::Vector &from,
const Math::Vector &at, const Math::Vector &worldUp)
{
@@ -280,10 +301,12 @@ inline void LoadViewMatrix(Math::Matrix &mat, const Math::Vector &from,
}
//! Loads a perspective projection matrix
-/** \a fov field of view in radians
- \a aspect aspect ratio (width / height)
- \a nearPlane distance to near cut plane
- \a farPlane distance to far cut plane */
+/**
+ * \param fov field of view in radians
+ * \param aspect aspect ratio (width / height)
+ * \param nearPlane distance to near cut plane
+ * \param farPlane distance to far cut plane
+ */
inline void LoadProjectionMatrix(Math::Matrix &mat, float fov = Math::PI / 2.0f, float aspect = 1.0f,
float nearPlane = 1.0f, float farPlane = 1000.0f)
{
@@ -302,9 +325,11 @@ inline void LoadProjectionMatrix(Math::Matrix &mat, float fov = Math::PI / 2.0f,
}
//! Loads an othogonal projection matrix
-/** \a left,right coordinates for left and right vertical clipping planes
- \a bottom,top coordinates for bottom and top horizontal clipping planes
- \a zNear,zFar distance to nearer and farther depth clipping planes */
+/**
+ * \param left,right coordinates for left and right vertical clipping planes
+ * \param bottom,top coordinates for bottom and top horizontal clipping planes
+ * \param zNear,zFar distance to nearer and farther depth clipping planes
+ */
inline void LoadOrthoProjectionMatrix(Math::Matrix &mat, float left, float right, float bottom, float top,
float zNear = -1.0f, float zFar = 1.0f)
{
@@ -320,7 +345,10 @@ inline void LoadOrthoProjectionMatrix(Math::Matrix &mat, float left, float right
}
//! Loads a translation matrix from given vector
-/** \a trans vector of translation*/
+/**
+ * \param mat result matrix
+ * \param trans vector of translation
+ */
inline void LoadTranslationMatrix(Math::Matrix &mat, const Math::Vector &trans)
{
mat.LoadIdentity();
@@ -330,7 +358,10 @@ inline void LoadTranslationMatrix(Math::Matrix &mat, const Math::Vector &trans)
}
//! Loads a scaling matrix fom given vector
-/** \a scale vector with scaling factors for X, Y, Z */
+/**
+ * \param mat result matrix
+ * \param scale vector with scaling factors for X, Y, Z
+ */
inline void LoadScaleMatrix(Math::Matrix &mat, const Math::Vector &scale)
{
mat.LoadIdentity();
@@ -340,7 +371,10 @@ inline void LoadScaleMatrix(Math::Matrix &mat, const Math::Vector &scale)
}
//! Loads a rotation matrix along the X axis
-/** \a angle angle in radians */
+/**
+ * \param mat result matrix
+ * \param angle angle [radians]
+ */
inline void LoadRotationXMatrix(Math::Matrix &mat, float angle)
{
mat.LoadIdentity();
@@ -351,7 +385,10 @@ inline void LoadRotationXMatrix(Math::Matrix &mat, float angle)
}
//! Loads a rotation matrix along the Y axis
-/** \a angle angle in radians */
+/**
+ * \param mat result matrix
+ * \param angle angle [radians]
+ */
inline void LoadRotationYMatrix(Math::Matrix &mat, float angle)
{
mat.LoadIdentity();
@@ -362,7 +399,10 @@ inline void LoadRotationYMatrix(Math::Matrix &mat, float angle)
}
//! Loads a rotation matrix along the Z axis
-/** \a angle angle in radians */
+/**
+ * \param mat result matrix
+ * \param angle angle [radians]
+ */
inline void LoadRotationZMatrix(Math::Matrix &mat, float angle)
{
mat.LoadIdentity();
@@ -373,8 +413,11 @@ inline void LoadRotationZMatrix(Math::Matrix &mat, float angle)
}
//! Loads a rotation matrix along the given axis
-/** \a dir axis of rotation
- \a angle angle in radians */
+/**
+ * \param mat result matrix
+ * \param dir axis of rotation
+ * \param angle angle [radians]
+ */
inline void LoadRotationMatrix(Math::Matrix &mat, const Math::Vector &dir, float angle)
{
float cos = cosf(angle);
@@ -397,28 +440,28 @@ inline void LoadRotationMatrix(Math::Matrix &mat, const Math::Vector &dir, float
}
//! Calculates the matrix to make three rotations in the order X, Z and Y
-inline void LoadRotationXZYMatrix(Math::Matrix &mat, const Math::Vector &angle)
+inline void LoadRotationXZYMatrix(Math::Matrix &mat, const Math::Vector &angles)
{
Math::Matrix temp;
- LoadRotationXMatrix(temp, angle.x);
+ LoadRotationXMatrix(temp, angles.x);
- LoadRotationZMatrix(mat, angle.z);
+ LoadRotationZMatrix(mat, angles.z);
mat = Math::MultiplyMatrices(temp, mat);
- LoadRotationYMatrix(temp, angle.y);
+ LoadRotationYMatrix(temp, angles.y);
mat = Math::MultiplyMatrices(temp, mat);
}
//! Calculates the matrix to make three rotations in the order Z, X and Y
-inline void LoadRotationZXYMatrix(Math::Matrix &mat, const Math::Vector &angle)
+inline void LoadRotationZXYMatrix(Math::Matrix &mat, const Math::Vector &angles)
{
Math::Matrix temp;
- LoadRotationZMatrix(temp, angle.z);
+ LoadRotationZMatrix(temp, angles.z);
- LoadRotationXMatrix(mat, angle.x);
+ LoadRotationXMatrix(mat, angles.x);
mat = Math::MultiplyMatrices(temp, mat);
- LoadRotationYMatrix(temp, angle.y);
+ LoadRotationYMatrix(temp, angles.y);
mat = Math::MultiplyMatrices(temp, mat);
}
@@ -430,7 +473,9 @@ inline float DistanceProjected(const Math::Vector &a, const Math::Vector &b)
}
//! Returns the normal vector to a plane
-/** \param p1,p2,p3 points defining the plane */
+/**
+ * \param p1,p2,p3 points defining the plane
+ */
inline Math::Vector NormalToPlane(const Math::Vector &p1, const Math::Vector &p2, const Math::Vector &p3)
{
Math::Vector u = p3 - p1;
@@ -440,16 +485,20 @@ inline Math::Vector NormalToPlane(const Math::Vector &p1, const Math::Vector &p2
}
//! Returns a point on the line \a p1 - \a p2, in \a dist distance from \a p1
-/** \a p1,p2 line start and end
- \a dist scaling factor from \a p1, relative to distance between \a p1 and \a p2 */
+/**
+ * \param p1,p2 line start and end
+ * \param dist scaling factor from \a p1, relative to distance between \a p1 and \a p2
+ */
inline Math::Vector SegmentPoint(const Math::Vector &p1, const Math::Vector &p2, float dist)
{
return p1 + (p2 - p1) * dist;
}
//! Returns the distance between given point and a plane
-/** \param p the point
- \param a,b,c points defining the plane */
+/**
+ * \param p the point
+ * \param a,b,c points defining the plane
+ */
inline float DistanceToPlane(const Math::Vector &a, const Math::Vector &b,
const Math::Vector &c, const Math::Vector &p)
{
@@ -460,8 +509,10 @@ inline float DistanceToPlane(const Math::Vector &a, const Math::Vector &b,
}
//! Checks if two planes defined by three points are the same
-/** \a plane1 array of three vectors defining the first plane
- \a plane2 array of three vectors defining the second plane */
+/**
+ * \param plane1 array of three vectors defining the first plane
+ * \param plane2 array of three vectors defining the second plane
+ */
inline bool IsSamePlane(const Math::Vector (&plane1)[3], const Math::Vector (&plane2)[3])
{
Math::Vector n1 = NormalToPlane(plane1[0], plane1[1], plane1[2]);
@@ -479,7 +530,7 @@ inline bool IsSamePlane(const Math::Vector (&plane1)[3], const Math::Vector (&pl
return true;
}
-//! Calculates the intersection "i" right "of" the plane "abc".
+//! Calculates the intersection "i" right "of" the plane "abc" (TODO: ?)
inline bool Intersect(const Math::Vector &a, const Math::Vector &b, const Math::Vector &c,
const Math::Vector &d, const Math::Vector &e, Math::Vector &i)
{
@@ -502,7 +553,7 @@ inline bool Intersect(const Math::Vector &a, const Math::Vector &b, const Math::
}
//! Calculates the intersection of the straight line passing through p (x, z)
-/** Line is parallel to the y axis, with the plane abc. Returns p.y. */
+/** Line is parallel to the y axis, with the plane abc. Returns p.y. (TODO: ?) */
inline bool IntersectY(const Math::Vector &a, const Math::Vector &b, const Math::Vector &c, Math::Vector &p)
{
float d = (b.x-a.x)*(c.z-a.z) - (c.x-a.x)*(b.z-a.z);
@@ -528,15 +579,18 @@ inline Math::Vector LookatPoint(const Math::Vector &eye, float angleH, float ang
return lookat;
}
-//! TODO documentation
+//! Transforms the point \a p by matrix \a m
+/** Is equal to multiplying the matrix by the vector (of course without perspective divide). */
inline Math::Vector Transform(const Math::Matrix &m, const Math::Vector &p)
{
return MatrixVectorMultiply(m, p);
}
-//! Calculates the projection of the point \a p on a straight line \a a to \a b.
-/** \a p point to project
- \a a,b two ends of the line */
+//! Calculates the projection of the point \a p on a straight line \a a to \a b
+/**
+ * \param point to project
+ * \param a,b two ends of the line
+ */
inline Math::Vector Projection(const Math::Vector &a, const Math::Vector &b, const Math::Vector &p)
{
float k = DotProduct(b - a, p - a);
diff --git a/src/math/matrix.h b/src/math/matrix.h
index 30e629a..30f790c 100644
--- a/src/math/matrix.h
+++ b/src/math/matrix.h
@@ -33,13 +33,14 @@
namespace Math
{
-/** \struct Matrix math/matrix.h
- \brief 4x4 matrix
-
- Represents an universal 4x4 matrix that can be used in OpenGL and DirectX engines.
- Contains the required methods for operating on matrices (inverting, multiplying, etc.).
-
- The internal representation is a 16-value table in column-major order, thus:
+/**
+ * \struct Matrix math/matrix.h
+ * \brief 4x4 matrix
+ *
+ * Represents an universal 4x4 matrix that can be used in OpenGL and DirectX engines.
+ * Contains the required methods for operating on matrices (inverting, multiplying, etc.).
+ *
+ * The internal representation is a 16-value table in column-major order, thus:
\verbatim
m[0 ] m[4 ] m[8 ] m[12]
@@ -48,16 +49,16 @@ m[2 ] m[6 ] m[10] m[14]
m[3 ] m[7 ] m[11] m[15]
\endverbatim
- This representation is native to OpenGL; DirectX requires transposing the matrix.
-
- The order of multiplication of matrix and vector is also OpenGL-native
- (see the function MatrixVectorMultiply).
-
- All methods are made inline to maximize optimization.
-
- Unit tests for the structure and related functions are in module: math/test/matrix_test.cpp.
-
- **/
+ * This representation is native to OpenGL; DirectX requires transposing the matrix.
+ *
+ * The order of multiplication of matrix and vector is also OpenGL-native
+ * (see the function MatrixVectorMultiply).
+ *
+ * All methods are made inline to maximize optimization.
+ *
+ * Unit tests for the structure and related functions are in module: math/test/matrix_test.cpp.
+ *
+ */
struct Matrix
{
//! Matrix values in column-major order
@@ -78,8 +79,10 @@ struct Matrix
}
//! Creates the matrix from 2D array
- /** The array's first index is row, second is column.
- \a m array with values */
+ /**
+ * The array's first index is row, second is column.
+ * \param m array with values
+ */
inline explicit Matrix(const float (&m)[4][4])
{
for (int c = 0; c < 4; ++c)
@@ -91,11 +94,23 @@ struct Matrix
}
}
+ //! Sets value in given row and col
+ /**
+ * \param row row (0 to 3)
+ * \param col column (0 to 3)
+ * \param value value
+ */
inline void Set(int row, int col, float value)
{
m[(col-1)*4+(row-1)] = value;
}
+ //! Returns the value in given row and col
+ /**
+ * \param row row (0 to 3)
+ * \param col column (0 to 3)
+ * \returns value
+ */
inline float Get(int row, int col)
{
return m[(col-1)*4+(row-1)];
@@ -148,9 +163,11 @@ struct Matrix
}
//! Calculates the cofactor of the matrix
- /** \a r row (0 to 3)
- \a c column (0 to 3)
- \returns the cofactor */
+ /**
+ * \param r row (0 to 3)
+ * \param c column (0 to 3)
+ * \returns the cofactor
+ */
inline float Cofactor(int r, int c) const
{
assert(r >= 0 && r <= 3);
@@ -330,8 +347,10 @@ struct Matrix
}
//! Calculates the inverse matrix
- /** The determinant of the matrix must not be zero.
- \returns the inverted matrix */
+ /**
+ * The determinant of the matrix must not be zero.
+ * \returns the inverted matrix
+ */
inline Matrix Inverse() const
{
float d = Det();
@@ -352,8 +371,10 @@ struct Matrix
}
//! Calculates the multiplication of this matrix * given matrix
- /** \a right right-hand matrix
- \returns multiplication result */
+ /**
+ * \param right right-hand matrix
+ * \returns multiplication result
+ */
inline Matrix Multiply(const Matrix &right) const
{
float result[16] = { 0.0f };
diff --git a/src/math/point.h b/src/math/point.h
index ecf896f..1093c54 100644
--- a/src/math/point.h
+++ b/src/math/point.h
@@ -32,14 +32,14 @@
namespace Math
{
-/** \struct Point math/point.h
- \brief 2D point
-
- Represents a 2D point (x, y).
- Contains the required methods for operating on points.
-
- All methods are made inline to maximize optimization.
-
+/**
+ * \struct Point
+ * \brief 2D point
+ *
+ * Represents a 2D point (x, y).
+ * Contains the required methods for operating on points.
+ *
+ * All methods are made inline to maximize optimization.
*/
struct Point
{
diff --git a/src/math/test/CMakeLists.txt b/src/math/test/CMakeLists.txt
index c736022..87121a0 100644
--- a/src/math/test/CMakeLists.txt
+++ b/src/math/test/CMakeLists.txt
@@ -1,33 +1,23 @@
cmake_minimum_required(VERSION 2.8)
set(CMAKE_BUILD_TYPE debug)
-set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0")
+set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wold-style-cast -std=gnu++0x")
-add_executable(matrix_test matrix_test.cpp)
-add_executable(vector_test vector_test.cpp)
-add_executable(geometry_test geometry_test.cpp ../old/math3d.cpp ../old/d3dmath.cpp ../../graphics/d3d/d3dutil.cpp)
-
-enable_testing()
-
-add_test(matrix_test ./matrix_test)
-add_test(vector_test ./vector_test)
-add_test(geometry_test ./geometry_test)
-
-# Change to DirectX SDK directory
-include_directories("c:/dxsdk/include")
+include_directories(
+.
+../../..
+${GTEST_DIR}/include
+)
-add_definitions(-DSTRICT -DD3D_OVERLOADS)
+add_executable(matrix_test matrix_test.cpp)
+target_link_libraries(matrix_test gtest)
-# 'make check' will compile the required test programs
-# Note that 'make test' will still fail without compiled programs
-add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS matrix_test vector_test)
+add_executable(vector_test vector_test.cpp)
+target_link_libraries(vector_test gtest)
-# Files to be removed in distclean
-set(REMOVE_FILES
- CMakeFiles Testing cmake_install.cmake CMakeCache.txt CTestTestfile.cmake Makefile
- ./matrix_test
- ./vector_test
- ./geometry_test
-)
+add_executable(geometry_test geometry_test.cpp)
+target_link_libraries(geometry_test gtest)
-add_custom_target(distclean COMMAND rm -rf ${REMOVE_FILES})
+add_test(matrix_test matrix_test)
+add_test(vector_test vector_test)
+add_test(geometry_test geometry_test)
diff --git a/src/math/test/geometry_test.cpp b/src/math/test/geometry_test.cpp
index 07fa2cf..8b83b8d 100644
--- a/src/math/test/geometry_test.cpp
+++ b/src/math/test/geometry_test.cpp
@@ -20,53 +20,41 @@
#include "../func.h"
#include "../geometry.h"
-#include "../conv.h"
-#include "../../old/math3d.h"
-#include "../../old/d3dutil.h"
-#include <d3d.h>
-#include <cstdio>
+#include "gtest/gtest.h"
-using namespace std;
const float TEST_TOLERANCE = 1e-5;
// Test for rewritten function RotateAngle()
-int TestRotateAngle()
+TEST(GeometryTest, RotateAngleTest)
{
- if (! Math::IsEqual(Math::RotateAngle(0.0f, 0.0f), 0.0f, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 0.0f), 0.0f, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(1.0f, 0.0f), 0.0f, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 0.0f), 0.0f, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(1.0f, 1.0f), 0.25f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, 1.0f), 0.25f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(0.0f, 2.0f), 0.5f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, 2.0f), 0.5f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(-0.5f, 0.5f), 0.75f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-0.5f, 0.5f), 0.75f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(-1.0f, 0.0f), Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, 0.0f), Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(-1.0f, -1.0f), 1.25f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(-1.0f, -1.0f), 1.25f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(0.0f, -2.0f), 1.5f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(0.0f, -2.0f), 1.5f * Math::PI, TEST_TOLERANCE));
- if (! Math::IsEqual(Math::RotateAngle(1.0f, -1.0f), 1.75f * Math::PI, TEST_TOLERANCE))
- return __LINE__;
-
- return 0;
+ EXPECT_TRUE(Math::IsEqual(Math::RotateAngle(1.0f, -1.0f), 1.75f * Math::PI, TEST_TOLERANCE));
}
// Tests for other altered, complex or uncertain functions
+/*
+
+ TODO: write meaningful tests with proper test values
+
int TestAngle()
{
const Math::Vector u(-0.0786076246943884, 0.2231249091714256, -1.1601361718477805);
@@ -360,42 +348,12 @@ int TestTransform()
return 0;
}
-int main()
-{
- // Functions to test
- int (*TESTS[])() =
- {
- TestRotateAngle,
- TestAngle,
- TestRotateView,
- TestLookatPoint,
- TestProjection,
- TestLoadViewMatrix,
- TestLoadProjectionMatrix,
- TestLoadTranslationMatrix,
- TestLoadScaleMatrix,
- TestLoadRotationXMatrix,
- TestLoadRotationYMatrix,
- TestLoadRotationZMatrix,
- TestLoadRotationMatrix,
- TestLoadRotationXZYMatrix,
- TestLoadRotationZXYMatrix,
- TestTransform
- };
- const int TESTS_SIZE = sizeof(TESTS) / sizeof(*TESTS);
-
- int result = 0;
- for (int i = 0; i < TESTS_SIZE; ++i)
- {
- result = TESTS[i]();
- if (result != 0)
- {
- fprintf(stderr, "Test function %d failed at line %d\n", i+1, result);
- return result;
- }
- }
+*/
- fprintf(stderr, "All tests successful\n");
- return 0;
+int main(int argc, char* argv[])
+{
+ ::testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
}
diff --git a/src/math/test/matrix_test.cpp b/src/math/test/matrix_test.cpp
index 663234c..867e0ec 100644
--- a/src/math/test/matrix_test.cpp
+++ b/src/math/test/matrix_test.cpp
@@ -26,13 +26,13 @@
#include "../func.h"
#include "../matrix.h"
-#include <cstdio>
+#include "gtest/gtest.h"
-using namespace std;
const float TEST_TOLERANCE = 1e-6;
-int TestTranspose()
+
+TEST(MatrixTest, TransposeTest)
{
const Math::Matrix mat(
(float[4][4])
@@ -56,16 +56,10 @@ int TestTranspose()
Math::Matrix transpose = Math::Transpose(mat);
- if (! Math::MatricesEqual(transpose, expectedTranspose, TEST_TOLERANCE))
- {
- fprintf(stderr, "Transpose mismatch!\n");
- return __LINE__;
- }
-
- return 0;
+ EXPECT_TRUE(Math::MatricesEqual(transpose, expectedTranspose, TEST_TOLERANCE));
}
-int TestCofactor()
+TEST(MatrixTest, CofactorTest)
{
const Math::Matrix mat1(
(float[4][4])
@@ -93,12 +87,7 @@ int TestCofactor()
{
float ret = mat1.Cofactor(r, c);
float exp = expectedCofactors1.m[4*c+r];
- if (! Math::IsEqual(ret, exp, TEST_TOLERANCE))
- {
- fprintf(stderr, "Cofactors 1 mismatch!\n");
- fprintf(stderr, "r=%d, c=%d, %f (returned) != %f (expected)\n", r, c, ret, exp);
- return __LINE__;
- }
+ EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE));
}
}
@@ -129,19 +118,12 @@ int TestCofactor()
{
float ret = mat2.Cofactor(r, c);
float exp = expectedCofactors2.m[4*c+r];
- if (! Math::IsEqual(ret, exp, TEST_TOLERANCE))
- {
- fprintf(stderr, "Cofactors 2 mismatch!\n");
- fprintf(stderr, "r=%d, c=%d, %f (returned) != %f (expected)\n", r, c, ret, exp);
- return __LINE__;
- }
+ EXPECT_TRUE(Math::IsEqual(ret, exp, TEST_TOLERANCE));
}
}
-
- return 0;
}
-int TestDet()
+TEST(MatrixTest, DetTest)
{
const Math::Matrix mat1(
(float[4][4])
@@ -156,12 +138,7 @@ int TestDet()
const float expectedDet1 = 4.07415413729671;
float ret1 = mat1.Det();
- if (! Math::IsEqual(ret1, expectedDet1, TEST_TOLERANCE))
- {
- fprintf(stderr, "Det mismatch!\n");
- fprintf(stderr, "%f (returned) != %f (expected)\n", ret1, expectedDet1);
- return __LINE__;
- }
+ EXPECT_TRUE(Math::IsEqual(ret1, expectedDet1, TEST_TOLERANCE));
const Math::Matrix mat2(
(float[4][4])
@@ -176,17 +153,10 @@ int TestDet()
const float expectedDet2 = -6.35122307880942;
float ret2 = mat2.Det();
- if (! Math::IsEqual(ret2, expectedDet2, TEST_TOLERANCE))
- {
- fprintf(stderr, "Det mismatch!\n");
- fprintf(stderr, "%f (returned) != %f (expected)\n", ret2, expectedDet2);
- return __LINE__;
- }
-
- return 0;
+ EXPECT_TRUE(Math::IsEqual(ret2, expectedDet2, TEST_TOLERANCE));
}
-int TestInverse()
+TEST(MatrixTest, InverseTest)
{
const Math::Matrix mat1(
(float[4][4])
@@ -210,11 +180,7 @@ int TestInverse()
Math::Matrix inverse1 = mat1.Inverse();
- if (! Math::MatricesEqual(inverse1, expectedInverse1, TEST_TOLERANCE))
- {
- fprintf(stderr, "Inverse 1 mismatch!\n");
- return __LINE__;
- }
+ EXPECT_TRUE(Math::MatricesEqual(inverse1, expectedInverse1, TEST_TOLERANCE));
const Math::Matrix mat2(
(float[4][4])
@@ -238,16 +204,10 @@ int TestInverse()
Math::Matrix inverse2 = mat2.Inverse();
- if (! Math::MatricesEqual(inverse2, expectedInverse2, TEST_TOLERANCE))
- {
- fprintf(stderr, "Inverse 2 mismatch!\n");
- return __LINE__;
- }
-
- return 0;
+ EXPECT_TRUE(Math::MatricesEqual(inverse2, expectedInverse2, TEST_TOLERANCE));
}
-int TestMultiply()
+TEST(MatrixTest, MultiplyTest)
{
const Math::Matrix mat1A(
(float[4][4])
@@ -280,11 +240,7 @@ int TestMultiply()
);
Math::Matrix multiply1 = Math::MultiplyMatrices(mat1A, mat1B);
- if (! Math::MatricesEqual(multiply1, expectedMultiply1, TEST_TOLERANCE ) )
- {
- fprintf(stderr, "Multiply 1 mismath!\n");
- return __LINE__;
- }
+ EXPECT_TRUE(Math::MatricesEqual(multiply1, expectedMultiply1, TEST_TOLERANCE));
const Math::Matrix mat2A(
(float[4][4])
@@ -317,16 +273,10 @@ int TestMultiply()
);
Math::Matrix multiply2 = Math::MultiplyMatrices(mat2A, mat2B);
- if (! Math::MatricesEqual(multiply2, expectedMultiply2, TEST_TOLERANCE ) )
- {
- fprintf(stderr, "Multiply 2 mismath!\n");
- return __LINE__;
- }
-
- return 0;
+ EXPECT_TRUE(Math::MatricesEqual(multiply2, expectedMultiply2, TEST_TOLERANCE));
}
-int TestMultiplyVector()
+TEST(MatrixTest, MultiplyVectorTest)
{
const Math::Matrix mat1(
(float[4][4])
@@ -343,11 +293,7 @@ int TestMultiplyVector()
const Math::Vector expectedMultiply1(0.608932463260470, -1.356893266403749, 3.457156276255142);
Math::Vector multiply1 = Math::MatrixVectorMultiply(mat1, vec1, false);
- if (! Math::VectorsEqual(multiply1, expectedMultiply1, TEST_TOLERANCE ) )
- {
- fprintf(stderr, "Multiply vector 1 mismath!\n");
- return __LINE__;
- }
+ EXPECT_TRUE(Math::VectorsEqual(multiply1, expectedMultiply1, TEST_TOLERANCE));
const Math::Matrix mat2(
(float[4][4])
@@ -364,39 +310,13 @@ int TestMultiplyVector()
const Math::Vector expectedMultiply2(0.2816820577317669, 0.0334468811767428, 0.1996974284970455);
Math::Vector multiply2 = Math::MatrixVectorMultiply(mat2, vec2, true);
- if (! Math::VectorsEqual(multiply2, expectedMultiply2, TEST_TOLERANCE ) )
- {
- fprintf(stderr, "Multiply vector 2 mismath!\n");
- return __LINE__;
- }
-
- return 0;
+ EXPECT_TRUE(Math::VectorsEqual(multiply2, expectedMultiply2, TEST_TOLERANCE));
}
-int main()
+int main(int argc, char* argv[])
{
- // Functions to test
- int (*TESTS[])() =
- {
- TestTranspose,
- TestCofactor,
- TestDet,
- TestInverse,
- TestMultiply,
- TestMultiplyVector
- };
- const int TESTS_SIZE = sizeof(TESTS) / sizeof(*TESTS);
-
- int result = 0;
- for (int i = 0; i < TESTS_SIZE; ++i)
- {
- result = TESTS[i]();
- if (result != 0)
- return result;
- }
-
- fprintf(stderr, "All tests successful\n");
+ ::testing::InitGoogleTest(&argc, argv);
- return 0;
+ return RUN_ALL_TESTS();
}
diff --git a/src/math/test/vector_test.cpp b/src/math/test/vector_test.cpp
index 899a580..ead2fd2 100644
--- a/src/math/test/vector_test.cpp
+++ b/src/math/test/vector_test.cpp
@@ -26,59 +26,41 @@
#include "../func.h"
#include "../vector.h"
-#include <cstdio>
+#include "gtest/gtest.h"
-using namespace std;
const float TEST_TOLERANCE = 1e-6;
-int TestLength()
+
+TEST(VectorTest, LengthTest)
{
Math::Vector vec(-1.288447945923275, 0.681452565308134, -0.633761098985957);
const float expectedLength = 1.58938001708428;
- if (! Math::IsEqual(vec.Length(), expectedLength, TEST_TOLERANCE) )
- {
- fprintf(stderr, "Length mismatch!\n");
- return __LINE__;
- }
-
- return 0;
+ EXPECT_TRUE(Math::IsEqual(vec.Length(), expectedLength, TEST_TOLERANCE));
}
-int TestNormalize()
+TEST(VectorTest, NormalizeTest)
{
Math::Vector vec(1.848877241804398, -0.157262961268577, -1.963031403332377);
const Math::Vector expectedNormalized(0.6844609421393856, -0.0582193085618106, -0.7267212194481797);
vec.Normalize();
- if (! Math::VectorsEqual(vec, expectedNormalized, TEST_TOLERANCE))
- {
- fprintf(stderr, "Normalize mismatch!\n");
- return __LINE__;
- }
-
- return 0;
+ EXPECT_TRUE(Math::VectorsEqual(vec, expectedNormalized, TEST_TOLERANCE));
}
-int TestDot()
+TEST(VectorTest, DotTest)
{
Math::Vector vecA(0.8202190530968309, 0.0130926060162780, 0.2411914183883510);
Math::Vector vecB(-0.0524083951404069, 1.5564932716738220, -0.8971342631500536);
float expectedDot = -0.238988896477326;
- if (! Math::IsEqual(Math::DotProduct(vecA, vecB), expectedDot, TEST_TOLERANCE) )
- {
- fprintf(stderr, "Dot product mismatch!\n");
- return __LINE__;
- }
-
- return 0;
+ EXPECT_TRUE(Math::IsEqual(Math::DotProduct(vecA, vecB), expectedDot, TEST_TOLERANCE));
}
-int TestCross()
+TEST(VectorTest, CrossTest)
{
Math::Vector vecA(1.37380499798567, 1.18054518384682, 1.95166361293121);
Math::Vector vecB(0.891657855926886, 0.447591335394532, -0.901604070087823);
@@ -86,42 +68,14 @@ int TestCross()
Math::Vector expectedCross(-1.937932065431669, 2.978844370287636, -0.437739173833581);
Math::Vector expectedReverseCross = -expectedCross;
- if (! Math::VectorsEqual(vecA.CrossMultiply(vecB), expectedCross, TEST_TOLERANCE) )
- {
- fprintf(stderr, "Cross product mismatch!\n");
- return __LINE__;
- }
-
- if (! Math::VectorsEqual(vecB.CrossMultiply(vecA), expectedReverseCross, TEST_TOLERANCE) )
- {
- fprintf(stderr, "Reverse cross product mismatch!\n");
- return __LINE__;
- }
+ EXPECT_TRUE(Math::VectorsEqual(vecA.CrossMultiply(vecB), expectedCross, TEST_TOLERANCE));
- return 0;
+ EXPECT_TRUE(Math::VectorsEqual(vecB.CrossMultiply(vecA), expectedReverseCross, TEST_TOLERANCE));
}
-int main()
+int main(int argc, char* argv[])
{
- // Functions to test
- int (*TESTS[])() =
- {
- TestLength,
- TestNormalize,
- TestDot,
- TestCross
- };
- const int TESTS_SIZE = sizeof(TESTS) / sizeof(*TESTS);
-
- int result = 0;
- for (int i = 0; i < TESTS_SIZE; ++i)
- {
- result = TESTS[i]();
- if (result != 0)
- return result;
- }
-
- fprintf(stderr, "All tests successful\n");
-
- return 0;
+ ::testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
}
diff --git a/src/math/vector.h b/src/math/vector.h
index 4378e75..222d0cd 100644
--- a/src/math/vector.h
+++ b/src/math/vector.h
@@ -32,16 +32,17 @@
namespace Math
{
-/** \struct Vector math/vector.h
- \brief 3D (3x1) vector
-
- Represents a universal 3x1 vector that can be used in OpenGL and DirectX engines.
- Contains the required methods for operating on vectors.
-
- All methods are made inline to maximize optimization.
-
- Unit tests for the structure and related functions are in module: math/test/vector_test.cpp.
-
+/**
+ * \struct Vector
+ * \brief 3D (3x1) vector
+ *
+ * Represents a universal 3x1 vector that can be used in OpenGL and DirectX engines.
+ * Contains the required methods for operating on vectors.
+ *
+ * All methods are made inline to maximize optimization.
+ *
+ * Unit tests for the structure and related functions are in module: math/test/vector_test.cpp.
+ *
*/
struct Vector
{
@@ -103,8 +104,10 @@ struct Vector
}
//! Calculates the cross product with another vector
- /** \a right right-hand side vector
- \returns the cross product*/
+ /**
+ * \param right right-hand side vector
+ * \returns the cross product
+ */
inline Vector CrossMultiply(const Vector &right) const
{
float px = y * right.z - z * right.y;
@@ -114,8 +117,10 @@ struct Vector
}
//! Calculates the dot product with another vector
- /** \a right right-hand side vector
- \returns the dot product */
+ /**
+ * \param right right-hand side vector
+ * \returns the dot product
+ */
inline float DotMultiply(const Vector &right) const
{
return x * right.x + y * right.y + z * right.z;
@@ -218,7 +223,7 @@ struct Vector
return s.str();
}
-}; // struct Point
+}; // struct Vector
//! Checks if two vectors are equal within given \a tolerance
inline bool VectorsEqual(const Math::Vector &a, const Math::Vector &b, float tolerance = TOLERANCE)
@@ -262,4 +267,14 @@ inline float Distance(const Math::Vector &a, const Math::Vector &b)
(a.z-b.z)*(a.z-b.z) );
}
+//! Clamps the vector \a vec to range between \a min and \a max
+inline Vector Clamp(const Vector &vec, const Vector &min, const Vector &max)
+{
+ Vector clamped;
+ clamped.x = Min(Max(min.x, vec.x), max.x);
+ clamped.y = Min(Max(min.y, vec.y), max.y);
+ clamped.z = Min(Max(min.z, vec.z), max.z);
+ return clamped;
+}
+
}; // namespace Math
diff --git a/src/object/auto/auto.cpp b/src/object/auto/auto.cpp
index d112721..711497d 100644
--- a/src/object/auto/auto.cpp
+++ b/src/object/auto/auto.cpp
@@ -15,8 +15,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/auto.h"
@@ -26,7 +24,8 @@
#include "ui/gauge.h"
#include "ui/window.h"
-
+#include <stdio.h>
+#include <string.h>
// Object's constructor.
@@ -37,22 +36,22 @@ CAuto::CAuto(CInstanceManager* iMan, CObject* object)
m_iMan->AddInstance(CLASS_AUTO, this, 100);
m_object = object;
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
- m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT);
- m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
- m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
- m_cloud = (CCloud*)m_iMan->SearchInstance(CLASS_CLOUD);
- m_planet = (CPlanet*)m_iMan->SearchInstance(CLASS_PLANET);
- m_blitz = (CBlitz*)m_iMan->SearchInstance(CLASS_BLITZ);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_displayText = (CDisplayText*)m_iMan->SearchInstance(CLASS_DISPLAYTEXT);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
-
- m_type = m_object->RetType();
+ m_event = static_cast< CEventQueue* >(m_iMan->SearchInstance(CLASS_EVENT));
+ m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_particle = static_cast< Gfx::CParticle* >(m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_lightMan = static_cast< Gfx::CLightManager* >(m_iMan->SearchInstance(CLASS_LIGHT));
+ m_terrain = static_cast< Gfx::CTerrain* >(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_water = static_cast< Gfx::CWater* >(m_iMan->SearchInstance(CLASS_WATER));
+ m_cloud = static_cast< Gfx::CCloud* >(m_iMan->SearchInstance(CLASS_CLOUD));
+ m_planet = static_cast< Gfx::CPlanet* >(m_iMan->SearchInstance(CLASS_PLANET));
+ m_lightning = static_cast< Gfx::CLightning* >(m_iMan->SearchInstance(CLASS_BLITZ));
+ m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_interface = static_cast< Ui::CInterface* >(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
+ m_displayText = static_cast< Ui::CDisplayText* >(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
+ m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
+
+ m_type = m_object->GetType();
m_time = 0.0f;
m_lastUpdateTime = 0.0f;
m_bMotor = false;
@@ -117,14 +116,14 @@ bool CAuto::SetString(char *string)
bool CAuto::EventProcess(const Event &event)
{
- if ( event.event == EVENT_FRAME &&
- !m_engine->RetPause() )
+ if ( event.type == EVENT_FRAME &&
+ !m_engine->GetPause() )
{
m_time += event.rTime;
UpdateInterface(event.rTime);
}
- if ( !m_object->RetSelect() ) // robot not selected?
+ if ( !m_object->GetSelect() ) // robot not selected?
{
return true;
}
@@ -151,13 +150,13 @@ bool CAuto::Abort()
bool CAuto::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
char name[100];
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw != 0 )
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw != nullptr )
{
pw->Flush(); // destroys the window buttons
m_interface->DeleteControl(EVENT_WINDOW0); // destroys the window
@@ -171,7 +170,7 @@ bool CAuto::CreateInterface(bool bSelect)
//? dim.y = 70.0f/480.0f;
dim.y = 86.0f/480.0f;
m_interface->CreateWindows(pos, dim, 3, EVENT_WINDOW0);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
m_object->GetTooltipName(name);
@@ -214,7 +213,7 @@ bool CAuto::CreateInterface(bool bSelect)
pos.y = oy+sy*0;
pw->CreateButton(pos, dim, 19, EVENT_OBJECT_HELP);
- if ( m_main->RetSceneSoluce() )
+ if ( m_main->GetSceneSoluce() )
{
pos.x = ox+sx*13.4f;
pos.y = oy+sy*1;
@@ -263,62 +262,62 @@ bool CAuto::CreateInterface(bool bSelect)
// Change the state of a button interface.
-void CAuto::CheckInterface(CWindow *pw, EventMsg event, bool bState)
+void CAuto::CheckInterface(Ui::CWindow *pw, EventType event, bool bState)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
- if ( control == 0 ) return;
+ if ( control == nullptr ) return;
- control->SetState(STATE_CHECK, bState);
+ control->SetState(Ui::STATE_CHECK, bState);
}
// Change the state of a button interface.
-void CAuto::EnableInterface(CWindow *pw, EventMsg event, bool bState)
+void CAuto::EnableInterface(Ui::CWindow *pw, EventType event, bool bState)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
- if ( control == 0 ) return;
+ if ( control == nullptr ) return;
- control->SetState(STATE_ENABLE, bState);
+ control->SetState(Ui::STATE_ENABLE, bState);
}
// Change the state of a button interface.
-void CAuto::VisibleInterface(CWindow *pw, EventMsg event, bool bState)
+void CAuto::VisibleInterface(Ui::CWindow *pw, EventType event, bool bState)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
- if ( control == 0 ) return;
+ if ( control == nullptr ) return;
- control->SetState(STATE_VISIBLE, bState);
+ control->SetState(Ui::STATE_VISIBLE, bState);
}
// Change the state of a button interface.
-void CAuto::DeadInterface(CWindow *pw, EventMsg event, bool bState)
+void CAuto::DeadInterface(Ui::CWindow *pw, EventType event, bool bState)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
- if ( control == 0 ) return;
+ if ( control == nullptr ) return;
- control->SetState(STATE_DEAD, !bState);
+ control->SetState(Ui::STATE_DEAD, !bState);
}
// Change the state of a button interface.
void CAuto::UpdateInterface()
{
- CWindow* pw;
+ Ui::CWindow* pw;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw == 0 ) return;
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw == nullptr ) return;
VisibleInterface(pw, EVENT_OBJECT_GPROGRESS, m_bBusy);
}
@@ -328,34 +327,34 @@ void CAuto::UpdateInterface()
void CAuto::UpdateInterface(float rTime)
{
- CWindow* pw;
- CGauge* pg;
+ Ui::CWindow* pw;
+ Ui::CGauge* pg;
if ( m_time < m_lastUpdateTime+0.1f ) return;
m_lastUpdateTime = m_time;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw == 0 ) return;
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw == nullptr ) return;
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GSHIELD);
- if ( pg != 0 )
+ pg = static_cast<Ui::CGauge*>(pw->SearchControl(EVENT_OBJECT_GSHIELD));
+ if ( pg != nullptr )
{
- pg->SetLevel(m_object->RetShield());
+ pg->SetLevel(m_object->GetShield());
}
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GPROGRESS);
- if ( pg != 0 )
+ pg = static_cast<Ui::CGauge*>(pw->SearchControl(EVENT_OBJECT_GPROGRESS));
+ if ( pg != nullptr )
{
pg->SetLevel(m_progressTime);
}
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAuto::RetError()
+Error CAuto::GetError()
{
return ERR_OK;
}
@@ -363,7 +362,7 @@ Error CAuto::RetError()
// Management of the occupation.
-bool CAuto::RetBusy()
+bool CAuto::GetBusy()
{
return m_bBusy;
}
@@ -387,7 +386,7 @@ void CAuto::EventProgress(float rTime)
// Engine management.
-bool CAuto::RetMotor()
+bool CAuto::GetMotor()
{
return m_bMotor;
}
@@ -422,11 +421,11 @@ bool CAuto::Write(char *line)
return false;
}
-// Return all settings to the controller.
+// Geturn all settings to the controller.
bool CAuto::Read(char *line)
{
- m_type = (ObjectType)OpInt(line, "aType", OBJECT_NULL);
+ m_type = static_cast<ObjectType>(OpInt(line, "aType", OBJECT_NULL));
m_bBusy = OpInt(line, "aBusy", 0);
m_time = OpFloat(line, "aTime", 0.0f);
m_progressTime = OpFloat(line, "aProgressTime", 0.0f);
diff --git a/src/object/auto/auto.h b/src/object/auto/auto.h
index 09efdd9..2194924 100644
--- a/src/object/auto/auto.h
+++ b/src/object/auto/auto.h
@@ -19,27 +19,32 @@
#pragma once
-#include "common/misc.h"
+#include "common/global.h"
#include "object/object.h"
class CInstanceManager;
-class CD3DEngine;
-class CParticule;
-class CLight;
-class CTerrain;
-class CWater;
-class CCloud;
-class CPlanet;
-class CBlitz;
-class CCamera;
-class CInterface;
class CRobotMain;
+class CSoundInterface;
+
+namespace Ui {
class CDisplayText;
+class CInterface;
class CWindow;
-class CSound;
+} /* Ui */
+namespace Gfx {
+class CEngine;
+class CParticle;
+class CLightManager;
+class CTarrain;
+class CWater;
+class CCloud;
+class CCamera;
+class CPlanet;
+class CLightning;
+} /* Gfx */
class CAuto
@@ -61,44 +66,44 @@ public:
virtual bool SetString(char *string);
virtual bool CreateInterface(bool bSelect);
- virtual Error RetError();
+ virtual Error GetError();
- virtual bool RetBusy();
+ virtual bool GetBusy();
virtual void SetBusy(bool bBuse);
virtual void InitProgressTotal(float total);
virtual void EventProgress(float rTime);
- virtual bool RetMotor();
+ virtual bool GetMotor();
virtual void SetMotor(bool bMotor);
virtual bool Write(char *line);
virtual bool Read(char *line);
protected:
- void CheckInterface(CWindow *pw, EventMsg event, bool bState);
- void EnableInterface(CWindow *pw, EventMsg event, bool bState);
- void VisibleInterface(CWindow *pw, EventMsg event, bool bState);
- void DeadInterface(CWindow *pw, EventMsg event, bool bState);
+ void CheckInterface(Ui::CWindow *pw, EventType event, bool bState);
+ void EnableInterface(Ui::CWindow *pw, EventType event, bool bState);
+ void VisibleInterface(Ui::CWindow *pw, EventType event, bool bState);
+ void DeadInterface(Ui::CWindow *pw, EventType event, bool bState);
void UpdateInterface();
void UpdateInterface(float rTime);
protected:
- CInstanceManager* m_iMan;
- CEvent* m_event;
- CD3DEngine* m_engine;
- CParticule* m_particule;
- CLight* m_light;
- CTerrain* m_terrain;
- CWater* m_water;
- CCloud * m_cloud;
- CPlanet * m_planet;
- CBlitz* m_blitz;
- CCamera* m_camera;
- CInterface* m_interface;
- CRobotMain* m_main;
- CDisplayText* m_displayText;
- CObject* m_object;
- CSound* m_sound;
+ CInstanceManager* m_iMan;
+ CEventQueue* m_event;
+ Gfx::CEngine* m_engine;
+ Gfx::CParticle* m_particle;
+ Gfx::CLightManager* m_lightMan;
+ Gfx::CTerrain* m_terrain;
+ Gfx::CWater* m_water;
+ Gfx::CCloud* m_cloud;
+ Gfx::CPlanet* m_planet;
+ Gfx::CLightning* m_lightning;
+ Gfx::CCamera* m_camera;
+ Ui::CInterface* m_interface;
+ Ui::CDisplayText* m_displayText;
+ CRobotMain* m_main;
+ CObject* m_object;
+ CSoundInterface* m_sound;
ObjectType m_type;
bool m_bBusy;
diff --git a/src/object/auto/autobase.cpp b/src/object/auto/autobase.cpp
index 19382b7..d7b3ca1 100644
--- a/src/object/auto/autobase.cpp
+++ b/src/object/auto/autobase.cpp
@@ -20,10 +20,10 @@
#include "object/auto/autobase.h"
#include "common/iman.h"
-#include "old/terrain.h"
-#include "old/cloud.h"
-#include "old/planet.h"
-#include "old/blitz.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/cloud.h"
+#include "graphics/engine/planet.h"
+#include "graphics/engine/lightning.h"
#include "math/geometry.h"
#include "object/robotmain.h"
#include "physics/physics.h"
@@ -50,8 +50,8 @@ const float BASE_TRANSIT_TIME = 15.0f; // transit duration
CAutoBase::CAutoBase(CInstanceManager* iMan, CObject* object)
: CAuto(iMan, object)
{
- m_fogStart = m_engine->RetFogStart();
- m_deepView = m_engine->RetDeepView();
+ m_fogStart = m_engine->GetFogStart();
+ m_deepView = m_engine->GetDeepView();
Init();
m_phase = ABP_WAIT;
m_soundChannel = -1;
@@ -85,10 +85,10 @@ void CAutoBase::Init()
{
m_bOpen = false;
m_time = 0.0f;
- m_lastParticule = 0.0f;
- m_lastMotorParticule = 0.0f;
+ m_lastParticle = 0.0f;
+ m_lastMotorParticle = 0.0f;
- m_pos = m_object->RetPosition(0);
+ m_pos = m_object->GetPosition(0);
m_lastPos = m_pos;
m_phase = ABP_WAIT;
@@ -124,10 +124,10 @@ bool CAutoBase::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
begin:
- iPos = m_object->RetPosition(0);
+ iPos = m_object->GetPosition(0);
if ( m_phase == ABP_START )
{
@@ -152,17 +152,17 @@ begin:
m_object->SetPosition(18+i, Math::Vector(23.5f, 0.0f, 11.5f));
}
- pObj = m_main->RetSelectObject();
+ pObj = m_main->GetSelectObject();
m_main->SelectObject(pObj);
- m_camera->SetObject(pObj);
+ m_camera->SetControllingObject(pObj);
if ( pObj == 0 )
{
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
}
else
{
- m_camera->SetType(pObj->RetCameraType());
- m_camera->SetDist(pObj->RetCameraDist());
+ m_camera->SetType(pObj->GetCameraType());
+ m_camera->SetDist(pObj->GetCameraDist());
}
m_main->StartMusic();
@@ -193,16 +193,16 @@ begin:
m_main->SetMovieLock(true); // blocks everything until the end of the landing
m_bMotor = true; // lights the jet engine
- m_camera->SetType(CAMERA_SCRIPT);
+ m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
pos = m_pos;
pos.x -= 150.0f;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
m_camera->SetScriptEye(pos);
m_posSound = pos;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 300.0f+50.0f;
m_camera->SetScriptLookat(pos);
@@ -223,7 +223,7 @@ begin:
if ( m_param == PARAM_PORTICO ) // gate on the porch?
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_finalPos = pos;
pos.z += BASE_PORTICO_TIME_MOVE*5.0f; // back
pos.y += 10.0f; // rises (the gate)
@@ -246,7 +246,7 @@ begin:
m_speed = 1.0f/BASE_TRANSIT_TIME;
m_object->SetAngleZ(0, -Math::PI/2.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 10000.0f; // in space
m_finalPos = pos;
m_object->SetPosition(0, pos);
@@ -254,7 +254,7 @@ begin:
m_main->SetMovieLock(true); // blocks everything until the end of the landing
m_bMotor = true; // lights the jet engine
- m_camera->SetType(CAMERA_SCRIPT);
+ m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
pos.x += 1000.0f;
pos.z -= 60.0f;
pos.y += 80.0f;
@@ -265,34 +265,34 @@ begin:
BeginTransit();
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 10.0f;
dim.y = dim.x;
pos = Math::Vector(42.0f, -2.0f, 17.0f);
pos = Transform(*mat, pos);
- m_partiChannel[0] = m_particule->CreateParticule(pos, speed, dim, PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
+ m_partiChannel[0] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
pos = Math::Vector(17.0f, -2.0f, 42.0f);
pos = Transform(*mat, pos);
- m_partiChannel[1] = m_particule->CreateParticule(pos, speed, dim, PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
+ m_partiChannel[1] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
pos = Math::Vector(42.0f, -2.0f, -17.0f);
pos = Transform(*mat, pos);
- m_partiChannel[2] = m_particule->CreateParticule(pos, speed, dim, PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
+ m_partiChannel[2] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
pos = Math::Vector(17.0f, -2.0f, -42.0f);
pos = Transform(*mat, pos);
- m_partiChannel[3] = m_particule->CreateParticule(pos, speed, dim, PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
+ m_partiChannel[3] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
pos = Math::Vector(-42.0f, -2.0f, 17.0f);
pos = Transform(*mat, pos);
- m_partiChannel[4] = m_particule->CreateParticule(pos, speed, dim, PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
+ m_partiChannel[4] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
pos = Math::Vector(-17.0f, -2.0f, 42.0f);
pos = Transform(*mat, pos);
- m_partiChannel[5] = m_particule->CreateParticule(pos, speed, dim, PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
+ m_partiChannel[5] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
pos = Math::Vector(-42.0f, -2.0f, -17.0f);
pos = Transform(*mat, pos);
- m_partiChannel[6] = m_particule->CreateParticule(pos, speed, dim, PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
+ m_partiChannel[6] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
pos = Math::Vector(-17.0f, -2.0f, -42.0f);
pos = Transform(*mat, pos);
- m_partiChannel[7] = m_particule->CreateParticule(pos, speed, dim, PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
+ m_partiChannel[7] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTILENS1, BASE_TRANSIT_TIME+1.0f, 0.0f, 0.0f);
if ( m_soundChannel == -1 )
{
@@ -303,12 +303,12 @@ begin:
}
}
- if ( event.event == EVENT_UPDINTERFACE )
+ if ( event.type == EVENT_UPDINTERFACE )
{
- if ( m_object->RetSelect() ) CreateInterface(true);
+ if ( m_object->GetSelect() ) CreateInterface(true);
}
- if ( event.event == EVENT_OBJECT_BTAKEOFF )
+ if ( event.type == EVENT_OBJECT_BTAKEOFF )
{
err = CheckCloseDoor();
if ( err != ERR_OK )
@@ -328,19 +328,19 @@ begin:
m_main->SetMovieLock(true); // blocks everything until the end
m_main->DeselectAll();
- m_event->MakeEvent(newEvent, EVENT_UPDINTERFACE);
+ newEvent.type = EVENT_UPDINTERFACE;
m_event->AddEvent(newEvent);
- m_camera->SetType(CAMERA_SCRIPT);
+ m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
pos = m_pos;
pos.x -= 110.0f;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
m_camera->SetScriptEye(pos);
m_posSound = pos;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 50.0f;
m_camera->SetScriptLookat(pos);
@@ -356,7 +356,7 @@ begin:
return true;
}
- if ( event.event != EVENT_FRAME ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_phase == ABP_WAIT ) return true;
m_progress += event.rTime*m_speed;
@@ -382,19 +382,19 @@ begin:
pos = m_pos;
pos.x -= 150.0f;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
m_camera->SetScriptEye(pos);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 50.0f;
m_camera->SetScriptLookat(pos);
m_engine->SetFocus(1.0f+(1.0f-m_progress));
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.10f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.10f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
// Dust thrown to the ground.
pos = m_pos;
@@ -410,19 +410,19 @@ begin:
dim.y = dim.x;
if ( dim.x >= 1.0f )
{
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 2.0f);
}
// Particles are ejected from the jet engine.
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 6.0f;
- h = m_terrain->RetFloorHeight(pos)/300.0f;
+ h = m_terrain->GetHeightToFloor(pos)/300.0f;
speed.x = (Math::Rand()-0.5f)*(80.0f-50.0f*h);
speed.z = (Math::Rand()-0.5f)*(80.0f-50.0f*h);
speed.y = -(Math::Rand()*(h+1.0f)*40.0f+(h+1.0f)*40.0f);
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 2.0f, 10.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 2.0f, 10.0f, 2.0f);
// Black smoke from the jet engine.
if ( m_progress > 0.8f )
@@ -436,7 +436,7 @@ begin:
speed.y = 0.0f;
dim.x = Math::Rand()*4.0f+4.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f, 0.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f, 0.0f, 2.0f);
}
}
}
@@ -449,7 +449,7 @@ begin:
MoveCargo(); // all cargo moves
// Impact with the ground.
- max = (int)(50.0f*m_engine->RetParticuleDensity());
+ max = static_cast<int>(50.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<max ; i++ )
{
angle = Math::Rand()*(Math::PI*2.0f);
@@ -461,11 +461,11 @@ begin:
dim.x = Math::Rand()*10.0f+10.0f;
dim.y = dim.x;
time = Math::Rand()*2.0f+1.5f;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, time, 0.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, time, 0.0f, 2.0f);
}
//? m_camera->StartEffect(CE_CRASH, m_pos, 1.0f);
- m_camera->StartEffect(CE_EXPLO, m_pos, 2.0f);
+ m_camera->StartEffect(Gfx::CAM_EFFECT_EXPLO, m_pos, 2.0f);
m_engine->SetFocus(1.0f);
m_sound->Play(SOUND_BOUM, m_posSound, 0.6f, 0.5f);
@@ -479,9 +479,9 @@ begin:
{
if ( m_progress < 1.0f )
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.10f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.10f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
// Black smoke from the reactor.
pos = m_pos;
@@ -493,7 +493,7 @@ begin:
speed.y = 0.0f;
dim.x = Math::Rand()*4.0f+4.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f, 0.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f, 0.0f, 2.0f);
}
}
else
@@ -526,7 +526,7 @@ begin:
pos = m_pos;
pos.x += p.x;
pos.z += p.y;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
pos.y += m_progress*40.0f;
m_camera->SetScriptEye(pos);
@@ -542,7 +542,7 @@ begin:
}
// Clash the doors with the ground.
- max = (int)(20.0f*m_engine->RetParticuleDensity());
+ max = static_cast<int>(20.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<max ; i++ )
{
angle = Math::Rand()*(20.0f*Math::PI/180.0f)-(10.0f*Math::PI/180.0f);
@@ -555,7 +555,7 @@ begin:
dim.x = Math::Rand()*8.0f+8.0f;
dim.y = dim.x;
time = Math::Rand()*2.0f+1.5f;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, time, 0.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, time, 0.0f, 2.0f);
}
m_soundChannel = m_sound->Play(SOUND_MANIP, m_posSound, 0.3f, 1.5f, true);
@@ -588,7 +588,7 @@ begin:
pos = m_pos;
pos.x += p.x;
pos.z += p.y;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
pos.y += m_progress*40.0f;
m_camera->SetScriptEye(pos);
@@ -622,19 +622,19 @@ begin:
{
m_main->SetMovieLock(false); // you can play!
- pObj = m_main->RetSelectObject();
+ pObj = m_main->GetSelectObject();
m_main->SelectObject(pObj);
- m_camera->SetObject(pObj);
+ m_camera->SetControllingObject(pObj);
if ( pObj == 0 )
{
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
}
else
{
- m_camera->SetType(pObj->RetCameraType());
- m_camera->SetDist(pObj->RetCameraDist());
+ m_camera->SetType(pObj->GetCameraType());
+ m_camera->SetDist(pObj->GetCameraDist());
}
- m_sound->Play(SOUND_BOUM, m_object->RetPosition(0));
+ m_sound->Play(SOUND_BOUM, m_object->GetPosition(0));
m_soundChannel = -1;
m_engine->SetFogStart(m_fogStart);
@@ -700,7 +700,7 @@ begin:
m_bMotor = true; // lights the jet engine
// Shock of the closing doors.
- max = (int)(20.0f*m_engine->RetParticuleDensity());
+ max = static_cast<int>(20.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<max ; i++ )
{
angle = Math::Rand()*Math::PI*2.0f;
@@ -713,9 +713,9 @@ begin:
dim.x = Math::Rand()*3.0f+3.0f;
dim.y = dim.x;
time = Math::Rand()*1.0f+1.0f;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, time);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, time);
}
- m_sound->Play(SOUND_BOUM, m_object->RetPosition(0));
+ m_sound->Play(SOUND_BOUM, m_object->GetPosition(0));
m_soundChannel = -1;
m_bOpen = false;
@@ -742,19 +742,19 @@ begin:
vibCir *= m_progress*1.0f;
m_object->SetCirVibration(vibCir);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
// Particles are ejected from the reactor.
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 6.0f;
speed.x = (Math::Rand()-0.5f)*160.0f;
speed.z = (Math::Rand()-0.5f)*160.0f;
speed.y = -(Math::Rand()*10.0f+10.0f);
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 2.0f, 10.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 2.0f, 10.0f, 2.0f);
}
m_engine->SetFogStart(m_fogStart+(0.9f-m_fogStart)*m_progress);
@@ -785,19 +785,19 @@ begin:
pos = m_pos;
pos.x -= 110.0f+m_progress*250.0f;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
pos.y += 10.0f;
m_camera->SetScriptEye(pos);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 50.0f;
m_camera->SetScriptLookat(pos);
m_engine->SetFocus(1.0f+m_progress);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.10f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.10f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
// Dust thrown to the ground.
pos = m_pos;
@@ -813,11 +813,11 @@ begin:
dim.y = dim.x;
if ( dim.x >= 1.0f )
{
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 2.0f);
}
// Particles are ejected from the reactor.
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 6.0f;
speed.x = (Math::Rand()-0.5f)*40.0f;
speed.z = (Math::Rand()-0.5f)*40.0f;
@@ -826,23 +826,23 @@ begin:
time = 2.0f+m_progress*12.0f;
dim.x = Math::Rand()*time+time;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 2.0f, 10.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 2.0f, 10.0f, 2.0f);
// Black smoke from the reactor.
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 3.0f;
speed.x = (Math::Rand()-0.5f)*10.0f*(4.0f-m_progress*3.0f);
speed.z = (Math::Rand()-0.5f)*10.0f*(4.0f-m_progress*3.0f);
speed.y = 0.0f;
dim.x = Math::Rand()*20.0f+20.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 10.0f, 0.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 10.0f, 0.0f, 2.0f);
}
}
else
{
m_soundChannel = -1;
- m_event->MakeEvent(newEvent, EVENT_WIN);
+ newEvent.type = EVENT_WIN;
m_event->AddEvent(newEvent);
m_phase = ABP_WAIT;
@@ -855,7 +855,7 @@ begin:
{
if ( m_progress < 1.0f )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.z -= event.rTime*5.0f;
m_object->SetPosition(0, pos);
MoveCargo(); // all cargo moves
@@ -882,7 +882,7 @@ begin:
{
if ( m_progress < 1.0f )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y -= event.rTime*(10.0f/BASE_PORTICO_TIME_DOWN);
m_object->SetPosition(0, pos);
MoveCargo(); // all cargo moves
@@ -890,7 +890,7 @@ begin:
else
{
// Impact with the ground.
- max = (int)(50.0f*m_engine->RetParticuleDensity());
+ max = static_cast<int>(50.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<max ; i++ )
{
angle = Math::Rand()*(Math::PI*2.0f);
@@ -902,7 +902,7 @@ begin:
dim.x = Math::Rand()*10.0f+10.0f;
dim.y = dim.x;
time = Math::Rand()*2.0f+1.5f;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, time, 0.0f, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, time, 0.0f, 2.0f);
}
m_phase = ABP_PORTICO_WAIT2;
@@ -938,7 +938,7 @@ begin:
{
if ( m_progress < 1.0f )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += event.rTime*(2000.0f/BASE_TRANSIT_TIME);
m_object->SetPosition(0, pos);
pos.x += 60.0f;
@@ -967,11 +967,11 @@ begin:
if ( m_bMotor )
{
- if ( m_lastMotorParticule+m_engine->ParticuleAdapt(0.02f) <= m_time )
+ if ( m_lastMotorParticle+m_engine->ParticleAdapt(0.02f) <= m_time )
{
- m_lastMotorParticule = m_time;
+ m_lastMotorParticle = m_time;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
if ( event.rTime == 0.0f )
{
@@ -979,7 +979,7 @@ begin:
}
else
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
if ( m_phase == ABP_TRANSIT_MOVE )
{
vSpeed = (pos.x-iPos.x)/event.rTime;
@@ -1003,7 +1003,7 @@ begin:
dim.x = 4.0f+Math::Rand()*4.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBASE, 3.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBASE, 3.0f, 0.0f, 0.0f);
if ( m_phase == ABP_TRANSIT_MOVE )
{
@@ -1013,7 +1013,7 @@ begin:
pos = Math::Vector(0.0f, 7.0f, 0.0f);
pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 1.0f, 0.0f, 0.0f);
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 4.0f;
@@ -1021,67 +1021,67 @@ begin:
pos = Math::Vector(42.0f, 0.0f, 17.0f);
pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = Math::Vector(17.0f, 0.0f, 42.0f);
pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = Math::Vector(42.0f, 0.0f, -17.0f);
pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = Math::Vector(17.0f, 0.0f, -42.0f);
pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = Math::Vector(-42.0f, 0.0f, 17.0f);
pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = Math::Vector(-17.0f, 0.0f, 42.0f);
pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = Math::Vector(-42.0f, 0.0f, -17.0f);
pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = Math::Vector(-17.0f, 0.0f, -42.0f);
pos.x += (Math::Rand()-0.5f)*2.0f; pos.z += (Math::Rand()-0.5f)*2.0f;
pos = Transform(*mat, pos);
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 0.5f, 0.0f, 0.0f);
pos = Math::Vector(42.0f, -2.0f, 17.0f);
pos = Transform(*mat, pos);
- m_particule->SetPosition(m_partiChannel[0], pos);
+ m_particle->SetPosition(m_partiChannel[0], pos);
pos = Math::Vector(17.0f, -2.0f, 42.0f);
pos = Transform(*mat, pos);
- m_particule->SetPosition(m_partiChannel[1], pos);
+ m_particle->SetPosition(m_partiChannel[1], pos);
pos = Math::Vector(42.0f, -2.0f, -17.0f);
pos = Transform(*mat, pos);
- m_particule->SetPosition(m_partiChannel[2], pos);
+ m_particle->SetPosition(m_partiChannel[2], pos);
pos = Math::Vector(17.0f, -2.0f, -42.0f);
pos = Transform(*mat, pos);
- m_particule->SetPosition(m_partiChannel[3], pos);
+ m_particle->SetPosition(m_partiChannel[3], pos);
pos = Math::Vector(-42.0f, -2.0f, 17.0f);
pos = Transform(*mat, pos);
- m_particule->SetPosition(m_partiChannel[4], pos);
+ m_particle->SetPosition(m_partiChannel[4], pos);
pos = Math::Vector(-17.0f, -2.0f, 42.0f);
pos = Transform(*mat, pos);
- m_particule->SetPosition(m_partiChannel[5], pos);
+ m_particle->SetPosition(m_partiChannel[5], pos);
pos = Math::Vector(-42.0f, -2.0f, -17.0f);
pos = Transform(*mat, pos);
- m_particule->SetPosition(m_partiChannel[6], pos);
+ m_particle->SetPosition(m_partiChannel[6], pos);
pos = Math::Vector(-17.0f, -2.0f, -42.0f);
pos = Transform(*mat, pos);
- m_particule->SetPosition(m_partiChannel[7], pos);
+ m_particle->SetPosition(m_partiChannel[7], pos);
}
}
}
if ( m_soundChannel != -1 )
{
- pos = m_engine->RetEyePt();
+ pos = m_engine->GetEyePt();
m_sound->Position(m_soundChannel, pos);
}
@@ -1154,17 +1154,17 @@ bool CAutoBase::Abort()
m_main->SetMovieLock(false); // you can play!
- pObj = m_main->RetSelectObject();
+ pObj = m_main->GetSelectObject();
m_main->SelectObject(pObj);
- m_camera->SetObject(pObj);
+ m_camera->SetControllingObject(pObj);
if ( pObj == 0 )
{
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
}
else
{
- m_camera->SetType(pObj->RetCameraType());
- m_camera->SetDist(pObj->RetCameraDist());
+ m_camera->SetType(pObj->GetCameraType());
+ m_camera->SetDist(pObj->GetCameraDist());
}
m_engine->SetFogStart(m_fogStart);
@@ -1175,7 +1175,7 @@ bool CAutoBase::Abort()
m_phase == ABP_TOWAIT ||
m_phase == ABP_TAKEOFF ) // off?
{
- m_event->MakeEvent(newEvent, EVENT_WIN);
+ newEvent.type = EVENT_WIN;
m_event->AddEvent(newEvent);
}
}
@@ -1198,9 +1198,9 @@ bool CAutoBase::Abort()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoBase::RetError()
+Error CAutoBase::GetError()
{
return ERR_OK;
}
@@ -1210,7 +1210,7 @@ Error CAutoBase::RetError()
bool CAutoBase::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
float sleep, delay, magnetic, progress;
@@ -1219,8 +1219,8 @@ bool CAutoBase::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw == 0 ) return false;
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw == nullptr ) return false;
dim.x = 33.0f/640.0f;
dim.y = 33.0f/480.0f;
@@ -1240,7 +1240,7 @@ bool CAutoBase::CreateInterface(bool bSelect)
pos.y = oy+sy*0.25f;
pw->CreateButton(pos, ddim, 28, EVENT_OBJECT_BTAKEOFF);
- if ( m_blitz->GetStatus(sleep, delay, magnetic, progress) )
+ if ( m_lightning->GetStatus(sleep, delay, magnetic, progress) )
{
pos.x = ox+sx*10.2f;
pos.y = oy+sy*0.5f;
@@ -1264,13 +1264,13 @@ bool CAutoBase::CreateInterface(bool bSelect)
void CAutoBase::UpdateInterface()
{
- CWindow* pw;
+// Ui::CWindow* pw;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
CAuto::UpdateInterface();
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+// pw = static_cast< Ui::CWindow* >( m_interface->SearchControl(EVENT_WINDOW0));
}
@@ -1286,15 +1286,15 @@ void CAutoBase::FreezeCargo(bool bFreeze)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
pObj->SetCargo(false);
if ( pObj == m_object ) continue; // yourself?
- if ( pObj->RetTruck() != 0 ) continue; // transport object?
+ if ( pObj->GetTruck() != 0 ) continue; // transport object?
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(m_pos, oPos);
if ( dist < 32.0f )
{
@@ -1303,7 +1303,7 @@ void CAutoBase::FreezeCargo(bool bFreeze)
pObj->SetCargo(true);
}
- physics = pObj->RetPhysics();
+ physics = pObj->GetPhysics();
if ( physics != 0 )
{
physics->SetFreeze(bFreeze);
@@ -1320,18 +1320,18 @@ void CAutoBase::MoveCargo()
Math::Vector oPos, sPos;
int i;
- sPos = m_object->RetPosition(0);
+ sPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast < CObject* > (m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetCargo() ) continue;
+ if ( !pObj->GetCargo() ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
oPos.y = sPos.y+30.0f;
- oPos.y += pObj->RetCharacter()->height;
+ oPos.y += pObj->GetCharacter()->height;
oPos.x += sPos.x-m_lastPos.x;
oPos.z += sPos.z-m_lastPos.z;
pObj->SetPosition(0, oPos);
@@ -1353,13 +1353,13 @@ Error CAutoBase::CheckCloseDoor()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* > (m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
- if ( !pObj->RetActif() ) continue; // inactive?
+ if ( !pObj->GetActif() ) continue; // inactive?
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_PORTICO ) continue;
j = 0;
@@ -1387,22 +1387,20 @@ Error CAutoBase::CheckCloseDoor()
void CAutoBase::BeginTransit()
{
- bool bFull, bQuarter;
-
if ( m_param == PARAM_TRANSIT2 )
{
- strcpy(m_bgBack, "back01.tga"); // clouds orange / blue
+ m_bgBack = "back01.png"; // clouds orange / blue
}
else if ( m_param == PARAM_TRANSIT3 )
{
- strcpy(m_bgBack, "back22.tga"); // blueberries clouds
+ m_bgBack = "back22.png"; // blueberries clouds
}
else
{
#if _DEMO
- strcpy(m_bgBack, "back46b.tga"); // paintings
+ m_bgBack = "back46b.png"; // paintings
#else
- strcpy(m_bgBack, "back46.tga"); // paintings
+ m_bgBack = "back46.png"; // paintings
#endif
}
@@ -1410,13 +1408,18 @@ void CAutoBase::BeginTransit()
m_engine->SetDeepView(2000.0f); // we see very far
m_engine->ApplyChange();
- m_engine->RetBackground(m_bgName, m_bgUp, m_bgDown, m_bgCloudUp, m_bgCloudDown, bFull, bQuarter);
- m_engine->FreeTexture(m_bgName);
+ Math::Point scale;
+ bool full;
+ m_engine->GetBackground(m_bgName, m_bgUp, m_bgDown, m_bgCloudUp, m_bgCloudDown, full, scale);
+ m_engine->DeleteTexture(m_bgName);
- m_engine->SetBackground(m_bgBack, 0x00000000, 0x00000000, 0x00000000, 0x00000000);
+ m_engine->SetBackground(m_bgBack, Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
m_engine->LoadTexture(m_bgBack);
- m_cloud->SetEnable(false); // cache clouds
+ m_cloud->SetEnabled(false); // cache clouds
m_planet->SetMode(1);
}
@@ -1428,12 +1431,12 @@ void CAutoBase::EndTransit()
m_engine->SetDeepView(m_deepView); // gives initial depth
m_engine->ApplyChange();
- m_engine->FreeTexture(m_bgBack);
+ m_engine->DeleteTexture(m_bgBack);
m_engine->SetBackground(m_bgName, m_bgUp, m_bgDown, m_bgCloudUp, m_bgCloudDown);
m_engine->LoadTexture(m_bgName);
- m_cloud->SetEnable(true); // gives the clouds
+ m_cloud->SetEnabled(true); // gives the clouds
m_planet->SetMode(0);
m_main->StartMusic();
diff --git a/src/object/auto/autobase.h b/src/object/auto/autobase.h
index eb47a93..439d414 100644
--- a/src/object/auto/autobase.h
+++ b/src/object/auto/autobase.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -73,7 +74,7 @@ public:
void Start(int param);
bool EventProcess(const Event &event);
bool Abort();
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -90,23 +91,23 @@ protected:
bool m_bOpen;
float m_progress;
float m_speed;
- float m_lastParticule;
- float m_lastMotorParticule;
+ float m_lastParticle;
+ float m_lastMotorParticle;
float m_fogStart;
float m_deepView;
- Math::Vector m_pos;
- Math::Vector m_posSound;
- Math::Vector m_finalPos;
- Math::Vector m_lastPos;
+ Math::Vector m_pos;
+ Math::Vector m_posSound;
+ Math::Vector m_finalPos;
+ Math::Vector m_lastPos;
int m_param;
int m_soundChannel;
int m_partiChannel[8];
- char m_bgBack[100];
- char m_bgName[100];
- D3DCOLOR m_bgUp;
- D3DCOLOR m_bgDown;
- D3DCOLOR m_bgCloudUp;
- D3DCOLOR m_bgCloudDown;
+ std::string m_bgBack;
+ std::string m_bgName;
+ Gfx::Color m_bgUp;
+ Gfx::Color m_bgDown;
+ Gfx::Color m_bgCloudUp;
+ Gfx::Color m_bgCloudDown;
};
diff --git a/src/object/auto/autoconvert.cpp b/src/object/auto/autoconvert.cpp
index b5ad43a..ec4392b 100644
--- a/src/object/auto/autoconvert.cpp
+++ b/src/object/auto/autoconvert.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoconvert.h"
#include "common/iman.h"
@@ -26,7 +25,8 @@
#include "ui/window.h"
#include "ui/displaytext.h"
-
+#include <stdio.h>
+#include <string.h>
// Object's constructor.
@@ -83,7 +83,7 @@ void CAutoConvert::Init()
m_speed = 1.0f/2.0f;
m_time = 0.0f;
m_timeVirus = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
CAuto::Init();
}
@@ -100,13 +100,13 @@ bool CAutoConvert::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
@@ -146,7 +146,7 @@ bool CAutoConvert::EventProcess(const Event &event)
InitProgressTotal(3.0f+10.0f+1.5f);
UpdateInterface();
- m_sound->Play(SOUND_OPEN, m_object->RetPosition(0), 1.0f, 1.0f);
+ m_sound->Play(SOUND_OPEN, m_object->GetPosition(0), 1.0f, 1.0f);
m_bSoundClose = false;
m_phase = ACP_CLOSE;
@@ -163,7 +163,7 @@ bool CAutoConvert::EventProcess(const Event &event)
if ( m_progress >= 0.8f && !m_bSoundClose )
{
m_bSoundClose = true;
- m_sound->Play(SOUND_CLOSE, m_object->RetPosition(0), 1.0f, 0.8f);
+ m_sound->Play(SOUND_CLOSE, m_object->GetPosition(0), 1.0f, 0.8f);
}
angle = -Math::PI*0.35f*(1.0f-Math::Bounce(m_progress, 0.85f, 0.05f));
m_object->SetAngleX(2, angle);
@@ -174,7 +174,7 @@ bool CAutoConvert::EventProcess(const Event &event)
m_object->SetAngleX(2, 0.0f);
m_object->SetAngleX(3, 0.0f);
- m_soundChannel = m_sound->Play(SOUND_CONVERT, m_object->RetPosition(0), 0.0f, 0.25f, true);
+ m_soundChannel = m_sound->Play(SOUND_CONVERT, m_object->GetPosition(0), 0.0f, 0.25f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.25f, 0.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.00f, 4.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.25f, 4.5f, SOPER_CONTINUE);
@@ -202,11 +202,11 @@ bool CAutoConvert::EventProcess(const Event &event)
m_object->SetAngleY(2, angle);
m_object->SetAngleY(3, angle+Math::PI);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
c.x = pos.x;
c.y = pos.z;
p.x = c.x;
@@ -218,7 +218,7 @@ bool CAutoConvert::EventProcess(const Event &event)
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = Math::Rand()*2.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS, 1.0f, 0.0f, 0.0f);
}
}
else
@@ -230,13 +230,13 @@ bool CAutoConvert::EventProcess(const Event &event)
fret = SearchStone(OBJECT_STONE);
if ( fret != 0 )
{
- m_bResetDelete = ( fret->RetResetCap() != RESET_NONE );
+ m_bResetDelete = ( fret->GetResetCap() != RESET_NONE );
fret->DeleteObject(); // destroy the stone
delete fret;
}
CreateMetal(); // Create the metal
- m_sound->Play(SOUND_OPEN, m_object->RetPosition(0), 1.0f, 1.5f);
+ m_sound->Play(SOUND_OPEN, m_object->GetPosition(0), 1.0f, 1.5f);
m_phase = ACP_OPEN;
m_progress = 0.0f;
@@ -253,18 +253,18 @@ bool CAutoConvert::EventProcess(const Event &event)
m_object->SetAngleX(3, angle);
if ( m_progress < 0.9f &&
- m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*6.0f;
pos.z += (Math::Rand()-0.5f)*6.0f;
pos.y += Math::Rand()*4.0f;
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = Math::Rand()*4.0f+3.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLUE, 1.0f, 0.0f, 0.0f);
}
}
else
@@ -285,11 +285,11 @@ bool CAutoConvert::EventProcess(const Event &event)
return true;
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoConvert::RetError()
+Error CAutoConvert::GetError()
{
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
@@ -330,7 +330,7 @@ bool CAutoConvert::Abort()
bool CAutoConvert::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -338,8 +338,8 @@ bool CAutoConvert::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw == 0 ) return false;
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw == nullptr ) return false;
ox = 3.0f/640.0f;
oy = 3.0f/480.0f;
@@ -390,11 +390,11 @@ bool CAutoConvert::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoConvertPhase)OpInt(line, "aPhase", ACP_WAIT);
+ m_phase = static_cast< AutoConvertPhase >(OpInt(line, "aPhase", ACP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
@@ -410,18 +410,18 @@ CObject* CAutoConvert::SearchStone(ObjectType type)
float dist;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType != type ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, cPos);
if ( dist <= 5.0f ) return pObj;
@@ -440,14 +440,14 @@ bool CAutoConvert::SearchVehicle()
float oRadius, dist;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_HUMAN &&
type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
@@ -506,8 +506,8 @@ void CAutoConvert::CreateMetal()
float angle;
CObject* fret;
- pos = m_object->RetPosition(0);
- angle = m_object->RetAngleY(0);
+ pos = m_object->GetPosition(0);
+ angle = m_object->GetAngleY(0);
fret = new CObject(m_iMan);
if ( !fret->CreateResource(pos, angle, OBJECT_METAL) )
diff --git a/src/object/auto/autoconvert.h b/src/object/auto/autoconvert.h
index c2042cf..b21690f 100644
--- a/src/object/auto/autoconvert.h
+++ b/src/object/auto/autoconvert.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -44,7 +45,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool Abort();
bool CreateInterface(bool bSelect);
@@ -62,7 +63,7 @@ protected:
float m_progress;
float m_speed;
float m_timeVirus;
- float m_lastParticule;
+ float m_lastParticle;
bool m_bResetDelete;
bool m_bSoundClose;
int m_soundChannel;
diff --git a/src/object/auto/autoderrick.cpp b/src/object/auto/autoderrick.cpp
index 3f1cda5..3578c0d 100644
--- a/src/object/auto/autoderrick.cpp
+++ b/src/object/auto/autoderrick.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,19 +16,18 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoderrick.h"
#include "common/iman.h"
-#include "old/terrain.h"
+#include "graphics/engine/terrain.h"
#include "math/geometry.h"
#include "script/cmdtoken.h"
#include "ui/interface.h"
#include "ui/window.h"
#include "ui/displaytext.h"
-
+#include <stdio.h>
+#include <string.h>
const float DERRICK_DELAY = 10.0f; // duration of the extraction
@@ -62,7 +62,7 @@ void CAutoDerrick::DeleteObject(bool bAll)
if ( !bAll )
{
fret = SearchFret();
- if ( fret != 0 && fret->RetLock() )
+ if ( fret != 0 && fret->GetLock() )
{
fret->DeleteObject();
delete fret;
@@ -86,25 +86,25 @@ void CAutoDerrick::Init()
{
Math::Matrix* mat;
Math::Vector pos;
- TerrainRes res;
+ Gfx::TerrainRes res;
- pos = m_object->RetPosition(0);
- res = m_terrain->RetResource(pos);
+ pos = m_object->GetPosition(0);
+ res = m_terrain->GetResource(pos);
- if ( res == TR_STONE ||
- res == TR_URANIUM ||
- res == TR_KEYa ||
- res == TR_KEYb ||
- res == TR_KEYc ||
- res == TR_KEYd )
+ if ( res == Gfx::TR_STONE ||
+ res == Gfx::TR_URANIUM ||
+ res == Gfx::TR_KEY_A ||
+ res == Gfx::TR_KEY_B ||
+ res == Gfx::TR_KEY_C ||
+ res == Gfx::TR_KEY_D )
{
m_type = OBJECT_FRET;
- if ( res == TR_STONE ) m_type = OBJECT_STONE;
- if ( res == TR_URANIUM ) m_type = OBJECT_URANIUM;
- if ( res == TR_KEYa ) m_type = OBJECT_KEYa;
- if ( res == TR_KEYb ) m_type = OBJECT_KEYb;
- if ( res == TR_KEYc ) m_type = OBJECT_KEYc;
- if ( res == TR_KEYd ) m_type = OBJECT_KEYd;
+ if ( res == Gfx::TR_STONE ) m_type = OBJECT_STONE;
+ if ( res == Gfx::TR_URANIUM ) m_type = OBJECT_URANIUM;
+ if ( res == Gfx::TR_KEY_A ) m_type = OBJECT_KEYa;
+ if ( res == Gfx::TR_KEY_B ) m_type = OBJECT_KEYb;
+ if ( res == Gfx::TR_KEY_C ) m_type = OBJECT_KEYc;
+ if ( res == Gfx::TR_KEY_D ) m_type = OBJECT_KEYd;
m_phase = ADP_EXCAVATE;
m_progress = 0.0f;
@@ -119,13 +119,13 @@ void CAutoDerrick::Init()
m_time = 0.0f;
m_timeVirus = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_lastTrack = 0.0f;
pos = Math::Vector(7.0f, 0.0f, 0.0f);
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Transform(*mat, pos);
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
m_fretPos = pos;
}
@@ -141,14 +141,14 @@ bool CAutoDerrick::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_phase == ADP_WAIT ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
@@ -176,7 +176,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
{
factor = 1.0f;
}
- m_soundChannel = m_sound->Play(SOUND_DERRICK, m_object->RetPosition(0), 1.0f, 0.5f, true);
+ m_soundChannel = m_sound->Play(SOUND_DERRICK, m_object->GetPosition(0), 1.0f, 0.5f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.5f, 4.0f*factor, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.3f, 6.0f*factor, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.5f, 1.0f, SOPER_CONTINUE);
@@ -184,25 +184,25 @@ bool CAutoDerrick::EventProcess(const Event &event)
}
if ( m_progress >= 6.0f/16.0f && // penetrates into the ground?
- m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*10.0f;
speed.z = (Math::Rand()-0.5f)*10.0f;
speed.y = Math::Rand()*5.0f;
dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
if ( m_progress >= 6.0f/16.0f && // penetrates into the ground?
- m_lastTrack+m_engine->ParticuleAdapt(0.5f) <= m_time )
+ m_lastTrack+m_engine->ParticleAdapt(0.5f) <= m_time )
{
m_lastTrack = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*12.0f;
speed.z = (Math::Rand()-0.5f)*12.0f;
speed.y = Math::Rand()*10.0f+10.0f;
@@ -210,7 +210,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
dim.y = dim.x;
pos.y += dim.y;
duration = Math::Rand()*2.0f+2.0f;
- m_particule->CreateTrack(pos, speed, dim, PARTITRACK5,
+ m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK5,
duration, Math::Rand()*10.0f+15.0f,
duration*0.2f, 1.0f);
}
@@ -222,7 +222,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
pos.y = -m_progress*16.0f;
m_object->SetPosition(1, pos); // down the drill
- angle = m_object->RetAngleY(1);
+ angle = m_object->GetAngleY(1);
angle += event.rTime*8.0f;
m_object->SetAngleY(1, angle); // rotates the drill
}
@@ -237,25 +237,25 @@ bool CAutoDerrick::EventProcess(const Event &event)
if ( m_phase == ADP_ASCEND )
{
if ( m_progress <= 7.0f/16.0f &&
- m_lastParticule+m_engine->ParticuleAdapt(0.1f) <= m_time )
+ m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*10.0f;
speed.z = (Math::Rand()-0.5f)*10.0f;
speed.y = Math::Rand()*5.0f;
dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
if ( m_progress <= 4.0f/16.0f &&
- m_lastTrack+m_engine->ParticuleAdapt(1.0f) <= m_time )
+ m_lastTrack+m_engine->ParticleAdapt(1.0f) <= m_time )
{
m_lastTrack = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*12.0f;
speed.z = (Math::Rand()-0.5f)*12.0f;
speed.y = Math::Rand()*10.0f+10.0f;
@@ -263,7 +263,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
dim.y = dim.x;
pos.y += dim.y;
duration = Math::Rand()*2.0f+2.0f;
- m_particule->CreateTrack(pos, speed, dim, PARTITRACK5,
+ m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK5,
duration, Math::Rand()*10.0f+15.0f,
duration*0.2f, 1.0f);
}
@@ -275,7 +275,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
pos.y = -(1.0f-m_progress)*16.0f;
m_object->SetPosition(1, pos); // back the drill
- angle = m_object->RetAngleY(1);
+ angle = m_object->GetAngleY(1);
angle -= event.rTime*2.0f;
m_object->SetAngleY(1, angle); // rotates the drill
}
@@ -308,7 +308,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
{
if ( SearchFree(m_fretPos) )
{
- angle = m_object->RetAngleY(0);
+ angle = m_object->GetAngleY(0);
CreateFret(m_fretPos, angle, m_type, 16.0f);
}
else
@@ -324,31 +324,31 @@ bool CAutoDerrick::EventProcess(const Event &event)
if ( fret != 0 &&
m_progress <= 0.5f &&
- m_lastParticule+m_engine->ParticuleAdapt(0.1f) <= m_time )
+ m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
if ( m_progress < 0.3f )
{
- pos = fret->RetPosition(0);
+ pos = fret->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*5.0f;
pos.z += (Math::Rand()-0.5f)*5.0f;
pos.y += (Math::Rand()-0.5f)*5.0f;
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 3.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFIRE, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIRE, 1.0f, 0.0f, 0.0f);
}
else
{
- pos = fret->RetPosition(0);
+ pos = fret->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*5.0f;
pos.z += (Math::Rand()-0.5f)*5.0f;
pos.y += Math::Rand()*2.5f;
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 2.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 2.0f, 0.0f, 0.0f);
}
}
@@ -356,7 +356,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
{
if ( fret != 0 )
{
- pos = fret->RetPosition(0);
+ pos = fret->GetPosition(0);
pos.y -= event.rTime*20.0f; // grave
if ( !m_bSoundFall && pos.y < m_fretPos.y )
{
@@ -396,7 +396,7 @@ bool CAutoDerrick::EventProcess(const Event &event)
bool CAutoDerrick::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -404,7 +404,7 @@ bool CAutoDerrick::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -455,11 +455,11 @@ bool CAutoDerrick::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoDerrickPhase)OpInt(line, "aPhase", ADP_WAIT);
+ m_phase = static_cast< AutoDerrickPhase >(OpInt(line, "aPhase", ADP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
@@ -476,13 +476,13 @@ CObject* CAutoDerrick::SearchFret()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_DERRICK ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
if ( oPos.x == m_fretPos.x &&
oPos.z == m_fretPos.z ) return pObj;
@@ -503,10 +503,10 @@ bool CAutoDerrick::SearchFree(Math::Vector pos)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_DERRICK ) continue;
j = 0;
@@ -537,12 +537,12 @@ void CAutoDerrick::CreateFret(Math::Vector pos, float angle, ObjectType type,
}
fret->SetLock(true); // object not yet usable
- if ( m_object->RetResetCap() == RESET_MOVE )
+ if ( m_object->GetResetCap() == RESET_MOVE )
{
fret->SetResetCap(RESET_DELETE);
}
- pos = fret->RetPosition(0);
+ pos = fret->GetPosition(0);
pos.y += height;
fret->SetPosition(0, pos);
}
@@ -562,10 +562,10 @@ bool CAutoDerrick::ExistKey()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == m_type ) return true;
}
@@ -573,11 +573,11 @@ bool CAutoDerrick::ExistKey()
}
-// Returns an error due the state of the automaton.
+// returns an error due the state of the automaton.
-Error CAutoDerrick::RetError()
+Error CAutoDerrick::GetError()
{
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
diff --git a/src/object/auto/autoderrick.h b/src/object/auto/autoderrick.h
index 61a1ff1..b52f93b 100644
--- a/src/object/auto/autoderrick.h
+++ b/src/object/auto/autoderrick.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -44,7 +45,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -62,7 +63,7 @@ protected:
float m_progress;
float m_speed;
float m_timeVirus;
- float m_lastParticule;
+ float m_lastParticle;
float m_lastTrack;
Math::Vector m_fretPos;
int m_soundChannel;
diff --git a/src/object/auto/autodestroyer.cpp b/src/object/auto/autodestroyer.cpp
index b40c374..740f600 100644
--- a/src/object/auto/autodestroyer.cpp
+++ b/src/object/auto/autodestroyer.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autodestroyer.h"
#include "common/iman.h"
@@ -24,7 +23,8 @@
#include "ui/interface.h"
#include "ui/window.h"
-
+#include <stdio.h>
+#include <string.h>
// Object's constructor.
@@ -61,7 +61,7 @@ void CAutoDestroyer::Init()
m_time = 0.0f;
m_timeVirus = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
CAuto::Init();
}
@@ -72,19 +72,19 @@ void CAutoDestroyer::Init()
bool CAutoDestroyer::EventProcess(const Event &event)
{
CObject* scrap;
- CPyro* pyro;
+ Gfx::CPyro* pyro;
Math::Vector pos, speed;
Math::Point dim;
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
@@ -117,7 +117,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
}
else
{
- m_sound->Play(SOUND_PSHHH2, m_object->RetPosition(0), 1.0f, 1.0f);
+ m_sound->Play(SOUND_PSHHH2, m_object->GetPosition(0), 1.0f, 1.0f);
m_phase = ADEP_DOWN;
m_progress = 0.0f;
@@ -133,10 +133,10 @@ bool CAutoDestroyer::EventProcess(const Event &event)
if ( m_progress >= 0.3f-0.05f && !m_bExplo )
{
scrap = SearchPlastic();
- if ( scrap != 0 )
+ if ( scrap != nullptr )
{
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FRAGT, scrap);
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FRAGT, scrap);
}
m_bExplo = true;
}
@@ -150,7 +150,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
else
{
m_object->SetPosition(1, Math::Vector(0.0f, -10.0f, 0.0f));
- m_sound->Play(SOUND_REPAIR, m_object->RetPosition(0));
+ m_sound->Play(SOUND_REPAIR, m_object->GetPosition(0));
m_phase = ADEP_REPAIR;
m_progress = 0.0f;
@@ -165,7 +165,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
}
else
{
- m_sound->Play(SOUND_OPEN, m_object->RetPosition(0), 1.0f, 0.8f);
+ m_sound->Play(SOUND_OPEN, m_object->GetPosition(0), 1.0f, 0.8f);
m_phase = ADEP_UP;
m_progress = 0.0f;
@@ -199,7 +199,7 @@ bool CAutoDestroyer::EventProcess(const Event &event)
bool CAutoDestroyer::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -207,8 +207,8 @@ bool CAutoDestroyer::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw == 0 ) return false;
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw == nullptr ) return false;
ox = 3.0f/640.0f;
oy = 3.0f/480.0f;
@@ -235,23 +235,23 @@ CObject* CAutoDestroyer::SearchPlastic()
float dist;
int i;
- sPos = m_object->RetPosition(0);
+ sPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if ( pObj == nullptr ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_SCRAP4 &&
type != OBJECT_SCRAP5 ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, sPos);
if ( dist <= 5.0f ) return pObj;
}
- return 0;
+ return nullptr;
}
// Seeks if one vehicle is too close.
@@ -264,14 +264,14 @@ bool CAutoDestroyer::SearchVehicle()
float oRadius, dist;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if ( pObj == nullptr ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_HUMAN &&
type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
@@ -316,11 +316,11 @@ bool CAutoDestroyer::SearchVehicle()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoDestroyer::RetError()
+Error CAutoDestroyer::GetError()
{
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
@@ -362,11 +362,11 @@ bool CAutoDestroyer::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoDestroyerPhase)OpInt(line, "aPhase", ADEP_WAIT);
+ m_phase = static_cast< AutoDestroyerPhase >(OpInt(line, "aPhase", ADEP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/autodestroyer.h b/src/object/auto/autodestroyer.h
index 88c93ea..50858d3 100644
--- a/src/object/auto/autodestroyer.h
+++ b/src/object/auto/autodestroyer.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -43,7 +44,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -59,7 +60,7 @@ protected:
float m_progress;
float m_speed;
float m_timeVirus;
- float m_lastParticule;
+ float m_lastParticle;
bool m_bExplo;
};
diff --git a/src/object/auto/autoegg.cpp b/src/object/auto/autoegg.cpp
index 4b999a9..35a6add 100644
--- a/src/object/auto/autoegg.cpp
+++ b/src/object/auto/autoegg.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,15 +16,14 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoegg.h"
#include "math/geometry.h"
#include "common/iman.h"
#include "script/cmdtoken.h"
-
+#include <stdio.h>
+#include <string.h>
// Object's constructor.
@@ -61,8 +61,8 @@ void CAutoEgg::DeleteObject(bool bAll)
if ( alien != 0 )
{
// Probably the intended action
- // Original code: ( alien->RetZoom(0) == 1.0f )
- if ( alien->RetZoomY(0) == 1.0f )
+ // Original code: ( alien->GetZoom(0) == 1.0f )
+ if ( alien->GetZoomY(0) == 1.0f )
{
alien->SetLock(false);
alien->SetActivity(true); // the insect is active
@@ -98,7 +98,7 @@ void CAutoEgg::Init()
m_speed = 1.0f/5.0f;
m_time = 0.0f;
- m_type = alien->RetType();
+ m_type = alien->GetType();
if ( m_type == OBJECT_ANT ||
m_type == OBJECT_SPIDER ||
@@ -164,9 +164,9 @@ bool CAutoEgg::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_phase == AEP_NULL ) return true;
if ( m_phase == AEP_DELAY )
@@ -175,7 +175,7 @@ bool CAutoEgg::EventProcess(const Event &event)
if ( m_progress < 1.0f ) return true;
alien = new CObject(m_iMan);
- if ( !alien->CreateInsect(m_object->RetPosition(0), m_object->RetAngleY(0), m_type) )
+ if ( !alien->CreateInsect(m_object->GetPosition(0), m_object->GetAngleY(0), m_type) )
{
delete alien;
m_phase = AEP_DELAY;
@@ -213,7 +213,7 @@ bool CAutoEgg::EventProcess(const Event &event)
Error CAutoEgg::IsEnded()
{
CObject* alien;
- CPyro* pyro;
+ Gfx::CPyro* pyro;
if ( m_phase == AEP_DELAY )
{
@@ -236,8 +236,8 @@ Error CAutoEgg::IsEnded()
{
if ( m_progress < 1.0f ) return ERR_CONTINUE;
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_EGG, m_object); // exploding egg
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_EGG, m_object); // exploding egg
alien->SetZoom(0, 1.0f); // this is a big boy now
@@ -258,9 +258,9 @@ Error CAutoEgg::IsEnded()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoEgg::RetError()
+Error CAutoEgg::GetError()
{
return ERR_OK;
}
@@ -277,23 +277,23 @@ CObject* CAutoEgg::SearchAlien()
float dist, min;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_ANT &&
type != OBJECT_BEE &&
type != OBJECT_SPIDER &&
type != OBJECT_WORM ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(oPos, cPos);
if ( dist < 8.0f && dist < min )
{
@@ -347,7 +347,7 @@ bool CAutoEgg::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoEggPhase)OpInt(line, "aPhase", AEP_NULL);
+ m_phase = static_cast< AutoEggPhase >(OpInt(line, "aPhase", AEP_NULL));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
m_type = OpTypeObject(line, "aParamType", OBJECT_NULL);
diff --git a/src/object/auto/autoegg.h b/src/object/auto/autoegg.h
index 443dff6..fec07a6 100644
--- a/src/object/auto/autoegg.h
+++ b/src/object/auto/autoegg.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -45,7 +46,7 @@ public:
void Start(int param);
bool EventProcess(const Event &event);
Error IsEnded();
- Error RetError();
+ Error GetError();
bool SetType(ObjectType type);
bool SetValue(int rank, float value);
diff --git a/src/object/auto/autoenergy.cpp b/src/object/auto/autoenergy.cpp
index 409e282..18a21ab 100644
--- a/src/object/auto/autoenergy.cpp
+++ b/src/object/auto/autoenergy.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,12 +16,10 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoenergy.h"
#include "common/iman.h"
-#include "old/terrain.h"
+#include "graphics/engine/terrain.h"
#include "math/geometry.h"
#include "script/cmdtoken.h"
#include "ui/interface.h"
@@ -28,6 +27,8 @@
#include "ui/window.h"
#include "ui/displaytext.h"
+#include <stdio.h>
+#include <string.h>
const float ENERGY_POWER = 0.4f; // Necessary energy for a battery
@@ -60,7 +61,7 @@ void CAutoEnergy::DeleteObject(bool bAll)
if ( m_partiSphere != -1 )
{
- m_particule->DeleteParticule(m_partiSphere);
+ m_particle->DeleteParticle(m_partiSphere);
m_partiSphere = -1;
}
@@ -92,7 +93,7 @@ void CAutoEnergy::Init()
m_time = 0.0f;
m_timeVirus = 0.0f;
m_lastUpdateTime = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_phase = AENP_WAIT; // waiting ...
m_progress = 0.0f;
@@ -109,35 +110,35 @@ bool CAutoEnergy::EventProcess(const Event &event)
CObject* fret;
Math::Vector pos, ppos, speed;
Math::Point dim, c, p;
- TerrainRes res;
+ Gfx::TerrainRes res;
float big;
bool bGO;
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
m_timeVirus = 0.1f+Math::Rand()*0.3f;
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
- pos = m_object->RetPosition(0);
+ m_lastParticle = m_time;
+ pos = m_object->GetPosition(0);
pos.y += 10.0f;
speed.x = (Math::Rand()-0.5f)*10.0f;
speed.z = (Math::Rand()-0.5f)*10.0f;
speed.y = -7.0f;
dim.x = Math::Rand()*0.5f+0.5f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ, 1.0f, 0.0f, 0.0f);
}
}
return true;
@@ -146,10 +147,10 @@ bool CAutoEnergy::EventProcess(const Event &event)
UpdateInterface(event.rTime);
EventProgress(event.rTime);
- big = m_object->RetEnergy();
+ big = m_object->GetEnergy();
- res = m_terrain->RetResource(m_object->RetPosition(0));
- if ( res == TR_POWER )
+ res = m_terrain->GetResource(m_object->GetPosition(0));
+ if ( res == Gfx::TR_POWER )
{
big += event.rTime*0.01f; // recharges the big pile
}
@@ -162,7 +163,7 @@ bool CAutoEnergy::EventProcess(const Event &event)
fret = SearchMetal(); // transform metal?
if ( fret != 0 )
{
- if ( fret->RetType() == OBJECT_METAL )
+ if ( fret->GetType() == OBJECT_METAL )
{
if ( big > ENERGY_POWER ) bGO = true;
}
@@ -174,7 +175,7 @@ bool CAutoEnergy::EventProcess(const Event &event)
if ( bGO )
{
- if ( fret->RetType() == OBJECT_METAL )
+ if ( fret->GetType() == OBJECT_METAL )
{
fret->SetLock(true); // usable metal
CreatePower(); // creates the battery
@@ -184,12 +185,12 @@ bool CAutoEnergy::EventProcess(const Event &event)
InitProgressTotal(ENERGY_DELAY);
CAuto::UpdateInterface();
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 4.0f;
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 3.0f;
dim.y = dim.x;
- m_partiSphere = m_particule->CreateParticule(pos, speed, dim, PARTISPHERE1, ENERGY_DELAY, 0.0f, 0.0f);
+ m_partiSphere = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISPHERE1, ENERGY_DELAY, 0.0f, 0.0f);
m_phase = AENP_CREATE;
m_progress = 0.0f;
@@ -217,17 +218,17 @@ bool CAutoEnergy::EventProcess(const Event &event)
{
if ( m_progress < 1.0f && big > 0.01f )
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
- pos = m_object->RetPosition(0);
+ m_lastParticle = m_time;
+ pos = m_object->GetPosition(0);
pos.y += 10.0f;
speed.x = (Math::Rand()-0.5f)*1.0f;
speed.z = (Math::Rand()-0.5f)*1.0f;
speed.y = -7.0f;
dim.x = Math::Rand()*0.5f+0.5f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ, 1.0f, 0.0f, 0.0f);
}
}
else
@@ -245,7 +246,7 @@ bool CAutoEnergy::EventProcess(const Event &event)
fret = SearchMetal();
if ( fret != 0 )
{
- if ( fret->RetType() == OBJECT_METAL )
+ if ( fret->GetType() == OBJECT_METAL )
{
big -= event.rTime/ENERGY_DELAY*ENERGY_POWER;
}
@@ -262,11 +263,11 @@ bool CAutoEnergy::EventProcess(const Event &event)
fret->SetZoom(0, m_progress);
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.10f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.10f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
c.x = pos.x;
c.y = pos.z;
p.x = c.x;
@@ -278,27 +279,27 @@ bool CAutoEnergy::EventProcess(const Event &event)
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = Math::Rand()*2.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 1.0f, 0.0f, 0.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 3.0f;
speed.x = (Math::Rand()-0.5f)*30.0f;
speed.z = (Math::Rand()-0.5f)*30.0f;
speed.y = Math::Rand()*20.0f+10.0f;
dim.x = Math::Rand()*0.4f+0.4f;
dim.y = dim.x;
- m_particule->CreateTrack(pos, speed, dim, PARTITRACK2, 2.0f, 50.0f, 1.2f, 1.2f);
+ m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK2, 2.0f, 50.0f, 1.2f, 1.2f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 10.0f;
speed.x = (Math::Rand()-0.5f)*1.5f;
speed.z = (Math::Rand()-0.5f)*1.5f;
speed.y = -6.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ, 1.0f, 0.0f, 0.0f);
- m_sound->Play(SOUND_ENERGY, m_object->RetPosition(0),
+ m_sound->Play(SOUND_ENERGY, m_object->GetPosition(0),
1.0f, 1.0f+Math::Rand()*1.5f);
}
}
@@ -337,11 +338,11 @@ bool CAutoEnergy::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 17.0f;
pos.x += (Math::Rand()-0.5f)*3.0f;
pos.z += (Math::Rand()-0.5f)*3.0f;
@@ -350,7 +351,7 @@ bool CAutoEnergy::EventProcess(const Event &event)
speed.y = 6.0f+Math::Rand()*6.0f;
dim.x = Math::Rand()*1.5f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f);
}
}
else
@@ -376,10 +377,10 @@ CObject* CAutoEnergy::SearchMetal()
CObject* pObj;
ObjectType type;
- pObj = m_object->RetPower();
+ pObj = m_object->GetPower();
if ( pObj == 0 ) return 0;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_METAL ||
type == OBJECT_SCRAP1 ||
type == OBJECT_SCRAP2 ||
@@ -398,14 +399,14 @@ bool CAutoEnergy::SearchVehicle()
float oRadius, dist;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_HUMAN &&
type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
@@ -457,8 +458,8 @@ void CAutoEnergy::CreatePower()
Math::Vector pos;
float angle;
- pos = m_object->RetPosition(0);
- angle = m_object->RetAngleY(0);
+ pos = m_object->GetPosition(0);
+ angle = m_object->GetAngleY(0);
power = new CObject(m_iMan);
if ( !power->CreateResource(pos, angle, OBJECT_POWER) )
@@ -469,7 +470,7 @@ void CAutoEnergy::CreatePower()
}
power->SetLock(true); // battery not yet usable
- pos = power->RetPosition(0);
+ pos = power->GetPosition(0);
pos.y += 3.0f;
power->SetPosition(0, pos);
}
@@ -483,19 +484,19 @@ CObject* CAutoEnergy::SearchPower()
ObjectType type;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetLock() ) continue;
+ if ( !pObj->GetLock() ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_POWER ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
if ( oPos.x == cPos.x &&
oPos.z == cPos.z )
{
@@ -507,15 +508,15 @@ CObject* CAutoEnergy::SearchPower()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoEnergy::RetError()
+Error CAutoEnergy::GetError()
{
CObject* pObj;
ObjectType type;
- TerrainRes res;
+ Gfx::TerrainRes res;
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
@@ -523,14 +524,14 @@ Error CAutoEnergy::RetError()
if ( m_phase != AENP_WAIT &&
m_phase != AENP_BLITZ ) return ERR_OK;
- res = m_terrain->RetResource(m_object->RetPosition(0));
- if ( res != TR_POWER ) return ERR_ENERGY_NULL;
+ res = m_terrain->GetResource(m_object->GetPosition(0));
+ if ( res != Gfx::TR_POWER ) return ERR_ENERGY_NULL;
- if ( m_object->RetEnergy() < ENERGY_POWER ) return ERR_ENERGY_LOW;
+ if ( m_object->GetEnergy() < ENERGY_POWER ) return ERR_ENERGY_LOW;
- pObj = m_object->RetPower();
+ pObj = m_object->GetPower();
if ( pObj == 0 ) return ERR_ENERGY_EMPTY;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_POWER ) return ERR_OK;
if ( type != OBJECT_METAL &&
type != OBJECT_SCRAP1 &&
@@ -545,7 +546,7 @@ Error CAutoEnergy::RetError()
bool CAutoEnergy::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -553,7 +554,7 @@ bool CAutoEnergy::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -581,23 +582,23 @@ bool CAutoEnergy::CreateInterface(bool bSelect)
void CAutoEnergy::UpdateInterface(float rTime)
{
- CWindow* pw;
- CGauge* pg;
+ Ui::CWindow* pw;
+ Ui::CGauge* pg;
CAuto::UpdateInterface(rTime);
if ( m_time < m_lastUpdateTime+0.1f ) return;
m_lastUpdateTime = m_time;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GENERGY);
+ pg = static_cast< Ui::CGauge* >(pw->SearchControl(EVENT_OBJECT_GENERGY));
if ( pg != 0 )
{
- pg->SetLevel(m_object->RetEnergy());
+ pg->SetLevel(m_object->GetEnergy());
}
}
@@ -636,12 +637,12 @@ bool CAutoEnergy::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoEnergyPhase)OpInt(line, "aPhase", AENP_WAIT);
+ m_phase = static_cast< AutoEnergyPhase >(OpInt(line, "aPhase", AENP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
m_lastUpdateTime = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/autoenergy.h b/src/object/auto/autoenergy.h
index 727f2c3..53d47b6 100644
--- a/src/object/auto/autoenergy.h
+++ b/src/object/auto/autoenergy.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -44,7 +45,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -65,7 +66,7 @@ protected:
float m_speed;
float m_timeVirus;
float m_lastUpdateTime;
- float m_lastParticule;
+ float m_lastParticle;
int m_partiSphere;
};
diff --git a/src/object/auto/autofactory.cpp b/src/object/auto/autofactory.cpp
index f02195c..0789443 100644
--- a/src/object/auto/autofactory.cpp
+++ b/src/object/auto/autofactory.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autofactory.h"
#include "common/global.h"
@@ -29,7 +28,8 @@
#include "ui/window.h"
#include "ui/displaytext.h"
-
+#include <stdio.h>
+#include <string.h>
@@ -95,9 +95,9 @@ void CAutoFactory::Init()
m_speed = 1.0f/2.0f;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
- m_fretPos = m_object->RetPosition(0);
+ m_fretPos = m_object->GetPosition(0);
CAuto::Init();
}
@@ -119,37 +119,37 @@ bool CAutoFactory::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
- if ( m_object->RetSelect() ) // factory selected?
+ if ( m_object->GetSelect() ) // factory selected?
{
- if ( event.event == EVENT_UPDINTERFACE )
+ if ( event.type == EVENT_UPDINTERFACE )
{
CreateInterface(true);
}
type = OBJECT_NULL;
- if ( event.event == EVENT_OBJECT_FACTORYwa ) type = OBJECT_MOBILEwa;
- if ( event.event == EVENT_OBJECT_FACTORYta ) type = OBJECT_MOBILEta;
- if ( event.event == EVENT_OBJECT_FACTORYfa ) type = OBJECT_MOBILEfa;
- if ( event.event == EVENT_OBJECT_FACTORYia ) type = OBJECT_MOBILEia;
- if ( event.event == EVENT_OBJECT_FACTORYws ) type = OBJECT_MOBILEws;
- if ( event.event == EVENT_OBJECT_FACTORYts ) type = OBJECT_MOBILEts;
- if ( event.event == EVENT_OBJECT_FACTORYfs ) type = OBJECT_MOBILEfs;
- if ( event.event == EVENT_OBJECT_FACTORYis ) type = OBJECT_MOBILEis;
- if ( event.event == EVENT_OBJECT_FACTORYwc ) type = OBJECT_MOBILEwc;
- if ( event.event == EVENT_OBJECT_FACTORYtc ) type = OBJECT_MOBILEtc;
- if ( event.event == EVENT_OBJECT_FACTORYfc ) type = OBJECT_MOBILEfc;
- if ( event.event == EVENT_OBJECT_FACTORYic ) type = OBJECT_MOBILEic;
- if ( event.event == EVENT_OBJECT_FACTORYwi ) type = OBJECT_MOBILEwi;
- if ( event.event == EVENT_OBJECT_FACTORYti ) type = OBJECT_MOBILEti;
- if ( event.event == EVENT_OBJECT_FACTORYfi ) type = OBJECT_MOBILEfi;
- if ( event.event == EVENT_OBJECT_FACTORYii ) type = OBJECT_MOBILEii;
- if ( event.event == EVENT_OBJECT_FACTORYrt ) type = OBJECT_MOBILErt;
- if ( event.event == EVENT_OBJECT_FACTORYrc ) type = OBJECT_MOBILErc;
- if ( event.event == EVENT_OBJECT_FACTORYrr ) type = OBJECT_MOBILErr;
- if ( event.event == EVENT_OBJECT_FACTORYrs ) type = OBJECT_MOBILErs;
- if ( event.event == EVENT_OBJECT_FACTORYsa ) type = OBJECT_MOBILEsa;
+ if ( event.type == EVENT_OBJECT_FACTORYwa ) type = OBJECT_MOBILEwa;
+ if ( event.type == EVENT_OBJECT_FACTORYta ) type = OBJECT_MOBILEta;
+ if ( event.type == EVENT_OBJECT_FACTORYfa ) type = OBJECT_MOBILEfa;
+ if ( event.type == EVENT_OBJECT_FACTORYia ) type = OBJECT_MOBILEia;
+ if ( event.type == EVENT_OBJECT_FACTORYws ) type = OBJECT_MOBILEws;
+ if ( event.type == EVENT_OBJECT_FACTORYts ) type = OBJECT_MOBILEts;
+ if ( event.type == EVENT_OBJECT_FACTORYfs ) type = OBJECT_MOBILEfs;
+ if ( event.type == EVENT_OBJECT_FACTORYis ) type = OBJECT_MOBILEis;
+ if ( event.type == EVENT_OBJECT_FACTORYwc ) type = OBJECT_MOBILEwc;
+ if ( event.type == EVENT_OBJECT_FACTORYtc ) type = OBJECT_MOBILEtc;
+ if ( event.type == EVENT_OBJECT_FACTORYfc ) type = OBJECT_MOBILEfc;
+ if ( event.type == EVENT_OBJECT_FACTORYic ) type = OBJECT_MOBILEic;
+ if ( event.type == EVENT_OBJECT_FACTORYwi ) type = OBJECT_MOBILEwi;
+ if ( event.type == EVENT_OBJECT_FACTORYti ) type = OBJECT_MOBILEti;
+ if ( event.type == EVENT_OBJECT_FACTORYfi ) type = OBJECT_MOBILEfi;
+ if ( event.type == EVENT_OBJECT_FACTORYii ) type = OBJECT_MOBILEii;
+ if ( event.type == EVENT_OBJECT_FACTORYrt ) type = OBJECT_MOBILErt;
+ if ( event.type == EVENT_OBJECT_FACTORYrc ) type = OBJECT_MOBILErc;
+ if ( event.type == EVENT_OBJECT_FACTORYrr ) type = OBJECT_MOBILErr;
+ if ( event.type == EVENT_OBJECT_FACTORYrs ) type = OBJECT_MOBILErs;
+ if ( event.type == EVENT_OBJECT_FACTORYsa ) type = OBJECT_MOBILEsa;
if ( type != OBJECT_NULL )
{
@@ -186,7 +186,7 @@ bool CAutoFactory::EventProcess(const Event &event)
}
}
- if ( event.event != EVENT_FRAME ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
EventProgress(event.rTime);
@@ -249,7 +249,7 @@ bool CAutoFactory::EventProcess(const Event &event)
m_object->SetAngleZ(10+i, 0.0f);
}
- m_channelSound = m_sound->Play(SOUND_FACTORY, m_object->RetPosition(0), 0.0f, 1.0f, true);
+ m_channelSound = m_sound->Play(SOUND_FACTORY, m_object->GetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, 2.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, 11.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_channelSound, 0.0f, 1.0f, 2.0f, SOPER_STOP);
@@ -300,7 +300,7 @@ bool CAutoFactory::EventProcess(const Event &event)
{
prog = 1.0f-m_progress;
}
- angle = powf(prog*10.0f, 2.0f)+m_object->RetAngleY(0);
+ angle = powf(prog*10.0f, 2.0f)+m_object->GetAngleY(0);
vehicle = SearchVehicle();
if ( vehicle != 0 )
@@ -315,9 +315,9 @@ bool CAutoFactory::EventProcess(const Event &event)
fret->SetZoom(0, 1.0f-m_progress);
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
#if 0
pos = m_fretPos;
@@ -329,9 +329,9 @@ bool CAutoFactory::EventProcess(const Event &event)
speed.y = Math::Rand()*12.0f;
dim.x = Math::Rand()*12.0f+10.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
#else
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(-12.0f, 20.0f, -4.0f); // position of chimney
pos = Math::Transform(*mat, pos);
pos.y += 2.0f;
@@ -342,7 +342,7 @@ bool CAutoFactory::EventProcess(const Event &event)
speed.y = 6.0f+Math::Rand()*6.0f;
dim.x = Math::Rand()*1.5f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f);
#endif
}
}
@@ -361,15 +361,15 @@ bool CAutoFactory::EventProcess(const Event &event)
vehicle = SearchVehicle();
if ( vehicle != 0 )
{
- physics = vehicle->RetPhysics();
+ physics = vehicle->GetPhysics();
if ( physics != 0 )
{
physics->SetFreeze(false); // can move
}
vehicle->SetLock(false); // vehicle useable
-//? vehicle->RetPhysics()->RetBrain()->StartTaskAdvance(16.0f);
- vehicle->SetAngleY(0, m_object->RetAngleY(0)+Math::PI);
+//? vehicle->GetPhysics()->GetBrain()->StartTaskAdvance(16.0f);
+ vehicle->SetAngleY(0, m_object->GetAngleY(0)+Math::PI);
vehicle->SetZoom(0, 1.0f);
}
@@ -392,9 +392,9 @@ bool CAutoFactory::EventProcess(const Event &event)
m_object->SetAngleZ(10+i, -angle);
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.1f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_fretPos;
pos.x += (Math::Rand()-0.5f)*10.0f;
@@ -403,7 +403,7 @@ bool CAutoFactory::EventProcess(const Event &event)
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 2.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 2.0f, 0.0f, 0.0f);
}
}
else
@@ -435,9 +435,9 @@ bool CAutoFactory::EventProcess(const Event &event)
m_object->SetZoomZ(10+i, zoom);
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.1f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.1f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_fretPos;
pos.x += (Math::Rand()-0.5f)*10.0f;
@@ -446,7 +446,7 @@ bool CAutoFactory::EventProcess(const Event &event)
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 2.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 2.0f, 0.0f, 0.0f);
}
}
else
@@ -503,12 +503,12 @@ bool CAutoFactory::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoFactoryPhase)OpInt(line, "aPhase", AFP_WAIT);
+ m_phase = static_cast< AutoFactoryPhase >(OpInt(line, "aPhase", AFP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
- m_fretPos = m_object->RetPosition(0);
+ m_lastParticle = 0.0f;
+ m_fretPos = m_object->GetPosition(0);
return true;
}
@@ -526,14 +526,14 @@ CObject* CAutoFactory::SearchFret()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_METAL ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, m_fretPos);
if ( dist < 8.0f ) return pObj;
@@ -552,14 +552,14 @@ bool CAutoFactory::NearestVehicle()
float oRadius, dist;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_HUMAN &&
type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
@@ -616,9 +616,9 @@ bool CAutoFactory::CreateVehicle()
char* name;
int i;
- angle = m_object->RetAngleY(0);
+ angle = m_object->GetAngleY(0);
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
if ( m_type == OBJECT_MOBILErt ||
m_type == OBJECT_MOBILErc ||
m_type == OBJECT_MOBILErr ||
@@ -643,7 +643,7 @@ bool CAutoFactory::CreateVehicle()
vehicle->SetLock(true); // not usable
vehicle->SetRange(30.0f);
- physics = vehicle->RetPhysics();
+ physics = vehicle->GetPhysics();
if ( physics != 0 )
{
physics->SetFreeze(true); // it doesn't move
@@ -651,7 +651,7 @@ bool CAutoFactory::CreateVehicle()
for ( i=0 ; i<10 ; i++ )
{
- name = m_main->RetNewScriptName(m_type, i);
+ name = m_main->GetNewScriptName(m_type, i);
if ( name == 0 ) break;
vehicle->ReadProgram(i, name);
}
@@ -671,16 +671,16 @@ CObject* CAutoFactory::SearchVehicle()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetLock() ) continue;
+ if ( !pObj->GetLock() ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != m_type ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, m_fretPos);
if ( dist < 8.0f ) return pObj;
@@ -694,7 +694,7 @@ CObject* CAutoFactory::SearchVehicle()
bool CAutoFactory::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
@@ -702,8 +702,8 @@ bool CAutoFactory::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw == 0 ) return false;
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw == nullptr ) return false;
dim.x = 33.0f/640.0f;
dim.y = 33.0f/480.0f;
@@ -786,13 +786,13 @@ bool CAutoFactory::CreateInterface(bool bSelect)
void CAutoFactory::UpdateInterface()
{
- CWindow* pw;
+ Ui::CWindow* pw;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
CAuto::UpdateInterface();
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
UpdateButton(pw, EVENT_OBJECT_FACTORYwa, m_bBusy);
UpdateButton(pw, EVENT_OBJECT_FACTORYta, m_bBusy);
@@ -819,7 +819,7 @@ void CAutoFactory::UpdateInterface()
// Updates the status of one interface button.
-void CAutoFactory::UpdateButton(CWindow *pw, EventMsg event, bool bBusy)
+void CAutoFactory::UpdateButton(Ui::CWindow *pw, EventType event, bool bBusy)
{
bool bEnable = true;
@@ -933,7 +933,7 @@ void CAutoFactory::SoundManip(float time, float amplitude, float frequency)
{
int i;
- i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f*frequency, true);
+ i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f*frequency, true);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, 0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, time-0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.3f*frequency, 0.1f, SOPER_STOP);
diff --git a/src/object/auto/autofactory.h b/src/object/auto/autofactory.h
index acbdf40..f62080d 100644
--- a/src/object/auto/autofactory.h
+++ b/src/object/auto/autofactory.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -54,7 +55,7 @@ public:
protected:
void UpdateInterface();
- void UpdateButton(CWindow *pw, EventMsg event, bool bBusy);
+ void UpdateButton(Ui::CWindow *pw, EventType event, bool bBusy);
CObject* SearchFret();
bool NearestVehicle();
@@ -67,7 +68,7 @@ protected:
AutoFactoryPhase m_phase;
float m_progress;
float m_speed;
- float m_lastParticule;
+ float m_lastParticle;
Math::Vector m_fretPos;
int m_channelSound;
};
diff --git a/src/object/auto/autoflag.cpp b/src/object/auto/autoflag.cpp
index ea74b17..e88ee3a 100644
--- a/src/object/auto/autoflag.cpp
+++ b/src/object/auto/autoflag.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,12 +16,12 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoflag.h"
#include "math/geometry.h"
-#include "old/terrain.h"
+#include "graphics/engine/terrain.h"
+
+#include <stdio.h>
@@ -68,7 +69,7 @@ void CAutoFlag::Init()
m_param = 0;
m_progress = 0.0f;
- wind = m_terrain->RetWind();
+ wind = m_terrain->GetWind();
angle = Math::RotateAngle(wind.x, -wind.z);
m_object->SetAngleY(0, angle); // directs the flag in the wind
@@ -98,7 +99,7 @@ bool CAutoFlag::EventProcess(const Event &event)
CAuto::EventProcess(event);
#if ADJUST_ANGLE
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEYDOWN )
{
if ( event.param == 'E' ) g_flag1 += 0.1f;
if ( event.param == 'D' ) g_flag1 -= 0.1f;
@@ -109,8 +110,8 @@ bool CAutoFlag::EventProcess(const Event &event)
}
#endif
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_param == 1 ) // shakes?
{
@@ -152,9 +153,9 @@ bool CAutoFlag::EventProcess(const Event &event)
}
-// Returns an error due the state of the automation
+// Geturns an error due the state of the automation
-Error CAutoFlag::RetError()
+Error CAutoFlag::GetError()
{
return ERR_OK;
}
diff --git a/src/object/auto/autoflag.h b/src/object/auto/autoflag.h
index fdec682..3c6cf99 100644
--- a/src/object/auto/autoflag.h
+++ b/src/object/auto/autoflag.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -34,7 +35,7 @@ public:
void Init();
void Start(int param);
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
protected:
diff --git a/src/object/auto/autohuston.cpp b/src/object/auto/autohuston.cpp
index a96bcb8..1e81a65 100644
--- a/src/object/auto/autohuston.cpp
+++ b/src/object/auto/autohuston.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,14 +16,12 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autohuston.h"
#include "ui/interface.h"
#include "ui/window.h"
-
+#include <stdio.h>
// Object's constructor.
@@ -38,11 +37,11 @@ CAutoHuston::CAutoHuston(CInstanceManager* iMan, CObject* object)
m_lens[i].parti = -1;
}
- pos = m_object->RetPosition(0);
- m_lens[0].type = PARTISELR;
- m_lens[1].type = PARTISELR;
- m_lens[2].type = PARTISELR;
- m_lens[3].type = PARTISELR;
+ pos = m_object->GetPosition(0);
+ m_lens[0].type = Gfx::PARTISELR;
+ m_lens[1].type = Gfx::PARTISELR;
+ m_lens[2].type = Gfx::PARTISELR;
+ m_lens[3].type = Gfx::PARTISELR;
m_lens[0].pos = pos+Math::Vector(0.0f+13.0f, 34.0f, 30.0f );
m_lens[1].pos = pos+Math::Vector(0.0f-13.0f, 34.0f, 30.0f );
m_lens[2].pos = pos+Math::Vector(0.0f , 34.0f, 30.0f+13.0f);
@@ -62,46 +61,46 @@ CAutoHuston::CAutoHuston(CInstanceManager* iMan, CObject* object)
// Part under the radar.
i = 4;
- m_lens[i].type = PARTISELR;
+ m_lens[i].type = Gfx::PARTISELR;
m_lens[i].pos = pos+Math::Vector(-7.0f, 9.9f, 40.1f);
m_lens[i].dim = 1.8f;
m_lens[i].total = 0.4f;
m_lens[i].off = 0.2f;
i ++;
- m_lens[i].type = PARTISELY;
+ m_lens[i].type = Gfx::PARTISELY;
m_lens[i].pos = pos+Math::Vector(-7.0f, 7.2f, 34.8f);
m_lens[i].dim = 0.4f;
m_lens[i].total = 0.7f;
m_lens[i].off = 0.3f;
i ++;
- m_lens[i].type = PARTISELY;
+ m_lens[i].type = Gfx::PARTISELY;
m_lens[i].pos = pos+Math::Vector(-7.0f, 6.5f, 34.3f);
m_lens[i].dim = 0.4f;
m_lens[i].total = 0.7f;
m_lens[i].off = 0.3f;
i ++;
- m_lens[i].type = PARTISELR;
+ m_lens[i].type = Gfx::PARTISELR;
m_lens[i].pos = pos+Math::Vector(-7.0f, 6.5f, 33.4f);
m_lens[i].dim = 0.4f;
m_lens[i].total = 0.0f;
m_lens[i].off = 0.0f;
i ++;
- m_lens[i].type = PARTISELR;
+ m_lens[i].type = Gfx::PARTISELR;
m_lens[i].pos = pos+Math::Vector(-7.0f, 6.5f, 33.0f);
m_lens[i].dim = 0.4f;
m_lens[i].total = 1.0f;
m_lens[i].off = 0.5f;
i ++;
- m_lens[i].type = PARTISELY;
+ m_lens[i].type = Gfx::PARTISELY;
m_lens[i].pos = pos+Math::Vector(-7.0f, 8.5f, 14.0f);
m_lens[i].dim = 1.2f;
m_lens[i].total = 0.8f;
m_lens[i].off = 0.2f;
i ++;
- m_lens[i].type = PARTISELR;
+ m_lens[i].type = Gfx::PARTISELR;
m_lens[i].pos = pos+Math::Vector(4.0f, 6.0f, 8.6f);
m_lens[i].dim = 1.0f;
m_lens[i].total = 0.9f;
@@ -109,53 +108,53 @@ CAutoHuston::CAutoHuston(CInstanceManager* iMan, CObject* object)
i ++;
// Part with three windows.
- m_lens[i].type = PARTISELR;
+ m_lens[i].type = Gfx::PARTISELR;
m_lens[i].pos = pos+Math::Vector(-7.0f, 9.9f, -19.9f);
m_lens[i].dim = 1.0f;
m_lens[i].total = 0.6f;
m_lens[i].off = 0.3f;
i ++;
- m_lens[i].type = PARTISELY;
+ m_lens[i].type = Gfx::PARTISELY;
m_lens[i].pos = pos+Math::Vector(-7.0f, 7.2f, 34.8f-60.0f);
m_lens[i].dim = 0.4f;
m_lens[i].total = 0.7f;
m_lens[i].off = 0.3f;
i ++;
- m_lens[i].type = PARTISELY;
+ m_lens[i].type = Gfx::PARTISELY;
m_lens[i].pos = pos+Math::Vector(-7.0f, 6.5f, 34.3f-60.0f);
m_lens[i].dim = 0.4f;
m_lens[i].total = 0.0f;
m_lens[i].off = 0.0f;
i ++;
- m_lens[i].type = PARTISELR;
+ m_lens[i].type = Gfx::PARTISELR;
m_lens[i].pos = pos+Math::Vector(-7.0f, 6.5f, 33.4f-60.0f);
m_lens[i].dim = 0.4f;
m_lens[i].total = 0.6f;
m_lens[i].off = 0.4f;
i ++;
- m_lens[i].type = PARTISELR;
+ m_lens[i].type = Gfx::PARTISELR;
m_lens[i].pos = pos+Math::Vector(-7.0f, 6.5f, 33.0f-60.0f);
m_lens[i].dim = 0.4f;
m_lens[i].total = 0.8f;
m_lens[i].off = 0.2f;
i ++;
- m_lens[i].type = PARTISELY;
+ m_lens[i].type = Gfx::PARTISELY;
m_lens[i].pos = pos+Math::Vector(-6.5f, 13.5f, -37.0f);
m_lens[i].dim = 1.0f;
m_lens[i].total = 0.0f;
m_lens[i].off = 0.0f;
i ++;
- m_lens[i].type = PARTISELY;
+ m_lens[i].type = Gfx::PARTISELY;
m_lens[i].pos = pos+Math::Vector(-7.0f, 12.2f, -39.8f);
m_lens[i].dim = 1.8f;
m_lens[i].total = 1.5f;
m_lens[i].off = 0.5f;
i ++;
- m_lens[i].type = PARTISELY;
+ m_lens[i].type = Gfx::PARTISELY;
m_lens[i].pos = pos+Math::Vector(-7.0f, 8.5f, -47.0f);
m_lens[i].dim = 0.6f;
m_lens[i].total = 0.7f;
@@ -211,14 +210,14 @@ bool CAutoHuston::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
angle = -m_time*1.0f;
m_object->SetAngleY(1, angle); // rotates the radar
angle = sinf(m_time*4.0f)*0.3f;
m_object->SetAngleX(2, angle);
- if ( event.event != EVENT_FRAME ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
@@ -231,7 +230,7 @@ bool CAutoHuston::EventProcess(const Event &event)
{
if ( m_lens[i].parti != -1 )
{
- m_particule->DeleteParticule(m_lens[i].parti);
+ m_particle->DeleteParticle(m_lens[i].parti);
m_lens[i].parti = -1;
}
}
@@ -241,7 +240,7 @@ bool CAutoHuston::EventProcess(const Event &event)
{
dim.x = m_lens[i].dim;
dim.y = dim.x;
- m_lens[i].parti = m_particule->CreateParticule(m_lens[i].pos, speed, dim, m_lens[i].type, 1.0f, 0.0f, 0.0f);
+ m_lens[i].parti = m_particle->CreateParticle(m_lens[i].pos, speed, dim, m_lens[i].type, 1.0f, 0.0f, 0.0f);
}
}
}
@@ -261,7 +260,7 @@ bool CAutoHuston::Abort()
bool CAutoHuston::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -269,8 +268,8 @@ bool CAutoHuston::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw == 0 ) return false;
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw == nullptr ) return false;
ox = 3.0f/640.0f;
oy = 3.0f/480.0f;
@@ -287,9 +286,9 @@ bool CAutoHuston::CreateInterface(bool bSelect)
}
-// Returns an error due to state of the automation.
+// Geturns an error due to state of the automation.
-Error CAutoHuston::RetError()
+Error CAutoHuston::GetError()
{
return ERR_OK;
}
diff --git a/src/object/auto/autohuston.h b/src/object/auto/autohuston.h
index a59f8f2..27b016b 100644
--- a/src/object/auto/autohuston.h
+++ b/src/object/auto/autohuston.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -20,18 +21,18 @@
#include "object/auto/auto.h"
-#include "old/particule.h"
+#include "graphics/engine/particle.h"
struct HustonLens
{
- int parti;
- ParticuleType type;
+ int parti;
+ Gfx::ParticleType type;
Math::Vector pos;
- float dim;
- float total;
- float off;
+ float dim;
+ float total;
+ float off;
};
@@ -50,7 +51,7 @@ public:
void Start(int param);
bool EventProcess(const Event &event);
bool Abort();
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
diff --git a/src/object/auto/autoinfo.cpp b/src/object/auto/autoinfo.cpp
index 56fd8c7..78cc249 100644
--- a/src/object/auto/autoinfo.cpp
+++ b/src/object/auto/autoinfo.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoinfo.h"
#include "script/cmdtoken.h"
@@ -24,7 +23,8 @@
#include "ui/list.h"
#include "ui/window.h"
-
+#include <stdio.h>
+#include <string.h>
@@ -90,8 +90,8 @@ void CAutoInfo::Start(int param)
m_speed = 1.0f/2.0f;
}
- m_lastParticule = 0;
- m_goal = m_object->RetPosition(0);
+ m_lastParticle = 0;
+ m_goal = m_object->GetPosition(0);
if ( m_phase == AIP_EMETTE )
{
@@ -100,7 +100,7 @@ void CAutoInfo::Start(int param)
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 30.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISPHERE4, 1.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISPHERE4, 1.5f, 0.0f, 0.0f);
m_sound->Play(SOUND_LABO, pos, 1.0f, 2.0f);
}
@@ -111,7 +111,7 @@ void CAutoInfo::Start(int param)
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 50.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISPHERE6, 1.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISPHERE6, 1.5f, 0.0f, 0.0f);
m_sound->Play(SOUND_LABO, pos, 1.0f, 2.0f);
}
@@ -133,18 +133,18 @@ bool CAutoInfo::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
m_timeVirus = 0.1f+Math::Rand()*0.3f;
- angle = m_object->RetAngleY(1);
+ angle = m_object->GetAngleY(1);
angle += Math::Rand()*0.3f;
m_object->SetAngleY(1, angle);
@@ -170,7 +170,7 @@ bool CAutoInfo::EventProcess(const Event &event)
}
else
{
- if ( m_object->RetInfoUpdate() )
+ if ( m_object->GetInfoUpdate() )
{
UpdateList(); // updates the list
}
@@ -184,9 +184,9 @@ bool CAutoInfo::EventProcess(const Event &event)
if ( m_phase == AIP_EMETTE ) // instruction "receive" ?
{
if ( m_progress < 0.5f &&
- m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
for ( i=0 ; i<4 ; i++ )
{
@@ -199,7 +199,7 @@ bool CAutoInfo::EventProcess(const Event &event)
dim.x = 0.6f;
dim.y = dim.x;
duration = Math::Rand()*0.5f+0.5f;
- m_particule->CreateTrack(pos, speed, dim, PARTITRACK6,
+ m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
duration, 0.0f,
duration*0.9f, 0.7f);
}
@@ -230,9 +230,9 @@ bool CAutoInfo::EventProcess(const Event &event)
if ( m_phase == AIP_RECEIVE ) // instruction "send" ?
{
if ( m_progress < 0.5f &&
- m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
for ( i=0 ; i<4 ; i++ )
{
@@ -247,7 +247,7 @@ bool CAutoInfo::EventProcess(const Event &event)
dim.x = 0.6f;
dim.y = dim.x;
duration = Math::Rand()*0.5f+0.5f;
- m_particule->CreateTrack(pos, speed, dim, PARTITRACK6,
+ m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
duration, 0.0f,
duration*0.9f, 0.7f);
}
@@ -278,9 +278,9 @@ bool CAutoInfo::EventProcess(const Event &event)
if ( m_phase == AIP_ERROR )
{
if ( m_progress < 0.5f &&
- m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_goal;
speed.x = (Math::Rand()-0.5f)*5.0f;
@@ -289,7 +289,7 @@ bool CAutoInfo::EventProcess(const Event &event)
dim.x = 5.0f+Math::Rand()*5.0f;
dim.y = dim.x;
duration = Math::Rand()*0.5f+0.5f;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 4.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE1, 4.0f);
}
if ( m_progress < 1.0f )
@@ -327,7 +327,7 @@ bool CAutoInfo::EventProcess(const Event &event)
}
}
- angle = m_object->RetAngleY(1);
+ angle = m_object->GetAngleY(1);
angle += rTime*0.5f;
m_object->SetAngleY(1, angle);
@@ -339,11 +339,11 @@ bool CAutoInfo::EventProcess(const Event &event)
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoInfo::RetError()
+Error CAutoInfo::GetError()
{
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
@@ -356,8 +356,8 @@ Error CAutoInfo::RetError()
bool CAutoInfo::CreateInterface(bool bSelect)
{
- CWindow* pw;
- CList* pl;
+ Ui::CWindow* pw;
+ Ui::CList* pl;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -365,7 +365,7 @@ bool CAutoInfo::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -403,31 +403,31 @@ void CAutoInfo::UpdateInterface(float rTime)
void CAutoInfo::UpdateList()
{
- CWindow* pw;
- CList* pl;
+ Ui::CWindow* pw;
+ Ui::CList* pl;
Info info;
int total, i;
char text[100];
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw == 0 ) return;
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw == nullptr ) return;
- pl = (CList*)pw->SearchControl(EVENT_OBJECT_GINFO);
- if ( pl == 0 ) return;
+ pl = static_cast< Ui::CList* >(pw->SearchControl(EVENT_OBJECT_GINFO));
+ if ( pl == nullptr ) return;
pl->Flush();
- total = m_object->RetInfoTotal();
+ total = m_object->GetInfoTotal();
if ( total == 0 )
{
- pl->ClearState(STATE_ENABLE);
+ pl->ClearState(Ui::STATE_ENABLE);
}
else
{
- pl->SetState(STATE_ENABLE);
+ pl->SetState(Ui::STATE_ENABLE);
for ( i=0 ; i<total ; i++ )
{
- info = m_object->RetInfo(i);
+ info = m_object->GetInfo(i);
sprintf(text, "%s = %.2f", info.name, info.value);
pl->SetName(i, text);
}
@@ -440,28 +440,28 @@ void CAutoInfo::UpdateList()
void CAutoInfo::UpdateListVirus()
{
- CWindow* pw;
- CList* pl;
+ Ui::CWindow* pw;
+ Ui::CList* pl;
int i, j, max;
char text[100];
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_OBJECT_GINFO);
+ pl = static_cast< Ui::CList* >(pw->SearchControl(EVENT_OBJECT_GINFO));
if ( pl == 0 ) return;
- pl->SetState(STATE_ENABLE);
+ pl->SetState(Ui::STATE_ENABLE);
pl->Flush();
for ( i=0 ; i<4 ; i++ )
{
- max = (int)(2.0f+Math::Rand()*10.0f);
+ max = static_cast< int >(2.0f+Math::Rand()*10.0f);
for ( j=0 ; j<max ; j++ )
{
do
{
- text[j] = ' '+(int)(Math::Rand()*94.0f);
+ text[j] = ' '+static_cast< int >(Math::Rand()*94.0f);
}
while ( text[j] == '\\' );
}
@@ -505,11 +505,11 @@ bool CAutoInfo::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoInfoPhase)OpInt(line, "aPhase", AIP_WAIT);
+ m_phase = static_cast< AutoInfoPhase > (OpInt(line, "aPhase", AIP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/autoinfo.h b/src/object/auto/autoinfo.h
index cfe3c1b..30481bb 100644
--- a/src/object/auto/autoinfo.h
+++ b/src/object/auto/autoinfo.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -44,7 +45,7 @@ public:
void Init();
void Start(int param);
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -61,7 +62,7 @@ protected:
float m_progress;
float m_speed;
float m_timeVirus;
- float m_lastParticule;
+ float m_lastParticle;
Math::Vector m_goal;
bool m_bLastVirus;
};
diff --git a/src/object/auto/autojostle.cpp b/src/object/auto/autojostle.cpp
index 3944297..788b562 100644
--- a/src/object/auto/autojostle.cpp
+++ b/src/object/auto/autojostle.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,11 +16,9 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autojostle.h"
-
+#include <stdio.h>
// Object's constructor.
@@ -71,7 +70,7 @@ void CAutoJostle::Start(int param, float force)
m_time = 0.0f;
m_error = ERR_CONTINUE;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type >= OBJECT_PLANT5 &&
type <= OBJECT_PLANT7 ) // clover?
{
@@ -89,8 +88,8 @@ bool CAutoJostle::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_progress < 1.0f )
{
diff --git a/src/object/auto/autojostle.h b/src/object/auto/autojostle.h
index 70bb5e6..c156893 100644
--- a/src/object/auto/autojostle.h
+++ b/src/object/auto/autojostle.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -42,7 +43,7 @@ protected:
float m_force;
float m_progress;
float m_speed;
- float m_lastParticule;
+ float m_lastParticle;
Error m_error;
};
diff --git a/src/object/auto/autokid.cpp b/src/object/auto/autokid.cpp
index e5987cc..7004e6b 100644
--- a/src/object/auto/autokid.cpp
+++ b/src/object/auto/autokid.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,13 +16,12 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autokid.h"
-#include "old/particule.h"
-#include "old/water.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/water.h"
+#include <stdio.h>
// Object's constructor.
@@ -62,18 +62,18 @@ void CAutoKid::Init()
m_speed = 1.0f/1.0f;
m_progress = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
if ( m_type == OBJECT_TEEN36 ) // trunk ?
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_speed = 1.0f/(1.0f+(Math::Mod(pos.x/10.0f-0.5f, 1.0f)*0.2f));
m_progress = Math::Mod(pos.x/10.0f, 1.0f);
}
if ( m_type == OBJECT_TEEN37 ) // boat?
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_speed = 1.0f/(1.0f+(Math::Mod(pos.x/10.0f-0.5f, 1.0f)*0.2f))*2.5f;
m_progress = Math::Mod(pos.x/10.0f, 1.0f);
}
@@ -82,7 +82,7 @@ void CAutoKid::Init()
{
if ( m_soundChannel == -1 )
{
-//? m_soundChannel = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 1.0f, 0.5f, true);
+//? m_soundChannel = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 1.0f, 0.5f, true);
m_bSilent = false;
}
}
@@ -100,7 +100,7 @@ bool CAutoKid::EventProcess(const Event &event)
if ( m_soundChannel != -1 )
{
- if ( m_engine->RetPause() )
+ if ( m_engine->GetPause() )
{
if ( !m_bSilent )
{
@@ -118,8 +118,8 @@ bool CAutoKid::EventProcess(const Event &event)
}
}
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
@@ -135,12 +135,12 @@ bool CAutoKid::EventProcess(const Event &event)
vib.z = sinf(m_progress*0.5f)*0.05f;
m_object->SetCirVibration(vib);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.15f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.15f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
- pos.y = m_water->RetLevel()+1.0f;
+ pos = m_object->GetPosition(0);
+ pos.y = m_water->GetLevel()+1.0f;
pos.x += (Math::Rand()-0.5f)*50.0f;
pos.z += (Math::Rand()-0.5f)*50.0f;
speed.y = 0.0f;
@@ -148,7 +148,7 @@ bool CAutoKid::EventProcess(const Event &event)
speed.z = 0.0f;
dim.x = 50.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFLIC, 3.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFLIC, 3.0f, 0.0f, 0.0f);
}
}
@@ -164,12 +164,12 @@ bool CAutoKid::EventProcess(const Event &event)
vib.z = sinf(m_progress*0.5f)*0.15f;
m_object->SetCirVibration(vib);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.15f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.15f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
- pos.y = m_water->RetLevel()+1.0f;
+ pos = m_object->GetPosition(0);
+ pos.y = m_water->GetLevel()+1.0f;
pos.x += (Math::Rand()-0.5f)*20.0f;
pos.z += (Math::Rand()-0.5f)*20.0f;
speed.y = 0.0f;
@@ -177,7 +177,7 @@ bool CAutoKid::EventProcess(const Event &event)
speed.z = 0.0f;
dim.x = 20.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFLIC, 3.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFLIC, 3.0f, 0.0f, 0.0f);
}
}
@@ -191,9 +191,9 @@ bool CAutoKid::EventProcess(const Event &event)
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoKid::RetError()
+Error CAutoKid::GetError()
{
return ERR_OK;
}
diff --git a/src/object/auto/autokid.h b/src/object/auto/autokid.h
index 6d4258f..3e2fba7 100644
--- a/src/object/auto/autokid.h
+++ b/src/object/auto/autokid.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -33,14 +34,14 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
protected:
protected:
float m_speed;
float m_progress;
- float m_lastParticule;
+ float m_lastParticle;
int m_soundChannel;
bool m_bSilent;
};
diff --git a/src/object/auto/autolabo.cpp b/src/object/auto/autolabo.cpp
index 270ec09..af780e0 100644
--- a/src/object/auto/autolabo.cpp
+++ b/src/object/auto/autolabo.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autolabo.h"
#include "common/global.h"
@@ -28,6 +27,8 @@
#include "ui/window.h"
#include "ui/displaytext.h"
+#include <stdio.h>
+#include <string.h>
const float LABO_DELAY = 20.0f; // duration of the analysis
@@ -69,14 +70,14 @@ void CAutoLabo::DeleteObject(bool bAll)
{
if ( m_partiRank[i] != -1 )
{
- m_particule->DeleteParticule(m_partiRank[i]);
+ m_particle->DeleteParticle(m_partiRank[i]);
m_partiRank[i] = -1;
}
}
if ( m_partiSphere != -1 )
{
- m_particule->DeleteParticule(m_partiSphere);
+ m_particle->DeleteParticle(m_partiSphere);
m_partiSphere = -1;
}
@@ -97,7 +98,7 @@ void CAutoLabo::Init()
{
m_time = 0.0f;
m_timeVirus = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_phase = ALAP_WAIT; // waiting ...
m_progress = 0.0f;
@@ -119,23 +120,23 @@ bool CAutoLabo::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
- if ( event.event == EVENT_UPDINTERFACE )
+ if ( event.type == EVENT_UPDINTERFACE )
{
- if ( m_object->RetSelect() ) CreateInterface(true);
+ if ( m_object->GetSelect() ) CreateInterface(true);
}
- if ( m_object->RetSelect() && // center selected?
- (event.event == EVENT_OBJECT_RiPAW ||
- event.event == EVENT_OBJECT_RiGUN) )
+ if ( m_object->GetSelect() && // center selected?
+ (event.type == EVENT_OBJECT_RiPAW ||
+ event.type == EVENT_OBJECT_RiGUN) )
{
if ( m_phase != ALAP_WAIT )
{
return false;
}
- m_research = event.event;
+ m_research = event.type;
if ( TestResearch(m_research) )
{
@@ -143,13 +144,13 @@ bool CAutoLabo::EventProcess(const Event &event)
return false;
}
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 )
{
m_displayText->DisplayError(ERR_LABO_NULL, m_object);
return false;
}
- if ( power->RetType() != OBJECT_BULLET )
+ if ( power->GetType() != OBJECT_BULLET )
{
m_displayText->DisplayError(ERR_LABO_BAD, m_object);
return false;
@@ -168,12 +169,12 @@ bool CAutoLabo::EventProcess(const Event &event)
return true;
}
- if ( event.event != EVENT_FRAME ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
@@ -247,31 +248,32 @@ bool CAutoLabo::EventProcess(const Event &event)
{
m_object->SetAngleZ(1, 0.0f);
- goal = m_object->RetPosition(0);
+ goal = m_object->GetPosition(0);
goal.y += 3.0f;
pos = goal;
pos.x -= 4.0f;
pos.y += 4.0f;
for ( i=0 ; i<3 ; i++ )
{
- m_partiRank[i] = m_particule->CreateRay(pos, goal,
- PARTIRAY2,
+ m_partiRank[i] = m_particle->CreateRay(pos, goal,
+ Gfx::PARTIRAY2,
Math::Point(2.9f, 2.9f),
LABO_DELAY);
}
- m_soundChannel = m_sound->Play(SOUND_LABO, m_object->RetPosition(0), 0.0f, 0.25f, true);
+ m_soundChannel = m_sound->Play(SOUND_LABO, m_object->GetPosition(0), 0.0f, 0.25f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.60f, 2.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 2.00f, 8.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 0.60f, 8.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.25f, 2.0f, SOPER_STOP);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 4.0f;
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 4.0f;
dim.y = dim.x;
- m_partiSphere = m_particule->CreateParticule(pos, speed, dim, PARTISPHERE2, LABO_DELAY, 0.0f, 0.0f);
+ m_partiSphere = m_particle->CreateParticle(pos, speed,
+ dim, Gfx::PARTISPHERE2, LABO_DELAY, 0.0f, 0.0f);
m_phase = ALAP_ANALYSE;
m_progress = 0.0f;
@@ -283,13 +285,13 @@ bool CAutoLabo::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
power->SetZoom(0, 1.0f-m_progress);
}
- angle = m_object->RetAngleY(2);
+ angle = m_object->GetAngleY(2);
if ( m_progress < 0.5f )
{
angle -= event.rTime*m_progress*20.0f;
@@ -300,27 +302,27 @@ bool CAutoLabo::EventProcess(const Event &event)
}
m_object->SetAngleY(2, angle); // rotates the analyzer
- angle += m_object->RetAngleY(0);
+ angle += m_object->GetAngleY(0);
for ( i=0 ; i<3 ; i++ )
{
rot = Math::RotatePoint(-angle, -4.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += rot.x;
pos.z += rot.y;
pos.y += 3.0f+4.0f;;
- m_particule->SetPosition(m_partiRank[i], pos); // adjusts ray
+ m_particle->SetPosition(m_partiRank[i], pos); // adjusts ray
angle += Math::PI*2.0f/3.0f;
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
if ( m_progress > 0.25f &&
m_progress < 0.80f )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 3.0f;
pos.x += (Math::Rand()-0.5f)*2.0f;
pos.z += (Math::Rand()-0.5f)*2.0f;
@@ -329,7 +331,7 @@ bool CAutoLabo::EventProcess(const Event &event)
speed.z = (Math::Rand()-0.5f)*10.0f;
dim.x = Math::Rand()*0.4f*m_progress+1.0f;
dim.y = dim.x;
- m_particule->CreateTrack(pos, speed, dim, PARTITRACK2,
+ m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK2,
2.0f+2.0f*m_progress, 10.0f, 1.5f, 1.4f);
}
}
@@ -338,7 +340,7 @@ bool CAutoLabo::EventProcess(const Event &event)
{
SetResearch(m_research); // research done
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
m_object->SetPower(0);
@@ -421,21 +423,21 @@ bool CAutoLabo::EventProcess(const Event &event)
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoLabo::RetError()
+Error CAutoLabo::GetError()
{
CObject* pObj;
ObjectType type;
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
- pObj = m_object->RetPower();
+ pObj = m_object->GetPower();
if ( pObj == 0 ) return ERR_LABO_NULL;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_BULLET ) return ERR_LABO_BAD;
return ERR_OK;
@@ -446,7 +448,7 @@ Error CAutoLabo::RetError()
bool CAutoLabo::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
@@ -454,7 +456,7 @@ bool CAutoLabo::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
dim.x = 33.0f/640.0f;
@@ -487,13 +489,13 @@ bool CAutoLabo::CreateInterface(bool bSelect)
void CAutoLabo::UpdateInterface()
{
- CWindow* pw;
+ Ui::CWindow* pw;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
CAuto::UpdateInterface();
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
DeadInterface(pw, EVENT_OBJECT_RiPAW, g_researchEnable&RESEARCH_iPAW);
@@ -508,20 +510,20 @@ void CAutoLabo::UpdateInterface()
// Indicates the research conducted for a button.
-void CAutoLabo::OkayButton(CWindow *pw, EventMsg event)
+void CAutoLabo::OkayButton(Ui::CWindow *pw, EventType event)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
if ( control == 0 ) return;
- control->SetState(STATE_OKAY, TestResearch(event));
+ control->SetState(Ui::STATE_OKAY, TestResearch(event));
}
// Test whether a search has already been done.
-bool CAutoLabo::TestResearch(EventMsg event)
+bool CAutoLabo::TestResearch(EventType event)
{
if ( event == EVENT_OBJECT_RiPAW ) return (g_researchDone & RESEARCH_iPAW);
if ( event == EVENT_OBJECT_RiGUN ) return (g_researchDone & RESEARCH_iGUN);
@@ -531,16 +533,17 @@ bool CAutoLabo::TestResearch(EventMsg event)
// Indicates a search as made.
-void CAutoLabo::SetResearch(EventMsg event)
+void CAutoLabo::SetResearch(EventType event)
{
- Event newEvent;
+
if ( event == EVENT_OBJECT_RiPAW ) g_researchDone |= RESEARCH_iPAW;
if ( event == EVENT_OBJECT_RiGUN ) g_researchDone |= RESEARCH_iGUN;
m_main->WriteFreeParam();
- m_event->MakeEvent(newEvent, EVENT_UPDINTERFACE);
+ Event newEvent(EVENT_UPDINTERFACE);
+// m_event->MakeEvent(newEvent, EVENT_UPDINTERFACE);
m_event->AddEvent(newEvent);
UpdateInterface();
}
@@ -551,7 +554,7 @@ void CAutoLabo::SoundManip(float time, float amplitude, float frequency)
{
int i;
- i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f*frequency, true);
+ i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f*frequency, true);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, 0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, time-0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.3f*frequency, 0.1f, SOPER_STOP);
@@ -597,12 +600,12 @@ bool CAutoLabo::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoLaboPhase)OpInt(line, "aPhase", ALAP_WAIT);
+ m_phase = static_cast< AutoLaboPhase >(OpInt(line, "aPhase", ALAP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_research = (EventMsg)OpInt(line, "aResearch", 0);
+ m_research = static_cast< EventType >(OpInt(line, "aResearch", 0));
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/autolabo.h b/src/object/auto/autolabo.h
index 244e633..8225462 100644
--- a/src/object/auto/autolabo.h
+++ b/src/object/auto/autolabo.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -47,7 +48,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -56,9 +57,9 @@ public:
protected:
void UpdateInterface();
- void OkayButton(CWindow *pw, EventMsg event);
- bool TestResearch(EventMsg event);
- void SetResearch(EventMsg event);
+ void OkayButton(Ui::CWindow *pw, EventType event);
+ bool TestResearch(EventType event);
+ void SetResearch(EventType event);
void SoundManip(float time, float amplitude, float frequency);
protected:
@@ -66,8 +67,8 @@ protected:
float m_progress;
float m_speed;
float m_timeVirus;
- float m_lastParticule;
- EventMsg m_research;
+ float m_lastParticle;
+ EventType m_research;
int m_partiRank[3];
int m_partiSphere;
int m_soundChannel;
diff --git a/src/object/auto/automush.cpp b/src/object/auto/automush.cpp
index c3eaaaf..d7aa98e 100644
--- a/src/object/auto/automush.cpp
+++ b/src/object/auto/automush.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,14 +16,14 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/automush.h"
#include "common/iman.h"
#include "script/cmdtoken.h"
+#include <stdio.h>
+#include <string.h>
// Object's constructor.
@@ -57,7 +58,7 @@ void CAutoMush::Init()
m_speed = 1.0f/4.0f;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
}
@@ -72,8 +73,8 @@ bool CAutoMush::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
@@ -122,7 +123,7 @@ bool CAutoMush::EventProcess(const Event &event)
}
else
{
- m_sound->Play(SOUND_MUSHROOM, m_object->RetPosition(0));
+ m_sound->Play(SOUND_MUSHROOM, m_object->GetPosition(0));
m_phase = AMP_FIRE;
m_progress = 0.0f;
@@ -137,21 +138,21 @@ bool CAutoMush::EventProcess(const Event &event)
factor = 1.0f-m_progress;
size = 1.0f+(1.0f-m_progress)*0.3f;
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
for ( i=0 ; i<10 ; i++ )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 5.0f;
speed.x = (Math::Rand()-0.5f)*200.0f;
speed.z = (Math::Rand()-0.5f)*200.0f;
speed.y = -(20.0f+Math::Rand()*20.0f);
dim.x = 1.0f;
dim.y = dim.x;
- channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN2, 2.0f, 100.0f, 0.0f);
- m_particule->SetObjectFather(channel, m_object);
+ channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN2, 2.0f, 100.0f, 0.0f);
+ m_particle->SetObjectFather(channel, m_object);
}
}
}
@@ -167,18 +168,18 @@ bool CAutoMush::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.10f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.10f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 5.0f;
speed.x = (Math::Rand()-0.5f)*4.0f;
speed.z = (Math::Rand()-0.5f)*4.0f;
speed.y = -(0.5f+Math::Rand()*0.5f);
dim.x = Math::Rand()*2.5f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f, 0.0f, 0.0f);
}
}
else
@@ -226,16 +227,16 @@ bool CAutoMush::SearchTarget()
float dist;
int i;
- iPos = m_object->RetPosition(0);
+ iPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( pObj->RetLock() ) continue;
+ if ( pObj->GetLock() ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
type != OBJECT_MOBILEwa &&
@@ -279,7 +280,7 @@ bool CAutoMush::SearchTarget()
type != OBJECT_PARA &&
type != OBJECT_HUMAN ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, iPos);
if ( dist < 50.0f ) return true;
}
@@ -288,9 +289,9 @@ bool CAutoMush::SearchTarget()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoMush::RetError()
+Error CAutoMush::GetError()
{
return ERR_OK;
}
@@ -332,11 +333,11 @@ bool CAutoMush::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoMushPhase)OpInt(line, "aPhase", AMP_WAIT);
+ m_phase = static_cast< AutoMushPhase >(OpInt(line, "aPhase", AMP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/automush.h b/src/object/auto/automush.h
index 113d22f..245393a 100644
--- a/src/object/auto/automush.h
+++ b/src/object/auto/automush.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -44,7 +45,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool Write(char *line);
bool Read(char *line);
@@ -56,6 +57,6 @@ protected:
AutoMushPhase m_phase;
float m_progress;
float m_speed;
- float m_lastParticule;
+ float m_lastParticle;
};
diff --git a/src/object/auto/autonest.cpp b/src/object/auto/autonest.cpp
index f3c70fb..4a8132a 100644
--- a/src/object/auto/autonest.cpp
+++ b/src/object/auto/autonest.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,15 +16,14 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autonest.h"
#include "common/iman.h"
-#include "old/terrain.h"
+#include "graphics/engine/terrain.h"
#include "script/cmdtoken.h"
-
+#include <stdio.h>
+#include <string.h>
// Object's constructor.
@@ -72,10 +72,10 @@ void CAutoNest::Init()
m_speed = 1.0f/4.0f;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
- pos = m_object->RetPosition(0);
- m_terrain->MoveOnFloor(pos);
+ pos = m_object->GetPosition(0);
+ m_terrain->AdjustToFloor(pos);
m_fretPos = pos;
}
@@ -88,8 +88,8 @@ bool CAutoNest::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
@@ -154,10 +154,10 @@ bool CAutoNest::SearchFree(Math::Vector pos)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_NEST ) continue;
j = 0;
@@ -199,15 +199,15 @@ CObject* CAutoNest::SearchFret()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetLock() ) continue;
+ if ( !pObj->GetLock() ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_BULLET ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
if ( oPos.x == m_fretPos.x &&
oPos.z == m_fretPos.z )
{
@@ -219,9 +219,9 @@ CObject* CAutoNest::SearchFret()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoNest::RetError()
+Error CAutoNest::GetError()
{
return ERR_OK;
}
@@ -263,11 +263,11 @@ bool CAutoNest::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoNestPhase)OpInt(line, "aPhase", ANP_WAIT);
+ m_phase = static_cast< AutoNestPhase >(OpInt(line, "aPhase", ANP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/autonest.h b/src/object/auto/autonest.h
index 612551d..1009457 100644
--- a/src/object/auto/autonest.h
+++ b/src/object/auto/autonest.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -41,7 +42,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool Write(char *line);
bool Read(char *line);
@@ -55,7 +56,7 @@ protected:
AutoNestPhase m_phase;
float m_progress;
float m_speed;
- float m_lastParticule;
- Math::Vector m_fretPos;
+ float m_lastParticle;
+ Math::Vector m_fretPos;
};
diff --git a/src/object/auto/autonuclear.cpp b/src/object/auto/autonuclear.cpp
index 05f0b29..bb20dde 100644
--- a/src/object/auto/autonuclear.cpp
+++ b/src/object/auto/autonuclear.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autonuclear.h"
#include "common/iman.h"
@@ -26,6 +25,8 @@
#include "ui/window.h"
#include "ui/displaytext.h"
+#include <stdio.h>
+#include <string.h>
const float NUCLEAR_DELAY = 30.0f; // duration of the generation
@@ -84,9 +85,9 @@ void CAutoNuclear::Init()
m_time = 0.0f;
m_timeVirus = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
m_pos = Math::Transform(*mat, Math::Vector(22.0f, 4.0f, 0.0f));
m_phase = ANUP_WAIT; // waiting ...
@@ -110,13 +111,13 @@ bool CAutoNuclear::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
@@ -146,7 +147,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
InitProgressTotal(1.5f+NUCLEAR_DELAY+1.5f);
UpdateInterface();
- m_sound->Play(SOUND_OPEN, m_object->RetPosition(0), 1.0f, 1.4f);
+ m_sound->Play(SOUND_OPEN, m_object->GetPosition(0), 1.0f, 1.4f);
m_phase = ANUP_CLOSE;
m_progress = 0.0f;
@@ -166,8 +167,8 @@ bool CAutoNuclear::EventProcess(const Event &event)
{
m_object->SetAngleZ(1, 0.0f);
- mat = m_object->RetWorldMatrix(0);
- max = (int)(10.0f*m_engine->RetParticuleDensity());
+ mat = m_object->GetWorldMatrix(0);
+ max = static_cast< int >(10.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<max ; i++ )
{
pos.x = 27.0f;
@@ -179,12 +180,12 @@ bool CAutoNuclear::EventProcess(const Event &event)
speed.z = 0.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH);
}
- m_sound->Play(SOUND_CLOSE, m_object->RetPosition(0), 1.0f, 1.0f);
+ m_sound->Play(SOUND_CLOSE, m_object->GetPosition(0), 1.0f, 1.0f);
- m_channelSound = m_sound->Play(SOUND_NUCLEAR, m_object->RetPosition(0), 1.0f, 0.1f, true);
+ m_channelSound = m_sound->Play(SOUND_NUCLEAR, m_object->GetPosition(0), 1.0f, 0.1f, true);
m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, NUCLEAR_DELAY-1.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_channelSound, 0.0f, 1.0f, 2.0f, SOPER_STOP);
@@ -198,11 +199,11 @@ bool CAutoNuclear::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.10f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.10f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 30.0f;
pos.x += (Math::Rand()-0.5f)*6.0f;
pos.z += (Math::Rand()-0.5f)*6.0f;
@@ -211,7 +212,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
speed.z = 0.0f;
dim.x = Math::Rand()*8.0f+8.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH);
pos = m_pos;
speed.x = (Math::Rand()-0.5f)*20.0f;
@@ -219,7 +220,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
speed.z = (Math::Rand()-0.5f)*20.0f;
dim.x = 2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLITZ, 1.0f, 0.0f, 0.0f);
}
}
else
@@ -234,7 +235,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
CreatePower(); // creates the atomic cell
- max = (int)(20.0f*m_engine->RetParticuleDensity());
+ max = static_cast< int >(20.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<max ; i++ )
{
pos = m_pos;
@@ -246,10 +247,10 @@ bool CAutoNuclear::EventProcess(const Event &event)
speed.z = 0.0f;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, Math::Rand()*5.0f+5.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLUE, Math::Rand()*5.0f+5.0f, 0.0f, 0.0f);
}
- m_sound->Play(SOUND_OPEN, m_object->RetPosition(0), 1.0f, 1.4f);
+ m_sound->Play(SOUND_OPEN, m_object->GetPosition(0), 1.0f, 1.4f);
m_phase = ANUP_OPEN;
m_progress = 0.0f;
@@ -287,7 +288,7 @@ bool CAutoNuclear::EventProcess(const Event &event)
bool CAutoNuclear::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -295,7 +296,7 @@ bool CAutoNuclear::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -319,9 +320,9 @@ CObject* CAutoNuclear::SearchUranium()
{
CObject* pObj;
- pObj = m_object->RetPower();
+ pObj = m_object->GetPower();
if ( pObj == 0 ) return 0;
- if ( pObj->RetType() == OBJECT_URANIUM ) return pObj;
+ if ( pObj->GetType() == OBJECT_URANIUM ) return pObj;
return 0;
}
@@ -337,10 +338,10 @@ bool CAutoNuclear::SearchVehicle()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_HUMAN &&
type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
@@ -392,8 +393,8 @@ void CAutoNuclear::CreatePower()
Math::Vector pos;
float angle;
- pos = m_object->RetPosition(0);
- angle = m_object->RetAngleY(0);
+ pos = m_object->GetPosition(0);
+ angle = m_object->GetAngleY(0);
power = new CObject(m_iMan);
if ( !power->CreateResource(pos, angle, OBJECT_ATOMIC) )
@@ -409,28 +410,28 @@ void CAutoNuclear::CreatePower()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoNuclear::RetError()
+Error CAutoNuclear::GetError()
{
CObject* pObj;
ObjectType type;
//? TerrainRes res;
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
-//? res = m_terrain->RetResource(m_object->RetPosition(0));
+//? res = m_terrain->GetResource(m_object->GetPosition(0));
//? if ( res != TR_POWER ) return ERR_NUCLEAR_NULL;
-//? if ( m_object->RetEnergy() < ENERGY_POWER ) return ERR_NUCLEAR_LOW;
+//? if ( m_object->GetEnergy() < ENERGY_POWER ) return ERR_NUCLEAR_LOW;
- pObj = m_object->RetPower();
+ pObj = m_object->GetPower();
if ( pObj == 0 ) return ERR_NUCLEAR_EMPTY;
- if ( pObj->RetLock() ) return ERR_OK;
- type = pObj->RetType();
+ if ( pObj->GetLock() ) return ERR_OK;
+ type = pObj->GetType();
if ( type == OBJECT_ATOMIC ) return ERR_OK;
if ( type != OBJECT_URANIUM ) return ERR_NUCLEAR_BAD;
@@ -472,11 +473,11 @@ bool CAutoNuclear::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoNuclearPhase)OpInt(line, "aPhase", ANUP_WAIT);
+ m_phase = static_cast< AutoNuclearPhase >(OpInt(line, "aPhase", ANUP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/autonuclear.h b/src/object/auto/autonuclear.h
index 8a4b0da..06a99af 100644
--- a/src/object/auto/autonuclear.h
+++ b/src/object/auto/autonuclear.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -44,7 +45,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -61,7 +62,7 @@ protected:
float m_progress;
float m_speed;
float m_timeVirus;
- float m_lastParticule;
+ float m_lastParticle;
Math::Vector m_pos;
int m_channelSound;
};
diff --git a/src/object/auto/autopara.cpp b/src/object/auto/autopara.cpp
index 80ce90a..b52344f 100644
--- a/src/object/auto/autopara.cpp
+++ b/src/object/auto/autopara.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autopara.h"
@@ -26,6 +25,8 @@
#include "ui/interface.h"
#include "ui/window.h"
+#include <stdio.h>
+#include <string.h>
@@ -68,9 +69,9 @@ void CAutoPara::Init()
m_time = 0.0f;
m_timeVirus = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
m_pos = Math::Transform(*mat, Math::Vector(22.0f, 4.0f, 0.0f));
m_phase = APAP_WAIT; // waiting ...
@@ -83,9 +84,9 @@ void CAutoPara::Init()
// Reception of lightning.
-void CAutoPara::StartBlitz()
+void CAutoPara::StartLightning()
{
- m_phase = APAP_BLITZ;
+ m_phase = APAP_LIGHTNING;
m_progress = 0.0f;
m_speed = 1.0f/2.0f;
}
@@ -101,13 +102,13 @@ bool CAutoPara::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
@@ -118,17 +119,17 @@ bool CAutoPara::EventProcess(const Event &event)
EventProgress(event.rTime);
- if ( m_phase == APAP_BLITZ )
+ if ( m_phase == APAP_LIGHTNING )
{
if ( m_progress < 1.0f )
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
for ( i=0 ; i<10 ; i++ )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*m_progress*40.0f;
pos.z += (Math::Rand()-0.5f)*m_progress*40.0f;
pos.y += 50.0f-m_progress*50.0f;
@@ -137,7 +138,7 @@ bool CAutoPara::EventProcess(const Event &event)
speed.y = 5.0f+Math::Rand()*5.0f;
dim.x = 2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 1.0f, 20.0f, 0.5f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLITZ, 1.0f, 20.0f, 0.5f);
}
}
}
@@ -153,20 +154,20 @@ bool CAutoPara::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
for ( i=0 ; i<2 ; i++ )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 16.0f;
speed.x = (Math::Rand()-0.5f)*10.0f;
speed.z = (Math::Rand()-0.5f)*10.0f;
speed.y = -Math::Rand()*30.0f;
dim.x = 1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLITZ, 1.0f, 0.0f, 0.0f);
}
}
@@ -188,7 +189,7 @@ bool CAutoPara::EventProcess(const Event &event)
bool CAutoPara::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -196,7 +197,7 @@ bool CAutoPara::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -220,11 +221,11 @@ bool CAutoPara::CreateInterface(bool bSelect)
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoPara::RetError()
+Error CAutoPara::GetError()
{
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
@@ -242,38 +243,38 @@ void CAutoPara::ChargeObject(float rTime)
float dist, energy;
int i;
- sPos = m_object->RetPosition(0);
+ sPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, sPos);
if ( dist > 20.0f ) continue;
- if ( pObj->RetTruck() == 0 && pObj->RetType() == OBJECT_POWER )
+ if ( pObj->GetTruck() == 0 && pObj->GetType() == OBJECT_POWER )
{
- energy = pObj->RetEnergy();
+ energy = pObj->GetEnergy();
energy += rTime/2.0f;
if ( energy > 1.0f ) energy = 1.0f;
pObj->SetEnergy(energy);
}
- power = pObj->RetPower();
- if ( power != 0 && power->RetType() == OBJECT_POWER )
+ power = pObj->GetPower();
+ if ( power != 0 && power->GetType() == OBJECT_POWER )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
energy += rTime/2.0f;
if ( energy > 1.0f ) energy = 1.0f;
power->SetEnergy(energy);
}
- power = pObj->RetFret();
- if ( power != 0 && power->RetType() == OBJECT_POWER )
+ power = pObj->GetFret();
+ if ( power != 0 && power->GetType() == OBJECT_POWER )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
energy += rTime/2.0f;
if ( energy > 1.0f ) energy = 1.0f;
power->SetEnergy(energy);
@@ -315,11 +316,11 @@ bool CAutoPara::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoParaPhase)OpInt(line, "aPhase", APAP_WAIT);
+ m_phase = static_cast< AutoParaPhase >(OpInt(line, "aPhase", APAP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/autopara.h b/src/object/auto/autopara.h
index b230fd2..10a33a8 100644
--- a/src/object/auto/autopara.h
+++ b/src/object/auto/autopara.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -26,7 +27,7 @@
enum AutoParaPhase
{
APAP_WAIT = 1,
- APAP_BLITZ = 2,
+ APAP_LIGHTNING = 2,
APAP_CHARGE = 3,
};
@@ -42,8 +43,8 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
- void StartBlitz();
+ Error GetError();
+ void StartLightning();
bool CreateInterface(bool bSelect);
@@ -58,7 +59,7 @@ protected:
float m_progress;
float m_speed;
float m_timeVirus;
- float m_lastParticule;
+ float m_lastParticle;
Math::Vector m_pos;
int m_channelSound;
};
diff --git a/src/object/auto/autoportico.cpp b/src/object/auto/autoportico.cpp
index 5665556..9d04982 100644
--- a/src/object/auto/autoportico.cpp
+++ b/src/object/auto/autoportico.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,14 +16,13 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoportico.h"
#include "object/robotmain.h"
-
+#include <stdio.h>
+#include <string.h>
const int PARAM_DEPOSE = 2; // run=2 -> deposits the spaceship
@@ -90,7 +90,7 @@ void CAutoPortico::DeleteObject(bool bAll)
void CAutoPortico::Init()
{
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_posTrack = 0.0f;
m_phase = APOP_WAIT;
@@ -108,7 +108,7 @@ void CAutoPortico::Start(int param)
{
Math::Vector pos;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_finalPos = pos;
pos.z += PORTICO_TIME_MOVE*5.0f; // back to start
m_object->SetPosition(0, pos);
@@ -140,15 +140,15 @@ bool CAutoPortico::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
if ( m_phase == APOP_START )
{
if ( m_param == PARAM_DEPOSE ) // deposits the ship?
{
- m_startPos = m_object->RetPosition(0);
+ m_startPos = m_object->GetPosition(0);
- m_soundChannel = m_sound->Play(SOUND_MOTORr, m_object->RetPosition(0), 0.0f, 0.3f, true);
+ m_soundChannel = m_sound->Play(SOUND_MOTORr, m_object->GetPosition(0), 0.0f, 0.3f, true);
m_sound->AddEnvelope(m_soundChannel, 0.5f, 0.6f, 0.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.5f, 0.6f, PORTICO_TIME_MOVE-0.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.3f, 0.5f, SOPER_STOP);
@@ -159,7 +159,7 @@ bool CAutoPortico::EventProcess(const Event &event)
m_main->SetMovieLock(true); // blocks everything until the end of the landing
- m_camera->SetType(CAMERA_SCRIPT);
+ m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
pos = m_startPos;
pos.x += -100.0f;
@@ -167,7 +167,7 @@ bool CAutoPortico::EventProcess(const Event &event)
pos.z += -200.0f;
m_camera->SetScriptEye(pos);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += 0.0f;
pos.y += 10.0f;
pos.z += -40.0f;
@@ -187,7 +187,7 @@ bool CAutoPortico::EventProcess(const Event &event)
angle = sinf(m_time*4.0f)*0.3f;
m_object->SetAngleX(11, angle);
- if ( event.event != EVENT_FRAME ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_phase == APOP_WAIT ) return true;
m_progress += event.rTime*m_speed;
@@ -197,7 +197,7 @@ bool CAutoPortico::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.z -= event.rTime*5.0f; // advance
m_object->SetPosition(0, pos);
@@ -216,7 +216,7 @@ bool CAutoPortico::EventProcess(const Event &event)
{
if ( m_progress >= 1.0f )
{
- m_soundChannel = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f, true);
+ m_soundChannel = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f, true);
m_sound->AddEnvelope(m_soundChannel, 0.3f, 0.5f, 1.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.3f, 0.6f, PORTICO_TIME_DOWN-1.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.3f, 1.0f, SOPER_STOP);
@@ -253,12 +253,12 @@ bool CAutoPortico::EventProcess(const Event &event)
{
if ( m_progress >= 1.0f )
{
- m_soundChannel = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.5f, true);
+ m_soundChannel = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.5f, true);
m_sound->AddEnvelope(m_soundChannel, 0.5f, 1.0f, 0.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.5f, 1.0f, PORTICO_TIME_OPEN/2.0f-0.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.5f, 0.5f, SOPER_STOP);
- m_soundChannel = m_sound->Play(SOUND_MOTORr, m_object->RetPosition(0), 0.0f, 0.3f, true);
+ m_soundChannel = m_sound->Play(SOUND_MOTORr, m_object->GetPosition(0), 0.0f, 0.3f, true);
m_sound->AddEnvelope(m_soundChannel, 0.5f, 0.6f, 0.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.5f, 0.6f, PORTICO_TIME_OPEN-0.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.3f, 0.5f, SOPER_STOP);
@@ -273,7 +273,7 @@ bool CAutoPortico::EventProcess(const Event &event)
{
if ( m_progress < 1.0f )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.z += event.rTime*5.3f; // back
m_object->SetPosition(0, pos);
@@ -308,8 +308,8 @@ bool CAutoPortico::EventProcess(const Event &event)
pObj = m_main->SearchHuman();
m_main->SelectObject(pObj);
- m_camera->SetObject(pObj);
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetControllingObject(pObj);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
m_phase = APOP_WAIT;
m_progress = 0.0f;
@@ -319,8 +319,8 @@ bool CAutoPortico::EventProcess(const Event &event)
if ( m_soundChannel != -1 )
{
-//? m_sound->Position(m_soundChannel, m_object->RetPosition(0));
- pos = m_engine->RetEyePt();
+//? m_sound->Position(m_soundChannel, m_object->GetPosition(0));
+ pos = m_engine->GetEyePt();
m_sound->Position(m_soundChannel, pos);
}
@@ -338,7 +338,7 @@ bool CAutoPortico::EventProcess(const Event &event)
m_camera->SetScriptEye(pos);
}
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += 0.0f;
pos.y += 10.0f;
pos.z += -40.0f;
@@ -367,8 +367,8 @@ bool CAutoPortico::Abort()
pObj = m_main->SearchHuman();
m_main->SelectObject(pObj);
- m_camera->SetObject(pObj);
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetControllingObject(pObj);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
if ( m_soundChannel != -1 )
{
@@ -385,9 +385,9 @@ bool CAutoPortico::Abort()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoPortico::RetError()
+Error CAutoPortico::GetError()
{
return ERR_OK;
}
@@ -397,11 +397,11 @@ Error CAutoPortico::RetError()
void CAutoPortico::UpdateTrackMapping(float left, float right)
{
- D3DMATERIAL7 mat;
+ Gfx::Material mat;
float limit[2];
int rank;
- ZeroMemory( &mat, sizeof(D3DMATERIAL7) );
+ memset( &mat, 0, sizeof(Gfx::Material));
mat.diffuse.r = 1.0f;
mat.diffuse.g = 1.0f;
mat.diffuse.b = 1.0f; // blank
@@ -409,17 +409,17 @@ void CAutoPortico::UpdateTrackMapping(float left, float right)
mat.ambient.g = 0.5f;
mat.ambient.b = 0.5f;
- rank = m_object->RetObjectRank(0);
+ rank = m_object->GetObjectRank(0);
limit[0] = 0.0f;
limit[1] = 1000000.0f;
- m_engine->TrackTextureMapping(rank, mat, D3DSTATEPART1, "lemt.tga", "",
- limit[0], limit[1], D3DMAPPINGX,
+ m_engine->TrackTextureMapping(rank, mat, Gfx::ENG_RSTATE_PART1, "lemt.png", "",
+ limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
right, 8.0f, 8.0f, 192.0f, 256.0f);
- m_engine->TrackTextureMapping(rank, mat, D3DSTATEPART2, "lemt.tga", "",
- limit[0], limit[1], D3DMAPPINGX,
+ m_engine->TrackTextureMapping(rank, mat, Gfx::ENG_RSTATE_PART2, "lemt.png", "",
+ limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
left, 8.0f, 8.0f, 192.0f, 256.0f);
}
diff --git a/src/object/auto/autoportico.h b/src/object/auto/autoportico.h
index f2cd6d1..c211d37 100644
--- a/src/object/auto/autoportico.h
+++ b/src/object/auto/autoportico.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -48,7 +49,7 @@ public:
void Start(int param);
bool EventProcess(const Event &event);
bool Abort();
- Error RetError();
+ Error GetError();
protected:
void UpdateTrackMapping(float left, float right);
@@ -59,7 +60,7 @@ protected:
float m_speed;
float m_cameraProgress;
float m_cameraSpeed;
- float m_lastParticule;
+ float m_lastParticle;
Math::Vector m_finalPos;
Math::Vector m_startPos;
float m_posTrack;
diff --git a/src/object/auto/autoradar.cpp b/src/object/auto/autoradar.cpp
index 1cb20d6..b586521 100644
--- a/src/object/auto/autoradar.cpp
+++ b/src/object/auto/autoradar.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoradar.h"
#include "common/iman.h"
@@ -25,6 +24,8 @@
#include "ui/window.h"
#include "ui/gauge.h"
+#include <stdio.h>
+
// Object's constructor.
@@ -74,31 +75,31 @@ bool CAutoRadar::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_phase == ARAP_WAIT ) return true;
m_progress += event.rTime*m_speed;
m_aTime += event.rTime;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
m_timeVirus = 0.1f+Math::Rand()*0.3f;
- angle = m_object->RetAngleY(1);
+ angle = m_object->GetAngleY(1);
angle += (Math::Rand()-0.2f)*0.5f;
m_object->SetAngleY(1, angle);
- angle = m_object->RetAngleY(2);
+ angle = m_object->GetAngleY(2);
angle += (Math::Rand()-0.8f)*1.0f;
m_object->SetAngleY(2, angle);
m_object->SetAngleX(3, (Math::Rand()-0.5f)*0.3f);
- m_totalDetect = (int)(Math::Rand()*10.0f);
+ m_totalDetect = static_cast< int >(Math::Rand()*10.0f);
UpdateInterface();
}
return true;
@@ -109,7 +110,7 @@ bool CAutoRadar::EventProcess(const Event &event)
if ( m_progress < 1.0f )
{
speed = Math::Min(10.0f, m_progress*50.0f);
- angle = m_object->RetAngleY(1);
+ angle = m_object->GetAngleY(1);
angle += event.rTime*speed;
m_object->SetAngleY(1, angle);
}
@@ -123,11 +124,11 @@ bool CAutoRadar::EventProcess(const Event &event)
}
else
{
- pos = m_object->RetPosition(0);
- m_start = m_object->RetAngleY(1);
+ pos = m_object->GetPosition(0);
+ m_start = m_object->GetAngleY(1);
m_angle = m_start-Math::NormAngle(m_start)+Math::PI*2.0f;
m_angle += Math::RotateAngle(pos.x-ePos.x, ePos.z-pos.z);
- m_angle += Math::PI-m_object->RetAngleY(0);
+ m_angle += Math::PI-m_object->GetAngleY(0);
m_phase = ARAP_SHOW;
m_progress = 0.0f;
@@ -145,7 +146,7 @@ bool CAutoRadar::EventProcess(const Event &event)
}
else
{
- m_sound->Play(SOUND_RADAR, m_object->RetPosition(0));
+ m_sound->Play(SOUND_RADAR, m_object->GetPosition(0));
m_phase = ARAP_SINUS;
m_progress = 0.0f;
@@ -182,11 +183,11 @@ bool CAutoRadar::EventProcess(const Event &event)
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoRadar::RetError()
+Error CAutoRadar::GetError()
{
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
@@ -199,7 +200,7 @@ Error CAutoRadar::RetError()
bool CAutoRadar::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
@@ -207,7 +208,7 @@ bool CAutoRadar::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -235,21 +236,21 @@ bool CAutoRadar::CreateInterface(bool bSelect)
void CAutoRadar::UpdateInterface()
{
- CWindow* pw;
- CGauge* pg;
+ Ui::CWindow* pw;
+ Ui::CGauge* pg;
float level;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
CAuto::UpdateInterface();
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GRADAR);
+ pg = static_cast< Ui::CGauge* >(pw->SearchControl(EVENT_OBJECT_GRADAR));
if ( pg != 0 )
{
- level = (float)m_totalDetect*(1.0f/8.0f);
+ level = static_cast< float >(m_totalDetect*(1.0f/8.0f));
if ( level > 1.0f ) level = 1.0f;
pg->SetLevel(level);
}
@@ -267,18 +268,18 @@ bool CAutoRadar::SearchEnemy(Math::Vector &pos)
float distance, min;
int i;
- iPos = m_object->RetPosition(0);
+ iPos = m_object->GetPosition(0);
min = 1000000.0f;
m_totalDetect = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetActif() ) continue;
+ if ( !pObj->GetActif() ) continue;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType != OBJECT_ANT &&
oType != OBJECT_SPIDER &&
oType != OBJECT_BEE &&
@@ -287,7 +288,7 @@ bool CAutoRadar::SearchEnemy(Math::Vector &pos)
m_totalDetect ++;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
distance = Math::Distance(oPos, iPos);
if ( distance < min )
{
@@ -299,7 +300,7 @@ bool CAutoRadar::SearchEnemy(Math::Vector &pos)
UpdateInterface();
if ( pBest == 0 ) return false;
- pos = pBest->RetPosition(0);
+ pos = pBest->GetPosition(0);
return true;
}
diff --git a/src/object/auto/autoradar.h b/src/object/auto/autoradar.h
index 8b38ff9..e2c9df5 100644
--- a/src/object/auto/autoradar.h
+++ b/src/object/auto/autoradar.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -44,7 +45,7 @@ public:
void Init();
bool EventProcess(const Event &event);
bool CreateInterface(bool bSelect);
- Error RetError();
+ Error GetError();
protected:
void UpdateInterface();
@@ -56,7 +57,7 @@ protected:
float m_speed;
float m_aTime;
float m_timeVirus;
- float m_lastParticule;
+ float m_lastParticle;
float m_angle;
float m_start;
int m_totalDetect;
diff --git a/src/object/auto/autorepair.cpp b/src/object/auto/autorepair.cpp
index ad5deee..4662699 100644
--- a/src/object/auto/autorepair.cpp
+++ b/src/object/auto/autorepair.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autorepair.h"
#include "common/iman.h"
@@ -25,6 +24,9 @@
#include "ui/interface.h"
#include "ui/window.h"
+#include <stdio.h>
+#include <string.h>
+
// Object's constructor.
@@ -60,7 +62,7 @@ void CAutoRepair::Init()
m_time = 0.0f;
m_timeVirus = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
CAuto::Init();
}
@@ -77,13 +79,13 @@ bool CAutoRepair::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
@@ -104,7 +106,7 @@ bool CAutoRepair::EventProcess(const Event &event)
}
else
{
- m_sound->Play(SOUND_OPEN, m_object->RetPosition(0), 1.0f, 0.8f);
+ m_sound->Play(SOUND_OPEN, m_object->GetPosition(0), 1.0f, 0.8f);
m_phase = ARP_DOWN;
m_progress = 0.0f;
@@ -123,7 +125,7 @@ bool CAutoRepair::EventProcess(const Event &event)
else
{
m_object->SetAngleZ(1, 0.0f);
- m_sound->Play(SOUND_REPAIR, m_object->RetPosition(0));
+ m_sound->Play(SOUND_REPAIR, m_object->GetPosition(0));
m_phase = ARP_REPAIR;
m_progress = 0.0f;
@@ -135,21 +137,21 @@ bool CAutoRepair::EventProcess(const Event &event)
{
vehicule = SearchVehicle();
if ( m_progress < 1.0f ||
- (vehicule != 0 && vehicule->RetShield() < 1.0f) )
+ (vehicule != 0 && vehicule->GetShield() < 1.0f) )
{
if ( vehicule != 0 )
{
- shield = vehicule->RetShield();
+ shield = vehicule->GetShield();
shield += event.rTime*0.2f;
if ( shield > 1.0f ) shield = 1.0f;
vehicule->SetShield(shield);
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*5.0f;
pos.z += (Math::Rand()-0.5f)*5.0f;
pos.y += 1.0f;
@@ -158,12 +160,12 @@ bool CAutoRepair::EventProcess(const Event &event)
speed.y = Math::Rand()*15.0f;
dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLUE, 1.0f, 0.0f, 0.0f);
}
}
else
{
- m_sound->Play(SOUND_OPEN, m_object->RetPosition(0), 1.0f, 0.8f);
+ m_sound->Play(SOUND_OPEN, m_object->GetPosition(0), 1.0f, 0.8f);
m_phase = ARP_UP;
m_progress = 0.0f;
@@ -196,7 +198,7 @@ bool CAutoRepair::EventProcess(const Event &event)
bool CAutoRepair::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -204,7 +206,7 @@ bool CAutoRepair::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -233,14 +235,14 @@ CObject* CAutoRepair::SearchVehicle()
float dist;
int i;
- sPos = m_object->RetPosition(0);
+ sPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
type != OBJECT_MOBILEwa &&
@@ -269,10 +271,10 @@ CObject* CAutoRepair::SearchVehicle()
type != OBJECT_MOBILEit &&
type != OBJECT_MOBILEdr ) continue;
- physics = pObj->RetPhysics();
- if ( physics != 0 && !physics->RetLand() ) continue; // in flight?
+ physics = pObj->GetPhysics();
+ if ( physics != 0 && !physics->GetLand() ) continue; // in flight?
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, sPos);
if ( dist <= 5.0f ) return pObj;
}
@@ -281,11 +283,11 @@ CObject* CAutoRepair::SearchVehicle()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoRepair::RetError()
+Error CAutoRepair::GetError()
{
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
@@ -327,11 +329,11 @@ bool CAutoRepair::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoRepairPhase)OpInt(line, "aPhase", ARP_WAIT);
+ m_phase = static_cast< AutoRepairPhase >(OpInt(line, "aPhase", ARP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/autorepair.h b/src/object/auto/autorepair.h
index 1279ba3..e8bb0b1 100644
--- a/src/object/auto/autorepair.h
+++ b/src/object/auto/autorepair.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -44,7 +45,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -59,7 +60,7 @@ protected:
float m_progress;
float m_speed;
float m_timeVirus;
- float m_lastParticule;
+ float m_lastParticle;
};
diff --git a/src/object/auto/autoresearch.cpp b/src/object/auto/autoresearch.cpp
index 410e6ac..a3ce464 100644
--- a/src/object/auto/autoresearch.cpp
+++ b/src/object/auto/autoresearch.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoresearch.h"
#include "common/global.h"
@@ -28,6 +27,8 @@
#include "ui/window.h"
#include "ui/displaytext.h"
+#include <stdio.h>
+#include <string.h>
const float SEARCH_TIME = 30.0f; // duration of a research
@@ -84,7 +85,7 @@ void CAutoResearch::Init()
m_time = 0.0f;
m_timeVirus = 0.0f;
m_lastUpdateTime = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
}
@@ -100,29 +101,29 @@ bool CAutoResearch::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
- if ( event.event == EVENT_UPDINTERFACE )
+ if ( event.type == EVENT_UPDINTERFACE )
{
- if ( m_object->RetSelect() ) CreateInterface(true);
+ if ( m_object->GetSelect() ) CreateInterface(true);
}
- if ( m_object->RetSelect() && // center selected?
- (event.event == EVENT_OBJECT_RTANK ||
- event.event == EVENT_OBJECT_RFLY ||
- event.event == EVENT_OBJECT_RTHUMP ||
- event.event == EVENT_OBJECT_RCANON ||
- event.event == EVENT_OBJECT_RTOWER ||
- event.event == EVENT_OBJECT_RPHAZER ||
- event.event == EVENT_OBJECT_RSHIELD ||
- event.event == EVENT_OBJECT_RATOMIC ) )
+ if ( m_object->GetSelect() && // center selected?
+ (event.type == EVENT_OBJECT_RTANK ||
+ event.type == EVENT_OBJECT_RFLY ||
+ event.type == EVENT_OBJECT_RTHUMP ||
+ event.type == EVENT_OBJECT_RCANON ||
+ event.type == EVENT_OBJECT_RTOWER ||
+ event.type == EVENT_OBJECT_RPHAZER ||
+ event.type == EVENT_OBJECT_RSHIELD ||
+ event.type == EVENT_OBJECT_RATOMIC ) )
{
if ( m_phase != ALP_WAIT )
{
return false;
}
- m_research = event.event;
+ m_research = event.type;
if ( TestResearch(m_research) )
{
@@ -130,33 +131,33 @@ bool CAutoResearch::EventProcess(const Event &event)
return false;
}
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 )
{
m_displayText->DisplayError(ERR_RESEARCH_POWER, m_object);
return false;
}
- if ( power->RetCapacity() > 1.0f )
+ if ( power->GetCapacity() > 1.0f )
{
m_displayText->DisplayError(ERR_RESEARCH_TYPE, m_object);
return false;
}
- if ( power->RetEnergy() < 1.0f )
+ if ( power->GetEnergy() < 1.0f )
{
m_displayText->DisplayError(ERR_RESEARCH_ENERGY, m_object);
return false;
}
time = SEARCH_TIME;
- if ( event.event == EVENT_OBJECT_RTANK ) time *= 0.3f;
- if ( event.event == EVENT_OBJECT_RFLY ) time *= 0.3f;
- if ( event.event == EVENT_OBJECT_RATOMIC ) time *= 2.0f;
+ if ( event.type == EVENT_OBJECT_RTANK ) time *= 0.3f;
+ if ( event.type == EVENT_OBJECT_RFLY ) time *= 0.3f;
+ if ( event.type == EVENT_OBJECT_RATOMIC ) time *= 2.0f;
SetBusy(true);
InitProgressTotal(time);
UpdateInterface();
- m_channelSound = m_sound->Play(SOUND_RESEARCH, m_object->RetPosition(0), 0.0f, 1.0f, true);
+ m_channelSound = m_sound->Play(SOUND_RESEARCH, m_object->GetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, 2.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_channelSound, 1.0f, 1.0f, time-4.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_channelSound, 0.0f, 1.0f, 2.0f, SOPER_STOP);
@@ -167,12 +168,12 @@ bool CAutoResearch::EventProcess(const Event &event)
return true;
}
- if ( event.event != EVENT_FRAME ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
@@ -201,7 +202,7 @@ bool CAutoResearch::EventProcess(const Event &event)
FireStopUpdate(m_progress, true); // flashes
if ( m_progress < 1.0f )
{
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 ) // more battery?
{
SetBusy(false);
@@ -214,11 +215,11 @@ bool CAutoResearch::EventProcess(const Event &event)
}
power->SetEnergy(1.0f-m_progress);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*6.0f;
pos.z += (Math::Rand()-0.5f)*6.0f;
pos.y += 11.0f;
@@ -227,7 +228,7 @@ bool CAutoResearch::EventProcess(const Event &event)
speed.y = Math::Rand()*20.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIVAPOR);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIVAPOR);
}
}
else
@@ -262,9 +263,9 @@ bool CAutoResearch::EventProcess(const Event &event)
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoResearch::RetError()
+Error CAutoResearch::GetError()
{
CObject* power;
@@ -273,21 +274,21 @@ Error CAutoResearch::RetError()
return ERR_OK;
}
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 )
{
return ERR_RESEARCH_POWER;
}
- if ( power != 0 && power->RetCapacity() > 1.0f )
+ if ( power != 0 && power->GetCapacity() > 1.0f )
{
return ERR_RESEARCH_TYPE;
}
- if ( power != 0 && power->RetEnergy() < 1.0f )
+ if ( power != 0 && power->GetEnergy() < 1.0f )
{
return ERR_RESEARCH_ENERGY;
}
@@ -300,7 +301,7 @@ Error CAutoResearch::RetError()
bool CAutoResearch::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
@@ -308,7 +309,7 @@ bool CAutoResearch::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
dim.x = 33.0f/640.0f;
@@ -371,13 +372,13 @@ bool CAutoResearch::CreateInterface(bool bSelect)
void CAutoResearch::UpdateInterface()
{
- CWindow* pw;
+ Ui::CWindow* pw;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
CAuto::UpdateInterface();
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
DeadInterface(pw, EVENT_OBJECT_RTANK, g_researchEnable&RESEARCH_TANK);
@@ -413,8 +414,8 @@ void CAutoResearch::UpdateInterface()
void CAutoResearch::UpdateInterface(float rTime)
{
- CWindow* pw;
- CGauge* pg;
+ Ui::CWindow* pw;
+ Ui::CGauge* pg;
CObject* power;
float energy;
@@ -423,19 +424,19 @@ void CAutoResearch::UpdateInterface(float rTime)
if ( m_time < m_lastUpdateTime+0.1f ) return;
m_lastUpdateTime = m_time;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GENERGY);
+ pg = static_cast< Ui::CGauge* >(pw->SearchControl(EVENT_OBJECT_GENERGY));
if ( pg != 0 )
{
energy = 0.0f;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
pg->SetLevel(energy);
}
@@ -443,20 +444,20 @@ void CAutoResearch::UpdateInterface(float rTime)
// Research shows already performed button.
-void CAutoResearch::OkayButton(CWindow *pw, EventMsg event)
+void CAutoResearch::OkayButton(Ui::CWindow *pw, EventType event)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
if ( control == 0 ) return;
- control->SetState(STATE_OKAY, TestResearch(event));
+ control->SetState(Ui::STATE_OKAY, TestResearch(event));
}
// Test whether a search has already been done.
-bool CAutoResearch::TestResearch(EventMsg event)
+bool CAutoResearch::TestResearch(EventType event)
{
if ( event == EVENT_OBJECT_RTANK ) return (g_researchDone & RESEARCH_TANK );
if ( event == EVENT_OBJECT_RFLY ) return (g_researchDone & RESEARCH_FLY );
@@ -472,9 +473,8 @@ bool CAutoResearch::TestResearch(EventMsg event)
// Indicates a search as made.
-void CAutoResearch::SetResearch(EventMsg event)
+void CAutoResearch::SetResearch(EventType event)
{
- Event newEvent;
if ( event == EVENT_OBJECT_RTANK ) g_researchDone |= RESEARCH_TANK;
if ( event == EVENT_OBJECT_RFLY ) g_researchDone |= RESEARCH_FLY;
@@ -487,7 +487,7 @@ void CAutoResearch::SetResearch(EventMsg event)
m_main->WriteFreeParam();
- m_event->MakeEvent(newEvent, EVENT_UPDINTERFACE);
+ Event newEvent(EVENT_UPDINTERFACE);
m_event->AddEvent(newEvent);
UpdateInterface();
}
@@ -518,14 +518,14 @@ void CAutoResearch::FireStopUpdate(float progress, bool bLightOn)
{
if ( m_partiStop[i] != -1 )
{
- m_particule->DeleteParticule(m_partiStop[i]);
+ m_particle->DeleteParticle(m_partiStop[i]);
m_partiStop[i] = -1;
}
}
return;
}
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 2.0f;
@@ -537,7 +537,7 @@ void CAutoResearch::FireStopUpdate(float progress, bool bLightOn)
{
if ( m_partiStop[i] != -1 )
{
- m_particule->DeleteParticule(m_partiStop[i]);
+ m_particle->DeleteParticle(m_partiStop[i]);
m_partiStop[i] = -1;
}
}
@@ -549,8 +549,8 @@ void CAutoResearch::FireStopUpdate(float progress, bool bLightOn)
pos.y = 11.5f;
pos.z = listpos[i*2+1];
pos = Math::Transform(*mat, pos);
- m_partiStop[i] = m_particule->CreateParticule(pos, speed,
- dim, PARTISELY,
+ m_partiStop[i] = m_particle->CreateParticle(pos, speed,
+ dim, Gfx::PARTISELY,
1.0f, 0.0f, 0.0f);
}
}
@@ -594,13 +594,13 @@ bool CAutoResearch::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoResearchPhase)OpInt(line, "aPhase", ALP_WAIT);
+ m_phase = static_cast< AutoResearchPhase >(OpInt(line, "aPhase", ALP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_research = (EventMsg)OpInt(line, "aResearch", 0);
+ m_research = static_cast< EventType >(OpInt(line, "aResearch", 0));
m_lastUpdateTime = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
diff --git a/src/object/auto/autoresearch.h b/src/object/auto/autoresearch.h
index b60f4bd..a838e64 100644
--- a/src/object/auto/autoresearch.h
+++ b/src/object/auto/autoresearch.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -41,7 +42,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -51,9 +52,9 @@ public:
protected:
void UpdateInterface();
void UpdateInterface(float rTime);
- void OkayButton(CWindow *pw, EventMsg event);
- bool TestResearch(EventMsg event);
- void SetResearch(EventMsg event);
+ void OkayButton(Ui::CWindow *pw, EventType event);
+ bool TestResearch(EventType event);
+ void SetResearch(EventType event);
void FireStopUpdate(float progress, bool bLightOn);
protected:
@@ -62,8 +63,8 @@ protected:
float m_speed;
float m_timeVirus;
float m_lastUpdateTime;
- float m_lastParticule;
- EventMsg m_research;
+ float m_lastParticle;
+ EventType m_research;
int m_partiStop[6];
int m_channelSound;
};
diff --git a/src/object/auto/autoroot.cpp b/src/object/auto/autoroot.cpp
index 9282a01..4413d56 100644
--- a/src/object/auto/autoroot.cpp
+++ b/src/object/auto/autoroot.cpp
@@ -15,15 +15,13 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autoroot.h"
-#include "old/particule.h"
-#include "old/terrain.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/terrain.h"
#include "math/geometry.h"
-
+#include <stdio.h>
// Object's constructor.
@@ -58,9 +56,9 @@ void CAutoRoot::Init()
Math::Point dim;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(-5.0f, 28.0f, -4.0f); // peak position
pos = Math::Transform(*mat, pos);
m_center = pos;
@@ -68,7 +66,7 @@ void CAutoRoot::Init()
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 100.0f;
dim.y = dim.x;
- m_particule->CreateParticule(m_center, speed, dim, PARTISPHERE5, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(m_center, speed, dim, Gfx::PARTISPHERE5, 0.5f, 0.0f, 0.0f);
m_terrain->AddFlyingLimit(pos, 100.0f, 80.0f, pos.y-60.0f);
}
@@ -83,16 +81,16 @@ bool CAutoRoot::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_object->SetZoomX(1, 1.0f+sinf(m_time*2.0f)*0.2f);
m_object->SetZoomY(1, 1.0f+sinf(m_time*2.3f)*0.2f);
m_object->SetZoomZ(1, 1.0f+sinf(m_time*2.7f)*0.2f);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.10f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.10f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_center;
pos.x += (Math::Rand()-0.5f)*8.0f;
@@ -103,16 +101,16 @@ bool CAutoRoot::EventProcess(const Event &event)
speed.y = Math::Rand()*12.0f;
dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIROOT, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIROOT, 1.0f, 0.0f, 0.0f);
}
return true;
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoRoot::RetError()
+Error CAutoRoot::GetError()
{
return ERR_OK;
}
diff --git a/src/object/auto/autoroot.h b/src/object/auto/autoroot.h
index 1ecd5ba..d80abe8 100644
--- a/src/object/auto/autoroot.h
+++ b/src/object/auto/autoroot.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -33,12 +34,12 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
protected:
protected:
- float m_lastParticule;
+ float m_lastParticle;
Math::Vector m_center;
};
diff --git a/src/object/auto/autosafe.cpp b/src/object/auto/autosafe.cpp
index 11aac18..ea0c183 100644
--- a/src/object/auto/autosafe.cpp
+++ b/src/object/auto/autosafe.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autosafe.h"
#include "common/iman.h"
@@ -26,6 +25,9 @@
#include "ui/interface.h"
#include "ui/window.h"
+#include <stdio.h>
+#include <string.h>
+
const float OPEN_DELAY = 8.0f; // duration of opening
@@ -44,7 +46,7 @@ CAutoSafe::CAutoSafe(CInstanceManager* iMan, CObject* object)
}
m_bLock = false;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_channelSound = -1;
Init();
}
@@ -86,7 +88,7 @@ void CAutoSafe::Init()
{
m_time = 0.0f;
m_timeVirus = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_countKeys = 0;
m_actualAngle = 0.0f;
@@ -111,13 +113,13 @@ bool CAutoSafe::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
@@ -158,7 +160,7 @@ bool CAutoSafe::EventProcess(const Event &event)
{
LockKeys();
- m_channelSound = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 1.0f, 0.25f, true);
+ m_channelSound = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 1.0f, 0.25f, true);
m_sound->AddEnvelope(m_channelSound, 1.0f, 2.00f, OPEN_DELAY, SOPER_STOP);
m_phase = ASAP_OPEN;
@@ -168,7 +170,7 @@ bool CAutoSafe::EventProcess(const Event &event)
}
else
{
- m_channelSound = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 1.0f, 0.25f, true);
+ m_channelSound = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 1.0f, 0.25f, true);
m_sound->AddEnvelope(m_channelSound, 1.0f, 0.35f, 0.5f, SOPER_STOP);
}
}
@@ -185,13 +187,13 @@ bool CAutoSafe::EventProcess(const Event &event)
{
DownKeys(m_progress);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
for ( i=0 ; i<10 ; i++ )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*10.0f;
pos.z += (Math::Rand()-0.5f)*10.0f;
speed.x = (Math::Rand()-0.5f)*4.0f;
@@ -199,10 +201,10 @@ bool CAutoSafe::EventProcess(const Event &event)
speed.y = Math::Rand()*15.0f;
dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLUE, 1.0f, 0.0f, 0.0f);
}
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*10.0f;
pos.z += (Math::Rand()-0.5f)*10.0f;
speed.x = (Math::Rand()-0.5f)*4.0f;
@@ -210,7 +212,7 @@ bool CAutoSafe::EventProcess(const Event &event)
speed.y = Math::Rand()*10.0f;
dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGLINT, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINT, 1.0f, 0.0f, 0.0f);
for ( i=0 ; i<4 ; i++ )
{
@@ -220,7 +222,7 @@ bool CAutoSafe::EventProcess(const Event &event)
speed.y = 1.0f+Math::Rand()*1.0f;
dim.x = Math::Rand()*1.5f+1.5f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f, 0.0f, 0.0f);
}
}
}
@@ -238,7 +240,7 @@ bool CAutoSafe::EventProcess(const Event &event)
m_object->FlushCrashShere();
m_object->SetGlobalSphere(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f);
- m_sound->Play(SOUND_FINDING, m_object->RetPosition(0));
+ m_sound->Play(SOUND_FINDING, m_object->GetPosition(0));
m_phase = ASAP_FINISH;
m_progress = 0.0f;
@@ -283,7 +285,7 @@ bool CAutoSafe::EventProcess(const Event &event)
{
if ( m_keyParti[i] != -1 )
{
- m_particule->DeleteParticule(m_keyParti[i]);
+ m_particle->DeleteParticle(m_keyParti[i]);
m_keyParti[i] = -1;
}
}
@@ -293,7 +295,7 @@ bool CAutoSafe::EventProcess(const Event &event)
{
pos = m_keyPos[i];
pos.y += 2.2f;
- m_keyParti[i] = m_particule->CreateParticule(pos, speed, dim, PARTISELY, 1.0f, 0.0f, 0.0f);
+ m_keyParti[i] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
}
}
}
@@ -306,7 +308,7 @@ bool CAutoSafe::EventProcess(const Event &event)
bool CAutoSafe::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -314,7 +316,7 @@ bool CAutoSafe::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -332,11 +334,11 @@ bool CAutoSafe::CreateInterface(bool bSelect)
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoSafe::RetError()
+Error CAutoSafe::GetError()
{
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
@@ -377,11 +379,11 @@ bool CAutoSafe::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoSafePhase)OpInt(line, "aPhase", ASAP_WAIT);
+ m_phase = static_cast< AutoSafePhase >(OpInt(line, "aPhase", ASAP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return true;
}
@@ -398,8 +400,8 @@ int CAutoSafe::CountKeys()
float dist, angle, limit, cAngle, oAngle;
int i, index;
- cPos = m_object->RetPosition(0);
- cAngle = m_object->RetAngleY(0);
+ cPos = m_object->GetPosition(0);
+ cAngle = m_object->GetAngleY(0);
for ( index=0 ; index<4 ; index++ )
{
@@ -409,18 +411,18 @@ int CAutoSafe::CountKeys()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->RetType();
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
+ oType = pObj->GetType();
if ( oType != OBJECT_KEYa &&
oType != OBJECT_KEYb &&
oType != OBJECT_KEYc &&
oType != OBJECT_KEYd ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(oPos, cPos);
if ( dist > 20.0f ) continue;
@@ -482,22 +484,22 @@ void CAutoSafe::LockKeys()
float dist;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->RetType();
- if ( pObj->RetTruck() != 0 ) continue;
+ oType = pObj->GetType();
+ if ( pObj->GetTruck() != 0 ) continue;
if ( oType != OBJECT_KEYa &&
oType != OBJECT_KEYb &&
oType != OBJECT_KEYc &&
oType != OBJECT_KEYd ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(oPos, cPos);
if ( dist > 20.0f ) continue;
@@ -515,22 +517,22 @@ void CAutoSafe::DownKeys(float progress)
float dist;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->RetType();
- if ( pObj->RetTruck() != 0 ) continue;
+ oType = pObj->GetType();
+ if ( pObj->GetTruck() != 0 ) continue;
if ( oType != OBJECT_KEYa &&
oType != OBJECT_KEYb &&
oType != OBJECT_KEYc &&
oType != OBJECT_KEYd ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(oPos, cPos);
if ( dist > 20.0f ) continue;
@@ -550,25 +552,25 @@ void CAutoSafe::DeleteKeys()
int i;
bool bDelete;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
do
{
bDelete = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->RetType();
- if ( pObj->RetTruck() != 0 ) continue;
+ oType = pObj->GetType();
+ if ( pObj->GetTruck() != 0 ) continue;
if ( oType != OBJECT_KEYa &&
oType != OBJECT_KEYb &&
oType != OBJECT_KEYc &&
oType != OBJECT_KEYd ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(oPos, cPos);
if ( dist > 20.0f ) continue;
@@ -586,22 +588,20 @@ CObject* CAutoSafe::SearchVehicle()
{
CObject* pObj;
Math::Vector cPos, oPos;
- ObjectType oType;
float dist;
int i;
- cPos = m_object->RetPosition(0);
+ cPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->RetType();
if ( pObj == m_object ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(oPos, cPos);
if ( dist <= 4.0f ) return pObj;
}
diff --git a/src/object/auto/autosafe.h b/src/object/auto/autosafe.h
index d17435b..3c0bcce 100644
--- a/src/object/auto/autosafe.h
+++ b/src/object/auto/autosafe.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -42,7 +43,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -61,7 +62,7 @@ protected:
float m_progress;
float m_speed;
float m_timeVirus;
- float m_lastParticule;
+ float m_lastParticle;
int m_channelSound;
bool m_bLock;
int m_countKeys;
diff --git a/src/object/auto/autostation.cpp b/src/object/auto/autostation.cpp
index dba4ed8..1dbcf26 100644
--- a/src/object/auto/autostation.cpp
+++ b/src/object/auto/autostation.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,19 +16,17 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autostation.h"
#include "common/iman.h"
-#include "old/particule.h"
-#include "old/terrain.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/terrain.h"
#include "math/geometry.h"
#include "ui/interface.h"
#include "ui/gauge.h"
#include "ui/window.h"
-
+#include <stdio.h>
// Object's constructor.
@@ -66,7 +65,7 @@ void CAutoStation::Init()
m_time = 0.0f;
m_timeVirus = 0.0f;
m_lastUpdateTime = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_soundChannel = -1;
m_bLastVirus = false;
@@ -83,22 +82,22 @@ bool CAutoStation::EventProcess(const Event &event)
Math::Point dim;
CObject* vehicule;
CObject* power;
- TerrainRes res;
+ Gfx::TerrainRes res;
float big, energy, used, add, freq;
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( !m_bLastVirus )
{
m_bLastVirus = true;
- m_energyVirus = m_object->RetEnergy();
+ m_energyVirus = m_object->GetEnergy();
}
if ( m_timeVirus <= 0.0f )
@@ -120,10 +119,10 @@ bool CAutoStation::EventProcess(const Event &event)
UpdateInterface(event.rTime);
- big = m_object->RetEnergy();
+ big = m_object->GetEnergy();
- res = m_terrain->RetResource(m_object->RetPosition(0));
- if ( res == TR_POWER )
+ res = m_terrain->GetResource(m_object->GetPosition(0));
+ if ( res == Gfx::TR_POWER )
{
big += event.rTime*0.01f; // recharges the large battery
}
@@ -135,10 +134,10 @@ bool CAutoStation::EventProcess(const Event &event)
vehicule = SearchVehicle();
if ( vehicule != 0 )
{
- power = vehicule->RetPower();
- if ( power != 0 && power->RetCapacity() == 1.0f )
+ power = vehicule->GetPower();
+ if ( power != 0 && power->GetCapacity() == 1.0f )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
add = event.rTime*0.2f;
if ( add > big*4.0f ) add = big*4.0f;
if ( add > 1.0f-energy ) add = 1.0f-energy;
@@ -148,10 +147,10 @@ bool CAutoStation::EventProcess(const Event &event)
big -= add/4.0f; // discharge the large battery
}
- power = vehicule->RetFret();
- if ( power != 0 && power->RetType() == OBJECT_POWER )
+ power = vehicule->GetFret();
+ if ( power != 0 && power->GetType() == OBJECT_POWER )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
add = event.rTime*0.2f;
if ( add > big*4.0f ) add = big*4.0f;
if ( add > 1.0f-energy ) add = 1.0f-energy;
@@ -169,7 +168,7 @@ bool CAutoStation::EventProcess(const Event &event)
freq = 1.0f+3.0f*freq;
if ( m_soundChannel == -1 )
{
- m_soundChannel = m_sound->Play(SOUND_STATION, m_object->RetPosition(0),
+ m_soundChannel = m_sound->Play(SOUND_STATION, m_object->GetPosition(0),
0.3f, freq, true);
}
m_sound->Frequency(m_soundChannel, freq);
@@ -184,11 +183,11 @@ bool CAutoStation::EventProcess(const Event &event)
}
if ( used != 0.0f &&
- m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(-15.0f, 7.0f, 0.0f); // battery position
pos = Math::Transform(*mat, pos);
speed.x = (Math::Rand()-0.5f)*20.0f;
@@ -199,7 +198,7 @@ bool CAutoStation::EventProcess(const Event &event)
ppos.z = pos.z;
dim.x = 1.5f;
dim.y = 1.5f;
- m_particule->CreateParticule(ppos, speed, dim, PARTIBLITZ, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(ppos, speed, dim, Gfx::PARTIBLITZ, 1.0f, 0.0f, 0.0f);
#if 0
ppos = pos;
@@ -211,7 +210,7 @@ bool CAutoStation::EventProcess(const Event &event)
speed.y = 2.5f+Math::Rand()*6.0f;
dim.x = Math::Rand()*1.5f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(ppos, speed, dim, PARTISMOKE3, 4.0f);
+ m_particle->CreateParticle(ppos, speed, dim, Gfx::PARTISMOKE3, 4.0f);
#else
ppos = pos;
ppos.y += 1.0f;
@@ -222,7 +221,7 @@ bool CAutoStation::EventProcess(const Event &event)
speed.y = 2.5f+Math::Rand()*5.0f;
dim.x = Math::Rand()*1.0f+0.6f;
dim.y = dim.x;
- m_particule->CreateParticule(ppos, speed, dim, PARTIVAPOR, 3.0f);
+ m_particle->CreateParticle(ppos, speed, dim, Gfx::PARTIVAPOR, 3.0f);
#endif
}
@@ -244,14 +243,14 @@ CObject* CAutoStation::SearchVehicle()
float dist;
int i;
- sPos = m_object->RetPosition(0);
+ sPos = m_object->GetPosition(0);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_HUMAN &&
type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
@@ -280,7 +279,7 @@ CObject* CAutoStation::SearchVehicle()
type != OBJECT_MOBILEit &&
type != OBJECT_MOBILEdr ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, sPos);
if ( dist <= 5.0f ) return pObj;
}
@@ -289,19 +288,19 @@ CObject* CAutoStation::SearchVehicle()
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoStation::RetError()
+Error CAutoStation::GetError()
{
- TerrainRes res;
+ Gfx::TerrainRes res;
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
- res = m_terrain->RetResource(m_object->RetPosition(0));
- if ( res != TR_POWER ) return ERR_STATION_NULL;
+ res = m_terrain->GetResource(m_object->GetPosition(0));
+ if ( res != Gfx::TR_POWER ) return ERR_STATION_NULL;
return ERR_OK;
}
@@ -311,7 +310,7 @@ Error CAutoStation::RetError()
bool CAutoStation::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -319,7 +318,7 @@ bool CAutoStation::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -347,23 +346,23 @@ bool CAutoStation::CreateInterface(bool bSelect)
void CAutoStation::UpdateInterface(float rTime)
{
- CWindow* pw;
- CGauge* pg;
+ Ui::CWindow* pw;
+ Ui::CGauge* pg;
CAuto::UpdateInterface(rTime);
if ( m_time < m_lastUpdateTime+0.1f ) return;
m_lastUpdateTime = m_time;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GENERGY);
+ pg = static_cast< Ui::CGauge* >(pw->SearchControl(EVENT_OBJECT_GENERGY));
if ( pg != 0 )
{
- pg->SetLevel(m_object->RetEnergy());
+ pg->SetLevel(m_object->GetEnergy());
}
}
diff --git a/src/object/auto/autostation.h b/src/object/auto/autostation.h
index 5bf2b72..cb8be2b 100644
--- a/src/object/auto/autostation.h
+++ b/src/object/auto/autostation.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -33,7 +34,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -47,7 +48,7 @@ protected:
float m_speed;
float m_timeVirus;
float m_lastUpdateTime;
- float m_lastParticule;
+ float m_lastParticle;
int m_soundChannel;
Math::Vector m_fretPos;
bool m_bLastVirus;
diff --git a/src/object/auto/autotower.cpp b/src/object/auto/autotower.cpp
index 5f185fe..7674794 100644
--- a/src/object/auto/autotower.cpp
+++ b/src/object/auto/autotower.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,8 +16,6 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/auto/autotower.h"
#include "common/iman.h"
@@ -28,6 +27,9 @@
#include "ui/window.h"
#include "ui/gauge.h"
+#include <stdio.h>
+#include <string.h>
+
const float TOWER_SCOPE = 200.0f; // range of beam
const float ENERGY_FIRE = 0.125f; // energy consumed by fire
@@ -78,7 +80,7 @@ void CAutoTower::Init()
m_time = 0.0f;
m_timeVirus = 0.0f;
m_lastUpdateTime = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
}
@@ -93,18 +95,18 @@ bool CAutoTower::EventProcess(const Event &event)
CAuto::EventProcess(event);
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_timeVirus -= event.rTime;
- if ( m_object->RetVirusMode() ) // contaminated by a virus?
+ if ( m_object->GetVirusMode() ) // contaminated by a virus?
{
if ( m_timeVirus <= 0.0f )
{
m_timeVirus = 0.1f+Math::Rand()*0.3f;
- angle = m_object->RetAngleY(1);
+ angle = m_object->GetAngleY(1);
angle += Math::Rand()*0.5f;
m_object->SetAngleY(1, angle);
@@ -125,10 +127,10 @@ bool CAutoTower::EventProcess(const Event &event)
if ( m_progress < 1.0f )
{
energy = 0.0f;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
if ( energy >= ENERGY_FIRE )
{
@@ -153,11 +155,11 @@ bool CAutoTower::EventProcess(const Event &event)
quick = 1.0f;
//? if ( g_researchDone & RESEARCH_QUICK ) quick = 3.0f;
- angle = m_object->RetAngleY(1);
+ angle = m_object->GetAngleY(1);
angle -= event.rTime*quick*2.0f;
m_object->SetAngleY(1, angle);
- angle = m_object->RetAngleZ(2);
+ angle = m_object->GetAngleZ(2);
angle += event.rTime*quick*0.5f;
if ( angle > 0.0f ) angle = 0.0f;
m_object->SetAngleZ(2, angle);
@@ -165,10 +167,10 @@ bool CAutoTower::EventProcess(const Event &event)
else
{
energy = 0.0f;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
target = SearchTarget(m_targetPos);
@@ -184,16 +186,16 @@ bool CAutoTower::EventProcess(const Event &event)
}
else
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 24.5f;
m_angleYfinal = Math::RotateAngle(m_targetPos.x-pos.x, pos.z-m_targetPos.z); // CW !
m_angleYfinal += Math::PI*2.0f;
- m_angleYfinal -= m_object->RetAngleY(0);
- m_angleYactual = Math::NormAngle(m_object->RetAngleY(1));
+ m_angleYfinal -= m_object->GetAngleY(0);
+ m_angleYactual = Math::NormAngle(m_object->GetAngleY(1));
m_angleZfinal = -Math::PI/2.0f;
m_angleZfinal -= Math::RotateAngle(Math::DistanceProjected(m_targetPos, pos), pos.y-m_targetPos.y); // CW !
- m_angleZactual = m_object->RetAngleZ(2);
+ m_angleZactual = m_object->GetAngleZ(2);
m_phase = ATP_TURN;
m_progress = 0.0f;
@@ -218,15 +220,15 @@ bool CAutoTower::EventProcess(const Event &event)
m_object->SetAngleY(1, m_angleYfinal);
m_object->SetAngleZ(2, m_angleZfinal);
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
- energy -= ENERGY_FIRE/power->RetCapacity();
+ energy = power->GetEnergy();
+ energy -= ENERGY_FIRE/power->GetCapacity();
power->SetEnergy(energy);
}
- m_sound->Play(SOUND_GGG, m_object->RetPosition(0));
+ m_sound->Play(SOUND_GGG, m_object->GetPosition(0));
m_phase = ATP_FIRE;
m_progress = 0.0f;
@@ -238,9 +240,9 @@ bool CAutoTower::EventProcess(const Event &event)
{
if ( m_progress == 0.0f )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 24.5f;
- m_particule->CreateRay(pos, m_targetPos, PARTIRAY1,
+ m_particle->CreateRay(pos, m_targetPos, Gfx::PARTIRAY1,
Math::Point(5.0f, 5.0f), 1.5f);
}
if ( m_progress >= 1.0f )
@@ -267,30 +269,30 @@ CObject* CAutoTower::SearchTarget(Math::Vector &impact)
float distance, min, radius, speed;
int i;
- iPos = m_object->RetPosition(0);
+ iPos = m_object->GetPosition(0);
min = 1000000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast< CObject* >(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType != OBJECT_MOTHER &&
oType != OBJECT_ANT &&
oType != OBJECT_SPIDER &&
oType != OBJECT_BEE &&
oType != OBJECT_WORM ) continue;
- if ( !pObj->RetActif() ) continue; // inactive?
+ if ( !pObj->GetActif() ) continue; // inactive?
//? if ( g_researchDone & RESEARCH_QUICK )
if ( false )
{
- physics = pObj->RetPhysics();
+ physics = pObj->GetPhysics();
if ( physics != 0 )
{
- speed = fabs(physics->RetLinMotionX(MO_REASPEED));
+ speed = fabs(physics->GetLinMotionX(MO_REASPEED));
if ( speed > 20.0f ) continue; // moving too fast?
}
}
@@ -306,30 +308,30 @@ CObject* CAutoTower::SearchTarget(Math::Vector &impact)
}
if ( pBest == 0 ) return 0;
- impact = pBest->RetPosition(0);
+ impact = pBest->GetPosition(0);
return pBest;
}
-// Returns an error due the state of the automation.
+// Geturns an error due the state of the automation.
-Error CAutoTower::RetError()
+Error CAutoTower::GetError()
{
CObject* power;
- if ( m_object->RetVirusMode() )
+ if ( m_object->GetVirusMode() )
{
return ERR_BAT_VIRUS;
}
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 )
{
return ERR_TOWER_POWER; // no battery
}
else
{
- if ( power->RetEnergy() < ENERGY_FIRE )
+ if ( power->GetEnergy() < ENERGY_FIRE )
{
return ERR_TOWER_ENERGY; // not enough energy
}
@@ -361,14 +363,14 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
{
if ( m_partiStop[i] != -1 )
{
- m_particule->DeleteParticule(m_partiStop[i]);
+ m_particle->DeleteParticle(m_partiStop[i]);
m_partiStop[i] = -1;
}
}
return;
}
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 2.0f;
@@ -380,7 +382,7 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
{
if ( m_partiStop[i] != -1 )
{
- m_particule->DeleteParticule(m_partiStop[i]);
+ m_particle->DeleteParticle(m_partiStop[i]);
m_partiStop[i] = -1;
}
}
@@ -392,8 +394,9 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
pos.y = 18.0f;
pos.z = listpos[i*2+1];
pos = Transform(*mat, pos);
- m_partiStop[i] = m_particule->CreateParticule(pos, speed,
- dim, PARTISELR,
+
+ m_partiStop[i] = m_particle->CreateParticle(pos, speed,
+ dim, Gfx::PARTISELR,
1.0f, 0.0f, 0.0f);
}
}
@@ -405,7 +408,7 @@ void CAutoTower::FireStopUpdate(float progress, bool bLightOn)
bool CAutoTower::CreateInterface(bool bSelect)
{
- CWindow* pw;
+ Ui::CWindow* pw;
Math::Point pos, ddim;
float ox, oy, sx, sy;
@@ -413,7 +416,7 @@ bool CAutoTower::CreateInterface(bool bSelect)
if ( !bSelect ) return true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
ox = 3.0f/640.0f;
@@ -447,8 +450,8 @@ bool CAutoTower::CreateInterface(bool bSelect)
void CAutoTower::UpdateInterface(float rTime)
{
- CWindow* pw;
- CGauge* pg;
+ Ui::CWindow* pw;
+ Ui::CGauge* pg;
CObject* power;
float energy;
@@ -457,19 +460,19 @@ void CAutoTower::UpdateInterface(float rTime)
if ( m_time < m_lastUpdateTime+0.1f ) return;
m_lastUpdateTime = m_time;
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GENERGY);
+ pg = static_cast< Ui::CGauge* >(pw->SearchControl(EVENT_OBJECT_GENERGY));
if ( pg != 0 )
{
energy = 0.0f;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
pg->SetLevel(energy);
}
@@ -524,7 +527,7 @@ bool CAutoTower::Read(char *line)
CAuto::Read(line);
- m_phase = (AutoTowerPhase)OpInt(line, "aPhase", ATP_WAIT);
+ m_phase = static_cast< AutoTowerPhase >(OpInt(line, "aPhase", ATP_WAIT));
m_progress = OpFloat(line, "aProgress", 0.0f);
m_speed = OpFloat(line, "aSpeed", 1.0f);
m_targetPos = OpDir(line, "aTargetPos");
diff --git a/src/object/auto/autotower.h b/src/object/auto/autotower.h
index c9393ff..b29ba85 100644
--- a/src/object/auto/autotower.h
+++ b/src/object/auto/autotower.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -44,7 +45,7 @@ public:
void Init();
bool EventProcess(const Event &event);
- Error RetError();
+ Error GetError();
bool CreateInterface(bool bSelect);
@@ -63,7 +64,7 @@ protected:
float m_speed;
float m_timeVirus;
float m_lastUpdateTime;
- float m_lastParticule;
+ float m_lastParticle;
Math::Vector m_targetPos;
float m_angleYactual;
float m_angleZactual;
diff --git a/src/object/brain.cpp b/src/object/brain.cpp
index ef55e73..953f878 100644
--- a/src/object/brain.cpp
+++ b/src/object/brain.cpp
@@ -15,56 +15,23 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <stdio.h>
-
#include "object/brain.h"
-#include "CBot/CBotDll.h"
-#include "common/struct.h"
-#include "math/geometry.h"
-#include "math/const.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/language.h"
-#include "common/global.h"
-#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
-#include "common/restext.h"
-#include "old/math3d.h"
-#include "object/robotmain.h"
-#include "old/terrain.h"
-#include "old/water.h"
-#include "old/camera.h"
-#include "object/object.h"
-#include "physics/physics.h"
+#include "graphics/core/color.h"
+#include "graphics/engine/terrain.h"
#include "object/motion/motion.h"
-#include "object/motion/motionspider.h"
-#include "old/pyro.h"
#include "object/task/taskmanager.h"
-#include "object/task/task.h"
-#include "object/task/taskmanip.h"
-#include "object/task/taskflag.h"
-#include "object/task/taskshield.h"
+#include "physics/physics.h"
+#include "script/cmdtoken.h"
#include "script/script.h"
-#include "ui/studio.h"
+#include "sound/sound.h"
+#include "ui/displaytext.h"
#include "ui/interface.h"
-#include "ui/button.h"
-#include "ui/color.h"
-#include "ui/edit.h"
-#include "ui/list.h"
-#include "ui/label.h"
-#include "ui/group.h"
-#include "ui/gauge.h"
#include "ui/slider.h"
-#include "ui/compass.h"
-#include "ui/target.h"
+#include "ui/studio.h"
#include "ui/window.h"
-#include "ui/displaytext.h"
-#include "old/text.h"
-#include "old/sound.h"
-#include "old/particule.h"
-#include "script/cmdtoken.h"
@@ -82,15 +49,15 @@ CBrain::CBrain(CInstanceManager* iMan, CObject* object)
m_iMan->AddInstance(CLASS_BRAIN, this, 100);
m_object = object;
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
- m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_displayText = (CDisplayText*)m_iMan->SearchInstance(CLASS_DISPLAYTEXT);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_interface = static_cast<Ui::CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
m_physics = 0;
m_motion = 0;
m_primaryTask = 0;
@@ -213,15 +180,15 @@ bool CBrain::Read(char *line)
bool CBrain::EventProcess(const Event &event)
{
- CWindow* pw;
- CControl* pc;
- CSlider* ps;
- EventMsg action;
- ObjectType type;
- Error err;
- float axeX, axeY, axeZ, factor;
+ Ui::CWindow* pw;
+ Ui::CControl* pc;
+ Ui::CSlider* ps;
+ EventType action;
+ ObjectType type;
+ Error err;
+ float axeX, axeY, axeZ, factor;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( m_primaryTask != 0 ) // current task?
{
@@ -235,18 +202,18 @@ bool CBrain::EventProcess(const Event &event)
action = EVENT_NULL;
- if ( event.event == EVENT_KEYDOWN &&
- (event.param == m_engine->RetKey(KEYRANK_ACTION, 0) ||
- event.param == m_engine->RetKey(KEYRANK_ACTION, 1) ) &&
- !m_main->RetEditLock() )
+ if ( event.type == EVENT_KEY_DOWN &&
+ (event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).key ||
+ event.key.key == m_main->GetInputBinding(INPUT_SLOT_ACTION).joy ) &&
+ !m_main->GetEditLock() )
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != 0 )
{
pc = pw->SearchControl(m_defaultEnter);
if ( pc != 0 )
{
- if ( pc->TestState(STATE_ENABLE) )
+ if ( pc->TestState(Ui::STATE_ENABLE) )
{
action = m_defaultEnter;
}
@@ -255,14 +222,14 @@ bool CBrain::EventProcess(const Event &event)
}
else
{
- action = event.event;
+ action = event.type;
}
if ( action == EVENT_NULL ) return true;
if ( action == EVENT_UPDINTERFACE )
{
- if ( m_object->RetSelect() ) CreateInterface(true);
+ if ( m_object->GetSelect() ) CreateInterface(true);
}
if ( action == EVENT_FRAME )
@@ -270,10 +237,10 @@ bool CBrain::EventProcess(const Event &event)
EventFrame(event);
}
- if ( m_object->RetSelect() && // robot selected?
- m_studio != 0 ) // current issue?
+ if ( m_object->GetSelect() && // robot selected?
+ m_studio != 0 ) // current issue?
{
- m_studio->EventProcess(event);
+ // m_studio->EventProcess(event);
if ( action == EVENT_OBJECT_PROGRUN )
{
@@ -308,14 +275,14 @@ bool CBrain::EventProcess(const Event &event)
return true;
}
- if ( !m_object->RetSelect() && // robot pas sélectionné ?
+ if ( !m_object->GetSelect() && // robot pas sélectionné ?
m_program == -1 &&
m_primaryTask == 0 )
{
axeX = 0.0f;
axeY = 0.0f;
axeZ = 0.0f;
- if ( m_object->RetBurn() ) // Gifted?
+ if ( m_object->GetBurn() ) // Gifted?
{
if ( !m_bBurn ) // beginning?
{
@@ -325,7 +292,7 @@ bool CBrain::EventProcess(const Event &event)
axeZ = -1.0f; // tomb
- if ( !m_object->RetFixed() &&
+ if ( !m_object->GetFixed() &&
(type == OBJECT_ANT ||
type == OBJECT_SPIDER ||
type == OBJECT_WORM ) )
@@ -348,13 +315,13 @@ bool CBrain::EventProcess(const Event &event)
}
if ( m_program != -1 &&
- m_object->RetRuin() )
+ m_object->GetRuin() )
{
StopProgram();
return true;
}
- if ( !m_object->RetSelect() ) // robot not selected?
+ if ( !m_object->GetSelect() ) // robot not selected?
{
return true;
}
@@ -375,7 +342,7 @@ bool CBrain::EventProcess(const Event &event)
}
if ( action == EVENT_OBJECT_PROGEDIT )
{
- StartEditScript(m_selScript, m_main->RetScriptName());
+ StartEditScript(m_selScript, m_main->GetScriptName());
}
if ( m_primaryTask == 0 || !m_primaryTask->IsPilot() ) return true;
}
@@ -389,18 +356,17 @@ bool CBrain::EventProcess(const Event &event)
{
m_buttonAxe = action;
}
- if ( action == EVENT_LBUTTONUP ||
- action == EVENT_RBUTTONUP )
+ if ( action == EVENT_MOUSE_BUTTON_UP )
{
m_buttonAxe = EVENT_NULL;
}
- axeX = event.axeX;
- axeY = event.axeY;
- axeZ = event.axeZ;
+ axeX = event.motionInput.x;
+ axeY = event.motionInput.y;
+ axeZ = event.motionInput.z;
- if ( !m_main->RetTrainerPilot() &&
- m_object->RetTrainer() ) // drive vehicle?
+ if ( !m_main->GetTrainerPilot() &&
+ m_object->GetTrainer() ) // drive vehicle?
{
axeX = 0.0f;
axeY = 0.0f;
@@ -414,7 +380,7 @@ bool CBrain::EventProcess(const Event &event)
if ( m_buttonAxe == EVENT_OBJECT_GASUP ) axeZ = 1.0f;
if ( m_buttonAxe == EVENT_OBJECT_GASDOWN ) axeZ = -1.0f;
- if ( m_object->RetManual() ) // scribbler in manual mode?
+ if ( m_object->GetManual() ) // scribbler in manual mode?
{
if ( axeX != 0.0f ) axeY = 0.0f; // if running -> not moving!
axeX *= 0.5f;
@@ -426,7 +392,7 @@ bool CBrain::EventProcess(const Event &event)
axeZ = -1.0f; // tomb
}
- axeX += m_camera->RetMotorTurn(); // additional power according to camera
+ axeX += m_camera->GetMotorTurn(); // additional power according to camera
if ( axeX > 1.0f ) axeX = 1.0f;
if ( axeX < -1.0f ) axeX = -1.0f;
@@ -436,13 +402,13 @@ bool CBrain::EventProcess(const Event &event)
if ( action == EVENT_OBJECT_PROGLIST )
{
- m_selScript = RetSelScript();
+ m_selScript = GetSelScript();
UpdateInterface();
}
if ( action == EVENT_OBJECT_PROGEDIT )
{
- StartEditScript(m_selScript, m_main->RetScriptName());
+ StartEditScript(m_selScript, m_main->GetScriptName());
}
if ( action == EVENT_OBJECT_PROGRUN )
@@ -566,7 +532,7 @@ bool CBrain::EventProcess(const Event &event)
action == EVENT_OBJECT_FCOLORy ||
action == EVENT_OBJECT_FCOLORv )
{
- ColorFlag(action-EVENT_OBJECT_FCOLORb);
+ ColorFlag(action - EVENT_OBJECT_FCOLORb);
}
if ( action == EVENT_OBJECT_SEARCH )
@@ -591,26 +557,26 @@ bool CBrain::EventProcess(const Event &event)
if ( action == EVENT_OBJECT_DIMSHIELD )
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != 0 )
{
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_DIMSHIELD);
+ ps = static_cast< Ui::CSlider* >(pw->SearchControl(EVENT_OBJECT_DIMSHIELD));
if ( ps != 0 )
{
- m_object->SetParam((ps->RetVisibleValue()-(RADIUS_SHIELD_MIN/g_unit))/((RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)/g_unit));
+ m_object->SetParam((ps->GetVisibleValue()-(RADIUS_SHIELD_MIN/g_unit))/((RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)/g_unit));
}
}
}
- if ( action == EVENT_OBJECT_FIRE && m_primaryTask == 0 && !m_object->RetTrainer())
+ if ( action == EVENT_OBJECT_FIRE && m_primaryTask == 0 && !m_object->GetTrainer())
{
- if ( m_camera->RetType() != CAMERA_ONBOARD )
+ if ( m_camera->GetType() != Gfx::CAM_TYPE_ONBOARD )
{
- m_camera->SetType(CAMERA_ONBOARD);
+ m_camera->SetType(Gfx::CAM_TYPE_ONBOARD);
}
err = StartTaskFire(0.0f);
}
- if ( action == EVENT_OBJECT_TARGET && !m_object->RetTrainer() )
+ if ( action == EVENT_OBJECT_TARGET && !m_object->GetTrainer() )
{
err = StartTaskGunGoal((event.pos.y-0.50f)*1.3f, (event.pos.x-0.50f)*2.0f);
}
@@ -622,7 +588,7 @@ bool CBrain::EventProcess(const Event &event)
if ( action == EVENT_OBJECT_PEN0 ) // up
{
- err = StartTaskPen(false, m_object->RetTraceColor());
+ err = StartTaskPen(false, m_object->GetTraceColor());
m_object->SetTraceDown(false);
}
if ( action == EVENT_OBJECT_PEN1 ) // black
@@ -687,7 +653,7 @@ bool CBrain::EventProcess(const Event &event)
TraceRecordStart();
}
UpdateInterface();
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != 0 )
{
UpdateScript(pw);
@@ -701,7 +667,7 @@ bool CBrain::EventProcess(const Event &event)
TraceRecordStop();
}
UpdateInterface();
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != 0 )
{
UpdateScript(pw);
@@ -719,8 +685,8 @@ bool CBrain::EventProcess(const Event &event)
{
Math::Vector p1, p2;
float h;
- p1 = m_object->RetPosition(0);
- h = m_terrain->RetFloorLevel(p1);
+ p1 = m_object->GetPosition(0);
+ h = m_terrain->GetFloorLevel(p1);
p2 = p1;
p1.x -= 20.0f;
p1.z -= 20.0f;
@@ -732,8 +698,8 @@ bool CBrain::EventProcess(const Event &event)
{
Math::Vector p1, p2;
float h;
- p1 = m_object->RetPosition(0);
- h = m_terrain->RetFloorLevel(p1);
+ p1 = m_object->GetPosition(0);
+ h = m_terrain->GetFloorLevel(p1);
p2 = p1;
p1.x -= 20.0f;
p1.z -= 20.0f;
@@ -762,17 +728,17 @@ bool CBrain::EventFrame(const Event &event)
if ( m_soundChannelAlarm != -1 )
{
- m_sound->Position(m_soundChannelAlarm, m_object->RetPosition(0));
+ m_sound->Position(m_soundChannelAlarm, m_object->GetPosition(0));
}
- if ( m_studio != 0 ) // �urrent edition?
+ if ( m_studio != 0 ) // current edition?
{
m_studio->EventProcess(event);
}
UpdateInterface(event.rTime);
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
if ( !m_bActivity ) return true; // expected if idle
if ( EndedTask() == ERR_CONTINUE ) return true; // expected if not finished ...
@@ -799,8 +765,8 @@ void CBrain::StopProgram()
{
StopTask();
- if ( m_object->RetType() == OBJECT_HUMAN ||
- m_object->RetType() == OBJECT_TECH ) return;
+ if ( m_object->GetType() == OBJECT_HUMAN ||
+ m_object->GetType() == OBJECT_TECH ) return;
if ( m_program != -1 &&
m_script[m_program] != 0 )
@@ -820,7 +786,7 @@ void CBrain::StopProgram()
UpdateInterface();
m_main->UpdateShortcuts();
- m_object->CreateSelectParticule();
+ m_object->CreateSelectParticle();
}
// Stops the current task.
@@ -837,7 +803,7 @@ void CBrain::StopTask()
// Introduces a virus into a program.
-// Returns true if it was inserted.
+// Geturns true if it was inserted.
bool CBrain::IntroduceVirus()
{
@@ -874,7 +840,7 @@ void CBrain::SetActiveVirus(bool bActive)
}
}
-bool CBrain::RetActiveVirus()
+bool CBrain::GetActiveVirus()
{
return m_bActiveVirus;
}
@@ -891,7 +857,7 @@ void CBrain::StartEditScript(int rank, char* name)
m_script[rank] = new CScript(m_iMan, m_object, &m_secondaryTask);
}
- m_studio = new CStudio(m_iMan);
+ m_studio = new Ui::CStudio();
m_studio->StartEditScript(m_script[rank], name, rank);
}
@@ -1191,25 +1157,25 @@ void CBrain::GroundFlat()
Error err;
float level;
- if ( !m_physics->RetLand() )
+ if ( !m_physics->GetLand() )
{
err = ERR_FLAG_FLY;
- pos = m_object->RetPosition(0);
- if ( pos.y < m_water->RetLevel() ) err = ERR_FLAG_WATER;
+ pos = m_object->GetPosition(0);
+ if ( pos.y < m_water->GetLevel() ) err = ERR_FLAG_WATER;
m_displayText->DisplayError(err, m_object);
return;
}
- pos = m_object->RetPosition(0);
- m_terrain->GroundFlat(pos);
+ pos = m_object->GetPosition(0);
+ m_terrain->ShowFlatGround(pos);
m_sound->Play(SOUND_GFLAT, pos);
- level = m_terrain->RetFloorLevel(pos)+2.0f;
+ level = m_terrain->GetFloorLevel(pos)+2.0f;
if ( pos.y < level ) pos.y = level; // not below the soil
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 40.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGFLAT, 1.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGFLAT, 1.0f);
}
@@ -1226,18 +1192,18 @@ void CBrain::ColorFlag(int color)
bool CBrain::CreateInterface(bool bSelect)
{
- ObjectType type;
- CWindow* pw;
- CButton* pb;
- CColor* pc;
- CSlider* ps;
- CTarget* pt;
- CLabel* pl;
- Math::Point pos, dim, ddim;
+ ObjectType type;
+ Ui::CWindow* pw;
+ Ui::CButton* pb;
+ Ui::CSlider* ps;
+ Ui::CColor* pc;
+ Ui::CTarget* pt;
+ Ui::CLabel* pl;
+ Math::Point pos, dim, ddim;
float ox, oy, sx, sy;
char name[100];
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != 0 )
{
pw->Flush(); // destroys the window buttons
@@ -1250,17 +1216,17 @@ bool CBrain::CreateInterface(bool bSelect)
pos.x = 0.0f;
pos.y = 0.0f;
dim.x = 540.0f/640.0f;
- if ( !m_main->RetShowMap() ) dim.x = 640.0f/640.0f;
+ if ( !m_main->GetShowMap() ) dim.x = 640.0f/640.0f;
dim.y = 86.0f/480.0f;
m_interface->CreateWindows(pos, dim, 3, EVENT_WINDOW0);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return false;
m_object->GetTooltipName(name);
pos.x = 0.0f;
pos.y = 64.0f/480.0f;
ddim.x = 540.0f/640.0f;
- if ( !m_main->RetShowMap() ) ddim.x = 640.0f/640.0f;
+ if ( !m_main->GetShowMap() ) ddim.x = 640.0f/640.0f;
ddim.y = 16.0f/480.0f;
pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, name);
@@ -1271,7 +1237,7 @@ bool CBrain::CreateInterface(bool bSelect)
sx = 33.0f/640.0f;
sy = 33.0f/480.0f;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
@@ -1339,7 +1305,7 @@ bool CBrain::CreateInterface(bool bSelect)
pb->SetImmediat(true);
if ( type != OBJECT_HUMAN ||
- m_object->RetOption() != 2 )
+ m_object->GetOption() != 2 )
{
pos.x = ox+sx*15.3f;
pos.y = oy+sy*0;
@@ -1362,7 +1328,7 @@ bool CBrain::CreateInterface(bool bSelect)
type == OBJECT_MOBILEta ||
type == OBJECT_MOBILEwa ||
type == OBJECT_MOBILEia ) && // arm?
- !m_object->RetTrainer() )
+ !m_object->GetTrainer() )
{
pos.x = ox+sx*7.7f;
pos.y = oy+sy*0.5f;
@@ -1383,7 +1349,7 @@ bool CBrain::CreateInterface(bool bSelect)
}
if ( type == OBJECT_MOBILEsa && // underwater?
- !m_object->RetTrainer() )
+ !m_object->GetTrainer() )
{
pos.x = ox+sx*7.7f;
pos.y = oy+sy*0.5f;
@@ -1498,19 +1464,19 @@ bool CBrain::CreateInterface(bool bSelect)
pos.x = ox+sx*10.1f;
pos.y = oy+sy*2.0f-ddim.y;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORb);
- pc->SetColor(RetColor((D3DCOLOR)0x004890ff));
+ pc->SetColor(Gfx::Color(0.28f, 0.56f, 1.0f, 0.0f));
pos.x += ddim.x;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORr);
- pc->SetColor(RetColor((D3DCOLOR)0x00ff0000));
+ pc->SetColor(Gfx::Color(1.0f, 0.0f, 0.0f, 0.0f));
pos.x += ddim.x;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORg);
- pc->SetColor(RetColor((D3DCOLOR)0x0000ce00));
+ pc->SetColor(Gfx::Color(0.0f, 0.8f, 0.0f, 0.0f));
pos.x += ddim.x;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORy);
- pc->SetColor(RetColor((D3DCOLOR)0x00ffec00));
+ pc->SetColor(Gfx::Color(1.0f, 0.93f, 0.0f, 0.0f)); //0x00ffec00
pos.x += ddim.x;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_FCOLORv);
- pc->SetColor(RetColor((D3DCOLOR)0x00d101fe));
+ pc->SetColor(Gfx::Color(0.82f, 0.004f, 0.99f, 0.0f)); //0x00d101fe
}
}
@@ -1518,7 +1484,7 @@ bool CBrain::CreateInterface(bool bSelect)
type == OBJECT_MOBILEts ||
type == OBJECT_MOBILEws ||
type == OBJECT_MOBILEis ) && // Investigator?
- !m_object->RetTrainer() )
+ !m_object->GetTrainer() )
{
pos.x = ox+sx*7.7f;
pos.y = oy+sy*0.5f;
@@ -1527,7 +1493,7 @@ bool CBrain::CreateInterface(bool bSelect)
}
if ( type == OBJECT_MOBILErt && // Terraformer?
- !m_object->RetTrainer() )
+ !m_object->GetTrainer() )
{
pos.x = ox+sx*7.7f;
pos.y = oy+sy*0.5f;
@@ -1540,7 +1506,7 @@ bool CBrain::CreateInterface(bool bSelect)
}
if ( type == OBJECT_MOBILErr && // recoverer?
- !m_object->RetTrainer() )
+ !m_object->GetTrainer() )
{
pos.x = ox+sx*7.7f;
pos.y = oy+sy*0.5f;
@@ -1549,7 +1515,7 @@ bool CBrain::CreateInterface(bool bSelect)
}
if ( type == OBJECT_MOBILErs && // shield?
- !m_object->RetTrainer() )
+ !m_object->GetTrainer() )
{
pos.x = ox+sx*7.7f;
pos.y = oy+sy*0.5f;
@@ -1569,7 +1535,7 @@ bool CBrain::CreateInterface(bool bSelect)
ddim.x = dim.x*0.5f;
ddim.y = dim.y*2.0f;
ps = pw->CreateSlider(pos, ddim, 0, EVENT_OBJECT_DIMSHIELD);
- ps->SetState(STATE_VALUE);
+ ps->SetState(Ui::STATE_VALUE);
ps->SetLimit((RADIUS_SHIELD_MIN/g_unit), (RADIUS_SHIELD_MAX/g_unit));
ps->SetArrowStep(1.0f);
}
@@ -1583,7 +1549,7 @@ bool CBrain::CreateInterface(bool bSelect)
type == OBJECT_MOBILEwi ||
type == OBJECT_MOBILEii ||
type == OBJECT_MOBILErc ) && // cannon?
- !m_object->RetTrainer() )
+ !m_object->GetTrainer() )
{
pos.x = ox+sx*7.7f;
pos.y = oy+sy*0.5f;
@@ -1597,7 +1563,7 @@ bool CBrain::CreateInterface(bool bSelect)
}
if ( type == OBJECT_MOBILEdr &&
- m_object->RetManual() ) // scribbler in manual mode?
+ m_object->GetManual() ) // scribbler in manual mode?
{
pos.x = ox+sx*6.9f;
pos.y = oy+sy*0.0f;
@@ -1620,35 +1586,35 @@ bool CBrain::CreateInterface(bool bSelect)
pos.x = ox+sx*10.15f;
pos.y = oy+sy*1.50f;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN1); // black
- pc->SetColor(RetColor((D3DCOLOR)0x00000000));
+ pc->SetColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
pos.x = ox+sx*10.65f;
pos.y = oy+sy*1.25f;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN2); // yellow
- pc->SetColor(RetColor((D3DCOLOR)0x00ffff00));
+ pc->SetColor(Gfx::Color(1.0f, 1.0f, 0.0f, 0.0f ));
pos.x = ox+sx*10.90f;
pos.y = oy+sy*0.75f;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN3); // orange
- pc->SetColor(RetColor((D3DCOLOR)0x00ff8800));
+ pc->SetColor(Gfx::Color(1.0f, 0.53f, 0x00, 0x00));
pos.x = ox+sx*10.65f;
pos.y = oy+sy*0.25f;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN4); // red
- pc->SetColor(RetColor((D3DCOLOR)0x00ff0000));
+ pc->SetColor(Gfx::Color(1.0f, 0.0f, 0.0f, 0.0f));
pos.x = ox+sx*10.15f;
pos.y = oy+sy*0.00f;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN5); // violet
- pc->SetColor(RetColor((D3DCOLOR)0x00ff00ff));
+ pc->SetColor(Gfx::Color(1.0f, 0.0f, 1.0f, 0.0f));
pos.x = ox+sx*9.65f;
pos.y = oy+sy*0.25f;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN6); // blue
- pc->SetColor(RetColor((D3DCOLOR)0x000066ff));
+ pc->SetColor(Gfx::Color(0.0f, 0.4f, 1.0f, 0.0f));//0x000066ff));
pos.x = ox+sx*9.40f;
pos.y = oy+sy*0.75f;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN7); // green
- pc->SetColor(RetColor((D3DCOLOR)0x0000cc00));
+ pc->SetColor(Gfx::Color(0.0f, 0.0f, 0.8f, 0.0f));//0x0000cc00));
pos.x = ox+sx*9.65f;
pos.y = oy+sy*1.25f;
pc = pw->CreateColor(pos, ddim, -1, EVENT_OBJECT_PEN8); // brown
- pc->SetColor(RetColor((D3DCOLOR)0x00884400));
+ pc->SetColor(Gfx::Color(0.53f, 0.27f, 0.0f, 0.0f));//0x00884400));
pos.x = ox+sx*6.9f;
pos.y = oy+sy*1.2f;
@@ -1666,7 +1632,7 @@ bool CBrain::CreateInterface(bool bSelect)
pw->CreateButton(pos, dim, 45, EVENT_OBJECT_STOP);
}
- if ( m_object->RetToy() )
+ if ( m_object->GetToy() )
{
pos.x = ox+sx*12.1f;
pos.y = oy+sy*-0.1f;
@@ -1705,9 +1671,9 @@ bool CBrain::CreateInterface(bool bSelect)
if ( type != OBJECT_HUMAN &&
type != OBJECT_TECH &&
- !m_object->RetCameraLock() )
+ !m_object->GetCameraLock() )
{
-//? if ( m_main->RetShowMap() )
+//? if ( m_main->GetShowMap() )
if ( true )
{
pos.x = ox+sx*13.4f;
@@ -1724,7 +1690,7 @@ bool CBrain::CreateInterface(bool bSelect)
}
}
- if ( m_object->RetToy() && !m_object->RetManual() )
+ if ( m_object->GetToy() && !m_object->GetManual() )
{
#if 0
ddim.x = dim.x*0.66f;
@@ -1770,7 +1736,7 @@ bool CBrain::CreateInterface(bool bSelect)
#if _TEEN
pw->CreateButton(pos, dim, 9, EVENT_OBJECT_RESET);
#else
- if ( m_object->RetTrainer() ) // Training?
+ if ( m_object->GetTrainer() ) // Training?
{
pw->CreateButton(pos, dim, 9, EVENT_OBJECT_RESET);
}
@@ -1861,7 +1827,7 @@ bool CBrain::CreateInterface(bool bSelect)
pc = (CCompass*)pw->SearchControl(EVENT_OBJECT_COMPASS);
if ( pc != 0 )
{
- pc->SetState(STATE_VISIBLE, m_main->RetShowMap());
+ pc->SetState(Ui::STATE_VISIBLE, m_main->GetShowMap());
}
}
#endif
@@ -1887,7 +1853,7 @@ bool CBrain::CreateInterface(bool bSelect)
ddim.x = 600.0f/640.0f;
ddim.y = 340.0f/480.0f;
pt = pw->CreateTarget(pos, ddim, 0, EVENT_OBJECT_TARGET);
- pt->ClearState(STATE_GLINT);
+ pt->ClearState(Ui::STATE_GLINT);
}
ddim.x = 64.0f/640.0f;
@@ -1926,15 +1892,15 @@ bool CBrain::CreateInterface(bool bSelect)
void CBrain::UpdateInterface(float rTime)
{
- CWindow* pw;
-#if _TEEN
- CButton* pb;
-#endif
- CGauge* pg;
- CCompass* pc;
- CGroup* pgr;
- CTarget* ptg;
- CObject* power;
+ Ui::CWindow* pw;
+/* TODO: #if _TEEN
+ Ui::CButton* pb;
+#endif*/
+ Ui::CGauge* pg;
+ Ui::CCompass* pc;
+ Ui::CGroup* pgr;
+ Ui::CTarget* ptg;
+ CObject* power;
Math::Vector pos, hPos;
Math::Point ppos;
float energy, limit, angle, range;
@@ -1945,7 +1911,7 @@ void CBrain::UpdateInterface(float rTime)
if ( m_time < m_lastUpdateTime+0.1f ) return;
m_lastUpdateTime = m_time;
- if ( !m_object->RetSelect() )
+ if ( !m_object->GetSelect() )
{
if ( m_soundChannelAlarm != -1 )
{
@@ -1956,21 +1922,21 @@ void CBrain::UpdateInterface(float rTime)
return;
}
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GENERGY);
+ pg = static_cast< Ui::CGauge* >(pw->SearchControl(EVENT_OBJECT_GENERGY));
if ( pg != 0 )
{
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 )
{
energy = 0.0f;
}
else
{
- energy = power->RetEnergy();
- limit = energy*power->RetCapacity();
+ energy = power->GetEnergy();
+ limit = energy*power->GetCapacity();
}
icon = 0; // red/green
@@ -1991,19 +1957,19 @@ void CBrain::UpdateInterface(float rTime)
pg->SetIcon(icon);
}
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GSHIELD);
+ pg = static_cast< Ui::CGauge* >(pw->SearchControl(EVENT_OBJECT_GSHIELD));
if ( pg != 0 )
{
- pg->SetLevel(m_object->RetShield());
+ pg->SetLevel(m_object->GetShield());
}
- pg = (CGauge*)pw->SearchControl(EVENT_OBJECT_GRANGE);
+ pg = static_cast< Ui::CGauge* >(pw->SearchControl(EVENT_OBJECT_GRANGE));
if ( pg != 0 )
{
icon = 2; // blue/red
- range = m_physics->RetReactorRange();
+ range = m_physics->GetReactorRange();
- if ( range < 0.2f && range != 0.0f && !m_physics->RetLand() )
+ if ( range < 0.2f && range != 0.0f && !m_physics->GetLand() )
{
if ( Math::Mod(m_time, 0.5f) >= 0.2f ) // blinks?
{
@@ -2012,7 +1978,7 @@ void CBrain::UpdateInterface(float rTime)
}
if ( m_soundChannelAlarm == -1 )
{
- m_soundChannelAlarm = m_sound->Play(SOUND_ALARMt, m_object->RetPosition(0), 0.0f, 0.1f, true);
+ m_soundChannelAlarm = m_sound->Play(SOUND_ALARMt, m_object->GetPosition(0), 0.0f, 0.1f, true);
m_sound->AddEnvelope(m_soundChannelAlarm, 1.0f, 1.0f, 1.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannelAlarm, 1.0f, 1.0f, 1.0f, SOPER_LOOP);
}
@@ -2031,13 +1997,13 @@ void CBrain::UpdateInterface(float rTime)
pg->SetIcon(icon);
}
- pc = (CCompass*)pw->SearchControl(EVENT_OBJECT_COMPASS);
+ pc = static_cast< Ui::CCompass* >(pw->SearchControl(EVENT_OBJECT_COMPASS));
if ( pc != 0 )
{
- angle = -(m_object->RetAngleY(0)+Math::PI/2.0f);
+ angle = -(m_object->GetAngleY(0)+Math::PI/2.0f);
pc->SetDirection(angle);
- pc->SetState(STATE_VISIBLE, m_main->RetShowMap());
+ pc->SetState(Ui::STATE_VISIBLE, m_main->GetShowMap());
}
#if _TEEN
@@ -2046,25 +2012,25 @@ void CBrain::UpdateInterface(float rTime)
{
if ( m_bTraceRecord && Math::Mod(m_time, 0.4f) >= 0.2f )
{
- pb->SetState(STATE_CHECK);
+ pb->SetState(Ui::STATE_CHECK);
}
else
{
- pb->ClearState(STATE_CHECK);
+ pb->ClearState(Ui::STATE_CHECK);
}
}
#endif
- bOnBoard = m_camera->RetType() == CAMERA_ONBOARD;
+ bOnBoard = m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD;
- pgr = (CGroup*)pw->SearchControl(EVENT_OBJECT_CROSSHAIR);
+ pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CROSSHAIR));
if ( pgr != 0 )
{
if ( bOnBoard )
{
#if 0
- angle = m_object->RetGunGoalV();
- if ( m_object->RetType() != OBJECT_MOBILErc )
+ angle = m_object->GetGunGoalV();
+ if ( m_object->GetType() != OBJECT_MOBILErc )
{
angle += 10.0f*Math::PI/360.0f;
}
@@ -2075,53 +2041,53 @@ void CBrain::UpdateInterface(float rTime)
#else
ppos.x = 0.50f-(64.0f/640.0f)/2.0f;
ppos.y = 0.50f-(64.0f/480.0f)/2.0f;
- ppos.x += m_object->RetGunGoalH()/2.0f;
- ppos.y += m_object->RetGunGoalV()/1.3f;
+ ppos.x += m_object->GetGunGoalH()/2.0f;
+ ppos.y += m_object->GetGunGoalV()/1.3f;
pgr->SetPos(ppos);
#endif
- pgr->SetState(STATE_VISIBLE, !m_main->RetFriendAim());
+ pgr->SetState(Ui::STATE_VISIBLE, !m_main->GetFriendAim());
}
else
{
- pgr->ClearState(STATE_VISIBLE);
+ pgr->ClearState(Ui::STATE_VISIBLE);
}
}
- ptg = (CTarget*)pw->SearchControl(EVENT_OBJECT_TARGET);
+ ptg = static_cast< Ui::CTarget* >(pw->SearchControl(EVENT_OBJECT_TARGET));
if ( ptg != 0 )
{
if ( bOnBoard )
{
- ptg->SetState(STATE_VISIBLE);
+ ptg->SetState(Ui::STATE_VISIBLE);
}
else
{
- ptg->ClearState(STATE_VISIBLE);
+ ptg->ClearState(Ui::STATE_VISIBLE);
}
}
- pgr = (CGroup*)pw->SearchControl(EVENT_OBJECT_CORNERul);
+ pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CORNERul));
if ( pgr != 0 )
{
- pgr->SetState(STATE_VISIBLE, bOnBoard);
+ pgr->SetState(Ui::STATE_VISIBLE, bOnBoard);
}
- pgr = (CGroup*)pw->SearchControl(EVENT_OBJECT_CORNERur);
+ pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CORNERur));
if ( pgr != 0 )
{
- pgr->SetState(STATE_VISIBLE, bOnBoard);
+ pgr->SetState(Ui::STATE_VISIBLE, bOnBoard);
}
- pgr = (CGroup*)pw->SearchControl(EVENT_OBJECT_CORNERdl);
+ pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CORNERdl));
if ( pgr != 0 )
{
- pgr->SetState(STATE_VISIBLE, bOnBoard);
+ pgr->SetState(Ui::STATE_VISIBLE, bOnBoard);
}
- pgr = (CGroup*)pw->SearchControl(EVENT_OBJECT_CORNERdr);
+ pgr = static_cast< Ui::CGroup* >(pw->SearchControl(EVENT_OBJECT_CORNERdr));
if ( pgr != 0 )
{
- pgr->SetState(STATE_VISIBLE, bOnBoard);
+ pgr->SetState(Ui::STATE_VISIBLE, bOnBoard);
}
}
@@ -2130,9 +2096,9 @@ void CBrain::UpdateInterface(float rTime)
void CBrain::UpdateInterface()
{
ObjectType type;
- CWindow* pw;
- CButton* pb;
- CSlider* ps;
+ Ui::CWindow* pw;
+ Ui::CButton* pb;
+ Ui::CSlider* ps;
#if _TEEN
CColor* pc;
int color;
@@ -2140,12 +2106,12 @@ void CBrain::UpdateInterface()
bool bEnable, bFly, bRun;
char title[100];
- if ( !m_object->RetSelect() ) return;
+ if ( !m_object->GetSelect() ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
- type = m_object->RetType();
+ type = m_object->GetType();
bEnable = ( m_secondaryTask == 0 && m_program == -1 );
@@ -2202,10 +2168,10 @@ void CBrain::UpdateInterface()
EnableInterface(pw, EVENT_OBJECT_BXXXX, bEnable);
}
- pb = (CButton*)pw->SearchControl(EVENT_OBJECT_GFLAT);
+ pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_GFLAT));
if ( pb != 0 )
{
- pb->SetState(STATE_VISIBLE, m_engine->RetGroundSpot());
+ pb->SetState(Ui::STATE_VISIBLE, m_engine->GetGroundSpot());
}
if ( type == OBJECT_HUMAN || // builder?
@@ -2235,21 +2201,21 @@ void CBrain::UpdateInterface()
DefaultEnter (pw, EVENT_OBJECT_ENDSHIELD, false);
}
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_DIMSHIELD);
+ ps = static_cast< Ui::CSlider* >(pw->SearchControl(EVENT_OBJECT_DIMSHIELD));
if ( ps != 0 )
{
- ps->SetVisibleValue((RADIUS_SHIELD_MIN/g_unit)+m_object->RetParam()*((RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)/g_unit));
+ ps->SetVisibleValue((RADIUS_SHIELD_MIN/g_unit)+m_object->GetParam()*((RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)/g_unit));
}
}
bFly = bEnable;
if ( bFly && (type == OBJECT_HUMAN || type == OBJECT_TECH) )
{
- if ( m_object->RetFret() != 0 ) bFly = false; // if holder -> not fly
+ if ( m_object->GetFret() != 0 ) bFly = false; // if holder -> not fly
}
EnableInterface(pw, EVENT_OBJECT_GASUP, bFly);
EnableInterface(pw, EVENT_OBJECT_GASDOWN, bFly);
- if ( m_object->RetTrainer() ) // Training?
+ if ( m_object->GetTrainer() ) // Training?
{
DeadInterface(pw, EVENT_OBJECT_GASUP, false);
DeadInterface(pw, EVENT_OBJECT_GASDOWN, false);
@@ -2308,7 +2274,7 @@ void CBrain::UpdateInterface()
if ( m_bTraceRecord ) bRun = false;
EnableInterface(pw, EVENT_OBJECT_PROGRUN, bRun);
- pb = (CButton*)pw->SearchControl(EVENT_OBJECT_PROGRUN);
+ pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_PROGRUN));
if ( pb != 0 )
{
pb->SetIcon(m_program==-1?21:8); // run/stop
@@ -2334,103 +2300,103 @@ void CBrain::UpdateInterface()
}
#if _TEEN
- if ( m_object->RetTraceDown() )
+ if ( m_object->GetTraceDown() )
{
- pb = (CButton*)pw->SearchControl(EVENT_OBJECT_PEN0);
+ pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_PEN0));
if ( pb != 0 )
{
- pb->ClearState(STATE_CHECK);
+ pb->ClearState(Ui::STATE_CHECK);
}
- color = m_object->RetTraceColor();
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN1);
+ color = m_object->GetTraceColor();
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN1));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, color==1);
+ pc->SetState(Ui::STATE_CHECK, color==1);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN2);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN2));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, color==8);
+ pc->SetState(Ui::STATE_CHECK, color==8);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN3);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN3));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, color==7);
+ pc->SetState(Ui::STATE_CHECK, color==7);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN4);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN4));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, color==4);
+ pc->SetState(Ui::STATE_CHECK, color==4);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN5);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN5));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, color==6);
+ pc->SetState(Ui::STATE_CHECK, color==6);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN6);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN6));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, color==14);
+ pc->SetState(Ui::STATE_CHECK, color==14);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN7);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN7));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, color==12);
+ pc->SetState(Ui::STATE_CHECK, color==12);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN8);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN8));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, color==10);
+ pc->SetState(Ui::STATE_CHECK, color==10);
}
}
else
{
- pb = (CButton*)pw->SearchControl(EVENT_OBJECT_PEN0);
+ pb = static_cast< Ui::CButton* >(pw->SearchControl(EVENT_OBJECT_PEN0));
if ( pb != 0 )
{
- pb->SetState(STATE_CHECK);
+ pb->SetState(Ui::STATE_CHECK);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN1);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN1));
if ( pc != 0 )
{
- pc->ClearState(STATE_CHECK);
+ pc->ClearState(Ui::STATE_CHECK);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN2);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN2));
if ( pc != 0 )
{
- pc->ClearState(STATE_CHECK);
+ pc->ClearState(Ui::STATE_CHECK);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN3);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN3));
if ( pc != 0 )
{
- pc->ClearState(STATE_CHECK);
+ pc->ClearState(Ui::STATE_CHECK);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN4);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN4));
if ( pc != 0 )
{
- pc->ClearState(STATE_CHECK);
+ pc->ClearState(Ui::STATE_CHECK);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN5);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN5));
if ( pc != 0 )
{
- pc->ClearState(STATE_CHECK);
+ pc->ClearState(Ui::STATE_CHECK);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN6);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN6));
if ( pc != 0 )
{
- pc->ClearState(STATE_CHECK);
+ pc->ClearState(Ui::STATE_CHECK);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN7);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN7));
if ( pc != 0 )
{
- pc->ClearState(STATE_CHECK);
+ pc->ClearState(Ui::STATE_CHECK);
}
- pc = (CColor*)pw->SearchControl(EVENT_OBJECT_PEN8);
+ pc = static_cast< Ui::CColor* >(pw->SearchControl(EVENT_OBJECT_PEN8));
if ( pc != 0 )
{
- pc->ClearState(STATE_CHECK);
+ pc->ClearState(Ui::STATE_CHECK);
}
}
#endif
@@ -2438,19 +2404,19 @@ void CBrain::UpdateInterface()
// Updates the list of programs.
-void CBrain::UpdateScript(CWindow *pw)
+void CBrain::UpdateScript(Ui::CWindow *pw)
{
- CList* pl;
+ Ui::CList* pl;
char name[100];
char title[100];
int i;
bool bSoluce;
- pl = (CList*)pw->SearchControl(EVENT_OBJECT_PROGLIST);
+ pl = static_cast< Ui::CList* >(pw->SearchControl(EVENT_OBJECT_PROGLIST));
if ( pl == 0 ) return;
#if _SCHOOL
- bSoluce = m_main->RetSoluce4();
+ bSoluce = m_main->GetSoluce4();
#else
bSoluce = true;
#endif
@@ -2484,35 +2450,35 @@ void CBrain::UpdateScript(CWindow *pw)
pl->ShowSelect(true);
}
-// Returns the rank of selected script.
+// Geturns the rank of selected script.
-int CBrain::RetSelScript()
+int CBrain::GetSelScript()
{
- CWindow* pw;
- CList* pl;
+ Ui::CWindow* pw;
+ Ui::CList* pl;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return -1;
- pl = (CList*)pw->SearchControl(EVENT_OBJECT_PROGLIST);
+ pl = static_cast< Ui::CList* >(pw->SearchControl(EVENT_OBJECT_PROGLIST));
if ( pl == 0 ) return -1;
- return pl->RetSelect();
+ return pl->GetSelect();
}
// Blinks the running program.
void CBrain::BlinkScript(bool bEnable)
{
- CWindow* pw;
- CList* pl;
+ Ui::CWindow* pw;
+ Ui::CList* pl;
- if ( !m_object->RetSelect() ) return; // robot not selected?
+ if ( !m_object->GetSelect() ) return; // robot not selected?
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast< Ui::CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_OBJECT_PROGLIST);
+ pl = static_cast< Ui::CList* >(pw->SearchControl(EVENT_OBJECT_PROGLIST));
if ( pl == 0 ) return;
pl->SetBlink(bEnable);
@@ -2520,57 +2486,57 @@ void CBrain::BlinkScript(bool bEnable)
// Check the status of a button interface.
-void CBrain::CheckInterface(CWindow *pw, EventMsg event, bool bState)
+void CBrain::CheckInterface(Ui::CWindow *pw, EventType event, bool bState)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
if ( control == 0 ) return;
- control->SetState(STATE_CHECK, bState);
+ control->SetState(Ui::STATE_CHECK, bState);
}
// Changes the state of a button interface.
-void CBrain::EnableInterface(CWindow *pw, EventMsg event, bool bState)
+void CBrain::EnableInterface(Ui::CWindow *pw, EventType event, bool bState)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
if ( control == 0 ) return;
- control->SetState(STATE_ENABLE, bState);
+ control->SetState(Ui::STATE_ENABLE, bState);
}
// Changes the state of a button on the interface.
-void CBrain::DeadInterface(CWindow *pw, EventMsg event, bool bState)
+void CBrain::DeadInterface(Ui::CWindow *pw, EventType event, bool bState)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
if ( control == 0 ) return;
- control->SetState(STATE_DEAD, !bState);
+ control->SetState(Ui::STATE_DEAD, !bState);
}
// Change the default input state of a button interface.
-void CBrain::DefaultEnter(CWindow *pw, EventMsg event, bool bState)
+void CBrain::DefaultEnter(Ui::CWindow *pw, EventType event, bool bState)
{
- CControl* control;
+ Ui::CControl* control;
control = pw->SearchControl(event);
if ( control == 0 ) return;
if ( bState )
{
- control->SetState(STATE_DEFAULT);
+ control->SetState(Ui::STATE_DEFAULT);
m_defaultEnter = event;
}
else
{
- control->ClearState(STATE_DEFAULT);
+ control->ClearState(Ui::STATE_DEFAULT);
}
}
@@ -2589,7 +2555,7 @@ void CBrain::SetActivity(bool bMode)
m_bActivity = bMode;
}
-bool CBrain::RetActivity()
+bool CBrain::GetActivity()
{
return m_bActivity;
}
@@ -2619,12 +2585,12 @@ void CBrain::RunProgram(int rank)
{
m_program = rank; // start new program
BlinkScript(true); // blink
- m_object->CreateSelectParticule();
+ m_object->CreateSelectParticle();
m_main->UpdateShortcuts();
}
}
-// Returns the first free program.
+// Geturns the first free program.
int CBrain::FreeProgram()
{
@@ -2638,9 +2604,9 @@ int CBrain::FreeProgram()
}
-// Returns the current program.
+// Geturns the current program.
-int CBrain::RetProgram()
+int CBrain::GetProgram()
{
return m_program;
}
@@ -2653,7 +2619,7 @@ void CBrain::SetScriptRun(int rank)
m_scriptRun = rank;
}
-int CBrain::RetScriptRun()
+int CBrain::GetScriptRun()
{
return m_scriptRun;
}
@@ -2663,7 +2629,7 @@ void CBrain::SetScriptName(int rank, char *name)
strcpy(m_scriptName[rank], name);
}
-char* CBrain::RetScriptName(int rank)
+char* CBrain::GetScriptName(int rank)
{
return m_scriptName[rank];
}
@@ -2673,7 +2639,7 @@ void CBrain::SetSoluceName(char *name)
strcpy(m_soluceName, name);
}
-char* CBrain::RetSoluceName()
+char* CBrain::GetSoluceName()
{
return m_soluceName;
}
@@ -2708,7 +2674,7 @@ bool CBrain::ReadSoluce(char* filename)
// Load a script with a text file.
-bool CBrain::ReadProgram(int rank, char* filename)
+bool CBrain::ReadProgram(int rank, const char* filename)
{
if ( m_script[rank] == 0 )
{
@@ -2725,10 +2691,10 @@ bool CBrain::ReadProgram(int rank, char* filename)
// Indicates whether a program is compiled correctly.
-bool CBrain::RetCompile(int rank)
+bool CBrain::GetCompile(int rank)
{
if ( m_script[rank] == 0 ) return false;
- return m_script[rank]->RetCompile();
+ return m_script[rank]->GetCompile();
}
// Saves a script in a text file.
@@ -2807,12 +2773,12 @@ void CBrain::TraceRecordStart()
{
m_traceOper = TO_STOP;
- m_tracePos = m_object->RetPosition(0);
- m_traceAngle = m_object->RetAngleY(0);
+ m_tracePos = m_object->GetPosition(0);
+ m_traceAngle = m_object->GetAngleY(0);
- if ( m_object->RetTraceDown() ) // pencil down?
+ if ( m_object->GetTraceDown() ) // pencil down?
{
- m_traceColor = m_object->RetTraceColor();
+ m_traceColor = m_object->GetTraceColor();
}
else // pen up?
{
@@ -2820,7 +2786,7 @@ void CBrain::TraceRecordStart()
}
delete m_traceRecordBuffer;
- m_traceRecordBuffer = (TraceRecord*)malloc(sizeof(TraceRecord)*MAXTRACERECORD);
+ m_traceRecordBuffer = static_cast<TraceRecord*>(malloc(sizeof(TraceRecord)*MAXTRACERECORD));
m_traceRecordIndex = 0;
}
@@ -2833,16 +2799,16 @@ void CBrain::TraceRecordFrame()
float angle, len, speed;
int color;
- speed = m_physics->RetLinMotionX(MO_REASPEED);
+ speed = m_physics->GetLinMotionX(MO_REASPEED);
if ( speed > 0.0f ) oper = TO_ADVANCE;
if ( speed < 0.0f ) oper = TO_RECEDE;
- speed = m_physics->RetCirMotionY(MO_REASPEED);
+ speed = m_physics->GetCirMotionY(MO_REASPEED);
if ( speed != 0.0f ) oper = TO_TURN;
- if ( m_object->RetTraceDown() ) // pencil down?
+ if ( m_object->GetTraceDown() ) // pencil down?
{
- color = m_object->RetTraceColor();
+ color = m_object->GetTraceColor();
}
else // pen up?
{
@@ -2855,24 +2821,24 @@ void CBrain::TraceRecordFrame()
if ( m_traceOper == TO_ADVANCE ||
m_traceOper == TO_RECEDE )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
len = Math::DistanceProjected(pos, m_tracePos);
TraceRecordOper(m_traceOper, len);
}
if ( m_traceOper == TO_TURN )
{
- angle = m_object->RetAngleY(0)-m_traceAngle;
+ angle = m_object->GetAngleY(0)-m_traceAngle;
TraceRecordOper(m_traceOper, angle);
}
if ( color != m_traceColor )
{
- TraceRecordOper(TO_PEN, (float)color);
+ TraceRecordOper(TO_PEN, static_cast<float>(color));
}
m_traceOper = oper;
- m_tracePos = m_object->RetPosition(0);
- m_traceAngle = m_object->RetAngleY(0);
+ m_tracePos = m_object->GetPosition(0);
+ m_traceAngle = m_object->GetAngleY(0);
m_traceColor = color;
}
}
@@ -2889,7 +2855,7 @@ void CBrain::TraceRecordStop()
if ( m_traceRecordBuffer == 0 ) return;
max = 10000;
- buffer = (char*)malloc(max);
+ buffer = static_cast<char*>(malloc(max));
*buffer = 0;
strncat(buffer, "extern void object::AutoDraw()\n{\n", max-1);
@@ -2975,14 +2941,14 @@ bool CBrain::TraceRecordPut(char *buffer, int max, TraceOper oper, float param)
if ( oper == TO_TURN )
{
param = -param*180.0f/Math::PI;
- sprintf(line, "\tturn(%d);\n", (int)param);
+ sprintf(line, "\tturn(%d);\n", static_cast<int>(param));
//? sprintf(line, "\tturn(%.1f);\n", param);
strncat(buffer, line, max-1);
}
if ( oper == TO_PEN )
{
- color = (int)param;
+ color = static_cast<int>(param);
if ( color == -1 ) strncat(buffer, "\tpenup();\n", max-1);
if ( color == 1 ) strncat(buffer, "\tpendown(Black);\n", max-1);
if ( color == 8 ) strncat(buffer, "\tpendown(Yellow);\n", max-1);
diff --git a/src/object/brain.h b/src/object/brain.h
index 0220ffc..008fb67 100644
--- a/src/object/brain.h
+++ b/src/object/brain.h
@@ -18,11 +18,9 @@
#pragma once
-
-#include <stdio.h>
-
-#include "common/misc.h"
#include "common/event.h"
+#include "common/misc.h"
+
#include "object/object.h"
#include "object/task/taskmanip.h"
#include "object/task/taskflag.h"
@@ -30,22 +28,28 @@
class CInstanceManager;
-class CD3DEngine;
-class CTerrain;
-class CWater;
-class CCamera;
class CObject;
class CPhysics;
class CMotion;
class CTaskManager;
-class CInterface;
-class CWindow;
-class CDisplayText;
class CScript;
class CRobotMain;
+class CSoundInterface;
+
+namespace Ui {
class CStudio;
-class CSound;
-class CParticule;
+class CInterface;
+class CWindow;
+class CDisplayText;
+}
+
+namespace Gfx {
+class CEngine;
+class CTerrain;
+class CWater;
+class CCamera;
+class CParticle;
+} /* Gfx */
const int BRAINMAXSCRIPT = 10;
@@ -88,29 +92,29 @@ public:
bool IsBusy();
void SetActivity(bool bMode);
- bool RetActivity();
+ bool GetActivity();
bool IsProgram();
bool ProgramExist(int rank);
void RunProgram(int rank);
int FreeProgram();
- int RetProgram();
+ int GetProgram();
void StopProgram();
void StopTask();
bool IntroduceVirus();
void SetActiveVirus(bool bActive);
- bool RetActiveVirus();
+ bool GetActiveVirus();
void SetScriptRun(int rank);
- int RetScriptRun();
+ int GetScriptRun();
void SetScriptName(int rank, char *name);
- char* RetScriptName(int rank);
+ char* GetScriptName(int rank);
void SetSoluceName(char *name);
- char* RetSoluceName();
+ char* GetSoluceName();
bool ReadSoluce(char* filename);
- bool ReadProgram(int rank, char* filename);
- bool RetCompile(int rank);
+ bool ReadProgram(int rank, const char* filename);
+ bool GetCompile(int rank);
bool WriteProgram(int rank, char* filename);
bool ReadStack(FILE *file);
bool WriteStack(FILE *file);
@@ -143,14 +147,14 @@ protected:
void GroundFlat();
void ColorFlag(int color);
- void UpdateScript(CWindow *pw);
- int RetSelScript();
+ void UpdateScript(Ui::CWindow *pw);
+ int GetSelScript();
void BlinkScript(bool bEnable);
- void CheckInterface(CWindow *pw, EventMsg event, bool bState);
- void EnableInterface(CWindow *pw, EventMsg event, bool bState);
- void DeadInterface(CWindow *pw, EventMsg event, bool bState);
- void DefaultEnter(CWindow *pw, EventMsg event, bool bState=true);
+ void CheckInterface(Ui::CWindow *pw, EventType event, bool bState);
+ void EnableInterface(Ui::CWindow *pw, EventType event, bool bState);
+ void DeadInterface(Ui::CWindow *pw, EventType event, bool bState);
+ void DefaultEnter(Ui::CWindow *pw, EventType event, bool bState=true);
void TraceRecordStart();
void TraceRecordFrame();
@@ -159,60 +163,61 @@ protected:
bool TraceRecordPut(char *buffer, int max, TraceOper oper, float param);
protected:
- CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CTerrain* m_terrain;
- CWater* m_water;
- CCamera* m_camera;
- CObject* m_object;
- CPhysics* m_physics;
- CMotion* m_motion;
- CInterface* m_interface;
- CDisplayText* m_displayText;
- CRobotMain* m_main;
- CStudio* m_studio;
- CSound* m_sound;
- CParticule* m_particule;
- CTaskManager* m_primaryTask;
- CTaskManager* m_secondaryTask;
-
- CScript* m_script[BRAINMAXSCRIPT];
- int m_selScript; // rank of the selected script
- int m_program; // rank of the executed program / ​​-1
- bool m_bActivity;
- bool m_bBurn;
- bool m_bActiveVirus;
-
- int m_scriptRun;
- char m_scriptName[BRAINMAXSCRIPT][50];
- char m_soluceName[50];
-
- EventMsg m_buttonAxe;
- EventMsg m_manipStyle;
- EventMsg m_defaultEnter;
- EventMsg m_interfaceEvent[100];
-
- CObject* m_antTarget;
- CObject* m_beeBullet;
- float m_beeBulletSpeed;
- Math::Vector m_startPos;
- float m_time;
- float m_burnTime;
- float m_lastUpdateTime;
- float m_lastHumanTime;
- float m_lastSpiderTime;
- float m_lastWormTime;
- float m_lastBulletTime;
- float m_lastAlarmTime;
- int m_soundChannelAlarm;
- int m_flagColor;
-
- bool m_bTraceRecord;
- TraceOper m_traceOper;
- Math::Vector m_tracePos;
- float m_traceAngle;
- int m_traceColor;
- int m_traceRecordIndex;
- TraceRecord* m_traceRecordBuffer;
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ Gfx::CTerrain* m_terrain;
+ Gfx::CWater* m_water;
+ Gfx::CCamera* m_camera;
+ Gfx::CParticle* m_particle;
+ CObject* m_object;
+ CPhysics* m_physics;
+ CMotion* m_motion;
+ Ui::CInterface* m_interface;
+ Ui::CDisplayText* m_displayText;
+ CRobotMain* m_main;
+ Ui::CStudio* m_studio;
+ CSoundInterface* m_sound;
+
+ CTaskManager* m_primaryTask;
+ CTaskManager* m_secondaryTask;
+
+ CScript* m_script[BRAINMAXSCRIPT];
+ int m_selScript; // rank of the selected script
+ int m_program; // rank of the executed program / ​​-1
+ bool m_bActivity;
+ bool m_bBurn;
+ bool m_bActiveVirus;
+
+ int m_scriptRun;
+ char m_scriptName[BRAINMAXSCRIPT][50];
+ char m_soluceName[50];
+
+ EventType m_buttonAxe;
+ EventType m_manipStyle;
+ EventType m_defaultEnter;
+ EventType m_interfaceEvent[100];
+
+ CObject* m_antTarget;
+ CObject* m_beeBullet;
+ float m_beeBulletSpeed;
+ Math::Vector m_startPos;
+ float m_time;
+ float m_burnTime;
+ float m_lastUpdateTime;
+ float m_lastHumanTime;
+ float m_lastSpiderTime;
+ float m_lastWormTime;
+ float m_lastBulletTime;
+ float m_lastAlarmTime;
+ int m_soundChannelAlarm;
+ int m_flagColor;
+
+ bool m_bTraceRecord;
+ TraceOper m_traceOper;
+ Math::Vector m_tracePos;
+ float m_traceAngle;
+ int m_traceColor;
+ int m_traceRecordIndex;
+ TraceRecord* m_traceRecordBuffer;
};
diff --git a/src/object/mainmovie.cpp b/src/object/mainmovie.cpp
index 7049842..346f370 100644
--- a/src/object/mainmovie.cpp
+++ b/src/object/mainmovie.cpp
@@ -37,12 +37,10 @@ CMainMovie::CMainMovie(CInstanceManager* iMan)
m_iMan = iMan;
m_iMan->AddInstance(CLASS_SHORT, this);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
+ m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
Flush();
}
@@ -84,20 +82,20 @@ bool CMainMovie::Start(MainMovieType type, float time)
return true;
}
- motion = pObj->RetMotion();
+ motion = pObj->GetMotion();
if ( motion != 0 )
{
motion->SetAction(MHS_SATCOM, 0.5f); // reads the SatCom
}
- m_camera->RetCamera(m_initialEye, m_initialLookat);
- m_camera->SetType(CAMERA_SCRIPT);
- m_camera->SetSmooth(CS_HARD);
+ m_camera->GetCamera(m_initialEye, m_initialLookat);
+ m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
+ m_camera->SetSmooth(Gfx::CAM_SMOOTH_HARD);
m_camera->SetScriptEye(m_initialEye);
m_camera->SetScriptLookat(m_initialLookat);
m_camera->FixCamera();
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
m_finalLookat[0] = Math::Transform(*mat, Math::Vector( 1.6f, 1.0f, 1.2f));
m_finalEye[0] = Math::Transform(*mat, Math::Vector(-1.5f, 5.0f, 3.0f));
m_finalLookat[1] = Math::Transform(*mat, Math::Vector( 1.6f, 1.0f, 1.2f));
@@ -109,14 +107,14 @@ bool CMainMovie::Start(MainMovieType type, float time)
pObj = m_main->SearchHuman();
if ( pObj != 0 )
{
- motion = pObj->RetMotion();
+ motion = pObj->GetMotion();
if ( motion != 0 )
{
motion->SetAction(-1); // finishes reading SatCom
}
}
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
m_type = MM_NONE; // it's already over!
}
@@ -135,7 +133,7 @@ bool CMainMovie::Stop()
pObj = m_main->SearchHuman();
if ( pObj != 0 )
{
- motion = pObj->RetMotion();
+ motion = pObj->GetMotion();
if ( motion != 0 )
{
motion->SetAction(-1); // finishes reading SatCom
@@ -221,16 +219,16 @@ bool CMainMovie::EventProcess(const Event &event)
}
-// Returns the type of the current movie.
+// Geturns the type of the current movie.
-MainMovieType CMainMovie::RetType()
+MainMovieType CMainMovie::GetType()
{
return m_type;
}
-// Returns the type of movie stop.
+// Geturns the type of movie stop.
-MainMovieType CMainMovie::RetStopType()
+MainMovieType CMainMovie::GetStopType()
{
return m_stopType;
}
diff --git a/src/object/mainmovie.h b/src/object/mainmovie.h
index 23721fb..27e4df3 100644
--- a/src/object/mainmovie.h
+++ b/src/object/mainmovie.h
@@ -24,15 +24,14 @@
class CInstanceManager;
-class CEvent;
-class CD3DEngine;
-class CInterface;
class CRobotMain;
-class CCamera;
-class CSound;
-
-
+class CSoundInterface;
+namespace Gfx
+{
+ class CCamera;
+ class CEngine;
+};
enum MainMovieType
{
@@ -54,24 +53,22 @@ public:
bool Stop();
bool IsExist();
bool EventProcess(const Event &event);
- MainMovieType RetType();
- MainMovieType RetStopType();
+ MainMovieType GetType();
+ MainMovieType GetStopType();
protected:
protected:
- CInstanceManager* m_iMan;
- CEvent* m_event;
- CD3DEngine* m_engine;
- CInterface* m_interface;
- CRobotMain* m_main;
- CCamera* m_camera;
- CSound* m_sound;
-
- MainMovieType m_type;
- MainMovieType m_stopType;
- float m_speed;
- float m_progress;
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ CRobotMain* m_main;
+ Gfx::CCamera* m_camera;
+ CSoundInterface* m_sound;
+
+ MainMovieType m_type;
+ MainMovieType m_stopType;
+ float m_speed;
+ float m_progress;
Math::Vector m_initialEye;
Math::Vector m_initialLookat;
Math::Vector m_finalEye[2];
diff --git a/src/object/motion/motion.cpp b/src/object/motion/motion.cpp
index 6278627..df8a4be 100644
--- a/src/object/motion/motion.cpp
+++ b/src/object/motion/motion.cpp
@@ -17,14 +17,13 @@
// motion.cpp
-#include <stdio.h>
-
#include "object/motion/motion.h"
#include "common/iman.h"
#include "script/cmdtoken.h"
-
+#include <stdio.h>
+#include <string.h>
// Object's constructor.
@@ -34,14 +33,14 @@ CMotion::CMotion(CInstanceManager* iMan, CObject* object)
m_iMan = iMan;
m_iMan->AddInstance(CLASS_MOTION, this, 100);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
- m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
- m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast< Gfx::CEngine* >(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_light = static_cast< Gfx::CLight* >(m_iMan->SearchInstance(CLASS_LIGHT));
+ m_particle = static_cast< Gfx::CParticle* >(m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_terrain = static_cast< Gfx::CTerrain* >(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_water = static_cast< Gfx::CWater* >(m_iMan->SearchInstance(CLASS_WATER));
+ m_camera = static_cast< Gfx::CCamera* >(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_main = static_cast< CRobotMain* >(m_iMan->SearchInstance(CLASS_MAIN));
+ m_sound = static_cast< CSoundInterface* >(m_iMan->SearchInstance(CLASS_SOUND));
m_object = object;
m_physics = 0;
@@ -95,16 +94,16 @@ bool CMotion::EventProcess(const Event &event)
Math::Vector pos, dir;
float time;
- if ( m_object->RetType() != OBJECT_TOTO &&
- m_engine->RetPause() ) return true;
+ if ( m_object->GetType() != OBJECT_TOTO &&
+ m_engine->GetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_actionTime;
if ( m_progress > 1.0f ) m_progress = 1.0f; // (*)
- pos = m_object->RetPosition(0);
- if ( pos.y < m_water->RetLevel(m_object) ) // underwater?
+ pos = m_object->GetPosition(0);
+ if ( pos.y < m_water->GetLevel(m_object) ) // underwater?
{
time = event.rTime*3.0f; // everything is slower
}
@@ -113,19 +112,19 @@ bool CMotion::EventProcess(const Event &event)
time = event.rTime*10.0f;
}
- dir = m_object->RetLinVibration();
+ dir = m_object->GetLinVibration();
dir.x = Math::Smooth(dir.x, m_linVibration.x, time);
dir.y = Math::Smooth(dir.y, m_linVibration.y, time);
dir.z = Math::Smooth(dir.z, m_linVibration.z, time);
m_object->SetLinVibration(dir);
- dir = m_object->RetCirVibration();
+ dir = m_object->GetCirVibration();
dir.x = Math::Smooth(dir.x, m_cirVibration.x, time);
dir.y = Math::Smooth(dir.y, m_cirVibration.y, time);
dir.z = Math::Smooth(dir.z, m_cirVibration.z, time);
m_object->SetCirVibration(dir);
- dir = m_object->RetInclinaison();
+ dir = m_object->GetInclinaison();
dir.x = Math::Smooth(dir.x, m_inclinaison.x, time);
dir.y = Math::Smooth(dir.y, m_inclinaison.y, time);
dir.z = Math::Smooth(dir.z, m_inclinaison.z, time);
@@ -148,9 +147,9 @@ Error CMotion::SetAction(int action, float time)
return ERR_OK;
}
-// Returns the current action.
+// Geturns the current action.
-int CMotion::RetAction()
+int CMotion::GetAction()
{
return m_actionType;
}
@@ -163,7 +162,7 @@ bool CMotion::SetParam(int rank, float value)
return false;
}
-float CMotion::RetParam(int rank)
+float CMotion::GetParam(int rank)
{
return 0.0f;
}
@@ -208,7 +207,7 @@ void CMotion::SetLinVibration(Math::Vector dir)
m_linVibration = dir;
}
-Math::Vector CMotion::RetLinVibration()
+Math::Vector CMotion::GetLinVibration()
{
return m_linVibration;
}
@@ -220,7 +219,7 @@ void CMotion::SetCirVibration(Math::Vector dir)
m_cirVibration = dir;
}
-Math::Vector CMotion::RetCirVibration()
+Math::Vector CMotion::GetCirVibration()
{
return m_cirVibration;
}
@@ -232,7 +231,7 @@ void CMotion::SetInclinaison(Math::Vector dir)
m_inclinaison = dir;
}
-Math::Vector CMotion::RetInclinaison()
+Math::Vector CMotion::GetInclinaison()
{
return m_inclinaison;
}
diff --git a/src/object/motion/motion.h b/src/object/motion/motion.h
index 9828283..d195e65 100644
--- a/src/object/motion/motion.h
+++ b/src/object/motion/motion.h
@@ -20,22 +20,26 @@
#include "common/event.h"
-#include "common/misc.h"
+#include "common/global.h"
#include "object/object.h"
class CInstanceManager;
-class CD3DEngine;
+
+namespace Gfx {
+class CEngine;
class CLight;
-class CParticule;
+class CParticle;
class CTerrain;
class CWater;
class CCamera;
+}
+
class CBrain;
class CPhysics;
class CObject;
class CRobotMain;
-class CSound;
+class CSoundInterface;
class CMotion
@@ -47,44 +51,44 @@ public:
void SetPhysics(CPhysics* physics);
void SetBrain(CBrain* brain);
- virtual void DeleteObject(bool bAll=false);
- virtual bool Create(Math::Vector pos, float angle, ObjectType type, float power);
- virtual bool EventProcess(const Event &event);
- virtual Error SetAction(int action, float time=0.2f);
- virtual int RetAction();
+ virtual void DeleteObject(bool bAll=false);
+ virtual bool Create(Math::Vector pos, float angle, ObjectType type, float power);
+ virtual bool EventProcess(const Event &event);
+ virtual Error SetAction(int action, float time=0.2f);
+ virtual int GetAction();
- virtual bool SetParam(int rank, float value);
- virtual float RetParam(int rank);
+ virtual bool SetParam(int rank, float value);
+ virtual float GetParam(int rank);
- virtual bool Write(char *line);
- virtual bool Read(char *line);
+ virtual bool Write(char *line);
+ virtual bool Read(char *line);
- virtual void SetLinVibration(Math::Vector dir);
- virtual Math::Vector RetLinVibration();
- virtual void SetCirVibration(Math::Vector dir);
- virtual Math::Vector RetCirVibration();
- virtual void SetInclinaison(Math::Vector dir);
- virtual Math::Vector RetInclinaison();
+ virtual void SetLinVibration(Math::Vector dir);
+ virtual Math::Vector GetLinVibration();
+ virtual void SetCirVibration(Math::Vector dir);
+ virtual Math::Vector GetCirVibration();
+ virtual void SetInclinaison(Math::Vector dir);
+ virtual Math::Vector GetInclinaison();
protected:
protected:
- CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CLight* m_light;
- CParticule* m_particule;
- CTerrain* m_terrain;
- CWater* m_water;
- CCamera* m_camera;
- CObject* m_object;
- CBrain* m_brain;
- CPhysics* m_physics;
- CRobotMain* m_main;
- CSound* m_sound;
-
- int m_actionType;
- float m_actionTime;
- float m_progress;
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ Gfx::CLight* m_light;
+ Gfx::CParticle* m_particle;
+ Gfx::CTerrain* m_terrain;
+ Gfx::CWater* m_water;
+ Gfx::CCamera* m_camera;
+ CObject* m_object;
+ CBrain* m_brain;
+ CPhysics* m_physics;
+ CRobotMain* m_main;
+ CSoundInterface* m_sound;
+
+ int m_actionType;
+ float m_actionTime;
+ float m_progress;
Math::Vector m_linVibration; // linear vibration
Math::Vector m_cirVibration; // circular vibration
diff --git a/src/object/motion/motionant.cpp b/src/object/motion/motionant.cpp
index c6a9357..6259856 100644
--- a/src/object/motion/motionant.cpp
+++ b/src/object/motion/motionant.cpp
@@ -21,8 +21,8 @@
#include "object/motion/motionant.h"
-#include "old/modfile.h"
-#include "old/particule.h"
+#include "graphics/engine/modelfile.h"
+#include "graphics/engine/particle.h"
#include "physics/physics.h"
@@ -46,7 +46,7 @@ CMotionAnt::CMotionAnt(CInstanceManager* iMan, CObject* object)
m_armMemberIndex = 0;
m_armLastAction = -1;
m_bArmStop = false;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
}
// Object's destructor.
@@ -68,18 +68,18 @@ void CMotionAnt::DeleteObject(bool bAll)
bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank;
- if ( m_engine->RetRestCreate() < 3+18 ) return false;
+// if ( m_engine->GetRestCreate() < 3+18 ) return false;
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
// Creates the main base.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEVEHICULE); // this is a moving object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
pModFile->ReadModel("objects\\ant1.mod");
@@ -95,7 +95,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the head.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\ant2.mod");
@@ -104,7 +104,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the tail.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\ant3.mod");
@@ -113,7 +113,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-back thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -122,7 +122,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-back leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
pModFile->ReadModel("objects\\ant5.mod");
@@ -131,7 +131,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
pModFile->ReadModel("objects\\ant6.mod");
@@ -140,7 +140,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-right thighs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -149,7 +149,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-right legs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
pModFile->ReadModel("objects\\ant5.mod");
@@ -158,7 +158,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-right foots.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 7);
pModFile->ReadModel("objects\\ant6.mod");
@@ -167,7 +167,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right front thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -176,7 +176,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right front leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 9);
pModFile->ReadModel("objects\\ant5.mod");
@@ -185,7 +185,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 10);
pModFile->ReadModel("objects\\ant6.mod");
@@ -194,7 +194,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-back thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -204,7 +204,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-back leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
pModFile->ReadModel("objects\\ant5.mod");
@@ -214,7 +214,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 13);
pModFile->ReadModel("objects\\ant6.mod");
@@ -224,7 +224,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-left thighs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -234,7 +234,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-left legs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(16, rank);
m_object->SetObjectParent(16, 15);
pModFile->ReadModel("objects\\ant5.mod");
@@ -244,7 +244,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-left foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(17, rank);
m_object->SetObjectParent(17, 16);
pModFile->ReadModel("objects\\ant6.mod");
@@ -254,7 +254,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left front thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(18, rank);
m_object->SetObjectParent(18, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -264,7 +264,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left front leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19, rank);
m_object->SetObjectParent(19, 18);
pModFile->ReadModel("objects\\ant5.mod");
@@ -274,7 +274,7 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank,Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(20, rank);
m_object->SetObjectParent(20, 19);
pModFile->ReadModel("objects\\ant6.mod");
@@ -287,10 +287,10 @@ bool CMotionAnt::Create(Math::Vector pos, float angle, ObjectType type,
CreatePhysics();
m_object->SetFloorHeight(0.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_object->SetPosition(0, pos); // to display the shadows immediately
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -373,7 +373,7 @@ void CMotionAnt::CreatePhysics()
m_physics->SetType(TYPE_ROLLING);
- character = m_object->RetCharacter();
+ character = m_object->GetCharacter();
character->wheelFront = 3.0f;
character->wheelBack = 3.0f;
character->wheelLeft = 5.0f;
@@ -418,12 +418,12 @@ bool CMotionAnt::EventProcess(const Event &event)
{
CMotion::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
#if ADJUST_ANGLE
int i;
@@ -467,11 +467,11 @@ bool CMotionAnt::EventFrame(const Event &event)
int i, ii, st, nd, action;
bool bStop;
- if ( m_engine->RetPause() ) return true;
- if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( !m_engine->IsVisiblePoint(m_object->GetPosition(0)) ) return true;
- s = m_physics->RetLinMotionX(MO_MOTSPEED)*1.5f;
- a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.0f);
+ s = m_physics->GetLinMotionX(MO_MOTSPEED)*1.5f;
+ a = fabs(m_physics->GetCirMotionY(MO_MOTSPEED)*2.0f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -495,13 +495,13 @@ bool CMotionAnt::EventFrame(const Event &event)
m_armMember += a;
}
- if ( m_object->RetRuin() ) // destroyed?
+ if ( m_object->GetRuin() ) // destroyed?
{
m_actionType = MAS_RUIN;
}
- if ( m_object->RetBurn() ) // burning?
+ if ( m_object->GetBurn() ) // burning?
{
- if ( m_object->RetFixed() )
+ if ( m_object->GetFixed() )
{
m_actionType = MAS_BURN;
}
@@ -526,7 +526,7 @@ bool CMotionAnt::EventFrame(const Event &event)
else prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
if ( m_bArmStop )
{
- prog = (float)m_armTimeIndex/3.0f;
+ prog = static_cast< float >(m_armTimeIndex/3.0f);
}
if ( prog < 0.33f ) // t0..t1 ?
{
@@ -586,32 +586,32 @@ bool CMotionAnt::EventFrame(const Event &event)
if ( i < 3 ) // right leg (1..3) ?
{
- m_object->SetAngleX(3+3*i+0, Math::Smooth(m_object->RetAngleX(3+3*i+0), Math::PropAngle(tSt[0], tNd[0], prog), time));
- m_object->SetAngleY(3+3*i+0, Math::Smooth(m_object->RetAngleY(3+3*i+0), Math::PropAngle(tSt[1], tNd[1], prog), time));
- m_object->SetAngleZ(3+3*i+0, Math::Smooth(m_object->RetAngleZ(3+3*i+0), Math::PropAngle(tSt[2], tNd[2], prog), time));
- m_object->SetAngleX(3+3*i+1, Math::Smooth(m_object->RetAngleX(3+3*i+1), Math::PropAngle(tSt[3], tNd[3], prog), time));
- m_object->SetAngleY(3+3*i+1, Math::Smooth(m_object->RetAngleY(3+3*i+1), Math::PropAngle(tSt[4], tNd[4], prog), time));
- m_object->SetAngleZ(3+3*i+1, Math::Smooth(m_object->RetAngleZ(3+3*i+1), Math::PropAngle(tSt[5], tNd[5], prog), time));
- m_object->SetAngleX(3+3*i+2, Math::Smooth(m_object->RetAngleX(3+3*i+2), Math::PropAngle(tSt[6], tNd[6], prog), time));
- m_object->SetAngleY(3+3*i+2, Math::Smooth(m_object->RetAngleY(3+3*i+2), Math::PropAngle(tSt[7], tNd[7], prog), time));
- m_object->SetAngleZ(3+3*i+2, Math::Smooth(m_object->RetAngleZ(3+3*i+2), Math::PropAngle(tSt[8], tNd[8], prog), time));
+ m_object->SetAngleX(3+3*i+0, Math::Smooth(m_object->GetAngleX(3+3*i+0), Math::PropAngle(tSt[0], tNd[0], prog), time));
+ m_object->SetAngleY(3+3*i+0, Math::Smooth(m_object->GetAngleY(3+3*i+0), Math::PropAngle(tSt[1], tNd[1], prog), time));
+ m_object->SetAngleZ(3+3*i+0, Math::Smooth(m_object->GetAngleZ(3+3*i+0), Math::PropAngle(tSt[2], tNd[2], prog), time));
+ m_object->SetAngleX(3+3*i+1, Math::Smooth(m_object->GetAngleX(3+3*i+1), Math::PropAngle(tSt[3], tNd[3], prog), time));
+ m_object->SetAngleY(3+3*i+1, Math::Smooth(m_object->GetAngleY(3+3*i+1), Math::PropAngle(tSt[4], tNd[4], prog), time));
+ m_object->SetAngleZ(3+3*i+1, Math::Smooth(m_object->GetAngleZ(3+3*i+1), Math::PropAngle(tSt[5], tNd[5], prog), time));
+ m_object->SetAngleX(3+3*i+2, Math::Smooth(m_object->GetAngleX(3+3*i+2), Math::PropAngle(tSt[6], tNd[6], prog), time));
+ m_object->SetAngleY(3+3*i+2, Math::Smooth(m_object->GetAngleY(3+3*i+2), Math::PropAngle(tSt[7], tNd[7], prog), time));
+ m_object->SetAngleZ(3+3*i+2, Math::Smooth(m_object->GetAngleZ(3+3*i+2), Math::PropAngle(tSt[8], tNd[8], prog), time));
}
else // left leg (4..6) ?
{
- m_object->SetAngleX(3+3*i+0, Math::Smooth(m_object->RetAngleX(3+3*i+0), Math::PropAngle(-tSt[0], -tNd[0], prog), time));
- m_object->SetAngleY(3+3*i+0, Math::Smooth(m_object->RetAngleY(3+3*i+0), Math::PropAngle(-tSt[1], -tNd[1], prog), time));
- m_object->SetAngleZ(3+3*i+0, Math::Smooth(m_object->RetAngleZ(3+3*i+0), Math::PropAngle( tSt[2], tNd[2], prog), time));
- m_object->SetAngleX(3+3*i+1, Math::Smooth(m_object->RetAngleX(3+3*i+1), Math::PropAngle(-tSt[3], -tNd[3], prog), time));
- m_object->SetAngleY(3+3*i+1, Math::Smooth(m_object->RetAngleY(3+3*i+1), Math::PropAngle(-tSt[4], -tNd[4], prog), time));
- m_object->SetAngleZ(3+3*i+1, Math::Smooth(m_object->RetAngleZ(3+3*i+1), Math::PropAngle( tSt[5], tNd[5], prog), time));
- m_object->SetAngleX(3+3*i+2, Math::Smooth(m_object->RetAngleX(3+3*i+2), Math::PropAngle(-tSt[6], -tNd[6], prog), time));
- m_object->SetAngleY(3+3*i+2, Math::Smooth(m_object->RetAngleY(3+3*i+2), Math::PropAngle(-tSt[7], -tNd[7], prog), time));
- m_object->SetAngleZ(3+3*i+2, Math::Smooth(m_object->RetAngleZ(3+3*i+2), Math::PropAngle( tSt[8], tNd[8], prog), time));
+ m_object->SetAngleX(3+3*i+0, Math::Smooth(m_object->GetAngleX(3+3*i+0), Math::PropAngle(-tSt[0], -tNd[0], prog), time));
+ m_object->SetAngleY(3+3*i+0, Math::Smooth(m_object->GetAngleY(3+3*i+0), Math::PropAngle(-tSt[1], -tNd[1], prog), time));
+ m_object->SetAngleZ(3+3*i+0, Math::Smooth(m_object->GetAngleZ(3+3*i+0), Math::PropAngle( tSt[2], tNd[2], prog), time));
+ m_object->SetAngleX(3+3*i+1, Math::Smooth(m_object->GetAngleX(3+3*i+1), Math::PropAngle(-tSt[3], -tNd[3], prog), time));
+ m_object->SetAngleY(3+3*i+1, Math::Smooth(m_object->GetAngleY(3+3*i+1), Math::PropAngle(-tSt[4], -tNd[4], prog), time));
+ m_object->SetAngleZ(3+3*i+1, Math::Smooth(m_object->GetAngleZ(3+3*i+1), Math::PropAngle( tSt[5], tNd[5], prog), time));
+ m_object->SetAngleX(3+3*i+2, Math::Smooth(m_object->GetAngleX(3+3*i+2), Math::PropAngle(-tSt[6], -tNd[6], prog), time));
+ m_object->SetAngleY(3+3*i+2, Math::Smooth(m_object->GetAngleY(3+3*i+2), Math::PropAngle(-tSt[7], -tNd[7], prog), time));
+ m_object->SetAngleZ(3+3*i+2, Math::Smooth(m_object->GetAngleZ(3+3*i+2), Math::PropAngle( tSt[8], tNd[8], prog), time));
}
}
#if ADJUST_ANGLE
- if ( m_object->RetSelect() )
+ if ( m_object->GetSelect() )
{
char s[100];
sprintf(s, "A:time=%d Q:part=%d W:member=%d", m_armTimeIndex, m_armPartIndex, m_armMemberIndex);
@@ -664,8 +664,8 @@ bool CMotionAnt::EventFrame(const Event &event)
SetInclinaison(dir);
time = event.rTime*1.0f;
- m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), 0.0f, time)); // head
- m_object->SetAngleZ(2, Math::Smooth(m_object->RetAngleZ(2), 0.0f, time)); // tail
+ m_object->SetAngleZ(1, Math::Smooth(m_object->GetAngleZ(1), 0.0f, time)); // head
+ m_object->SetAngleZ(2, Math::Smooth(m_object->GetAngleZ(2), 0.0f, time)); // tail
}
else if ( m_actionType == MAS_RUIN ) // destroyed?
{
@@ -676,17 +676,17 @@ bool CMotionAnt::EventFrame(const Event &event)
}
else if ( m_actionType == MAS_BACK1 ) // starts on the back?
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_armTimeAbs )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_armTimeAbs )
{
- m_lastParticule = m_armTimeAbs;
+ m_lastParticle = m_armTimeAbs;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*10.0f;
speed.z = (Math::Rand()-0.5f)*10.0f;
speed.y = Math::Rand()*5.0f;
dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
if ( m_progress < 0.5f )
@@ -718,13 +718,13 @@ bool CMotionAnt::EventFrame(const Event &event)
}
else if ( m_actionType == MAS_BACK2 ) // moves on the back?
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_armTimeAbs )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_armTimeAbs )
{
- m_lastParticule = m_armTimeAbs;
+ m_lastParticle = m_armTimeAbs;
if ( rand()%10 == 0 )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*5.0f;
pos.z += (Math::Rand()-0.5f)*5.0f;
pos.y -= 1.0f;
@@ -733,7 +733,7 @@ bool CMotionAnt::EventFrame(const Event &event)
speed.y = Math::Rand()*2.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
}
@@ -767,17 +767,17 @@ bool CMotionAnt::EventFrame(const Event &event)
}
else if ( m_actionType == MAS_BACK3 ) // goes back on the legs?
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_armTimeAbs )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_armTimeAbs )
{
- m_lastParticule = m_armTimeAbs;
+ m_lastParticle = m_armTimeAbs;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*10.0f;
speed.z = (Math::Rand()-0.5f)*10.0f;
speed.y = Math::Rand()*5.0f;
dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
if ( m_progress < 0.5f )
diff --git a/src/object/motion/motionant.h b/src/object/motion/motionant.h
index 8ddd789..68a3b7f 100644
--- a/src/object/motion/motionant.h
+++ b/src/object/motion/motionant.h
@@ -68,6 +68,6 @@ protected:
int m_armMemberIndex;
int m_armLastAction;
bool m_bArmStop;
- float m_lastParticule;
+ float m_lastParticle;
};
diff --git a/src/object/motion/motionbee.cpp b/src/object/motion/motionbee.cpp
index e5c6b24..c679876 100644
--- a/src/object/motion/motionbee.cpp
+++ b/src/object/motion/motionbee.cpp
@@ -21,7 +21,7 @@
#include "object/motion/motionbee.h"
-#include "old/modfile.h"
+#include "graphics/engine/modelfile.h"
#include "physics/physics.h"
@@ -66,18 +66,18 @@ void CMotionBee::DeleteObject(bool bAll)
bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank;
- if ( m_engine->RetRestCreate() < 3+18+2 ) return false;
+// if ( m_engine->GetRestCreate() < 3+18+2 ) return false;
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
// Creates main base.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEVEHICULE); // this is a moving object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
pModFile->ReadModel("objects\\bee1.mod");
@@ -93,7 +93,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the head.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\bee2.mod");
@@ -102,7 +102,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the tail.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\bee3.mod");
@@ -111,7 +111,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-back thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -120,7 +120,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-back leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
pModFile->ReadModel("objects\\ant5.mod");
@@ -129,7 +129,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
pModFile->ReadModel("objects\\ant6.mod");
@@ -138,7 +138,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-right thighs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -147,7 +147,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-right legs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
pModFile->ReadModel("objects\\ant5.mod");
@@ -156,7 +156,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-right feet.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 7);
pModFile->ReadModel("objects\\ant6.mod");
@@ -165,7 +165,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right front thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -174,7 +174,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right front leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 9);
pModFile->ReadModel("objects\\ant5.mod");
@@ -183,7 +183,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 10);
pModFile->ReadModel("objects\\ant6.mod");
@@ -192,7 +192,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-back thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -202,7 +202,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-back leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
pModFile->ReadModel("objects\\ant5.mod");
@@ -211,7 +211,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 13);
pModFile->ReadModel("objects\\ant6.mod");
@@ -220,7 +220,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-left thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -230,7 +230,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-left legs.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(16, rank);
m_object->SetObjectParent(16, 15);
pModFile->ReadModel("objects\\ant5.mod");
@@ -239,7 +239,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates two middle-left feet.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(17, rank);
m_object->SetObjectParent(17, 16);
pModFile->ReadModel("objects\\ant6.mod");
@@ -248,7 +248,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates front-left thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(18, rank);
m_object->SetObjectParent(18, 0);
pModFile->ReadModel("objects\\ant4.mod");
@@ -258,7 +258,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates front-left leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19, rank);
m_object->SetObjectParent(19, 18);
pModFile->ReadModel("objects\\ant5.mod");
@@ -267,7 +267,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates front-left foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(20, rank);
m_object->SetObjectParent(20, 19);
pModFile->ReadModel("objects\\ant6.mod");
@@ -276,7 +276,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right wing.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(21, rank);
m_object->SetObjectParent(21, 0);
pModFile->ReadModel("objects\\bee7.mod");
@@ -285,7 +285,7 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left wing.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(22, rank);
m_object->SetObjectParent(22, 0);
pModFile->ReadModel("objects\\bee7.mod");
@@ -298,10 +298,10 @@ bool CMotionBee::Create(Math::Vector pos, float angle, ObjectType type,
CreatePhysics();
m_object->SetFloorHeight(0.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_object->SetPosition(0, pos); // to display the shadows immediately
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -348,7 +348,7 @@ void CMotionBee::CreatePhysics()
m_physics->SetType(TYPE_FLYING);
- character = m_object->RetCharacter();
+ character = m_object->GetCharacter();
character->wheelFront = 3.0f;
character->wheelBack = 3.0f;
character->wheelLeft = 5.0f;
@@ -394,12 +394,12 @@ bool CMotionBee::EventProcess(const Event &event)
{
CMotion::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
#if ADJUST_ANGLE
int i;
@@ -441,11 +441,11 @@ bool CMotionBee::EventFrame(const Event &event)
int action, i, st, nd;
bool bStop;
- if ( m_engine->RetPause() ) return true;
- if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( !m_engine->IsVisiblePoint(m_object->GetPosition(0)) ) return true;
- s = m_physics->RetLinMotionX(MO_MOTSPEED)*0.30f;
- a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.00f);
+ s = m_physics->GetLinMotionX(MO_MOTSPEED)*0.30f;
+ a = fabs(m_physics->GetCirMotionY(MO_MOTSPEED)*2.00f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -454,7 +454,7 @@ bool CMotionBee::EventFrame(const Event &event)
m_armMember += (s+a)*event.rTime*0.15f;
bStop = ( a == 0.0f && s == 0.0f ); // stopped?
- if ( !m_physics->RetLand() ) bStop = true;
+ if ( !m_physics->GetLand() ) bStop = true;
if ( bStop )
{
@@ -467,13 +467,13 @@ bool CMotionBee::EventFrame(const Event &event)
action = MB_MARCH; // flying
m_actionType = -1;
- if ( m_object->RetFret() != 0 ) m_actionType = MBS_HOLD; // carries the ball
+ if ( m_object->GetFret() != 0 ) m_actionType = MBS_HOLD; // carries the ball
- if ( m_object->RetRuin() ) // destroyed?
+ if ( m_object->GetRuin() ) // destroyed?
{
m_actionType = MBS_RUIN;
}
- if ( m_object->RetBurn() ) // burning?
+ if ( m_object->GetBurn() ) // burning?
{
m_actionType = MBS_BURN;
}
@@ -491,7 +491,7 @@ bool CMotionBee::EventFrame(const Event &event)
else prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
if ( m_bArmStop )
{
- prog = (float)m_armTimeIndex/3.0f;
+ prog = static_cast< float >(m_armTimeIndex/3.0f);
}
if ( prog < 0.33f ) // t0..t1 ?
{
@@ -542,7 +542,7 @@ bool CMotionBee::EventFrame(const Event &event)
}
#if ADJUST_ANGLE
- if ( m_object->RetSelect() )
+ if ( m_object->GetSelect() )
{
char s[100];
sprintf(s, "A:time=%d Q:part=%d W:member=%d", m_armTimeIndex, m_armPartIndex, m_armMemberIndex);
@@ -550,12 +550,12 @@ bool CMotionBee::EventFrame(const Event &event)
}
#endif
- if ( m_physics->RetLand() ) // on the ground?
+ if ( m_physics->GetLand() ) // on the ground?
{
- if ( m_object->RetRuin() )
+ if ( m_object->GetRuin() )
{
}
- else if ( bStop || m_object->RetBurn() )
+ else if ( bStop || m_object->GetBurn() )
{
m_object->SetAngleZ(2, sinf(m_armTimeAbs*1.7f)*0.15f+0.35f); // tail
}
@@ -595,7 +595,7 @@ bool CMotionBee::EventFrame(const Event &event)
}
}
- if ( m_physics->RetLand() )
+ if ( m_physics->GetLand() )
{
if ( bStop ) prog = 0.05f;
else prog = 0.15f;
@@ -628,7 +628,7 @@ bool CMotionBee::EventFrame(const Event &event)
m_object->SetAngleY(1, sinf(m_armTimeAbs*2.1f)*0.50f); // head
#if 0
- h = m_terrain->RetFloorHeight(RetPosition(0));
+ h = m_terrain->GetFloorHeight(GetPosition(0));
radius = 4.0f+h/4.0f;
color.r = 0.3f+h/80.0f;
color.g = color.r;
diff --git a/src/object/motion/motionhuman.cpp b/src/object/motion/motionhuman.cpp
index ba3003a..560a0de 100644
--- a/src/object/motion/motionhuman.cpp
+++ b/src/object/motion/motionhuman.cpp
@@ -21,9 +21,9 @@
#include "object/motion/motionhuman.h"
-#include "old/modfile.h"
-#include "old/terrain.h"
-#include "old/water.h"
+#include "graphics/engine/modelfile.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/water.h"
#include "math/geometry.h"
#include "object/robotmain.h"
#include "physics/physics.h"
@@ -72,7 +72,7 @@ void CMotionHuman::DeleteObject(bool bAll)
{
if ( m_partiReactor != -1 )
{
- m_particule->DeleteParticule(m_partiReactor);
+ m_particle->DeleteParticle(m_partiReactor);
m_partiReactor = -1;
}
}
@@ -93,32 +93,32 @@ Error CMotionHuman::SetAction(int action, float time)
bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
char filename[100];
int rank, option, face, glasses;
- if ( m_engine->RetRestCreate() < 16 ) return false;
+// if ( m_engine->GetRestCreate() < 16 ) return false;
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
- option = m_object->RetOption();
+ option = m_object->GetOption();
- if ( m_main->RetGamerOnlyHead() )
+ if ( m_main->GetGamerOnlyHead() )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEVEHICULE); // this is a moving object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
- face = m_main->RetGamerFace();
+ face = m_main->GetGamerFace();
sprintf(filename, "objects\\human2h%d.mod", face+1);
pModFile->ReadModel(filename);
pModFile->CreateEngineObject(rank);
- glasses = m_main->RetGamerGlasses();
+ glasses = m_main->GetGamerGlasses();
if ( glasses != 0 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
sprintf(filename, "objects\\human2g%d.mod", glasses);
@@ -129,7 +129,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
CreatePhysics(type);
m_object->SetFloorHeight(0.0f);
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -137,7 +137,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the main base.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEVEHICULE); // this is a moving object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
if ( option == 0 ) // head in helmet?
@@ -163,7 +163,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the head.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
@@ -171,14 +171,14 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
{
if ( option == 0 ) // head in helmet?
{
- face = m_main->RetGamerFace();
+ face = m_main->GetGamerFace();
sprintf(filename, "objects\\human2c%d.mod", face+1);
pModFile->ReadModel(filename);
}
if ( option == 1 || // head without helmet?
option == 2 ) // without a backpack?
{
- face = m_main->RetGamerFace();
+ face = m_main->GetGamerFace();
sprintf(filename, "objects\\human2h%d.mod", face+1);
pModFile->ReadModel(filename);
}
@@ -196,11 +196,11 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
}
// Creates the glasses.
- glasses = m_main->RetGamerGlasses();
+ glasses = m_main->GetGamerGlasses();
if ( glasses != 0 && type == OBJECT_HUMAN )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 1);
sprintf(filename, "objects\\human2g%d.mod", glasses);
@@ -210,7 +210,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right arm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\human3.mod");
@@ -220,7 +220,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right forearm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
pModFile->ReadModel("objects\\human4r.mod");
@@ -230,7 +230,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates right hand.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
pModFile->ReadModel("objects\\human5.mod");
@@ -239,7 +239,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 0);
pModFile->ReadModel("objects\\human6.mod");
@@ -249,7 +249,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 5);
pModFile->ReadModel("objects\\human7.mod");
@@ -259,7 +259,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
pModFile->ReadModel("objects\\human8.mod");
@@ -269,7 +269,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left arm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
pModFile->ReadModel("objects\\human3.mod");
@@ -280,7 +280,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left forearm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 8);
pModFile->ReadModel("objects\\human4l.mod");
@@ -291,7 +291,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates left hand.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 9);
pModFile->ReadModel("objects\\human5.mod");
@@ -301,7 +301,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left thigh.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 0);
pModFile->ReadModel("objects\\human6.mod");
@@ -312,7 +312,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 11);
pModFile->ReadModel("objects\\human7.mod");
@@ -323,7 +323,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
pModFile->ReadModel("objects\\human8.mod");
@@ -336,7 +336,7 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
if ( option != 2 ) // with backpack?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 0);
pModFile->ReadModel("objects\\human9.mod");
@@ -350,10 +350,10 @@ bool CMotionHuman::Create(Math::Vector pos, float angle, ObjectType type,
CreatePhysics(type);
m_object->SetFloorHeight(0.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_object->SetPosition(0, pos); // to display the shadows immediately
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -560,7 +560,7 @@ void CMotionHuman::CreatePhysics(ObjectType type)
m_physics->SetType(TYPE_FLYING);
- character = m_object->RetCharacter();
+ character = m_object->GetCharacter();
character->wheelFront = 4.0f;
character->wheelBack = 4.0f;
character->wheelLeft = 4.0f;
@@ -653,12 +653,12 @@ bool CMotionHuman::EventProcess(const Event &event)
{
CMotion::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
#if ADJUST_ANGLE
int i;
@@ -710,9 +710,9 @@ bool CMotionHuman::EventFrame(const Event &event)
float tSt[9], tNd[9];
float aa, bb, shield, deadFactor, level;
int i, ii, st, nd, action, legAction, armAction;
- bool bOnBoard, bSwim, bStop;
+ bool bOnBoard, bSwim;
- if ( m_engine->RetPause() )
+ if ( m_engine->GetPause() )
{
if ( m_actionType == MHS_SATCOM )
{
@@ -725,35 +725,35 @@ bool CMotionHuman::EventFrame(const Event &event)
}
bOnBoard = false;
- if ( m_object->RetSelect() &&
- m_camera->RetType() == CAMERA_ONBOARD )
+ if ( m_object->GetSelect() &&
+ m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD )
{
bOnBoard = true;
}
- if ( m_bDisplayPerso && m_main->RetGamerOnlyHead() )
+ if ( m_bDisplayPerso && m_main->GetGamerOnlyHead() )
{
m_time += event.rTime;
m_object->SetLinVibration(Math::Vector(0.0f, -0.55f, 0.0f));
- m_object->SetCirVibration(Math::Vector(0.0f, m_main->RetPersoAngle(), 0.0f));
+ m_object->SetCirVibration(Math::Vector(0.0f, m_main->GetPersoAngle(), 0.0f));
return true;
}
if ( m_bDisplayPerso )
{
- m_object->SetCirVibration(Math::Vector(0.0f, m_main->RetPersoAngle()+0.2f, 0.0f));
+ m_object->SetCirVibration(Math::Vector(0.0f, m_main->GetPersoAngle()+0.2f, 0.0f));
}
- shield = m_object->RetShield();
+ shield = m_object->GetShield();
shield += event.rTime*(1.0f/120.0f); // regeneration in 120 seconds
if ( shield > 1.0f ) shield = 1.0f;
m_object->SetShield(shield);
- bSwim = m_physics->RetSwim();
+ bSwim = m_physics->GetSwim();
#if 0
- rot = m_physics->RetCirMotionY(MO_MOTSPEED);
- s = m_physics->RetLinMotionX(MO_REASPEED)*2.0f;
- a = m_physics->RetLinMotionX(MO_TERSPEED);
+ rot = m_physics->GetCirMotionY(MO_MOTSPEED);
+ s = m_physics->GetLinMotionX(MO_REASPEED)*2.0f;
+ a = m_physics->GetLinMotionX(MO_TERSPEED);
if ( a < 0.0f ) // rises?
{
if ( s > 0.0f && s < 20.0f ) s = 20.0f; // moving slowly?
@@ -766,44 +766,44 @@ bool CMotionHuman::EventFrame(const Event &event)
}
a = fabs(rot*12.0f);
- if ( !m_physics->RetLand() && !bSwim ) // in flight?
+ if ( !m_physics->GetLand() && !bSwim ) // in flight?
{
s = 0.0f;
}
- if ( m_object->RetFret() != 0 ) // carries something?
+ if ( m_object->GetFret() != 0 ) // carries something?
{
s *= 1.3f;
}
#else
- rot = m_physics->RetCirMotionY(MO_MOTSPEED);
+ rot = m_physics->GetCirMotionY(MO_MOTSPEED);
#if 0
- s = m_physics->RetLinMotionX(MO_REASPEED);
+ s = m_physics->GetLinMotionX(MO_REASPEED);
#else
- a = m_physics->RetLinMotionX(MO_REASPEED);
- s = m_physics->RetLinMotionX(MO_MOTSPEED)*0.2f;
+ a = m_physics->GetLinMotionX(MO_REASPEED);
+ s = m_physics->GetLinMotionX(MO_MOTSPEED)*0.2f;
if ( fabs(a) > fabs(s) ) s = a; // the highest value
#endif
- a = m_physics->RetLinMotionX(MO_TERSPEED);
+ a = m_physics->GetLinMotionX(MO_TERSPEED);
if ( a < 0.0f ) // rises?
{
- a += m_physics->RetLinMotionX(MO_TERSLIDE);
+ a += m_physics->GetLinMotionX(MO_TERSLIDE);
if ( a < 0.0f ) s -= a;
}
if ( a > 0.0f ) // falls?
{
- a -= m_physics->RetLinMotionX(MO_TERSLIDE);
+ a -= m_physics->GetLinMotionX(MO_TERSLIDE);
if ( a > 0.0f ) s -= a;
}
s *= 2.0f;
a = fabs(rot*12.0f);
- if ( !m_physics->RetLand() && !bSwim ) // in flight?
+ if ( !m_physics->GetLand() && !bSwim ) // in flight?
{
s = 0.0f;
}
- if ( m_object->RetFret() != 0 ) // carries something?
+ if ( m_object->GetFret() != 0 ) // carries something?
{
s *= 1.3f;
}
@@ -815,7 +815,7 @@ bool CMotionHuman::EventFrame(const Event &event)
m_armMember += s*event.rTime*0.05f;
// Fatigue management when short.
- if ( m_physics->RetLand() && s != 0.0f ) // on the ground?
+ if ( m_physics->GetLand() && s != 0.0f ) // on the ground?
{
m_tired += event.rTime*0.1f;
if ( m_tired > 1.0f )
@@ -832,15 +832,14 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( bSwim ) // swims?
{
- s += fabs(m_physics->RetLinMotionY(MO_REASPEED)*2.0f);
+ s += fabs(m_physics->GetLinMotionY(MO_REASPEED)*2.0f);
a *= 2.0f;
m_armTimeSwim += Math::Min(Math::Max(s,a,3.0f),15.0f)*event.rTime*0.05f;
}
- bStop = ( s == 0.0f ); // stop?
prog = 0.0f;
- if ( m_physics->RetLand() ) // on the ground?
+ if ( m_physics->GetLand() ) // on the ground?
{
if ( s == 0.0f && a == 0.0f )
{
@@ -869,7 +868,7 @@ bool CMotionHuman::EventFrame(const Event &event)
else
{
action = MH_MARCH; // walking
- if ( m_object->RetFret() != 0 ) action = MH_MARCHTAKE; // take walking
+ if ( m_object->GetFret() != 0 ) action = MH_MARCHTAKE; // take walking
rTime[0] = rTime[1] = m_armMember;
lTime[0] = lTime[1] = m_armMember+0.5f;
}
@@ -908,34 +907,34 @@ bool CMotionHuman::EventFrame(const Event &event)
armAction = action;
legAction = action;
- if ( m_object->RetFret() != 0 ) // carries something?
+ if ( m_object->GetFret() != 0 ) // carries something?
{
armAction = MH_MARCHTAKE; // take walking
}
- if ( m_physics->RetLand() ) // on the ground?
+ if ( m_physics->GetLand() ) // on the ground?
{
- a = m_object->RetAngleY(0);
- pos = m_object->RetPosition(0);
- m_terrain->MoveOnFloor(pos);
+ a = m_object->GetAngleY(0);
+ pos = m_object->GetPosition(0);
+ m_terrain->AdjustToFloor(pos);
pf.x = pos.x+cosf(a+Math::PI*1.5f)*0.7f;
pf.y = pos.y;
pf.z = pos.z-sinf(a+Math::PI*1.5f)*0.7f;
- m_terrain->MoveOnFloor(pf);
+ m_terrain->AdjustToFloor(pf);
al = atanf((pf.y-pos.y)/0.7f); // angle for left leg
pf = pos;
pf.x = pos.x+cosf(a+Math::PI*0.5f)*0.7f;
pf.y = pos.y;
pf.z = pos.z-sinf(a+Math::PI*0.5f)*0.7f;
- m_terrain->MoveOnFloor(pf);
+ m_terrain->AdjustToFloor(pf);
ar = atanf((pf.y-pos.y)/0.7f); // angle to right leg
pf.x = pos.x+cosf(a+Math::PI)*0.3f;
pf.y = pos.y;
pf.z = pos.z-sinf(a+Math::PI)*0.3f;
- m_terrain->MoveOnFloor(pf);
+ m_terrain->AdjustToFloor(pf);
af = atanf((pf.y-pos.y)/0.3f); // angle for feet
}
else
@@ -1022,7 +1021,7 @@ bool CMotionHuman::EventFrame(const Event &event)
aa = 0.5f;
if ( i%2 == 0 ) // arm?
{
- if ( m_object->RetFret() == 0 ) // does nothing?
+ if ( m_object->GetFret() == 0 ) // does nothing?
{
aa = 2.0f; // moves a lot
}
@@ -1074,15 +1073,15 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( a < -0.2f ) a = -0.2f;
if ( a > 0.2f ) a = 0.2f;
- pos = m_object->RetPosition(ii+0);
+ pos = m_object->GetPosition(ii+0);
pos.y = 0.0f+a;
m_object->SetPosition(ii+0, pos); // lengthens / shortcuts thigh
- pos = m_object->RetPosition(ii+1);
+ pos = m_object->GetPosition(ii+1);
pos.y = -1.5f+a;
m_object->SetPosition(ii+1, pos); // lengthens / shortcuts leg
- pos = m_object->RetPosition(ii+2);
+ pos = m_object->GetPosition(ii+2);
pos.y = -1.5f+a;
m_object->SetPosition(ii+2, pos); // lengthens / shortcuts foot
@@ -1147,32 +1146,32 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( i < 2 ) // right member (0..1) ?
{
- m_object->SetAngleX(2+3*i+0, Math::Smooth(m_object->RetAngleX(2+3*i+0), Math::PropAngle(tSt[0], tNd[0], prog), time));
- m_object->SetAngleY(2+3*i+0, Math::Smooth(m_object->RetAngleY(2+3*i+0), Math::PropAngle(tSt[1], tNd[1], prog), time));
- m_object->SetAngleZ(2+3*i+0, Math::Smooth(m_object->RetAngleZ(2+3*i+0), Math::PropAngle(tSt[2], tNd[2], prog), time));
- m_object->SetAngleX(2+3*i+1, Math::Smooth(m_object->RetAngleX(2+3*i+1), Math::PropAngle(tSt[3], tNd[3], prog), time));
- m_object->SetAngleY(2+3*i+1, Math::Smooth(m_object->RetAngleY(2+3*i+1), Math::PropAngle(tSt[4], tNd[4], prog), time));
- m_object->SetAngleZ(2+3*i+1, Math::Smooth(m_object->RetAngleZ(2+3*i+1), Math::PropAngle(tSt[5], tNd[5], prog), time));
- m_object->SetAngleX(2+3*i+2, Math::Smooth(m_object->RetAngleX(2+3*i+2), Math::PropAngle(tSt[6], tNd[6], prog), time));
- m_object->SetAngleY(2+3*i+2, Math::Smooth(m_object->RetAngleY(2+3*i+2), Math::PropAngle(tSt[7], tNd[7], prog), time));
- m_object->SetAngleZ(2+3*i+2, Math::Smooth(m_object->RetAngleZ(2+3*i+2), Math::PropAngle(tSt[8], tNd[8], prog), time));
+ m_object->SetAngleX(2+3*i+0, Math::Smooth(m_object->GetAngleX(2+3*i+0), Math::PropAngle(tSt[0], tNd[0], prog), time));
+ m_object->SetAngleY(2+3*i+0, Math::Smooth(m_object->GetAngleY(2+3*i+0), Math::PropAngle(tSt[1], tNd[1], prog), time));
+ m_object->SetAngleZ(2+3*i+0, Math::Smooth(m_object->GetAngleZ(2+3*i+0), Math::PropAngle(tSt[2], tNd[2], prog), time));
+ m_object->SetAngleX(2+3*i+1, Math::Smooth(m_object->GetAngleX(2+3*i+1), Math::PropAngle(tSt[3], tNd[3], prog), time));
+ m_object->SetAngleY(2+3*i+1, Math::Smooth(m_object->GetAngleY(2+3*i+1), Math::PropAngle(tSt[4], tNd[4], prog), time));
+ m_object->SetAngleZ(2+3*i+1, Math::Smooth(m_object->GetAngleZ(2+3*i+1), Math::PropAngle(tSt[5], tNd[5], prog), time));
+ m_object->SetAngleX(2+3*i+2, Math::Smooth(m_object->GetAngleX(2+3*i+2), Math::PropAngle(tSt[6], tNd[6], prog), time));
+ m_object->SetAngleY(2+3*i+2, Math::Smooth(m_object->GetAngleY(2+3*i+2), Math::PropAngle(tSt[7], tNd[7], prog), time));
+ m_object->SetAngleZ(2+3*i+2, Math::Smooth(m_object->GetAngleZ(2+3*i+2), Math::PropAngle(tSt[8], tNd[8], prog), time));
}
else // left member (2..3) ?
{
- m_object->SetAngleX(2+3*i+0, Math::Smooth(m_object->RetAngleX(2+3*i+0), Math::PropAngle(-tSt[0], -tNd[0], prog), time));
- m_object->SetAngleY(2+3*i+0, Math::Smooth(m_object->RetAngleY(2+3*i+0), Math::PropAngle(-tSt[1], -tNd[1], prog), time));
- m_object->SetAngleZ(2+3*i+0, Math::Smooth(m_object->RetAngleZ(2+3*i+0), Math::PropAngle( tSt[2], tNd[2], prog), time));
- m_object->SetAngleX(2+3*i+1, Math::Smooth(m_object->RetAngleX(2+3*i+1), Math::PropAngle(-tSt[3], -tNd[3], prog), time));
- m_object->SetAngleY(2+3*i+1, Math::Smooth(m_object->RetAngleY(2+3*i+1), Math::PropAngle(-tSt[4], -tNd[4], prog), time));
- m_object->SetAngleZ(2+3*i+1, Math::Smooth(m_object->RetAngleZ(2+3*i+1), Math::PropAngle( tSt[5], tNd[5], prog), time));
- m_object->SetAngleX(2+3*i+2, Math::Smooth(m_object->RetAngleX(2+3*i+2), Math::PropAngle(-tSt[6], -tNd[6], prog), time));
- m_object->SetAngleY(2+3*i+2, Math::Smooth(m_object->RetAngleY(2+3*i+2), Math::PropAngle(-tSt[7], -tNd[7], prog), time));
- m_object->SetAngleZ(2+3*i+2, Math::Smooth(m_object->RetAngleZ(2+3*i+2), Math::PropAngle( tSt[8], tNd[8], prog), time));
+ m_object->SetAngleX(2+3*i+0, Math::Smooth(m_object->GetAngleX(2+3*i+0), Math::PropAngle(-tSt[0], -tNd[0], prog), time));
+ m_object->SetAngleY(2+3*i+0, Math::Smooth(m_object->GetAngleY(2+3*i+0), Math::PropAngle(-tSt[1], -tNd[1], prog), time));
+ m_object->SetAngleZ(2+3*i+0, Math::Smooth(m_object->GetAngleZ(2+3*i+0), Math::PropAngle( tSt[2], tNd[2], prog), time));
+ m_object->SetAngleX(2+3*i+1, Math::Smooth(m_object->GetAngleX(2+3*i+1), Math::PropAngle(-tSt[3], -tNd[3], prog), time));
+ m_object->SetAngleY(2+3*i+1, Math::Smooth(m_object->GetAngleY(2+3*i+1), Math::PropAngle(-tSt[4], -tNd[4], prog), time));
+ m_object->SetAngleZ(2+3*i+1, Math::Smooth(m_object->GetAngleZ(2+3*i+1), Math::PropAngle( tSt[5], tNd[5], prog), time));
+ m_object->SetAngleX(2+3*i+2, Math::Smooth(m_object->GetAngleX(2+3*i+2), Math::PropAngle(-tSt[6], -tNd[6], prog), time));
+ m_object->SetAngleY(2+3*i+2, Math::Smooth(m_object->GetAngleY(2+3*i+2), Math::PropAngle(-tSt[7], -tNd[7], prog), time));
+ m_object->SetAngleZ(2+3*i+2, Math::Smooth(m_object->GetAngleZ(2+3*i+2), Math::PropAngle( tSt[8], tNd[8], prog), time));
}
}
#if ADJUST_ANGLE
- if ( m_object->RetSelect() )
+ if ( m_object->GetSelect() )
{
char s[100];
sprintf(s, "A:time=%d Q:part=%d W:member=%d", m_armTimeIndex, m_armPartIndex, m_armMemberIndex);
@@ -1182,14 +1181,14 @@ bool CMotionHuman::EventFrame(const Event &event)
// calculates the height lowering as a function
// of the position of the legs.
- hr = 1.5f*(1.0f-cosf(m_object->RetAngleZ(5))) +
- 1.5f*(1.0f-cosf(m_object->RetAngleZ(5)+m_object->RetAngleZ(6)));
- a = 1.0f*sinf(m_object->RetAngleZ(5)+m_object->RetAngleZ(6)+m_object->RetAngleZ(7));
+ hr = 1.5f*(1.0f-cosf(m_object->GetAngleZ(5))) +
+ 1.5f*(1.0f-cosf(m_object->GetAngleZ(5)+m_object->GetAngleZ(6)));
+ a = 1.0f*sinf(m_object->GetAngleZ(5)+m_object->GetAngleZ(6)+m_object->GetAngleZ(7));
if ( a < 0.0f ) hr += a;
- hl = 1.5f*(1.0f-cosf(m_object->RetAngleZ(11))) +
- 1.5f*(1.0f-cosf(m_object->RetAngleZ(11)+m_object->RetAngleZ(12)));
- a = 1.0f*sinf(m_object->RetAngleZ(11)+m_object->RetAngleZ(12)+m_object->RetAngleZ(13));
+ hl = 1.5f*(1.0f-cosf(m_object->GetAngleZ(11))) +
+ 1.5f*(1.0f-cosf(m_object->GetAngleZ(11)+m_object->GetAngleZ(12)));
+ a = 1.0f*sinf(m_object->GetAngleZ(11)+m_object->GetAngleZ(12)+m_object->GetAngleZ(13));
if ( a < 0.0f ) hl += a;
hr = Math::Min(hr, hl);
@@ -1201,7 +1200,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = (Math::Rand()-0.5f)/8.0f;
dir.z = (Math::Rand()-0.5f)/8.0f;
dir.y = -0.5f; // slightly lower
- actual = m_object->RetLinVibration();
+ actual = m_object->GetLinVibration();
dir.x = Math::Smooth(actual.x, dir.x, time);
//? dir.y = Math::Smooth(actual.y, dir.y, time);
dir.y = -hr;
@@ -1211,7 +1210,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.y = (Math::Rand()-0.5f)/3.0f;
dir.z = -0.1f; // slightly leaning forward
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1225,7 +1224,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.z = 0.0f;
dir.y = -1.5f; // slightly lower
- actual = m_object->RetLinVibration();
+ actual = m_object->GetLinVibration();
dir.x = Math::Smooth(actual.x, dir.x, time);
//? dir.y = Math::Smooth(actual.y, dir.y, time);
dir.y = -hr;
@@ -1235,7 +1234,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = -0.2f;
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1248,7 +1247,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.4f; // slightly forward
dir.z = 0.0f;
dir.y = 0.0f;
- actual = m_object->RetLinVibration();
+ actual = m_object->GetLinVibration();
dir.x = Math::Smooth(actual.x, dir.x, time);
//? dir.y = Math::Smooth(actual.y, dir.y, time);
dir.y = -hr;
@@ -1258,7 +1257,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = -0.2f;
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1271,7 +1270,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.z = 0.0f;
dir.y = -2.0f; // slightly lower
- actual = m_object->RetLinVibration();
+ actual = m_object->GetLinVibration();
dir.x = Math::Smooth(actual.x, dir.x, time);
//? dir.y = Math::Smooth(actual.y, dir.y, time);
dir.y = -hr;
@@ -1281,7 +1280,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = -0.4f;
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1289,7 +1288,7 @@ bool CMotionHuman::EventFrame(const Event &event)
}
else if ( m_actionType == MHS_DEADg ) // shooting death (falls)?
{
- if ( m_physics->RetLand() ) // on the ground?
+ if ( m_physics->GetLand() ) // on the ground?
{
SetAction(MHS_DEADg1, 0.5f); // knees
}
@@ -1303,16 +1302,16 @@ bool CMotionHuman::EventFrame(const Event &event)
for ( i=0 ; i<10 ; i++ )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*4.0f;
pos.z += (Math::Rand()-0.5f)*4.0f;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 1.2f+Math::Rand()*1.2f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 0.0f);
}
- m_sound->Play(SOUND_BOUMv, m_object->RetPosition(0));
+ m_sound->Play(SOUND_BOUMv, m_object->GetPosition(0));
SetAction(MHS_DEADg2, 1.0f); // expects knees
}
@@ -1322,7 +1321,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.z = 0.0f;
dir.y = -1.5f*prog;
- actual = m_object->RetLinVibration();
+ actual = m_object->GetLinVibration();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1331,7 +1330,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = -(20.0f*Math::PI/180.0f)*prog;
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1349,7 +1348,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.z = 0.0f;
dir.y = -1.5f;
- actual = m_object->RetLinVibration();
+ actual = m_object->GetLinVibration();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1358,7 +1357,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = -(20.0f*Math::PI/180.0f);
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1373,16 +1372,16 @@ bool CMotionHuman::EventFrame(const Event &event)
for ( i=0 ; i<20 ; i++ )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*8.0f;
pos.z += (Math::Rand()-0.5f)*8.0f;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 2.0f+Math::Rand()*1.5f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 0.0f);
}
- m_sound->Play(SOUND_BOUMv, m_object->RetPosition(0));
+ m_sound->Play(SOUND_BOUMv, m_object->GetPosition(0));
SetAction(MHS_DEADg4, 3.0f); // expects face down
}
@@ -1393,7 +1392,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.y = -(1.5f+1.5f*prog);
dir.x = 0.0f;
dir.z = 0.0f;
- actual = m_object->RetLinVibration();
+ actual = m_object->GetLinVibration();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1402,7 +1401,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.z = -((20.0f*Math::PI/180.0f)+(70.0f*Math::PI/180.0f)*prog);
dir.x = 0.0f;
dir.y = 0.0f;
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1420,7 +1419,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.y = -(1.5f+1.5f);
dir.x = 0.0f;
dir.z = 0.0f;
- actual = m_object->RetLinVibration();
+ actual = m_object->GetLinVibration();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1429,7 +1428,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.z = -((20.0f*Math::PI/180.0f)+(70.0f*Math::PI/180.0f));
dir.x = 0.0f;
dir.y = 0.0f;
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1437,8 +1436,8 @@ bool CMotionHuman::EventFrame(const Event &event)
}
else if ( m_actionType == MHS_DEADw ) // drowned?
{
- pos = m_object->RetPosition(0);
- level = m_water->RetLevel()-0.5f;
+ pos = m_object->GetPosition(0);
+ level = m_water->GetLevel()-0.5f;
if ( pos.y < level )
{
pos.y += 4.0f*event.rTime; // back to the surface
@@ -1467,7 +1466,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.z = -(90.0f*Math::PI/180.0f)*prog;
dir.x = Math::Rand()*0.3f*deadFactor;
dir.y = Math::Rand()*0.3f*deadFactor;
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1494,7 +1493,7 @@ bool CMotionHuman::EventFrame(const Event &event)
m_object->SetLinVibration(dir);
SetLinVibration(dir);
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(0.5f, 3.7f, 0.0f);
pos.x += (Math::Rand()-0.5f)*1.0f;
pos.y += (Math::Rand()-0.5f)*1.0f;
@@ -1505,7 +1504,7 @@ bool CMotionHuman::EventFrame(const Event &event)
speed.z = (Math::Rand()-0.5f)*0.5f;
dim.x = 0.5f+Math::Rand()*0.5f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTILENS1, 5.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTILENS1, 5.0f, 0.0f, 0.0f);
}
else if ( m_actionType == MHS_SATCOM ) // look at the SatCom?
{
@@ -1515,7 +1514,7 @@ bool CMotionHuman::EventFrame(const Event &event)
}
else
{
- if ( m_physics->RetLand() ) // on the ground?
+ if ( m_physics->GetLand() ) // on the ground?
{
time = event.rTime*8.0f;
if ( bSwim ) time *= 0.25f;
@@ -1524,25 +1523,25 @@ bool CMotionHuman::EventFrame(const Event &event)
{
dir.x = sinf(Math::Mod(rTime[0]+0.5f, 1.0f)*Math::PI*2.0f)*0.10f;
dir.y = sinf(Math::Mod(rTime[0]+0.6f, 1.0f)*Math::PI*2.0f)*0.20f;
- s = m_physics->RetLinMotionX(MO_REASPEED)*0.03f;
+ s = m_physics->GetLinMotionX(MO_REASPEED)*0.03f;
}
else if ( action == MH_MARCHTAKE ) // takes walking?
{
dir.x = sinf(Math::Mod(rTime[0]+0.5f, 1.0f)*Math::PI*2.0f)*0.10f;
dir.y = sinf(Math::Mod(rTime[0]+0.6f, 1.0f)*Math::PI*2.0f)*0.15f;
- s = m_physics->RetLinMotionX(MO_REASPEED)*0.02f;
+ s = m_physics->GetLinMotionX(MO_REASPEED)*0.02f;
}
else
{
dir.x = 0.0f;
dir.y = 0.0f;
- s = m_physics->RetLinMotionX(MO_REASPEED)*0.03f;
+ s = m_physics->GetLinMotionX(MO_REASPEED)*0.03f;
}
if ( s < 0.0f ) s *= 0.5f;
dir.z = -s*0.7f;
- actual = m_object->RetInclinaison();
+ actual = m_object->GetInclinaison();
dir.x = Math::Smooth(actual.x, dir.x, time);
dir.y = Math::Smooth(actual.y, dir.y, time);
dir.z = Math::Smooth(actual.z, dir.z, time);
@@ -1554,7 +1553,7 @@ bool CMotionHuman::EventFrame(const Event &event)
{
p2.x = 0.0f;
p2.y = sinf(Math::Mod(rTime[0]+0.5f, 1.0f)*Math::PI*2.0f)*0.5f;
- p2 = Math::RotatePoint(-m_object->RetAngleY(0), p2);
+ p2 = Math::RotatePoint(-m_object->GetAngleY(0), p2);
dir.x = p2.x;
dir.z = p2.y;
dir.y = sinf(Math::Mod(rTime[0]*2.0f, 1.0f)*Math::PI*2.0f)*0.3f;
@@ -1563,7 +1562,7 @@ bool CMotionHuman::EventFrame(const Event &event)
{
p2.x = 0.0f;
p2.y = sinf(Math::Mod(rTime[0]+0.5f, 1.0f)*Math::PI*2.0f)*0.25f;
- p2 = Math::RotatePoint(-m_object->RetAngleY(0), p2);
+ p2 = Math::RotatePoint(-m_object->GetAngleY(0), p2);
dir.x = p2.x;
dir.z = p2.y;
dir.y = sinf(Math::Mod(rTime[0]*2.0f, 1.0f)*Math::PI*2.0f)*0.05f-0.3f;
@@ -1575,7 +1574,7 @@ bool CMotionHuman::EventFrame(const Event &event)
dir.y = 0.0f;
}
- actual = m_object->RetLinVibration();
+ actual = m_object->GetLinVibration();
dir.x = Math::Smooth(actual.x, dir.x, time);
if ( action == MH_MARCHTAKE ) // takes walking?
{
@@ -1602,16 +1601,16 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( m_actionType == MHS_TAKE || // takes?
m_actionType == MHS_FLAG ) // takes?
{
- m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f-0.6f, event.rTime*5.0f));
+ m_object->SetAngleZ(1, Math::Smooth(m_object->GetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f-0.6f, event.rTime*5.0f));
m_object->SetAngleX(1, sinf(m_armTimeAbs*1.1f)*0.1f);
- m_object->SetAngleY(1, Math::Smooth(m_object->RetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
+ m_object->SetAngleY(1, Math::Smooth(m_object->GetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
}
else if ( m_actionType == MHS_TAKEOTHER || // takes?
m_actionType == MHS_TAKEHIGH ) // takes?
{
- m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f-0.3f, event.rTime*5.0f));
+ m_object->SetAngleZ(1, Math::Smooth(m_object->GetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f-0.3f, event.rTime*5.0f));
m_object->SetAngleX(1, sinf(m_armTimeAbs*1.1f)*0.1f);
- m_object->SetAngleY(1, Math::Smooth(m_object->RetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
+ m_object->SetAngleY(1, Math::Smooth(m_object->GetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
}
else if ( m_actionType == MHS_WIN ) // win
{
@@ -1627,14 +1626,14 @@ bool CMotionHuman::EventFrame(const Event &event)
m_object->SetAngleX(1, sinf(m_armTimeAbs*0.7f)*0.10f);
m_object->SetAngleY(1, sinf(m_armTimeAbs*3.0f)*0.30f*factor);
}
- else if ( m_object->RetDead() ) // dead?
+ else if ( m_object->GetDead() ) // dead?
{
}
else
{
- m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f, event.rTime*5.0f));
+ m_object->SetAngleZ(1, Math::Smooth(m_object->GetAngleZ(1), sinf(m_armTimeAbs*1.0f)*0.2f, event.rTime*5.0f));
m_object->SetAngleX(1, sinf(m_armTimeAbs*1.1f)*0.1f);
- m_object->SetAngleY(1, Math::Smooth(m_object->RetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
+ m_object->SetAngleY(1, Math::Smooth(m_object->GetAngleY(1), sinf(m_armTimeAbs*1.3f)*0.2f+rot*0.3f, event.rTime*5.0f));
}
if ( bOnBoard )
@@ -1651,9 +1650,9 @@ bool CMotionHuman::EventFrame(const Event &event)
Sound sound[2];
float speed, synchro, volume[2], freq[2], hard, level;
- speed = m_physics->RetLinMotionX(MO_REASPEED);
+ speed = m_physics->GetLinMotionX(MO_REASPEED);
- if ( m_object->RetFret() == 0 )
+ if ( m_object->GetFret() == 0 )
{
if ( speed > 0.0f ) synchro = 0.21f; // synchro forward
else synchro = 0.29f; // synchro backward
@@ -1670,7 +1669,7 @@ bool CMotionHuman::EventFrame(const Event &event)
{
volume[0] = 0.5f;
freq[0] = 1.0f;
- if ( m_object->RetFret() != 0 )
+ if ( m_object->GetFret() != 0 )
{
//? volume[0] *= 2.0f;
freq[0] = 0.7f;
@@ -1680,16 +1679,16 @@ bool CMotionHuman::EventFrame(const Event &event)
sound[0] = SOUND_CLICK;
sound[1] = SOUND_CLICK;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
- level = m_water->RetLevel();
+ level = m_water->GetLevel();
if ( pos.y <= level+3.0f ) // underwater?
{
sound[0] = SOUND_STEPw;
}
else
{
- hard = m_terrain->RetHardness(pos);
+ hard = m_terrain->GetHardness(pos);
if ( hard >= 0.875 )
{
@@ -1737,17 +1736,17 @@ bool CMotionHuman::EventFrame(const Event &event)
if ( fabs(m_lastSoundMarch-time) > 0.9f &&
Math::Mod(time, 1.0f) < 0.1f )
{
- m_sound->Play(SOUND_SWIM, m_object->RetPosition(0), 0.5f);
+ m_sound->Play(SOUND_SWIM, m_object->GetPosition(0), 0.5f);
m_lastSoundMarch = time;
}
}
m_lastSoundHhh -= event.rTime;
if ( m_lastSoundHhh <= 0.0f &&
- m_object->RetSelect() &&
- m_object->RetOption() == 0 ) // helmet?
+ m_object->GetSelect() &&
+ m_object->GetOption() == 0 ) // helmet?
{
- m_sound->Play(SOUND_HUMAN1, m_object->RetPosition(0), (0.5f+m_tired*0.2f));
+ m_sound->Play(SOUND_HUMAN1, m_object->GetPosition(0), (0.5f+m_tired*0.2f));
m_lastSoundHhh = (4.0f-m_tired*2.5f)+(4.0f-m_tired*2.5f)*Math::Rand();
}
diff --git a/src/object/motion/motionmother.cpp b/src/object/motion/motionmother.cpp
index 0b783a3..d8850e2 100644
--- a/src/object/motion/motionmother.cpp
+++ b/src/object/motion/motionmother.cpp
@@ -21,7 +21,7 @@
#include "object/motion/motionmother.h"
-#include "old/modfile.h"
+#include "graphics/engine/modelfile.h"
#include "physics/physics.h"
@@ -67,18 +67,18 @@ void CMotionMother::DeleteObject(bool bAll)
bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank;
- if ( m_engine->RetRestCreate() < 2+12+6 ) return false;
+// if ( m_engine->GetRestCreate() < 2+12+6 ) return false;
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
// Creates main base.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEVEHICULE); // this is a moving object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
pModFile->ReadModel("objects\\mother1.mod");
@@ -94,7 +94,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the head.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\mother2.mod");
@@ -103,7 +103,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-back leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\mother3.mod");
@@ -112,7 +112,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
pModFile->ReadModel("objects\\mother4.mod");
@@ -121,7 +121,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a middle-right leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 0);
pModFile->ReadModel("objects\\mother3.mod");
@@ -130,7 +130,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a middle-right foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
pModFile->ReadModel("objects\\mother4.mod");
@@ -139,7 +139,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-front leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\mother3.mod");
@@ -148,7 +148,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a right-front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 6);
pModFile->ReadModel("objects\\mother4.mod");
@@ -157,7 +157,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-back leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
pModFile->ReadModel("objects\\mother3.mod");
@@ -167,7 +167,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 8);
pModFile->ReadModel("objects\\mother4.mod");
@@ -176,7 +176,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a middle-left leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 0);
pModFile->ReadModel("objects\\mother3.mod");
@@ -186,7 +186,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a middle-left foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 10);
pModFile->ReadModel("objects\\mother4.mod");
@@ -195,7 +195,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-front leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
pModFile->ReadModel("objects\\mother3.mod");
@@ -205,7 +205,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates a left-front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 12);
pModFile->ReadModel("objects\\mother4.mod");
@@ -214,7 +214,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right antenna.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(14, rank);
m_object->SetObjectParent(14, 1);
pModFile->ReadModel("objects\\mother5.mod");
@@ -222,7 +222,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetPosition(14, Math::Vector(6.0f, 1.0f, -2.5f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15, rank);
m_object->SetObjectParent(15, 14);
pModFile->ReadModel("objects\\mother6.mod");
@@ -231,7 +231,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left antenna.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(16, rank);
m_object->SetObjectParent(16, 1);
pModFile->ReadModel("objects\\mother5.mod");
@@ -239,7 +239,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetPosition(16, Math::Vector(6.0f, 1.0f, 2.5f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(17, rank);
m_object->SetObjectParent(17, 16);
pModFile->ReadModel("objects\\mother6.mod");
@@ -248,7 +248,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right claw.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(18, rank);
m_object->SetObjectParent(18, 1);
pModFile->ReadModel("objects\\mother7.mod");
@@ -258,7 +258,7 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left claw.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19, rank);
m_object->SetObjectParent(19, 1);
pModFile->ReadModel("objects\\mother7.mod");
@@ -272,10 +272,10 @@ bool CMotionMother::Create(Math::Vector pos, float angle, ObjectType type,
CreatePhysics();
m_object->SetFloorHeight(0.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_object->SetPosition(0, pos); // to display the shadows immediately
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -306,7 +306,7 @@ void CMotionMother::CreatePhysics()
m_physics->SetType(TYPE_ROLLING);
- character = m_object->RetCharacter();
+ character = m_object->GetCharacter();
character->wheelFront = 10.0f;
character->wheelBack = 10.0f;
character->wheelLeft = 20.0f;
@@ -343,12 +343,12 @@ bool CMotionMother::EventProcess(const Event &event)
{
CMotion::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
#if ADJUST_ANGLE
int i;
@@ -390,11 +390,11 @@ bool CMotionMother::EventFrame(const Event &event)
int i, st, nd;
bool bStop;
- if ( m_engine->RetPause() ) return true;
- if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( !m_engine->IsVisiblePoint(m_object->GetPosition(0)) ) return true;
- s = m_physics->RetLinMotionX(MO_MOTSPEED)*1.5f;
- a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*26.0f);
+ s = m_physics->GetLinMotionX(MO_MOTSPEED)*1.5f;
+ a = fabs(m_physics->GetCirMotionY(MO_MOTSPEED)*26.0f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -418,7 +418,7 @@ bool CMotionMother::EventFrame(const Event &event)
else prog = Math::Mod(m_armMember+(2.0f-(i%3))*0.33f+0.3f, 1.0f);
if ( m_bArmStop )
{
- prog = (float)m_armTimeIndex/3.0f;
+ prog = static_cast< float >(m_armTimeIndex/3.0f);
}
if ( prog < 0.33f ) // t0..t1 ?
{
@@ -461,7 +461,7 @@ bool CMotionMother::EventFrame(const Event &event)
}
#if ADJUST_ANGLE
- if ( m_object->RetSelect() )
+ if ( m_object->GetSelect() )
{
char s[100];
sprintf(s, "A:time=%d Q:part=%d W:member=%d", m_armTimeIndex, m_armPartIndex, m_armMemberIndex);
@@ -469,7 +469,7 @@ bool CMotionMother::EventFrame(const Event &event)
}
#endif
- if ( !bStop && !m_object->RetRuin() )
+ if ( !bStop && !m_object->GetRuin() )
{
a = Math::Mod(m_armTimeMarch, 1.0f);
if ( a < 0.5f ) a = -1.0f+4.0f*a; // -1..1
diff --git a/src/object/motion/motionspider.cpp b/src/object/motion/motionspider.cpp
index be16e08..a3b55fc 100644
--- a/src/object/motion/motionspider.cpp
+++ b/src/object/motion/motionspider.cpp
@@ -21,8 +21,8 @@
#include "object/motion/motionspider.h"
-#include "old/modfile.h"
-#include "old/particule.h"
+#include "graphics/engine/modelfile.h"
+#include "graphics/engine/particle.h"
#include "physics/physics.h"
@@ -46,7 +46,7 @@ CMotionSpider::CMotionSpider(CInstanceManager* iMan, CObject* object)
m_armMemberIndex = 0;
m_armLastAction = -1;
m_bArmStop = false;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
}
// Object's destructor.
@@ -68,7 +68,7 @@ void CMotionSpider::DeleteObject(bool bAll)
bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank, i, j, parent;
char name[50];
@@ -96,15 +96,15 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
0.0f, 0.0f, -2.0f,
};
- if ( m_engine->RetRestCreate() < 3+32+2 ) return false;
+// if ( m_engine->GetRestCreate() < 3+32+2 ) return false;
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
// Creates the main base.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEVEHICULE); // this is a moving object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
pModFile->ReadModel("objects\\spider0.mod"); // doesn't exist
pModFile->CreateEngineObject(rank);
@@ -118,7 +118,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the abdomen.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\spider1.mod");
@@ -127,7 +127,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the head.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\spider2.mod");
@@ -143,7 +143,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3+i*4+j, rank);
if ( j == 0 ) parent = 0;
else parent = 3+i*4+j-1;
@@ -157,7 +157,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(19+i*4+j, rank);
if ( j == 0 ) parent = 0;
else parent = 19+i*4+j-1;
@@ -174,7 +174,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right mandible.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(35, rank);
m_object->SetObjectParent(35, 1);
pModFile->ReadModel("objects\\spider7.mod");
@@ -183,7 +183,7 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left mandible.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(36, rank);
m_object->SetObjectParent(36, 1);
pModFile->ReadModel("objects\\spider7.mod");
@@ -196,10 +196,10 @@ bool CMotionSpider::Create(Math::Vector pos, float angle, ObjectType type,
CreatePhysics();
m_object->SetFloorHeight(0.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_object->SetPosition(0, pos); // to display the shadows immediately
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -286,7 +286,7 @@ void CMotionSpider::CreatePhysics()
m_physics->SetType(TYPE_ROLLING);
- character = m_object->RetCharacter();
+ character = m_object->GetCharacter();
character->wheelFront = 4.0f;
character->wheelBack = 4.0f;
character->wheelLeft = 6.0f;
@@ -331,12 +331,12 @@ bool CMotionSpider::EventProcess(const Event &event)
{
CMotion::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
#if ADJUST_ANGLE
int i;
@@ -381,11 +381,11 @@ bool CMotionSpider::EventFrame(const Event &event)
int i, ii, st, nd, action;
bool bStop;
- if ( m_engine->RetPause() ) return true;
- if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( !m_engine->IsVisiblePoint(m_object->GetPosition(0)) ) return true;
- s = m_physics->RetLinMotionX(MO_MOTSPEED)*1.5f;
- a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.0f);
+ s = m_physics->GetLinMotionX(MO_MOTSPEED)*1.5f;
+ a = fabs(m_physics->GetCirMotionY(MO_MOTSPEED)*2.0f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -410,13 +410,13 @@ bool CMotionSpider::EventFrame(const Event &event)
m_armMember += a;
}
- if ( m_object->RetRuin() ) // destroyed?
+ if ( m_object->GetRuin() ) // destroyed?
{
m_actionType = MSS_RUIN;
}
- if ( m_object->RetBurn() ) // burning?
+ if ( m_object->GetBurn() ) // burning?
{
- if ( m_object->RetFixed() )
+ if ( m_object->GetFixed() )
{
m_actionType = MSS_BURN;
}
@@ -443,7 +443,7 @@ bool CMotionSpider::EventFrame(const Event &event)
else prog = Math::Mod(m_armMember+(2.0f-(i%4))*0.25f+0.5f, 1.0f);
if ( m_bArmStop )
{
- prog = (float)m_armTimeIndex/3.0f;
+ prog = static_cast< float >(m_armTimeIndex/3.0f);
action = MS_MARCH;
}
if ( prog < 0.33f ) // t0..t1 ?
@@ -511,38 +511,38 @@ bool CMotionSpider::EventFrame(const Event &event)
if ( i < 4 ) // right leg (1..4) ?
{
- m_object->SetAngleX(3+4*i+0, Math::Smooth(m_object->RetAngleX(3+4*i+0), Math::PropAngle(tSt[ 0], tNd[ 0], prog), time));
- m_object->SetAngleY(3+4*i+0, Math::Smooth(m_object->RetAngleY(3+4*i+0), Math::PropAngle(tSt[ 1], tNd[ 1], prog), time));
- m_object->SetAngleZ(3+4*i+0, Math::Smooth(m_object->RetAngleZ(3+4*i+0), Math::PropAngle(tSt[ 2], tNd[ 2], prog), time));
- m_object->SetAngleX(3+4*i+1, Math::Smooth(m_object->RetAngleX(3+4*i+1), Math::PropAngle(tSt[ 3], tNd[ 3], prog), time));
- m_object->SetAngleY(3+4*i+1, Math::Smooth(m_object->RetAngleY(3+4*i+1), Math::PropAngle(tSt[ 4], tNd[ 4], prog), time));
- m_object->SetAngleZ(3+4*i+1, Math::Smooth(m_object->RetAngleZ(3+4*i+1), Math::PropAngle(tSt[ 5], tNd[ 5], prog), time));
- m_object->SetAngleX(3+4*i+2, Math::Smooth(m_object->RetAngleX(3+4*i+2), Math::PropAngle(tSt[ 6], tNd[ 6], prog), time));
- m_object->SetAngleY(3+4*i+2, Math::Smooth(m_object->RetAngleY(3+4*i+2), Math::PropAngle(tSt[ 7], tNd[ 7], prog), time));
- m_object->SetAngleZ(3+4*i+2, Math::Smooth(m_object->RetAngleZ(3+4*i+2), Math::PropAngle(tSt[ 8], tNd[ 8], prog), time));
- m_object->SetAngleX(3+4*i+3, Math::Smooth(m_object->RetAngleX(3+4*i+3), Math::PropAngle(tSt[ 9], tNd[ 9], prog), time));
- m_object->SetAngleY(3+4*i+3, Math::Smooth(m_object->RetAngleY(3+4*i+3), Math::PropAngle(tSt[10], tNd[10], prog), time));
- m_object->SetAngleZ(3+4*i+3, Math::Smooth(m_object->RetAngleZ(3+4*i+3), Math::PropAngle(tSt[11], tNd[11], prog), time));
+ m_object->SetAngleX(3+4*i+0, Math::Smooth(m_object->GetAngleX(3+4*i+0), Math::PropAngle(tSt[ 0], tNd[ 0], prog), time));
+ m_object->SetAngleY(3+4*i+0, Math::Smooth(m_object->GetAngleY(3+4*i+0), Math::PropAngle(tSt[ 1], tNd[ 1], prog), time));
+ m_object->SetAngleZ(3+4*i+0, Math::Smooth(m_object->GetAngleZ(3+4*i+0), Math::PropAngle(tSt[ 2], tNd[ 2], prog), time));
+ m_object->SetAngleX(3+4*i+1, Math::Smooth(m_object->GetAngleX(3+4*i+1), Math::PropAngle(tSt[ 3], tNd[ 3], prog), time));
+ m_object->SetAngleY(3+4*i+1, Math::Smooth(m_object->GetAngleY(3+4*i+1), Math::PropAngle(tSt[ 4], tNd[ 4], prog), time));
+ m_object->SetAngleZ(3+4*i+1, Math::Smooth(m_object->GetAngleZ(3+4*i+1), Math::PropAngle(tSt[ 5], tNd[ 5], prog), time));
+ m_object->SetAngleX(3+4*i+2, Math::Smooth(m_object->GetAngleX(3+4*i+2), Math::PropAngle(tSt[ 6], tNd[ 6], prog), time));
+ m_object->SetAngleY(3+4*i+2, Math::Smooth(m_object->GetAngleY(3+4*i+2), Math::PropAngle(tSt[ 7], tNd[ 7], prog), time));
+ m_object->SetAngleZ(3+4*i+2, Math::Smooth(m_object->GetAngleZ(3+4*i+2), Math::PropAngle(tSt[ 8], tNd[ 8], prog), time));
+ m_object->SetAngleX(3+4*i+3, Math::Smooth(m_object->GetAngleX(3+4*i+3), Math::PropAngle(tSt[ 9], tNd[ 9], prog), time));
+ m_object->SetAngleY(3+4*i+3, Math::Smooth(m_object->GetAngleY(3+4*i+3), Math::PropAngle(tSt[10], tNd[10], prog), time));
+ m_object->SetAngleZ(3+4*i+3, Math::Smooth(m_object->GetAngleZ(3+4*i+3), Math::PropAngle(tSt[11], tNd[11], prog), time));
}
else // left leg (5..8) ?
{
- m_object->SetAngleX(3+4*i+0, Math::Smooth(m_object->RetAngleX(3+4*i+0), Math::PropAngle(-tSt[ 0], -tNd[ 0], prog), time));
- m_object->SetAngleY(3+4*i+0, Math::Smooth(m_object->RetAngleY(3+4*i+0), Math::PropAngle(-tSt[ 1], -tNd[ 1], prog), time));
- m_object->SetAngleZ(3+4*i+0, Math::Smooth(m_object->RetAngleZ(3+4*i+0), Math::PropAngle( tSt[ 2], tNd[ 2], prog), time));
- m_object->SetAngleX(3+4*i+1, Math::Smooth(m_object->RetAngleX(3+4*i+1), Math::PropAngle(-tSt[ 3], -tNd[ 3], prog), time));
- m_object->SetAngleY(3+4*i+1, Math::Smooth(m_object->RetAngleY(3+4*i+1), Math::PropAngle(-tSt[ 4], -tNd[ 4], prog), time));
- m_object->SetAngleZ(3+4*i+1, Math::Smooth(m_object->RetAngleZ(3+4*i+1), Math::PropAngle( tSt[ 5], tNd[ 5], prog), time));
- m_object->SetAngleX(3+4*i+2, Math::Smooth(m_object->RetAngleX(3+4*i+2), Math::PropAngle(-tSt[ 6], -tNd[ 6], prog), time));
- m_object->SetAngleY(3+4*i+2, Math::Smooth(m_object->RetAngleY(3+4*i+2), Math::PropAngle(-tSt[ 7], -tNd[ 7], prog), time));
- m_object->SetAngleZ(3+4*i+2, Math::Smooth(m_object->RetAngleZ(3+4*i+2), Math::PropAngle( tSt[ 8], tNd[ 8], prog), time));
- m_object->SetAngleX(3+4*i+3, Math::Smooth(m_object->RetAngleX(3+4*i+3), Math::PropAngle(-tSt[ 9], -tNd[ 9], prog), time));
- m_object->SetAngleY(3+4*i+3, Math::Smooth(m_object->RetAngleY(3+4*i+3), Math::PropAngle(-tSt[10], -tNd[10], prog), time));
- m_object->SetAngleZ(3+4*i+3, Math::Smooth(m_object->RetAngleZ(3+4*i+3), Math::PropAngle( tSt[11], tNd[11], prog), time));
+ m_object->SetAngleX(3+4*i+0, Math::Smooth(m_object->GetAngleX(3+4*i+0), Math::PropAngle(-tSt[ 0], -tNd[ 0], prog), time));
+ m_object->SetAngleY(3+4*i+0, Math::Smooth(m_object->GetAngleY(3+4*i+0), Math::PropAngle(-tSt[ 1], -tNd[ 1], prog), time));
+ m_object->SetAngleZ(3+4*i+0, Math::Smooth(m_object->GetAngleZ(3+4*i+0), Math::PropAngle( tSt[ 2], tNd[ 2], prog), time));
+ m_object->SetAngleX(3+4*i+1, Math::Smooth(m_object->GetAngleX(3+4*i+1), Math::PropAngle(-tSt[ 3], -tNd[ 3], prog), time));
+ m_object->SetAngleY(3+4*i+1, Math::Smooth(m_object->GetAngleY(3+4*i+1), Math::PropAngle(-tSt[ 4], -tNd[ 4], prog), time));
+ m_object->SetAngleZ(3+4*i+1, Math::Smooth(m_object->GetAngleZ(3+4*i+1), Math::PropAngle( tSt[ 5], tNd[ 5], prog), time));
+ m_object->SetAngleX(3+4*i+2, Math::Smooth(m_object->GetAngleX(3+4*i+2), Math::PropAngle(-tSt[ 6], -tNd[ 6], prog), time));
+ m_object->SetAngleY(3+4*i+2, Math::Smooth(m_object->GetAngleY(3+4*i+2), Math::PropAngle(-tSt[ 7], -tNd[ 7], prog), time));
+ m_object->SetAngleZ(3+4*i+2, Math::Smooth(m_object->GetAngleZ(3+4*i+2), Math::PropAngle( tSt[ 8], tNd[ 8], prog), time));
+ m_object->SetAngleX(3+4*i+3, Math::Smooth(m_object->GetAngleX(3+4*i+3), Math::PropAngle(-tSt[ 9], -tNd[ 9], prog), time));
+ m_object->SetAngleY(3+4*i+3, Math::Smooth(m_object->GetAngleY(3+4*i+3), Math::PropAngle(-tSt[10], -tNd[10], prog), time));
+ m_object->SetAngleZ(3+4*i+3, Math::Smooth(m_object->GetAngleZ(3+4*i+3), Math::PropAngle( tSt[11], tNd[11], prog), time));
}
}
#if ADJUST_ANGLE
- if ( m_object->RetSelect() )
+ if ( m_object->GetSelect() )
{
char s[100];
sprintf(s, "A:time=%d Q:part=%d W:member=%d", m_armTimeIndex, m_armPartIndex, m_armMemberIndex);
@@ -559,7 +559,7 @@ bool CMotionSpider::EventFrame(const Event &event)
SetInclinaison(dir);
time = event.rTime*1.0f;
- m_object->SetAngleZ(1, Math::Smooth(m_object->RetAngleZ(1), 0.0f, time)); // head
+ m_object->SetAngleZ(1, Math::Smooth(m_object->GetAngleZ(1), 0.0f, time)); // head
}
else if ( m_actionType == MSS_RUIN ) // destroyed?
{
@@ -581,17 +581,17 @@ bool CMotionSpider::EventFrame(const Event &event)
}
else if ( m_actionType == MSS_BACK1 ) // turns on the back?
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_armTimeAbs )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_armTimeAbs )
{
- m_lastParticule = m_armTimeAbs;
+ m_lastParticle = m_armTimeAbs;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*10.0f;
speed.z = (Math::Rand()-0.5f)*10.0f;
speed.y = Math::Rand()*5.0f;
dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
if ( m_progress < 0.5f )
@@ -623,13 +623,13 @@ bool CMotionSpider::EventFrame(const Event &event)
}
else if ( m_actionType == MSS_BACK2 ) // moves on the back?
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_armTimeAbs )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_armTimeAbs )
{
- m_lastParticule = m_armTimeAbs;
+ m_lastParticle = m_armTimeAbs;
if ( rand()%10 == 0 )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*8.0f;
pos.z += (Math::Rand()-0.5f)*8.0f;
pos.y -= 1.0f;
@@ -638,7 +638,7 @@ bool CMotionSpider::EventFrame(const Event &event)
speed.y = Math::Rand()*2.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
}
@@ -672,17 +672,17 @@ bool CMotionSpider::EventFrame(const Event &event)
}
else if ( m_actionType == MSS_BACK3 ) // recovers on the legs?
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_armTimeAbs )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_armTimeAbs )
{
- m_lastParticule = m_armTimeAbs;
+ m_lastParticle = m_armTimeAbs;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*10.0f;
speed.z = (Math::Rand()-0.5f)*10.0f;
speed.y = Math::Rand()*5.0f;
dim.x = Math::Rand()*3.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
if ( m_progress < 0.5f )
diff --git a/src/object/motion/motionspider.h b/src/object/motion/motionspider.h
index e9f052c..fbf05f9 100644
--- a/src/object/motion/motionspider.h
+++ b/src/object/motion/motionspider.h
@@ -66,6 +66,6 @@ protected:
int m_armMemberIndex;
int m_armLastAction;
bool m_bArmStop;
- float m_lastParticule;
+ float m_lastParticle;
};
diff --git a/src/object/motion/motiontoto.cpp b/src/object/motion/motiontoto.cpp
index 6d39b36..af2cf6b 100644
--- a/src/object/motion/motiontoto.cpp
+++ b/src/object/motion/motiontoto.cpp
@@ -22,9 +22,9 @@
#include "object/motion/motiontoto.h"
#include "math/geometry.h"
-#include "old/terrain.h"
-#include "old/water.h"
-#include "old/modfile.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/water.h"
+#include "graphics/engine/modelfile.h"
#include "object/robotmain.h"
@@ -49,7 +49,7 @@ CMotionToto::CMotionToto(CInstanceManager* iMan, CObject* object)
m_clownTime = 0.0f;
m_blinkTime = 0.0f;
m_blinkProgress = -1.0f;
- m_lastMotorParticule = 0.0f;
+ m_lastMotorParticle = 0.0f;
m_type = OBJECT_NULL;
m_mousePos = Math::Point(0.0f, 0.0f);
}
@@ -78,18 +78,18 @@ void CMotionToto::DeleteObject(bool bAll)
bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank;
- if ( m_engine->RetRestCreate() < 10 ) return false;
+// if ( m_engine->GetRestCreate() < 10 ) return false;
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
// Creates the head.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEVEHICULE); // this is a moving object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
pModFile->ReadModel("objects\\toto1.mod");
pModFile->CreateEngineObject(rank);
@@ -98,7 +98,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
// Creates mouth.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\toto2.mod");
@@ -107,7 +107,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left eye.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\toto3.mod");
@@ -118,7 +118,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right eye.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 0);
pModFile->ReadModel("objects\\toto3.mod");
@@ -128,7 +128,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
// Creates left antenna.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 0);
pModFile->ReadModel("objects\\toto4.mod");
@@ -137,7 +137,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetAngleX(4, 30.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
pModFile->ReadModel("objects\\toto4.mod");
@@ -146,7 +146,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetAngleX(5, 30.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 5);
pModFile->ReadModel("objects\\toto5.mod");
@@ -156,7 +156,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
// Creates right antenna.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
pModFile->ReadModel("objects\\toto4.mod");
@@ -165,7 +165,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetAngleX(7, -30.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 7);
pModFile->ReadModel("objects\\toto4.mod");
@@ -174,7 +174,7 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetAngleX(8, -30.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 8);
pModFile->ReadModel("objects\\toto5.mod");
@@ -185,10 +185,10 @@ bool CMotionToto::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetZoom(0, 0.5f); // is little
m_object->SetFloorHeight(0.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_object->SetPosition(0, pos); // to display the shadows immediately
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -233,7 +233,7 @@ bool CMotionToto::EventProcess(const Event &event)
{
CMotion::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
@@ -249,15 +249,15 @@ bool CMotionToto::EventFrame(const Event &event)
Math::Vector eye, lookat, dir, perp, nPos, aPos, pos, speed;
Math::Vector vibLin, vibCir, dirSpeed, aAntenna;
Math::Point dim;
- POINT wDim;
- ParticuleType type;
+ Math::IntPoint wDim;
+ Gfx::ParticleType type;
float progress, focus, distance, shift, verti, level, zoom;
float aAngle, nAngle, mAngle, angle, linSpeed, cirSpeed;
int sheet, i, r;
bool bHidden;
- if ( m_engine->RetPause() &&
- !m_main->RetInfoLock() ) return true;
+ if ( m_engine->GetPause() &&
+ !m_main->GetInfoLock() ) return true;
if ( m_bDisplayInfo ) // "looks" mouse?
{
@@ -267,13 +267,13 @@ bool CMotionToto::EventFrame(const Event &event)
{
bHidden = false;
- if ( m_main->RetMovieLock() ) // current movie?
+ if ( m_main->GetMovieLock() ) // current movie?
{
bHidden = true;
}
- if ( !m_engine->RetTotoMode() )
+ if ( !m_engine->GetTotoMode() )
{
- if ( !m_main->RetEditLock() ) // current edition?
+ if ( !m_main->GetEditLock() ) // current edition?
{
bHidden = true;
}
@@ -282,8 +282,8 @@ bool CMotionToto::EventFrame(const Event &event)
if ( bHidden )
{
- nPos = m_object->RetPosition(0);
- m_terrain->MoveOnFloor(nPos, true);
+ nPos = m_object->GetPosition(0);
+ m_terrain->AdjustToFloor(nPos, true);
nPos.y -= 100.0f; // hidden under the ground!
m_object->SetPosition(0, nPos);
return true;
@@ -319,9 +319,9 @@ bool CMotionToto::EventFrame(const Event &event)
m_clownDelay = 0.0f;
}
- focus = m_engine->RetFocus();
- eye = m_engine->RetEyePt();
- lookat = m_engine->RetLookatPt();
+ focus = m_engine->GetFocus();
+ eye = m_engine->GetEyePt();
+ lookat = m_engine->GetLookatPt();
vibLin = Math::Vector(0.0f, 0.0f, 0.0f);
vibCir = Math::Vector(0.0f, 0.0f, 0.0f);
@@ -331,8 +331,8 @@ bool CMotionToto::EventFrame(const Event &event)
// Calculates the new position.
if ( m_bDisplayInfo )
{
- wDim = m_engine->RetDim();
- nPos.x = -4.0f*((float)wDim.x/(float)wDim.y)/(640.0f/480.0f);
+ wDim = m_engine->GetWindowSize();
+ nPos.x = -4.0f*(static_cast< float >(wDim.x)/static_cast< float >(wDim.y))/(640.0f/480.0f);
nPos.y = -0.5f;
nPos.z = 7.0f; // in the left margin
@@ -394,8 +394,8 @@ bool CMotionToto::EventFrame(const Event &event)
m_clownRadius = 0.0f;
m_clownDelay = 2.0f+Math::Rand()*2.0f;
}
- pos = m_object->RetPosition(0);
- if ( pos.y < m_water->RetLevel() ) // underwater?
+ pos = m_object->GetPosition(0);
+ if ( pos.y < m_water->GetLevel() ) // underwater?
{
m_clownRadius /= 1.5f;
m_clownDelay *= 2.0f;
@@ -432,7 +432,7 @@ bool CMotionToto::EventFrame(const Event &event)
}
else
{
- aPos = m_object->RetPosition(0);
+ aPos = m_object->GetPosition(0);
if ( m_actionType == -1 )
{
level = 4.0f;
@@ -468,7 +468,7 @@ bool CMotionToto::EventFrame(const Event &event)
}
level = Math::Min(linSpeed*0.1f, 1.0f);
nAngle = nAngle*(1.0f-level) + mAngle*level;
- aAngle = Math::NormAngle(m_object->RetAngleY(0));
+ aAngle = Math::NormAngle(m_object->GetAngleY(0));
if ( nAngle < aAngle )
{
@@ -579,7 +579,7 @@ bool CMotionToto::EventFrame(const Event &event)
else
{
nPos.y += vibLin.y;
- level = m_terrain->RetFloorLevel(nPos);
+ level = m_terrain->GetFloorLevel(nPos);
if ( nPos.y < level+2.0f )
{
nPos.y = level+2.0f; // just above the ground
@@ -717,19 +717,19 @@ bool CMotionToto::EventFrame(const Event &event)
m_object->SetAngleX(3, 0.0f);
}
- mat = m_object->RetWorldMatrix(0); // must be done every time!
+ mat = m_object->GetWorldMatrix(0); // must be done every time!
// Generates particles.
- if ( m_time-m_lastMotorParticule >= m_engine->ParticuleAdapt(0.05f) )
+ if ( m_time-m_lastMotorParticle >= m_engine->ParticleAdapt(0.05f) )
{
- m_lastMotorParticule = m_time;
+ m_lastMotorParticle = m_time;
- if ( m_bDisplayInfo ) sheet = SH_FRONT;
- else sheet = SH_WORLD;
+ if ( m_bDisplayInfo ) sheet = Gfx::SH_FRONT;
+ else sheet = Gfx::SH_WORLD;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
if ( !m_bDisplayInfo &&
- pos.y < m_water->RetLevel() ) // underwater?
+ pos.y < m_water->GetLevel() ) // underwater?
{
float t = Math::Mod(m_time, 3.5f);
if ( t >= 2.2f || ( t >= 1.2f && t <= 1.4f ) ) // breathe?
@@ -747,7 +747,7 @@ bool CMotionToto::EventFrame(const Event &event)
dim.x = 0.12f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
}
}
else // out of water?
@@ -760,13 +760,13 @@ bool CMotionToto::EventFrame(const Event &event)
speed.x += (Math::Rand()-0.5f)*2.0f;
speed.z += (Math::Rand()-0.5f)*2.0f;
-// mat = m_object->RetWorldMatrix(0);
+// mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = Transform(*mat, speed)-pos;
dim.x = (Math::Rand()*0.4f+0.4f)*(1.0f+Math::Min(linSpeed*0.1f, 5.0f));
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTITOTO, 1.0f+Math::Rand()*1.0f, 0.0f, 1.0f, sheet);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTITOTO, 1.0f+Math::Rand()*1.0f, 0.0f, 1.0f, sheet);
}
if ( m_actionType != -1 && // current action?
@@ -779,21 +779,21 @@ bool CMotionToto::EventFrame(const Event &event)
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = (Math::Rand()*0.3f+0.3f);
dim.y = dim.x;
- if ( m_actionType == MT_ERROR ) type = PARTIERROR;
- if ( m_actionType == MT_WARNING ) type = PARTIWARNING;
- if ( m_actionType == MT_INFO ) type = PARTIINFO;
- if ( m_actionType == MT_MESSAGE ) type = PARTIWARNING;
- m_particule->CreateParticule(pos, speed, dim, type, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, sheet);
+ if ( m_actionType == MT_ERROR ) type = Gfx::PARTIERROR;
+ if ( m_actionType == MT_WARNING ) type = Gfx::PARTIWARNING;
+ if ( m_actionType == MT_INFO ) type = Gfx::PARTIINFO;
+ if ( m_actionType == MT_MESSAGE ) type = Gfx::PARTIWARNING;
+ m_particle->CreateParticle(pos, speed, dim, type, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, sheet);
pos.x = 0.50f+(Math::Rand()-0.5f)*0.80f;
pos.y = 0.86f+(Math::Rand()-0.5f)*0.08f;
pos.z = 0.00f;
dim.x = (Math::Rand()*0.04f+0.04f);
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, type, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, SH_INTERFACE);
+ m_particle->CreateParticle(pos, speed, dim, type, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, Gfx::SH_INTERFACE);
}
-//? if ( m_bDisplayInfo && m_main->RetGlint() )
+//? if ( m_bDisplayInfo && m_main->GetGlint() )
if ( false )
{
pos.x = (Math::Rand()-0.5f)*1.4f;
@@ -803,7 +803,7 @@ bool CMotionToto::EventFrame(const Event &event)
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = (Math::Rand()*0.5f+0.5f);
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIERROR, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, sheet);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIERROR, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, sheet);
for ( i=0 ; i<10 ; i++ )
{
@@ -817,7 +817,7 @@ bool CMotionToto::EventFrame(const Event &event)
else pos.y = 0.92f; // on the upper edge
dim.x = (Math::Rand()*0.02f+0.02f);
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, PARTIERROR, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, SH_INTERFACE);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIERROR, 0.5f+Math::Rand()*0.5f, 0.0f, 1.0f, Gfx::SH_INTERFACE);
}
}
}
@@ -825,7 +825,7 @@ bool CMotionToto::EventFrame(const Event &event)
// Move the sound.
if ( m_soundChannel != -1 )
{
- if ( !m_sound->Position(m_soundChannel, m_object->RetPosition(0)) )
+ if ( !m_sound->Position(m_soundChannel, m_object->GetPosition(0)) )
{
m_soundChannel = -1;
}
@@ -853,7 +853,7 @@ Error CMotionToto::SetAction(int action, float time)
if ( sound != SOUND_CLICK )
{
- m_soundChannel = m_sound->Play(sound, m_object->RetPosition(0));
+ m_soundChannel = m_sound->Play(sound, m_object->GetPosition(0));
}
return ERR_OK;
diff --git a/src/object/motion/motiontoto.h b/src/object/motion/motiontoto.h
index 9df2d99..4072b62 100644
--- a/src/object/motion/motiontoto.h
+++ b/src/object/motion/motiontoto.h
@@ -53,7 +53,7 @@ protected:
protected:
float m_time;
- float m_lastMotorParticule;
+ float m_lastMotorParticle;
bool m_bDisplayInfo;
bool m_bQuickPos;
bool m_bStartAction;
diff --git a/src/object/motion/motionvehicle.cpp b/src/object/motion/motionvehicle.cpp
index ff05695..1a4b98f 100644
--- a/src/object/motion/motionvehicle.cpp
+++ b/src/object/motion/motionvehicle.cpp
@@ -17,17 +17,17 @@
// motionvehicle.cpp
-#include <stdio.h>
-
#include "object/motion/motionvehicle.h"
-#include "old/modfile.h"
-#include "old/particule.h"
-#include "old/terrain.h"
+#include "graphics/engine/modelfile.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/terrain.h"
#include "math/geometry.h"
#include "object/brain.h"
#include "physics/physics.h"
+#include <stdio.h>
+#include <string.h>
@@ -78,7 +78,7 @@ void CMotionVehicle::DeleteObject(bool bAll)
{
if ( m_partiReactor != -1 )
{
- m_particule->DeleteParticule(m_partiReactor);
+ m_particle->DeleteParticle(m_partiReactor);
m_partiReactor = -1;
}
}
@@ -89,21 +89,21 @@ void CMotionVehicle::DeleteObject(bool bAll)
bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
CObject* pPower;
int rank, i, j, parent;
- D3DCOLORVALUE color;
+ Gfx::Color color;
char name[50];
- if ( m_engine->RetRestCreate() < 1+5+18+1 ) return false;
+// if ( m_engine->GetRestCreate() < 1+5+18+1 ) return false;
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
// Creates the main base.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEVEHICULE); // this is a moving object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
if ( type == OBJECT_MOBILEfa ||
@@ -125,7 +125,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
type == OBJECT_MOBILEwi ||
type == OBJECT_MOBILEws )
{
- if ( m_object->RetTrainer() )
+ if ( m_object->GetTrainer() )
{
pModFile->ReadModel("objects\\lem1wt.mod");
}
@@ -222,7 +222,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the arm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\lem2.mod");
@@ -232,7 +232,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the forearm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
pModFile->ReadModel("objects\\lem3.mod");
@@ -242,7 +242,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the hand.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
pModFile->ReadModel("objects\\lem4.mod");
@@ -253,7 +253,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the close clamp.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 3);
pModFile->ReadModel("objects\\lem5.mod");
@@ -263,7 +263,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the remote clamp.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 3);
pModFile->ReadModel("objects\\lem6.mod");
@@ -279,7 +279,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the arm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\lem2.mod");
@@ -289,7 +289,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the forearm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
pModFile->ReadModel("objects\\lem3.mod");
@@ -299,7 +299,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the sensor.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
pModFile->ReadModel("objects\\lem4s.mod");
@@ -315,7 +315,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the cannon.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\canon.mod");
@@ -332,7 +332,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the insect cannon.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\canoni1.mod");
@@ -341,7 +341,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetAngleZ(1, 0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
pModFile->ReadModel("objects\\canoni2.mod");
@@ -358,7 +358,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the right-back wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\lem2w.mod");
@@ -367,7 +367,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left-back wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
pModFile->ReadModel("objects\\lem2w.mod");
@@ -377,7 +377,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right-front wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
pModFile->ReadModel("objects\\lem2w.mod");
@@ -386,7 +386,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left-front wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
pModFile->ReadModel("objects\\lem2w.mod");
@@ -399,7 +399,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the right-back wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\lem2w.mod");
@@ -408,7 +408,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left-back wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
pModFile->ReadModel("objects\\lem2w.mod");
@@ -418,7 +418,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right-front wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
pModFile->ReadModel("objects\\lem2w.mod");
@@ -427,7 +427,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left-front wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
pModFile->ReadModel("objects\\lem2w.mod");
@@ -443,7 +443,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\lem2t.mod");
@@ -452,7 +452,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left caterpillar.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
pModFile->ReadModel("objects\\lem3t.mod");
@@ -467,7 +467,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\roller2.mod");
@@ -476,7 +476,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left caterpillar.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
pModFile->ReadModel("objects\\roller3.mod");
@@ -488,7 +488,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\subm4.mod");
@@ -497,7 +497,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left caterpillar.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
pModFile->ReadModel("objects\\subm5.mod");
@@ -509,7 +509,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the right caterpillar.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\drawer2.mod");
@@ -518,7 +518,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left caterpillar.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
pModFile->ReadModel("objects\\drawer3.mod");
@@ -534,7 +534,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the front foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\lem2f.mod");
@@ -543,7 +543,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
pModFile->ReadModel("objects\\lem2f.mod");
@@ -553,7 +553,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left-back foot.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
pModFile->ReadModel("objects\\lem2f.mod");
@@ -591,7 +591,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6+i*3+j, rank);
if ( j == 0 ) parent = 0;
else parent = 6+i*3+j-1;
@@ -605,7 +605,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left leg.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(15+i*3+j, rank);
if ( j == 0 ) parent = 0;
else parent = 15+i*3+j-1;
@@ -625,7 +625,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the holder.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\roller2t.mod");
@@ -635,7 +635,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the pestle.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\roller3t.mod");
@@ -648,7 +648,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the holder.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\roller2c.mod");
@@ -658,7 +658,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the cannon.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\roller3p.mod");
@@ -671,7 +671,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the holder.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\recover1.mod");
@@ -680,7 +680,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right arm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
pModFile->ReadModel("objects\\recover2.mod");
@@ -690,7 +690,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right forearm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
pModFile->ReadModel("objects\\recover3.mod");
@@ -700,7 +700,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left arm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(4, rank);
m_object->SetObjectParent(4, 1);
pModFile->ReadModel("objects\\recover2.mod");
@@ -711,7 +711,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left forearm.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(5, rank);
m_object->SetObjectParent(5, 4);
pModFile->ReadModel("objects\\recover3.mod");
@@ -725,7 +725,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the holder.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\roller2s.mod");
@@ -735,7 +735,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the intermediate piston.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
pModFile->ReadModel("objects\\roller3s.mod");
@@ -745,7 +745,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the piston with the sphere.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 2);
pModFile->ReadModel("objects\\roller4s.mod");
@@ -758,7 +758,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the holder.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\subm2.mod");
@@ -767,7 +767,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the right tong.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 1);
pModFile->ReadModel("objects\\subm3.mod");
@@ -776,7 +776,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the left tong.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(3, rank);
m_object->SetObjectParent(3, 1);
pModFile->ReadModel("objects\\subm3.mod");
@@ -789,7 +789,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the carousel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\drawer4.mod");
@@ -797,10 +797,10 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetPosition(1, Math::Vector(-3.0f, 3.0f, 0.0f));
// Creates the key.
- if ( m_object->RetToy() )
+ if ( m_object->GetToy() )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\drawer5.mod");
@@ -814,7 +814,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
for ( i=0 ; i<8 ; i++ )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10+i, rank);
m_object->SetObjectParent(10+i, 1);
sprintf(name, "objects\\drawer%d.mod", 10+i);
@@ -828,10 +828,10 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
if ( type == OBJECT_MOBILEwt )
{
// Creates the key.
- if ( m_object->RetToy() )
+ if ( m_object->GetToy() )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\drawer5.mod");
@@ -846,7 +846,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
{
// Creates the accessories.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\apolloj2.mod"); // antenna
@@ -856,7 +856,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetAngleZ(1, 45.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2, rank);
m_object->SetObjectParent(2, 0);
pModFile->ReadModel("objects\\apolloj3.mod"); // camera
@@ -866,7 +866,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the wheels.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(6, rank);
m_object->SetObjectParent(6, 0);
pModFile->ReadModel("objects\\apolloj4.mod"); // wheel
@@ -874,7 +874,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetPosition(6, Math::Vector(-5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(7, rank);
m_object->SetObjectParent(7, 0);
pModFile->ReadModel("objects\\apolloj4.mod"); // wheel
@@ -882,7 +882,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetPosition(7, Math::Vector(-5.75f, 1.65f, 5.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(8, rank);
m_object->SetObjectParent(8, 0);
pModFile->ReadModel("objects\\apolloj4.mod"); // wheel
@@ -890,7 +890,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetPosition(8, Math::Vector(5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(9, rank);
m_object->SetObjectParent(9, 0);
pModFile->ReadModel("objects\\apolloj4.mod"); // wheel
@@ -899,7 +899,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
// Creates mud guards.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(10, rank);
m_object->SetObjectParent(10, 0);
pModFile->ReadModel("objects\\apolloj6.mod"); // wheel
@@ -907,7 +907,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetPosition(10, Math::Vector(-5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(11, rank);
m_object->SetObjectParent(11, 0);
pModFile->ReadModel("objects\\apolloj6.mod"); // wheel
@@ -915,7 +915,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetPosition(11, Math::Vector(-5.75f, 1.65f, 5.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(12, rank);
m_object->SetObjectParent(12, 0);
pModFile->ReadModel("objects\\apolloj5.mod"); // wheel
@@ -923,7 +923,7 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
m_object->SetPosition(12, Math::Vector(5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(13, rank);
m_object->SetObjectParent(13, 0);
pModFile->ReadModel("objects\\apolloj5.mod"); // wheel
@@ -1035,14 +1035,14 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
pPower->SetType(power<=1.0f?OBJECT_POWER:OBJECT_ATOMIC);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
pPower->SetObjectRank(0, rank);
if ( power <= 1.0f ) pModFile->ReadModel("objects\\power.mod");
else pModFile->ReadModel("objects\\atomic.mod");
pModFile->CreateEngineObject(rank);
- pPower->SetPosition(0, m_object->RetCharacter()->posPower);
+ pPower->SetPosition(0, m_object->GetCharacter()->posPower);
pPower->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
pPower->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f);
@@ -1053,10 +1053,10 @@ bool CMotionVehicle::Create(Math::Vector pos, float angle, ObjectType type,
else pPower->SetEnergy(power/100.0f);
}
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_object->SetPosition(0, pos); //to display the shadows immediately
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -1068,7 +1068,7 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
{
Character* character;
- character = m_object->RetCharacter();
+ character = m_object->GetCharacter();
if ( type == OBJECT_MOBILEwa ||
type == OBJECT_MOBILEwc ||
@@ -1352,12 +1352,12 @@ bool CMotionVehicle::EventProcess(const Event &event)
{
CMotion::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
}
@@ -1375,10 +1375,10 @@ bool CMotionVehicle::EventFrame(const Event &event)
float s, a, speedBL, speedBR, speedFL, speedFR, h, a1, a2;
float back, front, dist, radius, limit[2];
- if ( m_engine->RetPause() ) return true;
- if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( !m_engine->IsVisiblePoint(m_object->GetPosition(0)) ) return true;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_MOBILEwa ||
type == OBJECT_MOBILEwc ||
@@ -1388,8 +1388,8 @@ bool CMotionVehicle::EventFrame(const Event &event)
type == OBJECT_MOBILEtg ||
type == OBJECT_APOLLO2 ) // wheels?
{
- s = m_physics->RetLinMotionX(MO_MOTSPEED)*1.0f;
- a = m_physics->RetCirMotionY(MO_MOTSPEED)*3.0f;
+ s = m_physics->GetLinMotionX(MO_MOTSPEED)*1.0f;
+ a = m_physics->GetCirMotionY(MO_MOTSPEED)*3.0f;
if ( type == OBJECT_APOLLO2 ) s *= 0.5f;
@@ -1398,10 +1398,10 @@ bool CMotionVehicle::EventFrame(const Event &event)
speedFR = -s+a;
speedFL = s+a;
- m_object->SetAngleZ(6, m_object->RetAngleZ(6)+event.rTime*speedBR); // turning the wheels
- m_object->SetAngleZ(7, m_object->RetAngleZ(7)+event.rTime*speedBL);
- m_object->SetAngleZ(8, m_object->RetAngleZ(8)+event.rTime*speedFR);
- m_object->SetAngleZ(9, m_object->RetAngleZ(9)+event.rTime*speedFL);
+ m_object->SetAngleZ(6, m_object->GetAngleZ(6)+event.rTime*speedBR); // turning the wheels
+ m_object->SetAngleZ(7, m_object->GetAngleZ(7)+event.rTime*speedBL);
+ m_object->SetAngleZ(8, m_object->GetAngleZ(8)+event.rTime*speedFR);
+ m_object->SetAngleZ(9, m_object->GetAngleZ(9)+event.rTime*speedFL);
if ( s > 0.0f )
{
@@ -1424,21 +1424,21 @@ bool CMotionVehicle::EventFrame(const Event &event)
m_wheelTurn[2] = -fabs(a)*0.05f;
m_wheelTurn[3] = fabs(a)*0.05f+Math::PI;
}
- m_object->SetAngleY(6, m_object->RetAngleY(6)+(m_wheelTurn[0]-m_object->RetAngleY(6))*event.rTime*8.0f);
- m_object->SetAngleY(7, m_object->RetAngleY(7)+(m_wheelTurn[1]-m_object->RetAngleY(7))*event.rTime*8.0f);
- m_object->SetAngleY(8, m_object->RetAngleY(8)+(m_wheelTurn[2]-m_object->RetAngleY(8))*event.rTime*8.0f);
- m_object->SetAngleY(9, m_object->RetAngleY(9)+(m_wheelTurn[3]-m_object->RetAngleY(9))*event.rTime*8.0f);
+ m_object->SetAngleY(6, m_object->GetAngleY(6)+(m_wheelTurn[0]-m_object->GetAngleY(6))*event.rTime*8.0f);
+ m_object->SetAngleY(7, m_object->GetAngleY(7)+(m_wheelTurn[1]-m_object->GetAngleY(7))*event.rTime*8.0f);
+ m_object->SetAngleY(8, m_object->GetAngleY(8)+(m_wheelTurn[2]-m_object->GetAngleY(8))*event.rTime*8.0f);
+ m_object->SetAngleY(9, m_object->GetAngleY(9)+(m_wheelTurn[3]-m_object->GetAngleY(9))*event.rTime*8.0f);
if ( type == OBJECT_APOLLO2 )
{
- m_object->SetAngleY(10, m_object->RetAngleY(6)+(m_wheelTurn[0]-m_object->RetAngleY(6))*event.rTime*8.0f);
- m_object->SetAngleY(11, m_object->RetAngleY(7)+(m_wheelTurn[1]-m_object->RetAngleY(7))*event.rTime*8.0f+Math::PI);
- m_object->SetAngleY(12, m_object->RetAngleY(8)+(m_wheelTurn[2]-m_object->RetAngleY(8))*event.rTime*8.0f);
- m_object->SetAngleY(13, m_object->RetAngleY(9)+(m_wheelTurn[3]-m_object->RetAngleY(9))*event.rTime*8.0f+Math::PI);
+ m_object->SetAngleY(10, m_object->GetAngleY(6)+(m_wheelTurn[0]-m_object->GetAngleY(6))*event.rTime*8.0f);
+ m_object->SetAngleY(11, m_object->GetAngleY(7)+(m_wheelTurn[1]-m_object->GetAngleY(7))*event.rTime*8.0f+Math::PI);
+ m_object->SetAngleY(12, m_object->GetAngleY(8)+(m_wheelTurn[2]-m_object->GetAngleY(8))*event.rTime*8.0f);
+ m_object->SetAngleY(13, m_object->GetAngleY(9)+(m_wheelTurn[3]-m_object->GetAngleY(9))*event.rTime*8.0f+Math::PI);
}
- pos = m_object->RetPosition(0);
- angle = m_object->RetAngle(0);
+ pos = m_object->GetPosition(0);
+ angle = m_object->GetAngle(0);
if ( pos.x != m_wheelLastPos.x ||
pos.y != m_wheelLastPos.y ||
pos.z != m_wheelLastPos.z ||
@@ -1471,16 +1471,16 @@ bool CMotionVehicle::EventFrame(const Event &event)
radius = 1.0f;
}
- if ( Math::Distance(pos, m_engine->RetEyePt()) < 50.0f ) // suspension?
+ if ( Math::Distance(pos, m_engine->GetEyePt()) < 50.0f ) // suspension?
{
- character = m_object->RetCharacter();
- mat = m_object->RetWorldMatrix(0);
+ character = m_object->GetCharacter();
+ mat = m_object->GetWorldMatrix(0);
pos.x = -character->wheelBack; // right back wheel
pos.z = -character->wheelRight;
pos.y = 0.0f;
pos = Math::Transform(*mat, pos);
- h = m_terrain->RetFloorHeight(pos);
+ h = m_terrain->GetHeightToFloor(pos);
if ( h > 0.5f ) h = 0.5f;
if ( h < -0.5f ) h = -0.5f;
pos.x = back;
@@ -1493,7 +1493,7 @@ bool CMotionVehicle::EventFrame(const Event &event)
pos.z = character->wheelLeft;
pos.y = 0.0f;
pos = Math::Transform(*mat, pos);
- h = m_terrain->RetFloorHeight(pos);
+ h = m_terrain->GetHeightToFloor(pos);
if ( h > 0.5f ) h = 0.5f;
if ( h < -0.5f ) h = -0.5f;
pos.x = back;
@@ -1506,7 +1506,7 @@ bool CMotionVehicle::EventFrame(const Event &event)
pos.z = -character->wheelRight;
pos.y = 0.0f;
pos = Math::Transform(*mat, pos);
- h = m_terrain->RetFloorHeight(pos);
+ h = m_terrain->GetHeightToFloor(pos);
if ( h > 0.5f ) h = 0.5f;
if ( h < -0.5f ) h = -0.5f;
pos.x = front;
@@ -1519,7 +1519,7 @@ bool CMotionVehicle::EventFrame(const Event &event)
pos.z = character->wheelLeft;
pos.y = 0.0f;
pos = Math::Transform(*mat, pos);
- h = m_terrain->RetFloorHeight(pos);
+ h = m_terrain->GetHeightToFloor(pos);
if ( h > 0.5f ) h = 0.5f;
if ( h < -0.5f ) h = -0.5f;
pos.x = front;
@@ -1557,16 +1557,16 @@ bool CMotionVehicle::EventFrame(const Event &event)
type == OBJECT_MOBILEsa ||
type == OBJECT_MOBILEdr ) // caterpillars?
{
- s = m_physics->RetLinMotionX(MO_MOTSPEED)*0.7f;
- a = m_physics->RetCirMotionY(MO_MOTSPEED)*2.5f;
+ s = m_physics->GetLinMotionX(MO_MOTSPEED)*0.7f;
+ a = m_physics->GetCirMotionY(MO_MOTSPEED)*2.5f;
m_posTrackLeft += event.rTime*(s+a);
m_posTrackRight += event.rTime*(s-a);
UpdateTrackMapping(m_posTrackLeft, m_posTrackRight, type);
- pos = m_object->RetPosition(0);
- angle = m_object->RetAngle(0);
+ pos = m_object->GetPosition(0);
+ angle = m_object->GetAngle(0);
if ( pos.x != m_wheelLastPos.x ||
pos.y != m_wheelLastPos.y ||
pos.z != m_wheelLastPos.z ||
@@ -1601,22 +1601,22 @@ bool CMotionVehicle::EventFrame(const Event &event)
limit[1] = -10.0f*Math::PI/180.0f;
}
- if ( Math::Distance(pos, m_engine->RetEyePt()) < 50.0f ) // suspension?
+ if ( Math::Distance(pos, m_engine->GetEyePt()) < 50.0f ) // suspension?
{
- character = m_object->RetCharacter();
- mat = m_object->RetWorldMatrix(0);
+ character = m_object->GetCharacter();
+ mat = m_object->GetWorldMatrix(0);
pos.x = character->wheelFront; // right front wheel
pos.z = -character->wheelRight;
pos.y = 0.0f;
pos = Transform(*mat, pos);
- a1 = atanf(m_terrain->RetFloorHeight(pos)/character->wheelFront);
+ a1 = atanf(m_terrain->GetHeightToFloor(pos)/character->wheelFront);
pos.x = -character->wheelBack; // right back wheel
pos.z = -character->wheelRight;
pos.y = 0.0f;
pos = Transform(*mat, pos);
- a2 = atanf(m_terrain->RetFloorHeight(pos)/character->wheelBack);
+ a2 = atanf(m_terrain->GetHeightToFloor(pos)/character->wheelBack);
a = (a2-a1)/2.0f;
if ( a > limit[0] ) a = limit[0];
@@ -1627,13 +1627,13 @@ bool CMotionVehicle::EventFrame(const Event &event)
pos.z = character->wheelLeft;
pos.y = 0.0f;
pos = Transform(*mat, pos);
- a1 = atanf(m_terrain->RetFloorHeight(pos)/character->wheelFront);
+ a1 = atanf(m_terrain->GetHeightToFloor(pos)/character->wheelFront);
pos.x = -character->wheelBack; // left back wheel
pos.z = character->wheelLeft;
pos.y = 0.0f;
pos = Transform(*mat, pos);
- a2 = atanf(m_terrain->RetFloorHeight(pos)/character->wheelBack);
+ a2 = atanf(m_terrain->GetHeightToFloor(pos)/character->wheelBack);
a = (a2-a1)/2.0f;
if ( a > limit[0] ) a = limit[0];
@@ -1652,16 +1652,16 @@ bool CMotionVehicle::EventFrame(const Event &event)
type == OBJECT_MOBILEdr ) // toy is key?
{
pos = m_posKey;
- if ( m_object->RetSelect() &&
- m_camera->RetType() == CAMERA_ONBOARD )
+ if ( m_object->GetSelect() &&
+ m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD )
{
pos.y += 10.0f; // out of sight!
}
m_object->SetPosition(2, pos);
- s = -fabs(m_physics->RetLinMotionX(MO_MOTSPEED)*0.1f);
- s += -fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*1.5f);
- m_object->SetAngleY(2, m_object->RetAngleY(2)+event.rTime*s); // turns the key
+ s = -fabs(m_physics->GetLinMotionX(MO_MOTSPEED)*0.1f);
+ s += -fabs(m_physics->GetCirMotionY(MO_MOTSPEED)*1.5f);
+ m_object->SetAngleY(2, m_object->GetAngleY(2)+event.rTime*s); // turns the key
}
if ( type == OBJECT_MOBILEfa ||
@@ -1701,8 +1701,8 @@ bool CMotionVehicle::EventFrameFly(const Event &event)
float hope[3], actual, final, h, a;
int i;
- pos = m_object->RetPosition(0);
- angle = m_object->RetAngle(0);
+ pos = m_object->GetPosition(0);
+ angle = m_object->GetAngle(0);
if ( m_bFlyFix &&
pos.x == m_wheelLastPos.x &&
pos.y == m_wheelLastPos.y &&
@@ -1714,16 +1714,16 @@ bool CMotionVehicle::EventFrameFly(const Event &event)
m_wheelLastPos = pos;
m_wheelLastAngle = angle;
- if ( m_physics->RetLand() ) // on the ground?
+ if ( m_physics->GetLand() ) // on the ground?
{
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
paw[0] = Transform(*mat, Math::Vector( 4.2f, 0.0f, 0.0f)); // front
paw[1] = Transform(*mat, Math::Vector(-3.0f, 0.0f, -3.7f)); // right back
paw[2] = Transform(*mat, Math::Vector(-3.0f, 0.0f, 3.7f)); // left back
for ( i=0 ; i<3 ; i++ )
{
- h = m_terrain->RetFloorHeight(paw[i]);
+ h = m_terrain->GetHeightToFloor(paw[i]);
a = -atanf(h*0.5f);
if ( a > Math::PI*0.2f ) a = Math::PI*0.2f;
if ( a < -Math::PI*0.2f ) a = -Math::PI*0.2f;
@@ -1740,7 +1740,7 @@ bool CMotionVehicle::EventFrameFly(const Event &event)
m_bFlyFix = true;
for ( i=0 ; i<3 ; i++ )
{
- actual = m_object->RetAngleZ(6+i);
+ actual = m_object->GetAngleZ(6+i);
final = Math::Smooth(actual, hope[i], event.rTime*5.0f);
if ( final != actual )
{
@@ -1782,14 +1782,14 @@ bool CMotionVehicle::EventFrameInsect(const Event &event)
};
bOnBoard = false;
- if ( m_object->RetSelect() &&
- m_camera->RetType() == CAMERA_ONBOARD )
+ if ( m_object->GetSelect() &&
+ m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD )
{
bOnBoard = true;
}
- s = m_physics->RetLinMotionX(MO_MOTSPEED)*1.5f;
- a = fabs(m_physics->RetCirMotionY(MO_MOTSPEED)*2.0f);
+ s = m_physics->GetLinMotionX(MO_MOTSPEED)*1.5f;
+ a = fabs(m_physics->GetCirMotionY(MO_MOTSPEED)*2.0f);
if ( s == 0.0f && a != 0.0f ) a *= 1.5f;
@@ -1812,7 +1812,7 @@ bool CMotionVehicle::EventFrameInsect(const Event &event)
m_armMember += a;
}
- if ( m_object->RetRuin() ) // burn or explode?
+ if ( m_object->GetRuin() ) // burn or explode?
{
action = 3;
}
@@ -1856,27 +1856,27 @@ bool CMotionVehicle::EventFrameInsect(const Event &event)
if ( i < 3 ) // right leg (1..3) ?
{
- m_object->SetAngleX(6+3*i+0, Math::Smooth(m_object->RetAngleX(6+3*i+0), Math::PropAngle(table[st+ 0], table[nd+ 0], prog), time));
- m_object->SetAngleY(6+3*i+0, Math::Smooth(m_object->RetAngleY(6+3*i+0), Math::PropAngle(table[st+ 1], table[nd+ 1], prog), time));
- m_object->SetAngleZ(6+3*i+0, Math::Smooth(m_object->RetAngleZ(6+3*i+0), Math::PropAngle(table[st+ 2], table[nd+ 2], prog), time));
- m_object->SetAngleX(6+3*i+1, Math::Smooth(m_object->RetAngleX(6+3*i+1), Math::PropAngle(table[st+ 9], table[nd+ 9], prog), time));
- m_object->SetAngleY(6+3*i+1, Math::Smooth(m_object->RetAngleY(6+3*i+1), Math::PropAngle(table[st+10], table[nd+10], prog), time));
- m_object->SetAngleZ(6+3*i+1, Math::Smooth(m_object->RetAngleZ(6+3*i+1), Math::PropAngle(table[st+11], table[nd+11], prog), time));
- m_object->SetAngleX(6+3*i+2, Math::Smooth(m_object->RetAngleX(6+3*i+2), Math::PropAngle(table[st+18], table[nd+18], prog), time));
- m_object->SetAngleY(6+3*i+2, Math::Smooth(m_object->RetAngleY(6+3*i+2), Math::PropAngle(table[st+19], table[nd+19], prog), time));
- m_object->SetAngleZ(6+3*i+2, Math::Smooth(m_object->RetAngleZ(6+3*i+2), Math::PropAngle(table[st+20], table[nd+20], prog), time));
+ m_object->SetAngleX(6+3*i+0, Math::Smooth(m_object->GetAngleX(6+3*i+0), Math::PropAngle(table[st+ 0], table[nd+ 0], prog), time));
+ m_object->SetAngleY(6+3*i+0, Math::Smooth(m_object->GetAngleY(6+3*i+0), Math::PropAngle(table[st+ 1], table[nd+ 1], prog), time));
+ m_object->SetAngleZ(6+3*i+0, Math::Smooth(m_object->GetAngleZ(6+3*i+0), Math::PropAngle(table[st+ 2], table[nd+ 2], prog), time));
+ m_object->SetAngleX(6+3*i+1, Math::Smooth(m_object->GetAngleX(6+3*i+1), Math::PropAngle(table[st+ 9], table[nd+ 9], prog), time));
+ m_object->SetAngleY(6+3*i+1, Math::Smooth(m_object->GetAngleY(6+3*i+1), Math::PropAngle(table[st+10], table[nd+10], prog), time));
+ m_object->SetAngleZ(6+3*i+1, Math::Smooth(m_object->GetAngleZ(6+3*i+1), Math::PropAngle(table[st+11], table[nd+11], prog), time));
+ m_object->SetAngleX(6+3*i+2, Math::Smooth(m_object->GetAngleX(6+3*i+2), Math::PropAngle(table[st+18], table[nd+18], prog), time));
+ m_object->SetAngleY(6+3*i+2, Math::Smooth(m_object->GetAngleY(6+3*i+2), Math::PropAngle(table[st+19], table[nd+19], prog), time));
+ m_object->SetAngleZ(6+3*i+2, Math::Smooth(m_object->GetAngleZ(6+3*i+2), Math::PropAngle(table[st+20], table[nd+20], prog), time));
}
else // left leg (4..6) ?
{
- m_object->SetAngleX(6+3*i+0, Math::Smooth(m_object->RetAngleX(6+3*i+0), Math::PropAngle(-table[st+ 0], -table[nd+ 0], prog), time));
- m_object->SetAngleY(6+3*i+0, Math::Smooth(m_object->RetAngleY(6+3*i+0), Math::PropAngle(-table[st+ 1], -table[nd+ 1], prog), time));
- m_object->SetAngleZ(6+3*i+0, Math::Smooth(m_object->RetAngleZ(6+3*i+0), Math::PropAngle( table[st+ 2], table[nd+ 2], prog), time));
- m_object->SetAngleX(6+3*i+1, Math::Smooth(m_object->RetAngleX(6+3*i+1), Math::PropAngle(-table[st+ 9], -table[nd+ 9], prog), time));
- m_object->SetAngleY(6+3*i+1, Math::Smooth(m_object->RetAngleY(6+3*i+1), Math::PropAngle(-table[st+10], -table[nd+10], prog), time));
- m_object->SetAngleZ(6+3*i+1, Math::Smooth(m_object->RetAngleZ(6+3*i+1), Math::PropAngle( table[st+11], table[nd+11], prog), time));
- m_object->SetAngleX(6+3*i+2, Math::Smooth(m_object->RetAngleX(6+3*i+2), Math::PropAngle(-table[st+18], -table[nd+18], prog), time));
- m_object->SetAngleY(6+3*i+2, Math::Smooth(m_object->RetAngleY(6+3*i+2), Math::PropAngle(-table[st+19], -table[nd+19], prog), time));
- m_object->SetAngleZ(6+3*i+2, Math::Smooth(m_object->RetAngleZ(6+3*i+2), Math::PropAngle( table[st+20], table[nd+20], prog), time));
+ m_object->SetAngleX(6+3*i+0, Math::Smooth(m_object->GetAngleX(6+3*i+0), Math::PropAngle(-table[st+ 0], -table[nd+ 0], prog), time));
+ m_object->SetAngleY(6+3*i+0, Math::Smooth(m_object->GetAngleY(6+3*i+0), Math::PropAngle(-table[st+ 1], -table[nd+ 1], prog), time));
+ m_object->SetAngleZ(6+3*i+0, Math::Smooth(m_object->GetAngleZ(6+3*i+0), Math::PropAngle( table[st+ 2], table[nd+ 2], prog), time));
+ m_object->SetAngleX(6+3*i+1, Math::Smooth(m_object->GetAngleX(6+3*i+1), Math::PropAngle(-table[st+ 9], -table[nd+ 9], prog), time));
+ m_object->SetAngleY(6+3*i+1, Math::Smooth(m_object->GetAngleY(6+3*i+1), Math::PropAngle(-table[st+10], -table[nd+10], prog), time));
+ m_object->SetAngleZ(6+3*i+1, Math::Smooth(m_object->GetAngleZ(6+3*i+1), Math::PropAngle( table[st+11], table[nd+11], prog), time));
+ m_object->SetAngleX(6+3*i+2, Math::Smooth(m_object->GetAngleX(6+3*i+2), Math::PropAngle(-table[st+18], -table[nd+18], prog), time));
+ m_object->SetAngleY(6+3*i+2, Math::Smooth(m_object->GetAngleY(6+3*i+2), Math::PropAngle(-table[st+19], -table[nd+19], prog), time));
+ m_object->SetAngleZ(6+3*i+2, Math::Smooth(m_object->GetAngleZ(6+3*i+2), Math::PropAngle( table[st+20], table[nd+20], prog), time));
}
}
@@ -1916,20 +1916,20 @@ bool CMotionVehicle::EventFrameCanoni(const Event &event)
m_canonTime += event.rTime;
- if ( m_object->RetSelect() &&
- m_camera->RetType() == CAMERA_ONBOARD )
+ if ( m_object->GetSelect() &&
+ m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD )
{
bOnBoard = true;
}
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 )
{
energy = 0.0f;
}
else
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
if ( energy == 0.0f ) return true;
@@ -1961,13 +1961,13 @@ bool CMotionVehicle::EventFrameCanoni(const Event &event)
{
m_lastTimeCanon = m_engine->ParticuleAdapt(0.5f+Math::Rand()*0.5f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 8.0f;
speed.y = 7.0f+Math::Rand()*3.0f;
speed.x = (Math::Rand()-0.5f)*2.0f;
speed.z = 2.0f+Math::Rand()*2.0f;
if ( Math::Rand() < 0.5f ) speed.z = -speed.z;
- mat = m_object->RetRotateMatrix(0);
+ mat = m_object->GetRotateMatrix(0);
speed = Transform(*mat, speed);
dim.x = Math::Rand()*0.1f+0.1f;
if ( bOnBoard ) dim.x *= 0.4f;
@@ -1984,11 +1984,11 @@ bool CMotionVehicle::EventFrameCanoni(const Event &event)
void CMotionVehicle::UpdateTrackMapping(float left, float right, ObjectType type)
{
- D3DMATERIAL7 mat;
+ Gfx::Material mat;
float limit[4];
int rRank, lRank, i;
- ZeroMemory( &mat, sizeof(D3DMATERIAL7) );
+ memset( &mat, 0, sizeof(Gfx::Material) );
mat.diffuse.r = 1.0f;
mat.diffuse.g = 1.0f;
mat.diffuse.b = 1.0f; // white
@@ -1996,8 +1996,8 @@ void CMotionVehicle::UpdateTrackMapping(float left, float right, ObjectType type
mat.ambient.g = 0.5f;
mat.ambient.b = 0.5f;
- rRank = m_object->RetObjectRank(6);
- lRank = m_object->RetObjectRank(7);
+ rRank = m_object->GetObjectRank(6);
+ lRank = m_object->GetObjectRank(7);
if ( type == OBJECT_MOBILEdr )
@@ -2005,31 +2005,31 @@ void CMotionVehicle::UpdateTrackMapping(float left, float right, ObjectType type
limit[0] = 0.0f;
limit[1] = 1000000.0f;
limit[2] = limit[1];
- limit[3] = m_engine->RetLimitLOD(1);
+ limit[3] = m_engine->GetLimitLOD(1);
- m_engine->TrackTextureMapping(rRank, mat, D3DSTATEPART1, "drawer.tga", "",
- limit[0], limit[1], D3DMAPPINGX,
+ m_engine->TrackTextureMapping(rRank, mat, Gfx::ENG_RSTATE_PART1, "drawer.png", "",
+ limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
right, 1.0f, 8.0f, 192.0f, 256.0f);
- m_engine->TrackTextureMapping(lRank, mat, D3DSTATEPART2, "drawer.tga", "",
- limit[0], limit[1], D3DMAPPINGX,
+ m_engine->TrackTextureMapping(lRank, mat, Gfx::ENG_RSTATE_PART2, "drawer.png", "",
+ limit[0], limit[1], Gfx::ENG_TEX_MAPPING_X,
left, 1.0f, 8.0f, 192.0f, 256.0f);
}
else
{
limit[0] = 0.0f;
- limit[1] = m_engine->RetLimitLOD(0);
+ limit[1] = m_engine->GetLimitLOD(0);
limit[2] = limit[1];
- limit[3] = m_engine->RetLimitLOD(1);
+ limit[3] = m_engine->GetLimitLOD(1);
for ( i=0 ; i<2 ; i++ )
{
- m_engine->TrackTextureMapping(rRank, mat, D3DSTATEPART1, "lemt.tga", "",
- limit[i*2+0], limit[i*2+1], D3DMAPPINGX,
+ m_engine->TrackTextureMapping(rRank, mat, Gfx::ENG_RSTATE_PART1, "lemt.png", "",
+ limit[i*2+0], limit[i*2+1], Gfx::ENG_TEX_MAPPING_X,
right, 1.0f, 8.0f, 192.0f, 256.0f);
- m_engine->TrackTextureMapping(lRank, mat, D3DSTATEPART2, "lemt.tga", "",
- limit[i*2+0], limit[i*2+1], D3DMAPPINGX,
+ m_engine->TrackTextureMapping(lRank, mat, Gfx::ENG_RSTATE_PART2, "lemt.png", "",
+ limit[i*2+0], limit[i*2+1], Gfx::ENG_TEX_MAPPING_X,
left, 1.0f, 8.0f, 192.0f, 256.0f);
}
}
@@ -2040,7 +2040,7 @@ void CMotionVehicle::UpdateTrackMapping(float left, float right, ObjectType type
// State management of the pencil drawing robot.
-bool CMotionVehicle::RetTraceDown()
+bool CMotionVehicle::GetTraceDown()
{
return m_bTraceDown;
}
@@ -2050,7 +2050,7 @@ void CMotionVehicle::SetTraceDown(bool bDown)
m_bTraceDown = bDown;
}
-int CMotionVehicle::RetTraceColor()
+int CMotionVehicle::GetTraceColor()
{
return m_traceColor;
}
@@ -2060,7 +2060,7 @@ void CMotionVehicle::SetTraceColor(int color)
m_traceColor = color;
}
-float CMotionVehicle::RetTraceWidth()
+float CMotionVehicle::GetTraceWidth()
{
return m_traceWidth;
}
diff --git a/src/object/motion/motionvehicle.h b/src/object/motion/motionvehicle.h
index 5ca97cd..ca60c1e 100644
--- a/src/object/motion/motionvehicle.h
+++ b/src/object/motion/motionvehicle.h
@@ -33,11 +33,11 @@ public:
bool Create(Math::Vector pos, float angle, ObjectType type, float power);
bool EventProcess(const Event &event);
- bool RetTraceDown();
+ bool GetTraceDown();
void SetTraceDown(bool bDown);
- int RetTraceColor();
+ int GetTraceColor();
void SetTraceColor(int color);
- float RetTraceWidth();
+ float GetTraceWidth();
void SetTraceWidth(float width);
protected:
diff --git a/src/object/motion/motionworm.cpp b/src/object/motion/motionworm.cpp
index daf74ff..ce9ded2 100644
--- a/src/object/motion/motionworm.cpp
+++ b/src/object/motion/motionworm.cpp
@@ -21,9 +21,9 @@
#include "object/motion/motionworm.h"
-#include "old/modfile.h"
-#include "old/particule.h"
-#include "old/terrain.h"
+#include "graphics/engine/modelfile.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/terrain.h"
#include "math/geometry.h"
#include "physics/physics.h"
@@ -55,7 +55,7 @@ CMotionWorm::CMotionWorm(CInstanceManager* iMan, CObject* object)
m_armCirSpeed = 0.0f;
m_armLastAction = -1;
m_specAction = -1;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_bArmStop = false;
}
@@ -78,19 +78,19 @@ void CMotionWorm::DeleteObject(bool bAll)
bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank, i;
float px;
- if ( m_engine->RetRestCreate() < 2+WORM_PART+1 ) return false;
+// if ( m_engine->GetRestCreate() < 2+WORM_PART+1 ) return false;
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
m_object->SetType(type);
// Creates the main base.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEVEHICULE); // this is a moving object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_VEHICULE); // this is a moving object
m_object->SetObjectRank(0, rank);
pModFile->ReadModel("objects\\worm0.mod"); // there is no purpose!
pModFile->CreateEngineObject(rank);
@@ -105,7 +105,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the head.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(1, rank);
m_object->SetObjectParent(1, 0);
pModFile->ReadModel("objects\\worm1.mod");
@@ -117,7 +117,7 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
for ( i=0 ; i<WORM_PART ; i++ )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2+i, rank);
m_object->SetObjectParent(2+i, 0);
pModFile->ReadModel("objects\\worm2.mod");
@@ -128,22 +128,22 @@ bool CMotionWorm::Create(Math::Vector pos, float angle, ObjectType type,
// Creates the tail.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
m_object->SetObjectRank(2+WORM_PART, rank);
m_object->SetObjectParent(2+WORM_PART, 0);
pModFile->ReadModel("objects\\worm3.mod");
pModFile->CreateEngineObject(rank);
m_object->SetPosition(2+WORM_PART, Math::Vector(px, 0.0f, 0.0f));
- m_object->CreateShadowCircle(0.0f, 1.0f, D3DSHADOWWORM);
+ m_object->CreateShadowCircle(0.0f, 1.0f, Gfx::ENG_SHADOW_WORM);
CreatePhysics();
m_object->SetFloorHeight(0.0f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_object->SetPosition(0, pos); // to display the shadows immediately
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -157,7 +157,7 @@ void CMotionWorm::CreatePhysics()
m_physics->SetType(TYPE_ROLLING);
- character = m_object->RetCharacter();
+ character = m_object->GetCharacter();
character->wheelFront = 10.0f;
character->wheelBack = 10.0f;
character->wheelLeft = 2.0f;
@@ -203,7 +203,7 @@ bool CMotionWorm::SetParam(int rank, float value)
return false;
}
-float CMotionWorm::RetParam(int rank)
+float CMotionWorm::GetParam(int rank)
{
if ( rank == 0 ) return m_timeDown;
if ( rank == 1 ) return m_timeUp;
@@ -218,12 +218,12 @@ bool CMotionWorm::EventProcess(const Event &event)
{
CMotion::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
}
@@ -241,10 +241,10 @@ bool CMotionWorm::EventFrame(const Event &event)
float floor, a, s, px, curve, phase, h, zoom, radius;
int i, under;
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
- s = m_physics->RetLinMotionX(MO_MOTSPEED)/m_physics->RetLinMotionX(MO_ADVSPEED);
- a = m_physics->RetCirMotionY(MO_MOTSPEED)/m_physics->RetCirMotionY(MO_ADVSPEED);
+ s = m_physics->GetLinMotionX(MO_MOTSPEED)/m_physics->GetLinMotionX(MO_ADVSPEED);
+ a = m_physics->GetCirMotionY(MO_MOTSPEED)/m_physics->GetCirMotionY(MO_ADVSPEED);
if ( s == 0.0f && a != 0.0f ) s = a;
@@ -275,7 +275,7 @@ bool CMotionWorm::EventFrame(const Event &event)
{
h = 0.0f;
}
- if ( m_object->RetBurn() ) // is burning?
+ if ( m_object->GetBurn() ) // is burning?
{
h = 0.0f; // remains on earth
}
@@ -284,12 +284,12 @@ bool CMotionWorm::EventFrame(const Event &event)
}
m_object->SetVisible(under!=WORM_PART+2);
- if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return true;
+ if ( !m_engine->IsVisiblePoint(m_object->GetPosition(0)) ) return true;
- pos = m_object->RetPosition(0);
- floor = m_terrain->RetFloorLevel(pos, true);
+ pos = m_object->GetPosition(0);
+ floor = m_terrain->GetFloorLevel(pos, true);
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
px = 1.0f+WORM_PART/2;
for ( i=0 ; i<WORM_PART+2 ; i++ )
@@ -298,14 +298,14 @@ bool CMotionWorm::EventFrame(const Event &event)
radius = radius*1.3f-0.3f;
if ( radius < 0.0f ) radius = 0.0f;
radius *= 5.0f;
- m_engine->SetObjectShadowRadius(m_object->RetObjectRank(0), radius);
+ m_engine->SetObjectShadowRadius(m_object->GetObjectRank(0), radius);
pos.x = px+ sinf(m_armTimeMarch*4.0f+0.5f*i)*0.6f;
pos.y = height[i]+sinf(m_armTimeMarch*4.0f+0.5f*i)*0.2f*m_armLinSpeed;
pos.y += sinf(m_armTimeAbs *1.3f+0.2f*i)*0.1f;
pos.z = sinf(m_armTimeAbs *2.0f+0.7f*i)*0.2f;
- curve = ((float)i-(WORM_PART+2)/2)*m_armCirSpeed*0.1f;
+ curve = (static_cast< float >(i) -(WORM_PART+2)/2)*m_armCirSpeed*0.1f;
center.x = 0.0f;
center.y = 0.0f;
pp.x = pos.x;
@@ -315,7 +315,7 @@ bool CMotionWorm::EventFrame(const Event &event)
pos.z = pp.y;
p = Transform(*mat, pos);
- pos.y += m_terrain->RetFloorLevel(p, true)-floor;
+ pos.y += m_terrain->GetFloorLevel(p, true)-floor;
m_object->SetPosition(i+1, pos);
zoom = Math::Mod(m_armTimeAbs*0.5f+100.0f-i*0.1f, 2.0f);
@@ -326,9 +326,9 @@ bool CMotionWorm::EventFrame(const Event &event)
m_object->SetZoomZ(i+1, zoom);
if ( height[i] >= -1.0f && height[i] < -0.2f &&
- m_lastParticule+m_engine->ParticuleAdapt(0.2f) <= m_armTimeMarch )
+ m_lastParticle+m_engine->ParticleAdapt(0.2f) <= m_armTimeMarch )
{
- m_lastParticule = m_armTimeMarch;
+ m_lastParticle = m_armTimeMarch;
pos = p;
pos.y += -height[i];
@@ -337,7 +337,7 @@ bool CMotionWorm::EventFrame(const Event &event)
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = Math::Rand()*2.0f+1.5f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
px -= 1.0f;
@@ -345,8 +345,8 @@ bool CMotionWorm::EventFrame(const Event &event)
for ( i=0 ; i<WORM_PART+1 ; i++ )
{
- pos = m_object->RetPosition(i+2);
- pos -= m_object->RetPosition(i+1);
+ pos = m_object->GetPosition(i+2);
+ pos -= m_object->GetPosition(i+1);
angle.z = -Math::RotateAngle(Math::Point(pos.x, pos.z).Length(), pos.y);
angle.y = Math::PI-Math::RotateAngle(pos.x, pos.z);
diff --git a/src/object/motion/motionworm.h b/src/object/motion/motionworm.h
index 1b2abf9..aed5a23 100644
--- a/src/object/motion/motionworm.h
+++ b/src/object/motion/motionworm.h
@@ -34,7 +34,7 @@ public:
bool EventProcess(const Event &event);
bool SetParam(int rank, float value);
- float RetParam(int rank);
+ float GetParam(int rank);
protected:
void CreatePhysics();
@@ -57,6 +57,6 @@ protected:
int m_specAction;
float m_specTime;
bool m_bArmStop;
- float m_lastParticule;
+ float m_lastParticle;
};
diff --git a/src/object/object.cpp b/src/object/object.cpp
index e2e52e5..dd46e0e 100644
--- a/src/object/object.cpp
+++ b/src/object/object.cpp
@@ -17,76 +17,74 @@
// object.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
+//---------CBot
#include "CBot/CBotDll.h"
-#include "common/struct.h"
-#include "math/const.h"
-#include "math/geometry.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "old/d3dutil.h"
+
+//---------Common
#include "common/global.h"
-#include "common/event.h"
-#include "common/misc.h"
#include "common/iman.h"
#include "common/restext.h"
-#include "old/math3d.h"
-#include "object/mainmovie.h"
-#include "object/robotmain.h"
-#include "old/light.h"
-#include "old/terrain.h"
-#include "old/water.h"
-#include "old/blitz.h"
-#include "old/camera.h"
-#include "old/particule.h"
-#include "physics/physics.h"
-#include "object/brain.h"
-#include "object/motion/motion.h"
-#include "object/motion/motionhuman.h"
-#include "object/motion/motiontoto.h"
-#include "object/motion/motionvehicle.h"
-#include "object/motion/motionmother.h"
-#include "object/motion/motionant.h"
-#include "object/motion/motionspider.h"
-#include "object/motion/motionbee.h"
-#include "object/motion/motionworm.h"
-#include "old/modfile.h"
+
+//---------Graphic
+#include "graphics/engine/lightman.h"
+#include "graphics/engine/lightning.h"
+#include "graphics/engine/modelfile.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/pyro.h"
+#include "graphics/engine/terrain.h"
+
+//---------Math
+#include "math/geometry.h"
+
+//---------Object
#include "object/auto/auto.h"
#include "object/auto/autobase.h"
-#include "object/auto/autoportico.h"
+#include "object/auto/autoconvert.h"
#include "object/auto/autoderrick.h"
-#include "object/auto/autofactory.h"
-#include "object/auto/autorepair.h"
#include "object/auto/autodestroyer.h"
-#include "object/auto/autostation.h"
-#include "object/auto/autoenergy.h"
-#include "object/auto/autoconvert.h"
-#include "object/auto/autotower.h"
-#include "object/auto/autoresearch.h"
-#include "object/auto/autolabo.h"
-#include "object/auto/autonuclear.h"
-#include "object/auto/autoradar.h"
#include "object/auto/autoegg.h"
-#include "object/auto/autonest.h"
-#include "object/auto/autoroot.h"
+#include "object/auto/autoenergy.h"
+#include "object/auto/autofactory.h"
#include "object/auto/autoflag.h"
+#include "object/auto/autohuston.h"
#include "object/auto/autoinfo.h"
#include "object/auto/autojostle.h"
+#include "object/auto/autokid.h"
+#include "object/auto/autolabo.h"
+#include "object/auto/automush.h"
+#include "object/auto/autonest.h"
+#include "object/auto/autonuclear.h"
#include "object/auto/autopara.h"
+#include "object/auto/autoportico.h"
+#include "object/auto/autoradar.h"
+#include "object/auto/autorepair.h"
+#include "object/auto/autoresearch.h"
+#include "object/auto/autoroot.h"
#include "object/auto/autosafe.h"
-#include "object/auto/autohuston.h"
-#include "object/auto/automush.h"
-#include "object/auto/autokid.h"
-#include "object/task/task.h"
-#include "old/pyro.h"
-#include "ui/displaytext.h"
-#include "script/cmdtoken.h"
-#include "script/cbottoken.h"
-#include "old/sound.h"
+#include "object/auto/autostation.h"
+#include "object/auto/autotower.h"
+#include "object/brain.h"
+#include "object/motion/motion.h"
+#include "object/motion/motionant.h"
+#include "object/motion/motionbee.h"
+#include "object/motion/motionhuman.h"
+#include "object/motion/motionmother.h"
+#include "object/motion/motionspider.h"
+#include "object/motion/motiontoto.h"
+#include "object/motion/motionvehicle.h"
+#include "object/motion/motionworm.h"
#include "object/object.h"
+#include "object/robotmain.h"
+
+//---------Physics
+#include "physics/physics.h"
+
+//---------Script
+#include "script/cbottoken.h"
+#include "script/cmdtoken.h"
+
+//---------Ui
+#include "ui/displaytext.h"
@@ -116,7 +114,7 @@ static float debug_arm3 = 0.0f;
void uObject(CBotVar* botThis, void* user)
{
- CObject* object = (CObject*)user;
+ CObject* object = static_cast<CObject*>(user);
CObject* power;
CObject* fret;
CPhysics* physics;
@@ -128,19 +126,19 @@ void uObject(CBotVar* botThis, void* user)
if ( object == 0 ) return;
- physics = object->RetPhysics();
+ physics = object->GetPhysics();
// Updates the object's type.
pVar = botThis->GetItemList(); // "category"
- type = object->RetType();
- pVar->SetValInt(type, object->RetName());
+ type = object->GetType();
+ pVar->SetValInt(type, object->GetName());
// Updates the position of the object.
pVar = pVar->GetNext(); // "position"
- if ( object->RetTruck() == 0 )
+ if ( object->GetTruck() == 0 )
{
- pos = object->RetPosition(0);
- pos.y -= object->RetWaterLevel(); // relative to sea level!
+ pos = object->GetPosition(0);
+ pos.y -= object->GetWaterLevel(); // relative to sea level!
pSub = pVar->GetItemList(); // "x"
pSub->SetValFloat(pos.x/g_unit);
pSub = pSub->GetNext(); // "y"
@@ -159,8 +157,8 @@ void uObject(CBotVar* botThis, void* user)
}
// Updates the angle.
- pos = object->RetAngle(0);
- pos += object->RetInclinaison();
+ pos = object->GetAngle(0);
+ pos += object->GetInclinaison();
pVar = pVar->GetNext(); // "orientation"
pVar->SetValFloat(360.0f-Math::Mod(pos.y*180.0f/Math::PI, 360.0f));
pVar = pVar->GetNext(); // "pitch"
@@ -170,47 +168,47 @@ void uObject(CBotVar* botThis, void* user)
// Updates the energy level of the object.
pVar = pVar->GetNext(); // "energyLevel"
- value = object->RetEnergy();
+ value = object->GetEnergy();
pVar->SetValFloat(value);
// Updates the shield level of the object.
pVar = pVar->GetNext(); // "shieldLevel"
- value = object->RetShield();
+ value = object->GetShield();
pVar->SetValFloat(value);
// Updates the temperature of the reactor.
pVar = pVar->GetNext(); // "temperature"
if ( physics == 0 ) value = 0.0f;
- else value = 1.0f-physics->RetReactorRange();
+ else value = 1.0f-physics->GetReactorRange();
pVar->SetValFloat(value);
// Updates the height above the ground.
pVar = pVar->GetNext(); // "altitude"
if ( physics == 0 ) value = 0.0f;
- else value = physics->RetFloorHeight();
+ else value = physics->GetFloorHeight();
pVar->SetValFloat(value/g_unit);
// Updates the lifetime of the object.
pVar = pVar->GetNext(); // "lifeTime"
- value = object->RetAbsTime();
+ value = object->GetAbsTime();
pVar->SetValFloat(value);
// Updates the material of the object.
pVar = pVar->GetNext(); // "material"
- iValue = object->RetMaterial();
+ iValue = object->GetMaterial();
pVar->SetValInt(iValue);
// Updates the type of battery.
pVar = pVar->GetNext(); // "energyCell"
- power = object->RetPower();
+ power = object->GetPower();
if ( power == 0 ) pVar->SetPointer(0);
- else pVar->SetPointer(power->RetBotVar());
+ else pVar->SetPointer(power->GetBotVar());
// Updates the transported object's type.
pVar = pVar->GetNext(); // "load"
- fret = object->RetFret();
+ fret = object->GetFret();
if ( fret == 0 ) pVar->SetPointer(0);
- else pVar->SetPointer(fret->RetBotVar());
+ else pVar->SetPointer(fret->GetBotVar());
}
@@ -225,15 +223,15 @@ CObject::CObject(CInstanceManager* iMan)
m_iMan = iMan;
m_iMan->AddInstance(CLASS_OBJECT, this, 500);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT);
- m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
- m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_displayText = (CDisplayText*)m_iMan->SearchInstance(CLASS_DISPLAYTEXT);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
+ m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_physics = 0;
m_brain = 0;
m_motion = 0;
@@ -250,7 +248,7 @@ CObject::CObject(CInstanceManager* iMan)
m_linVibration = Math::Vector(0.0f, 0.0f, 0.0f);
m_cirVibration = Math::Vector(0.0f, 0.0f, 0.0f);
m_inclinaison = Math::Vector(0.0f, 0.0f, 0.0f);
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_power = 0;
m_fret = 0;
@@ -281,7 +279,7 @@ CObject::CObject(CInstanceManager* iMan)
m_shotTime = 0.0f;
m_bVirusMode = false;
m_virusTime = 0.0f;
- m_lastVirusParticule = 0.0f;
+ m_lastVirusParticle = 0.0f;
m_totalDesectList = 0;
m_bLock = false;
m_bExplo = false;
@@ -297,7 +295,7 @@ CObject::CObject(CInstanceManager* iMan)
m_proxyDistance = 60.0f;
m_param = 0.0f;
- ZeroMemory(&m_character, sizeof(Character));
+ memset(&m_character, 0, sizeof(m_character));
m_character.wheelFront = 1.0f;
m_character.wheelBack = 1.0f;
m_character.wheelLeft = 1.0f;
@@ -309,7 +307,7 @@ CObject::CObject(CInstanceManager* iMan)
m_resetAngle = Math::Vector(0.0f, 0.0f, 0.0f);
m_resetRun = -1;
- m_cameraType = CAMERA_BACK;
+ m_cameraType = Gfx::CAM_TYPE_BACK;
m_cameraDist = 50.0f;
m_bCameraLock = false;
@@ -376,7 +374,7 @@ CObject::~CObject()
void CObject::DeleteObject(bool bAll)
{
CObject* pObj;
- CPyro* pPyro;
+ Gfx::CPyro* pPyro;
int i;
if ( m_botVar != 0 )
@@ -384,14 +382,14 @@ void CObject::DeleteObject(bool bAll)
m_botVar->SetUserPtr(OBJECTDELETED);
}
- if ( m_camera->RetObject() == this )
+ if ( m_camera->GetControllingObject() == this )
{
- m_camera->SetObject(0);
+ m_camera->SetControllingObject(0);
}
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
pObj->DeleteDeselList(this);
@@ -400,29 +398,29 @@ void CObject::DeleteObject(bool bAll)
if ( !bAll )
{
#if 0
- type = m_camera->RetType();
- if ( (type == CAMERA_BACK ||
- type == CAMERA_FIX ||
- type == CAMERA_EXPLO ||
- type == CAMERA_ONBOARD) &&
- m_camera->RetObject() == this )
+ type = m_camera->GetType();
+ if ( (type == Gfx::CAM_TYPE_BACK ||
+ type == Gfx::CAM_TYPE_FIX ||
+ type == Gfx::CAM_TYPE_EXPLO ||
+ type == Gfx::CAM_TYPE_ONBOARD) &&
+ m_camera->GetControllingObject() == this )
{
- pObj = m_main->SearchNearest(RetPosition(0), this);
+ pObj = m_main->SearchNearest(GetPosition(0), this);
if ( pObj == 0 )
{
- m_camera->SetObject(0);
- m_camera->SetType(CAMERA_FREE);
+ m_camera->SetControllingObject(0);
+ m_camera->SetType(Gfx::CAM_TYPE_FREE);
}
else
{
- m_camera->SetObject(pObj);
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetControllingObject(pObj);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
}
}
#endif
for ( i=0 ; i<1000000 ; i++ )
{
- pPyro = (CPyro*)m_iMan->SearchInstance(CLASS_PYRO, i);
+ pPyro = static_cast<Gfx::CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, i));
if ( pPyro == 0 ) break;
pPyro->CutObjectLink(this); // the object no longer exists
@@ -453,7 +451,7 @@ void CObject::DeleteObject(bool bAll)
m_type == OBJECT_START ||
m_type == OBJECT_END ) // building?
{
- m_terrain->DeleteBuildingLevel(RetPosition(0)); // flattens the field
+ m_terrain->DeleteBuildingLevel(GetPosition(0)); // flattens the field
}
}
@@ -461,19 +459,19 @@ void CObject::DeleteObject(bool bAll)
if ( m_partiReactor != -1 )
{
- m_particule->DeleteParticule(m_partiReactor);
+ m_particle->DeleteParticle(m_partiReactor);
m_partiReactor = -1;
}
if ( m_shadowLight != -1 )
{
- m_light->DeleteLight(m_shadowLight);
+ m_lightMan->DeleteLight(m_shadowLight);
m_shadowLight = -1;
}
if ( m_effectLight != -1 )
{
- m_light->DeleteLight(m_effectLight);
+ m_lightMan->DeleteLight(m_effectLight);
m_effectLight = -1;
}
@@ -506,7 +504,7 @@ void CObject::DeleteObject(bool bAll)
if ( m_objectPart[i].masterParti != -1 )
{
- m_particule->DeleteParticule(m_objectPart[i].masterParti);
+ m_particle->DeleteParticle(m_objectPart[i].masterParti);
m_objectPart[i].masterParti = -1;
}
}
@@ -569,8 +567,8 @@ void CObject::Simplify()
bool CObject::ExploObject(ExploType type, float force, float decay)
{
- PyroType pyroType;
- CPyro* pyro;
+ Gfx::PyroType pyroType;
+ Gfx::CPyro* pyro;
float loss, shield;
if ( type == EXPLO_BURN )
@@ -627,7 +625,7 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
loss *= decay;
// Decreases the power of the shield.
- shield = RetShield();
+ shield = GetShield();
shield -= loss;
if ( shield < 0.0f ) shield = 0.0f;
SetShield(shield);
@@ -638,26 +636,26 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
{
if ( m_type == OBJECT_HUMAN )
{
- pyroType = PT_SHOTH;
+ pyroType = Gfx::PT_SHOTH;
}
else
{
- pyroType = PT_SHOTW;
+ pyroType = Gfx::PT_SHOTW;
}
}
else
{
if ( m_type == OBJECT_HUMAN )
{
- pyroType = PT_SHOTH;
+ pyroType = Gfx::PT_SHOTH;
}
else if ( m_type == OBJECT_MOTHER )
{
- pyroType = PT_SHOTM;
+ pyroType = Gfx::PT_SHOTM;
}
else
{
- pyroType = PT_SHOTT;
+ pyroType = Gfx::PT_SHOTT;
}
}
}
@@ -672,16 +670,16 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
m_type == OBJECT_WORM ||
m_type == OBJECT_BULLET )
{
- pyroType = PT_BURNO;
+ pyroType = Gfx::PT_BURNO;
SetBurn(true);
}
else if ( m_type == OBJECT_HUMAN )
{
- pyroType = PT_DEADG;
+ pyroType = Gfx::PT_DEADG;
}
else
{
- pyroType = PT_BURNT;
+ pyroType = Gfx::PT_BURNT;
SetBurn(true);
}
SetVirusMode(false);
@@ -690,11 +688,11 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
{
if ( m_type == OBJECT_HUMAN )
{
- pyroType = PT_DEADW;
+ pyroType = Gfx::PT_DEADW;
}
else
{
- pyroType = PT_FRAGW;
+ pyroType = Gfx::PT_FRAGW;
}
}
else // explosion?
@@ -704,17 +702,17 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
m_type == OBJECT_BEE ||
m_type == OBJECT_WORM )
{
- pyroType = PT_EXPLOO;
+ pyroType = Gfx::PT_EXPLOO;
}
else if ( m_type == OBJECT_MOTHER ||
m_type == OBJECT_NEST ||
m_type == OBJECT_BULLET )
{
- pyroType = PT_FRAGO;
+ pyroType = Gfx::PT_FRAGO;
}
else if ( m_type == OBJECT_HUMAN )
{
- pyroType = PT_DEADG;
+ pyroType = Gfx::PT_DEADG;
}
else if ( m_type == OBJECT_BASE ||
m_type == OBJECT_DERRICK ||
@@ -737,24 +735,24 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
m_type == OBJECT_START ||
m_type == OBJECT_END ) // building?
{
- pyroType = PT_FRAGT;
+ pyroType = Gfx::PT_FRAGT;
}
else if ( m_type == OBJECT_MOBILEtg ||
m_type == OBJECT_TEEN28 || // cylinder?
m_type == OBJECT_TEEN31 ) // basket?
{
- pyroType = PT_FRAGT;
+ pyroType = Gfx::PT_FRAGT;
}
else
{
- pyroType = PT_EXPLOT;
+ pyroType = Gfx::PT_EXPLOT;
}
}
loss = 1.0f;
}
- pyro = new CPyro(m_iMan);
+ pyro = new Gfx::CPyro(m_iMan);
pyro->Create(pyroType, this, loss);
if ( shield == 0.0f ) // dead?
@@ -768,10 +766,10 @@ bool CObject::ExploObject(ExploType type, float force, float decay)
if ( shield > 0.0f ) return false; // not dead yet
- if ( RetSelect() )
+ if ( GetSelect() )
{
SetSelect(false); // deselects the object
- m_camera->SetType(CAMERA_EXPLO);
+ m_camera->SetType(Gfx::CAM_TYPE_EXPLO);
m_main->DeselectAll();
}
DeleteDeselList(this);
@@ -830,7 +828,7 @@ void CObject::InitPart(int part)
}
// Creates a new part, and returns its number.
-// Returns -1 on error.
+// Geturns -1 on error.
int CObject::CreatePart()
{
@@ -855,7 +853,7 @@ void CObject::DeletePart(int part)
if ( m_objectPart[part].masterParti != -1 )
{
- m_particule->DeleteParticule(m_objectPart[part].masterParti);
+ m_particle->DeleteParticle(m_objectPart[part].masterParti);
m_objectPart[part].masterParti = -1;
}
@@ -891,9 +889,9 @@ void CObject::SetObjectRank(int part, int objRank)
m_objectPart[part].object = objRank;
}
-// Returns the number of part.
+// Geturns the number of part.
-int CObject::RetObjectRank(int part)
+int CObject::GetObjectRank(int part)
{
if ( !m_objectPart[part].bUsed ) return -1;
return m_objectPart[part].object;
@@ -914,7 +912,7 @@ void CObject::SetObjectParent(int part, int parent)
void CObject::SetType(ObjectType type)
{
m_type = type;
- strcpy(m_name, RetObjectName(m_type));
+ strcpy(m_name, GetObjectName(m_type));
if ( m_type == OBJECT_MOBILErs )
{
@@ -940,16 +938,16 @@ void CObject::SetType(ObjectType type)
m_type == OBJECT_MOBILEii ||
m_type == OBJECT_MOBILErc ) // cannon vehicle?
{
- m_cameraType = CAMERA_ONBOARD;
+ m_cameraType = Gfx::CAM_TYPE_ONBOARD;
}
}
-ObjectType CObject::RetType()
+ObjectType CObject::GetType()
{
return m_type;
}
-char* CObject::RetName()
+char* CObject::GetName()
{
return m_name;
}
@@ -962,7 +960,7 @@ void CObject::SetOption(int option)
m_option = option;
}
-int CObject::RetOption()
+int CObject::GetOption()
{
return m_option;
}
@@ -980,7 +978,7 @@ void CObject::SetID(int id)
}
}
-int CObject::RetID()
+int CObject::GetID()
{
return m_id;
}
@@ -996,115 +994,115 @@ bool CObject::Write(char *line)
float value;
int i;
- sprintf(name, " camera=%s", GetCamera(RetCameraType()));
+ sprintf(name, " camera=%s", GetCamera(GetCameraType()));
strcat(line, name);
- if ( RetCameraLock() != 0 )
+ if ( GetCameraLock() != 0 )
{
- sprintf(name, " cameraLock=%d", RetCameraLock());
+ sprintf(name, " cameraLock=%d", GetCameraLock());
strcat(line, name);
}
- if ( RetEnergy() != 0.0f )
+ if ( GetEnergy() != 0.0f )
{
- sprintf(name, " energy=%.2f", RetEnergy());
+ sprintf(name, " energy=%.2f", GetEnergy());
strcat(line, name);
}
- if ( RetCapacity() != 1.0f )
+ if ( GetCapacity() != 1.0f )
{
- sprintf(name, " capacity=%.2f", RetCapacity());
+ sprintf(name, " capacity=%.2f", GetCapacity());
strcat(line, name);
}
- if ( RetShield() != 1.0f )
+ if ( GetShield() != 1.0f )
{
- sprintf(name, " shield=%.2f", RetShield());
+ sprintf(name, " shield=%.2f", GetShield());
strcat(line, name);
}
- if ( RetRange() != 1.0f )
+ if ( GetRange() != 1.0f )
{
- sprintf(name, " range=%.2f", RetRange());
+ sprintf(name, " range=%.2f", GetRange());
strcat(line, name);
}
- if ( RetSelectable() != 1 )
+ if ( GetSelectable() != 1 )
{
- sprintf(name, " selectable=%d", RetSelectable());
+ sprintf(name, " selectable=%d", GetSelectable());
strcat(line, name);
}
- if ( RetEnable() != 1 )
+ if ( GetEnable() != 1 )
{
- sprintf(name, " enable=%d", RetEnable());
+ sprintf(name, " enable=%d", GetEnable());
strcat(line, name);
}
- if ( RetFixed() != 0 )
+ if ( GetFixed() != 0 )
{
- sprintf(name, " fixed=%d", RetFixed());
+ sprintf(name, " fixed=%d", GetFixed());
strcat(line, name);
}
- if ( RetClip() != 1 )
+ if ( GetClip() != 1 )
{
- sprintf(name, " clip=%d", RetClip());
+ sprintf(name, " clip=%d", GetClip());
strcat(line, name);
}
- if ( RetLock() != 0 )
+ if ( GetLock() != 0 )
{
- sprintf(name, " lock=%d", RetLock());
+ sprintf(name, " lock=%d", GetLock());
strcat(line, name);
}
- if ( RetProxyActivate() != 0 )
+ if ( GetProxyActivate() != 0 )
{
- sprintf(name, " proxyActivate=%d", RetProxyActivate());
+ sprintf(name, " proxyActivate=%d", GetProxyActivate());
strcat(line, name);
- sprintf(name, " proxyDistance=%.2f", RetProxyDistance()/g_unit);
+ sprintf(name, " proxyDistance=%.2f", GetProxyDistance()/g_unit);
strcat(line, name);
}
- if ( RetMagnifyDamage() != 1.0f )
+ if ( GetMagnifyDamage() != 1.0f )
{
- sprintf(name, " magnifyDamage=%.2f", RetMagnifyDamage());
+ sprintf(name, " magnifyDamage=%.2f", GetMagnifyDamage());
strcat(line, name);
}
- if ( RetGunGoalV() != 0.0f )
+ if ( GetGunGoalV() != 0.0f )
{
- sprintf(name, " aimV=%.2f", RetGunGoalV());
+ sprintf(name, " aimV=%.2f", GetGunGoalV());
strcat(line, name);
}
- if ( RetGunGoalH() != 0.0f )
+ if ( GetGunGoalH() != 0.0f )
{
- sprintf(name, " aimH=%.2f", RetGunGoalH());
+ sprintf(name, " aimH=%.2f", GetGunGoalH());
strcat(line, name);
}
- if ( RetParam() != 0.0f )
+ if ( GetParam() != 0.0f )
{
- sprintf(name, " param=%.2f", RetParam());
+ sprintf(name, " param=%.2f", GetParam());
strcat(line, name);
}
- if ( RetResetCap() != 0 )
+ if ( GetResetCap() != 0 )
{
- sprintf(name, " resetCap=%d", RetResetCap());
+ sprintf(name, " resetCap=%d", GetResetCap());
strcat(line, name);
- pos = RetResetPosition()/g_unit;
+ pos = GetResetPosition()/g_unit;
sprintf(name, " resetPos=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
strcat(line, name);
- pos = RetResetAngle()/(Math::PI/180.0f);
+ pos = GetResetAngle()/(Math::PI/180.0f);
sprintf(name, " resetAngle=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
strcat(line, name);
- sprintf(name, " resetRun=%d", RetResetRun());
+ sprintf(name, " resetRun=%d", GetResetRun());
strcat(line, name);
}
@@ -1123,7 +1121,7 @@ bool CObject::Write(char *line)
// Puts information in terminal (OBJECT_INFO).
for ( i=0 ; i<m_infoTotal ; i++ )
{
- info = RetInfo(i);
+ info = GetInfo(i);
if ( info.name[0] == 0 ) break;
sprintf(name, " info%d=\"%s=%.2f\"", i+1, info.name, info.value);
@@ -1133,7 +1131,7 @@ bool CObject::Write(char *line)
// Sets the parameters of the command line.
for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
{
- value = RetCmdLine(i);
+ value = GetCmdLine(i);
if ( value == NAN ) break;
if ( i == 0 ) sprintf(name, " cmdline=%.2f", value);
@@ -1164,21 +1162,21 @@ bool CObject::Write(char *line)
return true;
}
-// Returns all parameters of the object.
+// Geturns all parameters of the object.
bool CObject::Read(char *line)
{
Math::Vector pos, dir;
- Info info;
- CameraType cType;
- char op[20];
- char text[100];
- char* p;
- float value;
- int i;
+ Info info;
+ Gfx::CameraType cType;
+ char op[20];
+ char text[100];
+ char* p;
+ float value;
+ int i;
cType = OpCamera(line, "camera");
- if ( cType != CAMERA_NULL )
+ if ( cType != Gfx::CAM_TYPE_NULL )
{
SetCameraType(cType);
}
@@ -1200,7 +1198,7 @@ bool CObject::Read(char *line)
SetGunGoalV(OpFloat(line, "aimV", 0.0f));
SetGunGoalH(OpFloat(line, "aimH", 0.0f));
SetParam(OpFloat(line, "param", 0.0f));
- SetResetCap((ResetCap)OpInt(line, "resetCap", 0));
+ SetResetCap(static_cast<ResetCap>(OpInt(line, "resetCap", 0)));
SetResetPosition(OpDir(line, "resetPos")*g_unit);
SetResetAngle(OpDir(line, "resetAngle")*(Math::PI/180.0f));
SetResetRun(OpInt(line, "resetRun", 0));
@@ -1291,7 +1289,7 @@ int CObject::CreateCrashSphere(Math::Vector pos, float radius, Sound sound,
if ( m_crashSphereUsed >= MAXCRASHSPHERE ) return -1;
- zoom = RetZoomX(0);
+ zoom = GetZoomX(0);
m_crashSpherePos[m_crashSphereUsed] = pos;
m_crashSphereRadius[m_crashSphereUsed] = radius*zoom;
m_crashSphereHardness[m_crashSphereUsed] = hardness;
@@ -1299,14 +1297,14 @@ int CObject::CreateCrashSphere(Math::Vector pos, float radius, Sound sound,
return m_crashSphereUsed++;
}
-// Returns the number of spheres.
+// Geturns the number of spheres.
-int CObject::RetCrashSphereTotal()
+int CObject::GetCrashSphereTotal()
{
return m_crashSphereUsed;
}
-// Returns a sphere for collisions.
+// Geturns a sphere for collisions.
// The position is absolute in the world.
bool CObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius)
@@ -1318,7 +1316,7 @@ bool CObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius)
return false;
}
- // Returns to the sphere collisions,
+ // Geturns to the sphere collisions,
// which ignores the inclination of the vehicle.
// This is necessary to collisions with vehicles,
// so as not to reflect SetInclinaison, for example.
@@ -1342,16 +1340,16 @@ bool CObject::GetCrashSphere(int rank, Math::Vector &pos, float &radius)
return true;
}
-// Returns the hardness of a sphere.
+// Geturns the hardness of a sphere.
-Sound CObject::RetCrashSphereSound(int rank)
+Sound CObject::GetCrashSphereSound(int rank)
{
return m_crashSphereSound[rank];
}
-// Returns the hardness of a sphere.
+// Geturns the hardness of a sphere.
-float CObject::RetCrashSphereHardness(int rank)
+float CObject::GetCrashSphereHardness(int rank)
{
return m_crashSphereHardness[rank];
}
@@ -1378,12 +1376,12 @@ void CObject::SetGlobalSphere(Math::Vector pos, float radius)
{
float zoom;
- zoom = RetZoomX(0);
+ zoom = GetZoomX(0);
m_globalSpherePos = pos;
m_globalSphereRadius = radius*zoom;
}
-// Returns the global sphere, in the world.
+// Geturns the global sphere, in the world.
void CObject::GetGlobalSphere(Math::Vector &pos, float &radius)
{
@@ -1416,9 +1414,9 @@ void CObject::SetShieldRadius(float radius)
m_shieldRadius = radius;
}
-// Returns the radius of the shield.
+// Geturns the radius of the shield.
-float CObject::RetShieldRadius()
+float CObject::GetShieldRadius()
{
return m_shieldRadius;
}
@@ -1431,7 +1429,7 @@ void CObject::SetFloorHeight(float height)
Math::Vector pos;
pos = m_objectPart[0].position;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
if ( m_physics != 0 )
{
@@ -1451,7 +1449,7 @@ void CObject::FloorAdjust()
Math::Point nn;
float a;
- pos = RetPosition(0);
+ pos = GetPosition(0);
if ( m_terrain->GetNormal(n, pos) )
{
#if 0
@@ -1459,7 +1457,7 @@ void CObject::FloorAdjust()
SetAngleZ(0, -sinf(n.x));
SetAngleY(0, 0.0f);
#else
- a = RetAngleY(0);
+ a = GetAngleY(0);
nn = Math::RotatePoint(-a, Math::Point(n.z, n.x));
SetAngleX(0, sinf(nn.x));
SetAngleZ(0, -sinf(nn.y));
@@ -1481,7 +1479,7 @@ void CObject::SetLinVibration(Math::Vector dir)
}
}
-Math::Vector CObject::RetLinVibration()
+Math::Vector CObject::GetLinVibration()
{
return m_linVibration;
}
@@ -1499,7 +1497,7 @@ void CObject::SetCirVibration(Math::Vector dir)
}
}
-Math::Vector CObject::RetCirVibration()
+Math::Vector CObject::GetCirVibration()
{
return m_cirVibration;
}
@@ -1517,7 +1515,7 @@ void CObject::SetInclinaison(Math::Vector dir)
}
}
-Math::Vector CObject::RetInclinaison()
+Math::Vector CObject::GetInclinaison()
{
return m_inclinaison;
}
@@ -1539,10 +1537,10 @@ void CObject::SetPosition(int part, const Math::Vector &pos)
rank = m_objectPart[0].object;
shPos = pos;
- m_terrain->MoveOnFloor(shPos, true);
+ m_terrain->AdjustToFloor(shPos, true);
m_engine->SetObjectShadowPos(rank, shPos);
- if ( m_physics != 0 && m_physics->RetType() == TYPE_FLYING )
+ if ( m_physics != 0 && m_physics->GetType() == TYPE_FLYING )
{
height = pos.y-shPos.y;
}
@@ -1554,7 +1552,7 @@ void CObject::SetPosition(int part, const Math::Vector &pos)
// Calculating the normal to the ground in nine strategic locations,
// then perform a weighted average (the dots in the center are more important).
- radius = m_engine->RetObjectShadowRadius(rank);
+ radius = m_engine->GetObjectShadowRadius(rank);
i = 0;
m_terrain->GetNormal(norm, pos);
@@ -1619,7 +1617,7 @@ void CObject::SetPosition(int part, const Math::Vector &pos)
{
norm += n[j];
}
- norm /= (float)i; // average vector
+ norm /= static_cast<float>(i); // average vector
m_engine->SetObjectShadowNormal(rank, norm);
@@ -1627,14 +1625,14 @@ void CObject::SetPosition(int part, const Math::Vector &pos)
{
shPos = pos;
shPos.y += m_shadowHeight;
- m_light->SetLightPos(m_shadowLight, shPos);
+ m_lightMan->SetLightPos(m_shadowLight, shPos);
}
if ( m_effectLight != -1 )
{
shPos = pos;
shPos.y += m_effectHeight;
- m_light->SetLightPos(m_effectLight, shPos);
+ m_lightMan->SetLightPos(m_effectLight, shPos);
}
if ( m_bShowLimit )
@@ -1644,7 +1642,7 @@ void CObject::SetPosition(int part, const Math::Vector &pos)
}
}
-Math::Vector CObject::RetPosition(int part)
+Math::Vector CObject::GetPosition(int part)
{
return m_objectPart[part].position;
}
@@ -1662,7 +1660,7 @@ void CObject::SetAngle(int part, const Math::Vector &angle)
}
}
-Math::Vector CObject::RetAngle(int part)
+Math::Vector CObject::GetAngle(int part)
{
return m_objectPart[part].angle;
}
@@ -1696,17 +1694,17 @@ void CObject::SetAngleZ(int part, float angle)
m_objectPart[part].bRotate = true; //it will recalculate the matrices
}
-float CObject::RetAngleY(int part)
+float CObject::GetAngleY(int part)
{
return m_objectPart[part].angle.y;
}
-float CObject::RetAngleX(int part)
+float CObject::GetAngleX(int part)
{
return m_objectPart[part].angle.x;
}
-float CObject::RetAngleZ(int part)
+float CObject::GetAngleZ(int part)
{
return m_objectPart[part].angle.z;
}
@@ -1736,7 +1734,7 @@ void CObject::SetZoom(int part, Math::Vector zoom)
m_objectPart[part].zoom.z != 1.0f );
}
-Math::Vector CObject::RetZoom(int part)
+Math::Vector CObject::GetZoom(int part)
{
return m_objectPart[part].zoom;
}
@@ -1771,27 +1769,27 @@ void CObject::SetZoomZ(int part, float zoom)
m_objectPart[part].zoom.z != 1.0f );
}
-float CObject::RetZoomX(int part)
+float CObject::GetZoomX(int part)
{
return m_objectPart[part].zoom.x;
}
-float CObject::RetZoomY(int part)
+float CObject::GetZoomY(int part)
{
return m_objectPart[part].zoom.y;
}
-float CObject::RetZoomZ(int part)
+float CObject::GetZoomZ(int part)
{
return m_objectPart[part].zoom.z;
}
-// Returns the water level.
+// Geturns the water level.
-float CObject::RetWaterLevel()
+float CObject::GetWaterLevel()
{
- return m_water->RetLevel();
+ return m_water->GetLevel();
}
@@ -1801,11 +1799,11 @@ void CObject::SetTrainer(bool bEnable)
if ( m_bTrainer ) // training?
{
- m_cameraType = CAMERA_FIX;
+ m_cameraType = Gfx::CAM_TYPE_FIX;
}
}
-bool CObject::RetTrainer()
+bool CObject::GetTrainer()
{
return m_bTrainer;
}
@@ -1815,7 +1813,7 @@ void CObject::SetToy(bool bEnable)
m_bToy = bEnable;
}
-bool CObject::RetToy()
+bool CObject::GetToy()
{
return m_bToy;
}
@@ -1825,7 +1823,7 @@ void CObject::SetManual(bool bManual)
m_bManual = bManual;
}
-bool CObject::RetManual()
+bool CObject::GetManual()
{
return m_bManual;
}
@@ -1835,7 +1833,7 @@ void CObject::SetResetCap(ResetCap cap)
m_resetCap = cap;
}
-ResetCap CObject::RetResetCap()
+ResetCap CObject::GetResetCap()
{
return m_resetCap;
}
@@ -1845,7 +1843,7 @@ void CObject::SetResetBusy(bool bBusy)
m_bResetBusy = bBusy;
}
-bool CObject::RetResetBusy()
+bool CObject::GetResetBusy()
{
return m_bResetBusy;
}
@@ -1855,7 +1853,7 @@ void CObject::SetResetPosition(const Math::Vector &pos)
m_resetPosition = pos;
}
-Math::Vector CObject::RetResetPosition()
+Math::Vector CObject::GetResetPosition()
{
return m_resetPosition;
}
@@ -1865,12 +1863,12 @@ void CObject::SetResetAngle(const Math::Vector &angle)
m_resetAngle = angle;
}
-Math::Vector CObject::RetResetAngle()
+Math::Vector CObject::GetResetAngle()
{
return m_resetAngle;
}
-int CObject::RetResetRun()
+int CObject::GetResetRun()
{
return m_resetRun;
}
@@ -1883,12 +1881,12 @@ void CObject::SetResetRun(int run)
// Management of the particle master.
-void CObject::SetMasterParticule(int part, int parti)
+void CObject::SetMasterParticle(int part, int parti)
{
m_objectPart[part].masterParti = parti;
}
-int CObject::RetMasterParticule(int part)
+int CObject::GetMasterParticle(int part)
{
return m_objectPart[part].masterParti;
}
@@ -1901,7 +1899,7 @@ void CObject::SetPower(CObject* power)
m_power = power;
}
-CObject* CObject::RetPower()
+CObject* CObject::GetPower()
{
return m_power;
}
@@ -1913,7 +1911,7 @@ void CObject::SetFret(CObject* fret)
m_fret = fret;
}
-CObject* CObject::RetFret()
+CObject* CObject::GetFret()
{
return m_fret;
}
@@ -1928,7 +1926,7 @@ void CObject::SetTruck(CObject* truck)
m_engine->SetObjectShadowHide(m_objectPart[0].object, (m_truck != 0));
}
-CObject* CObject::RetTruck()
+CObject* CObject::GetTruck()
{
return m_truck;
}
@@ -1940,7 +1938,7 @@ void CObject::SetTruckPart(int part)
m_truckLink = part;
}
-int CObject::RetTruckPart()
+int CObject::GetTruckPart()
{
return m_truckLink;
}
@@ -1977,13 +1975,13 @@ void CObject::SetInfo(int rank, Info info)
m_bInfoUpdate = true;
}
-Info CObject::RetInfo(int rank)
+Info CObject::GetInfo(int rank)
{
if ( rank < 0 || rank >= OBJECTMAXINFO ) rank = 0;
return m_info[rank];
}
-int CObject::RetInfoTotal()
+int CObject::GetInfoTotal()
{
return m_infoTotal;
}
@@ -1993,7 +1991,7 @@ void CObject::SetInfoReturn(float value)
m_infoReturn = value;
}
-float CObject::RetInfoReturn()
+float CObject::GetInfoReturn()
{
return m_infoReturn;
}
@@ -2003,7 +2001,7 @@ void CObject::SetInfoUpdate(bool bUpdate)
m_bInfoUpdate = bUpdate;
}
-bool CObject::RetInfoUpdate()
+bool CObject::GetInfoUpdate()
{
return m_bInfoUpdate;
}
@@ -2016,31 +2014,31 @@ bool CObject::SetCmdLine(int rank, float value)
return true;
}
-float CObject::RetCmdLine(int rank)
+float CObject::GetCmdLine(int rank)
{
if ( rank < 0 || rank >= OBJECTMAXCMDLINE ) return 0.0f;
return m_cmdLine[rank];
}
-// Returns matrices of an object portion.
+// Geturns matrices of an object portion.
-Math::Matrix* CObject::RetRotateMatrix(int part)
+Math::Matrix* CObject::GetRotateMatrix(int part)
{
return &m_objectPart[part].matRotate;
}
-Math::Matrix* CObject::RetTranslateMatrix(int part)
+Math::Matrix* CObject::GetTranslateMatrix(int part)
{
return &m_objectPart[part].matTranslate;
}
-Math::Matrix* CObject::RetTransformMatrix(int part)
+Math::Matrix* CObject::GetTransformMatrix(int part)
{
return &m_objectPart[part].matTransform;
}
-Math::Matrix* CObject::RetWorldMatrix(int part)
+Math::Matrix* CObject::GetWorldMatrix(int part)
{
if ( m_objectPart[0].bTranslate ||
m_objectPart[0].bRotate )
@@ -2062,7 +2060,7 @@ void CObject::SetDrawWorld(bool bDraw)
{
if ( m_objectPart[i].bUsed )
{
- m_engine->SetDrawWorld(m_objectPart[i].object, bDraw);
+ m_engine->SetObjectDrawWorld(m_objectPart[i].object, bDraw);
}
}
}
@@ -2077,7 +2075,7 @@ void CObject::SetDrawFront(bool bDraw)
{
if ( m_objectPart[i].bUsed )
{
- m_engine->SetDrawFront(m_objectPart[i].object, bDraw);
+ m_engine->SetObjectDrawFront(m_objectPart[i].object, bDraw);
}
}
}
@@ -2242,94 +2240,93 @@ bool CObject::CreateInsect(Math::Vector pos, float angle, ObjectType type)
// Creates shade under a vehicle as a negative light.
-bool CObject::CreateShadowLight(float height, D3DCOLORVALUE color)
+bool CObject::CreateShadowLight(float height, Gfx::Color color)
{
- D3DLIGHT7 light;
+ Gfx::Light light;
Math::Vector pos;
- if ( !m_engine->RetLightMode() ) return true;
+ if ( !m_engine->GetLightMode() ) return true;
- pos = RetPosition(0);
+ pos = GetPosition(0);
m_shadowHeight = height;
- ZeroMemory( &light, sizeof(light) );
- light.dltType = D3DLIGHT_SPOT;
- light.dcvDiffuse.r = color.r;
- light.dcvDiffuse.g = color.g;
- light.dcvDiffuse.b = color.b;
- light.dvPosition.x = pos.x;
- light.dvPosition.y = pos.y+height;
- light.dvPosition.z = pos.z;
- light.dvDirection.x = 0.0f;
- light.dvDirection.y = -1.0f; // against the bottom
- light.dvDirection.z = 0.0f;
- light.dvRange = D3DLIGHT_RANGE_MAX;
- light.dvFalloff = 1.0f;
- light.dvAttenuation0 = 1.0f;
- light.dvAttenuation1 = 0.0f;
- light.dvAttenuation2 = 0.0f;
- light.dvTheta = 0.0f;
- light.dvPhi = Math::PI/4.0f;
-
- m_shadowLight = m_light->CreateLight();
+ light.type = Gfx::LIGHT_SPOT;
+ light.diffuse.r = color.r;
+ light.diffuse.g = color.g;
+ light.diffuse.b = color.b;
+ light.position.x = pos.x;
+ light.position.y = pos.y+height;
+ light.position.z = pos.z;
+ light.direction.x = 0.0f;
+ light.direction.y = -1.0f; // against the bottom
+ light.direction.z = 0.0f;
+ //TODO Is this value correct
+ light.spotIntensity = 128;
+ light.attenuation0 = 1.0f;
+ light.attenuation1 = 0.0f;
+ light.attenuation2 = 0.0f;
+ //TODO Is this value correct
+ light.spotAngle = 90;
+
+ m_shadowLight = m_lightMan->CreateLight();
if ( m_shadowLight == -1 ) return false;
- m_light->SetLight(m_shadowLight, light);
+ m_lightMan->SetLight(m_shadowLight, light);
// Only illuminates the objects on the ground.
- m_light->SetLightIncluType(m_shadowLight, TYPETERRAIN);
+ m_lightMan->SetLightIncludeType(m_shadowLight, Gfx::ENG_OBJTYPE_TERRAIN);
return true;
}
-// Returns the number of negative light shade.
+// Geturns the number of negative light shade.
-int CObject::RetShadowLight()
+int CObject::GetShadowLight()
{
return m_shadowLight;
}
// Creates light for the effects of a vehicle.
-bool CObject::CreateEffectLight(float height, D3DCOLORVALUE color)
+bool CObject::CreateEffectLight(float height, Gfx::Color color)
{
- D3DLIGHT7 light;
+ Gfx::Light light;
- if ( !m_engine->RetLightMode() ) return true;
+ if ( !m_engine->GetLightMode() ) return true;
m_effectHeight = height;
- ZeroMemory( &light, sizeof(light) );
- light.dltType = D3DLIGHT_SPOT;
- light.dcvDiffuse.r = color.r;
- light.dcvDiffuse.g = color.g;
- light.dcvDiffuse.b = color.b;
- light.dvPosition.x = 0.0f;
- light.dvPosition.y = 0.0f+height;
- light.dvPosition.z = 0.0f;
- light.dvDirection.x = 0.0f;
- light.dvDirection.y = -1.0f; // against the bottom
- light.dvDirection.z = 0.0f;
- light.dvRange = D3DLIGHT_RANGE_MAX;
- light.dvFalloff = 1.0f;
- light.dvAttenuation0 = 1.0f;
- light.dvAttenuation1 = 0.0f;
- light.dvAttenuation2 = 0.0f;
- light.dvTheta = 0.0f;
- light.dvPhi = Math::PI/4.0f;
-
- m_effectLight = m_light->CreateLight();
+ memset( &light, 0, sizeof(light) );
+ light.type = Gfx::LIGHT_SPOT;
+ light.diffuse.r = color.r;
+ light.diffuse.g = color.g;
+ light.diffuse.b = color.b;
+ light.position.x = 0.0f;
+ light.position.y = 0.0f+height;
+ light.position.z = 0.0f;
+ light.direction.x = 0.0f;
+ light.direction.y = -1.0f; // against the bottom
+ light.direction.z = 0.0f;
+ //TODO Is this value correct
+ light.spotIntensity = 1.0f;
+ light.attenuation0 = 1.0f;
+ light.attenuation1 = 0.0f;
+ light.attenuation2 = 0.0f;
+ //TODO Is this value correct
+ light.spotAngle = 90;
+
+ m_effectLight = m_lightMan->CreateLight();
if ( m_effectLight == -1 ) return false;
- m_light->SetLight(m_effectLight, light);
- m_light->SetLightIntensity(m_effectLight, 0.0f);
+ m_lightMan->SetLight(m_effectLight, light);
+ m_lightMan->SetLightIntensity(m_effectLight, 0.0f);
return true;
}
-// Returns the number of light effects.
+// Geturns the number of light effects.
-int CObject::RetEffectLight()
+int CObject::GetEffectLight()
{
return m_effectLight;
}
@@ -2337,15 +2334,15 @@ int CObject::RetEffectLight()
// Creates the circular shadow underneath a vehicle.
bool CObject::CreateShadowCircle(float radius, float intensity,
- D3DShadowType type)
+ Gfx::EngineShadowType type)
{
float zoom;
if ( intensity == 0.0f ) return true;
- zoom = RetZoomX(0);
+ zoom = GetZoomX(0);
- m_engine->ShadowCreate(m_objectPart[0].object);
+ m_engine->CreateShadow(m_objectPart[0].object);
m_engine->SetObjectShadowRadius(m_objectPart[0].object, radius*zoom);
m_engine->SetObjectShadowIntensity(m_objectPart[0].object, intensity);
@@ -2361,18 +2358,16 @@ bool CObject::CreateShadowCircle(float radius, float intensity,
bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
ObjectType type, float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
Math::Point p;
int rank, i;
- if ( m_engine->RetRestCreate() < 20 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX); // it is a stationary object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
if ( m_type == OBJECT_PORTICO )
@@ -2384,7 +2379,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\portico2.mod");
@@ -2392,7 +2387,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetPosition(1, Math::Vector(0.0f, 67.0f, 0.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
pModFile->ReadModel("objects\\portico3.mod");
@@ -2401,7 +2396,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleY(2, 45.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 2);
pModFile->ReadModel("objects\\portico4.mod");
@@ -2410,7 +2405,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleY(3, -60.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(4, rank);
SetObjectParent(4, 3);
pModFile->ReadModel("objects\\portico5.mod");
@@ -2419,7 +2414,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleY(4, -55.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(5, rank);
SetObjectParent(5, 1);
pModFile->ReadModel("objects\\portico3.mod");
@@ -2428,7 +2423,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleY(5, -45.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(6, rank);
SetObjectParent(6, 5);
pModFile->ReadModel("objects\\portico4.mod");
@@ -2437,7 +2432,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleY(6, 60.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(7, rank);
SetObjectParent(7, 6);
pModFile->ReadModel("objects\\portico5.mod");
@@ -2446,7 +2441,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleY(7, 55.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(8, rank);
SetObjectParent(8, 0);
pModFile->ReadModel("objects\\portico6.mod");
@@ -2456,7 +2451,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetZoom(8, 2.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(9, rank);
SetObjectParent(9, 8);
pModFile->ReadModel("objects\\portico7.mod");
@@ -2464,7 +2459,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetPosition(9, Math::Vector(0.0f, 4.5f, 1.9f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(10, rank);
SetObjectParent(10, 0);
pModFile->ReadModel("objects\\portico6.mod");
@@ -2474,7 +2469,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetZoom(10, 2.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(11, rank);
SetObjectParent(11, 10);
pModFile->ReadModel("objects\\portico7.mod");
@@ -2508,7 +2503,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
for ( i=0 ; i<8 ; i++ )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1+i, rank);
SetObjectParent(1+i, 0);
pModFile->ReadModel("objects\\base2.mod");
@@ -2519,7 +2514,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleZ(1+i, Math::PI/2.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(10+i, rank);
SetObjectParent(10+i, 1+i);
pModFile->ReadModel("objects\\base4.mod");
@@ -2527,7 +2522,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetPosition(10+i, Math::Vector(23.5f, 0.0f, 7.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(18+i, rank);
SetObjectParent(18+i, 1+i);
pModFile->ReadModel("objects\\base4.mod");
@@ -2537,7 +2532,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
}
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(9, rank);
SetObjectParent(9, 0);
pModFile->ReadModel("objects\\base3.mod"); // central pillar
@@ -2578,7 +2573,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\derrick2.mod");
@@ -2603,7 +2598,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\search2.mod");
@@ -2611,7 +2606,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetPosition(1, Math::Vector(0.0f, 13.0f, 0.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
pModFile->ReadModel("objects\\search3.mod");
@@ -2638,7 +2633,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\radar2.mod");
@@ -2646,7 +2641,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetPosition(1, Math::Vector(0.0f, 5.0f, 0.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 0);
pModFile->ReadModel("objects\\radar3.mod");
@@ -2655,7 +2650,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleY(2, -Math::PI/2.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 2);
pModFile->ReadModel("objects\\radar4.mod");
@@ -2678,7 +2673,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\info2.mod");
@@ -2688,7 +2683,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
for ( i=0 ; i<3 ; i++ )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2+i*2, rank);
SetObjectParent(2+i*2, 1);
pModFile->ReadModel("objects\\info3.mod");
@@ -2696,7 +2691,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetPosition(2+i*2, Math::Vector(0.0f, 4.5f, 0.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3+i*2, rank);
SetObjectParent(3+i*2, 2+i*2);
pModFile->ReadModel("objects\\radar4.mod");
@@ -2741,7 +2736,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\labo2.mod");
@@ -2750,7 +2745,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleZ(1, Math::PI/2.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
pModFile->ReadModel("objects\\labo3.mod");
@@ -2758,7 +2753,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetPosition(2, Math::Vector(9.0f, -1.0f, 0.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 2);
pModFile->ReadModel("objects\\labo4.mod");
@@ -2767,7 +2762,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleZ(3, 80.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(4, rank);
SetObjectParent(4, 2);
pModFile->ReadModel("objects\\labo4.mod");
@@ -2777,7 +2772,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleY(4, Math::PI*2.0f/3.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(5, rank);
SetObjectParent(5, 2);
pModFile->ReadModel("objects\\labo4.mod");
@@ -2809,7 +2804,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
for ( i=0 ; i<9 ; i++ )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1+i, rank);
SetObjectParent(1+i, 0);
pModFile->ReadModel("objects\\factory2.mod");
@@ -2819,7 +2814,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetZoomZ(1+i, 0.30f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(10+i, rank);
SetObjectParent(10+i, 0);
pModFile->ReadModel("objects\\factory2.mod");
@@ -2832,7 +2827,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
for ( i=0 ; i<2 ; i++ )
{
- float s = (float)(i*2-1);
+ float s = static_cast<float>(i*2-1);
CreateCrashSphere(Math::Vector(-10.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector( -3.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector( 3.0f, 2.0f, 11.0f*s), 4.0f, SOUND_BOUMm, 0.45f);
@@ -2867,7 +2862,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\repair2.mod");
@@ -2893,7 +2888,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\destroy2.mod");
@@ -2936,7 +2931,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\convert2.mod");
@@ -2944,7 +2939,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetPosition(1, Math::Vector(0.0f, 14.0f, 0.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 0);
pModFile->ReadModel("objects\\convert3.mod");
@@ -2953,7 +2948,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleX(2, -Math::PI*0.35f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 0);
pModFile->ReadModel("objects\\convert3.mod");
@@ -2980,7 +2975,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\roller2c.mod");
@@ -2989,7 +2984,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetAngleZ(1, Math::PI/2.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
pModFile->ReadModel("objects\\roller3c.mod");
@@ -3006,7 +3001,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
m_character.posPower = Math::Vector(5.0f, 3.0f, 0.0f);
CreateShadowCircle(6.0f, 1.0f);
- m_showLimitRadius = BLITZPARA;
+ m_showLimitRadius = Gfx::BLITZPARA;
}
if ( m_type == OBJECT_NUCLEAR )
@@ -3018,7 +3013,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\nuclear2.mod");
@@ -3059,7 +3054,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetGlobalSphere(Math::Vector(0.0f, 10.0f, 0.0f), 20.0f);
CreateShadowCircle(21.0f, 1.0f);
- m_showLimitRadius = BLITZPARA;
+ m_showLimitRadius = Gfx::BLITZPARA;
}
if ( m_type == OBJECT_SAFE )
@@ -3071,7 +3066,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\safe2.mod");
@@ -3079,7 +3074,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetZoom(1, 1.05f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 0);
pModFile->ReadModel("objects\\safe3.mod");
@@ -3103,7 +3098,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\huston2.mod");
@@ -3113,7 +3108,7 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
SetZoom(1, 3.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
pModFile->ReadModel("objects\\huston3.mod");
@@ -3223,14 +3218,14 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
pPower->SetType(power<=1.0f?OBJECT_POWER:OBJECT_ATOMIC);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
pPower->SetObjectRank(0, rank);
if ( power <= 1.0f ) pModFile->ReadModel("objects\\power.mod");
else pModFile->ReadModel("objects\\atomic.mod");
pModFile->CreateEngineObject(rank);
- pPower->SetPosition(0, RetCharacter()->posPower);
+ pPower->SetPosition(0, GetCharacter()->posPower);
pPower->CreateCrashSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
pPower->SetGlobalSphere(Math::Vector(0.0f, 1.0f, 0.0f), 1.5f);
@@ -3242,12 +3237,12 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
}
#endif
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos); // to display the shadows immediately
CreateOtherObject(type);
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
delete pModFile;
return true;
@@ -3258,22 +3253,17 @@ bool CObject::CreateBuilding(Math::Vector pos, float angle, float height,
bool CObject::CreateResource(Math::Vector pos, float angle, ObjectType type,
float power)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
char name[50];
int rank;
float radius, height;
- if ( type != OBJECT_SHOW )
- {
- if ( m_engine->RetRestCreate() < 1 ) return false;
- }
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX); // it is a stationary object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
SetEnergy(power);
@@ -3363,10 +3353,10 @@ bool CObject::CreateResource(Math::Vector pos, float angle, ObjectType type,
SetFloorHeight(0.0f);
CreateOtherObject(type);
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
FloorAdjust();
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos); // to display the shadows immediately
@@ -3378,13 +3368,11 @@ bool CObject::CreateResource(Math::Vector pos, float angle, ObjectType type,
bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
char name[50];
int rank, i;
- if ( m_engine->RetRestCreate() < 1+4 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
@@ -3396,7 +3384,7 @@ bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type)
if ( type == OBJECT_FLAGv ) strcpy(name, "objects\\flag1v.mod");
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX); // it is a stationary object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
pModFile->ReadModel(name);
pModFile->CreateEngineObject(rank);
@@ -3413,7 +3401,7 @@ bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type)
for ( i=0 ; i<4 ; i++ )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1+i, rank);
SetObjectParent(1+i, i);
pModFile->ReadModel(name);
@@ -3427,10 +3415,10 @@ bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type)
SetFloorHeight(0.0f);
CreateOtherObject(type);
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
FloorAdjust();
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
delete pModFile;
@@ -3442,19 +3430,17 @@ bool CObject::CreateFlag(Math::Vector pos, float angle, ObjectType type)
bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank;
- if ( m_engine->RetRestCreate() < 1 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
if ( type == OBJECT_BARRIER0 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\barrier0.mod");
pModFile->CreateEngineObject(rank);
@@ -3465,13 +3451,13 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
CreateCrashSphere(Math::Vector( 0.0f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f);
- CreateShadowCircle(6.0f, 0.5f, D3DSHADOWWORM);
+ CreateShadowCircle(6.0f, 0.5f, Gfx::ENG_SHADOW_WORM);
}
if ( type == OBJECT_BARRIER1 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\barrier1.mod");
pModFile->CreateEngineObject(rank);
@@ -3484,13 +3470,13 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector(-8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f);
- CreateShadowCircle(12.0f, 0.5f, D3DSHADOWWORM);
+ CreateShadowCircle(12.0f, 0.5f, Gfx::ENG_SHADOW_WORM);
}
if ( type == OBJECT_BARRIER2 ) // cardboard?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\barrier2.mod");
pModFile->CreateEngineObject(rank);
@@ -3503,13 +3489,13 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector(-8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f);
- CreateShadowCircle(12.0f, 0.8f, D3DSHADOWWORM);
+ CreateShadowCircle(12.0f, 0.8f, Gfx::ENG_SHADOW_WORM);
}
if ( type == OBJECT_BARRIER3 ) // match + straw?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\barrier3.mod");
pModFile->CreateEngineObject(rank);
@@ -3522,17 +3508,17 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
CreateCrashSphere(Math::Vector(-3.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector(-8.5f, 3.0f, 0.0f), 0.7f, SOUND_BOUMm, 0.45f);
- CreateShadowCircle(10.0f, 0.5f, D3DSHADOWWORM);
+ CreateShadowCircle(10.0f, 0.5f, Gfx::ENG_SHADOW_WORM);
}
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
SetFloorHeight(0.0f);
CreateOtherObject(type);
FloorAdjust();
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos);
@@ -3545,12 +3531,10 @@ bool CObject::CreateBarrier(Math::Vector pos, float angle, float height,
bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank;
- if ( m_engine->RetRestCreate() < 1 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
@@ -3561,7 +3545,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
type == OBJECT_PLANT4 ) // standard?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
if ( type == OBJECT_PLANT0 ) pModFile->ReadModel("objects\\plant0.mod");
if ( type == OBJECT_PLANT1 ) pModFile->ReadModel("objects\\plant1.mod");
@@ -3586,7 +3570,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
type == OBJECT_PLANT7 ) // clover?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
if ( type == OBJECT_PLANT5 ) pModFile->ReadModel("objects\\plant5.mod");
if ( type == OBJECT_PLANT6 ) pModFile->ReadModel("objects\\plant6.mod");
@@ -3605,7 +3589,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
type == OBJECT_PLANT9 ) // squash?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
if ( type == OBJECT_PLANT8 ) pModFile->ReadModel("objects\\plant8.mod");
if ( type == OBJECT_PLANT9 ) pModFile->ReadModel("objects\\plant9.mod");
@@ -3626,7 +3610,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
type == OBJECT_PLANT14 ) // succulent?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
if ( type == OBJECT_PLANT10 ) pModFile->ReadModel("objects\\plant10.mod");
if ( type == OBJECT_PLANT11 ) pModFile->ReadModel("objects\\plant11.mod");
@@ -3651,7 +3635,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
type == OBJECT_PLANT19 ) // fern?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
if ( type == OBJECT_PLANT15 ) pModFile->ReadModel("objects\\plant15.mod");
if ( type == OBJECT_PLANT16 ) pModFile->ReadModel("objects\\plant16.mod");
@@ -3675,7 +3659,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
if ( type == OBJECT_TREE0 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\tree0.mod");
pModFile->CreateEngineObject(rank);
@@ -3693,7 +3677,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
if ( type == OBJECT_TREE1 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\tree1.mod");
pModFile->CreateEngineObject(rank);
@@ -3712,7 +3696,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
if ( type == OBJECT_TREE2 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\tree2.mod");
pModFile->CreateEngineObject(rank);
@@ -3731,7 +3715,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
if ( type == OBJECT_TREE3 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\tree3.mod");
pModFile->CreateEngineObject(rank);
@@ -3749,7 +3733,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
if ( type == OBJECT_TREE4 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\tree4.mod");
pModFile->CreateEngineObject(rank);
@@ -3766,7 +3750,7 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
if ( type == OBJECT_TREE5 ) // giant tree (for the world "teen")
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\tree5.mod");
pModFile->CreateEngineObject(rank);
@@ -3780,13 +3764,13 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
CreateShadowCircle(50.0f, 0.5f);
}
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
SetFloorHeight(0.0f);
CreateOtherObject(type);
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos);
@@ -3799,19 +3783,17 @@ bool CObject::CreatePlant(Math::Vector pos, float angle, float height,
bool CObject::CreateMushroom(Math::Vector pos, float angle, float height,
ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank;
- if ( m_engine->RetRestCreate() < 1 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
if ( type == OBJECT_MUSHROOM1 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\mush1.mod");
pModFile->CreateEngineObject(rank);
@@ -3828,7 +3810,7 @@ bool CObject::CreateMushroom(Math::Vector pos, float angle, float height,
if ( type == OBJECT_MUSHROOM2 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\mush2.mod");
pModFile->CreateEngineObject(rank);
@@ -3842,13 +3824,13 @@ bool CObject::CreateMushroom(Math::Vector pos, float angle, float height,
CreateShadowCircle(5.0f, 0.5f);
}
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
SetFloorHeight(0.0f);
CreateOtherObject(type);
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos);
@@ -3861,16 +3843,14 @@ bool CObject::CreateMushroom(Math::Vector pos, float angle, float height,
bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height,
ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
Math::Matrix* mat;
- D3DCOLORVALUE color;
- int rank;
- float fShadow;
- bool bFloorAdjust = true;
-
- if ( m_engine->RetRestCreate() < 1 ) return false;
+ Gfx::Color color;
+ int rank;
+ float fShadow;
+ bool bFloorAdjust = true;
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
@@ -3879,7 +3859,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN0 ) // orange pencil lg=10
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen0.mod");
pModFile->CreateEngineObject(rank);
@@ -3893,13 +3873,13 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
CreateCrashSphere(Math::Vector(-2.5f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector(-5.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
- CreateShadowCircle(5.0f, 0.8f*fShadow, D3DSHADOWWORM);
+ CreateShadowCircle(5.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM);
}
if ( type == OBJECT_TEEN1 ) // blue pencil lg=14
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen1.mod");
pModFile->CreateEngineObject(rank);
@@ -3915,13 +3895,13 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
CreateCrashSphere(Math::Vector(-4.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector(-6.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
- CreateShadowCircle(6.0f, 0.8f*fShadow, D3DSHADOWWORM);
+ CreateShadowCircle(6.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM);
}
if ( type == OBJECT_TEEN2 ) // red pencil lg=16
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen2.mod");
pModFile->CreateEngineObject(rank);
@@ -3937,14 +3917,14 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
CreateCrashSphere(Math::Vector(-4.7f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector(-7.0f, 1.0f, 0.0f), 1.0f, SOUND_BOUMm, 0.45f);
- CreateShadowCircle(6.0f, 0.8f*fShadow, D3DSHADOWWORM);
+ CreateShadowCircle(6.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM);
}
if ( type == OBJECT_TEEN3 ) // jar with pencils
{
rank = m_engine->CreateObject();
-//? m_engine->SetObjectType(rank, TYPEFIX);
- m_engine->SetObjectType(rank, TYPEMETAL);
+//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen3.mod");
pModFile->CreateEngineObject(rank);
@@ -3960,7 +3940,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN4 ) // scissors
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen4.mod");
pModFile->CreateEngineObject(rank);
@@ -3976,13 +3956,13 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
CreateCrashSphere(Math::Vector( 8.0f, 1.0f, 2.2f), 2.3f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector( 9.4f, 1.0f,-2.0f), 2.0f, SOUND_BOUMm, 0.45f);
- CreateShadowCircle(10.0f, 0.5f*fShadow, D3DSHADOWWORM);
+ CreateShadowCircle(10.0f, 0.5f*fShadow, Gfx::ENG_SHADOW_WORM);
}
if ( type == OBJECT_TEEN5 ) // CD
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen5.mod");
pModFile->CreateEngineObject(rank);
@@ -3999,7 +3979,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN6 ) // book 1
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen6.mod");
pModFile->CreateEngineObject(rank);
@@ -4020,7 +4000,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN7 ) // book 2
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen7.mod");
pModFile->CreateEngineObject(rank);
@@ -4041,7 +4021,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN8 ) // a stack of books 1
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen8.mod");
pModFile->CreateEngineObject(rank);
@@ -4063,7 +4043,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN9 ) // a stack of books 2
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen9.mod");
pModFile->CreateEngineObject(rank);
@@ -4085,7 +4065,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN10 ) // bookcase
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen10.mod");
pModFile->CreateEngineObject(rank);
@@ -4111,7 +4091,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN11 ) // lamp
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen11.mod");
pModFile->CreateEngineObject(rank);
@@ -4120,9 +4100,9 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
SetFloorHeight(0.0f);
SetZoom(0, zoom);
- mat = RetWorldMatrix(0);
+ mat = GetWorldMatrix(0);
pos = Math::Transform(*mat, Math::Vector(-56.0f, 22.0f, 0.0f));
- m_particule->CreateParticule(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(20.0f, 20.0f), PARTISELY, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(20.0f, 20.0f), Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
pos = Math::Transform(*mat, Math::Vector(-65.0f, 40.0f, 0.0f));
color.r = 4.0f;
@@ -4135,8 +4115,8 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN12 ) // coke
{
rank = m_engine->CreateObject();
-//? m_engine->SetObjectType(rank, TYPEFIX);
- m_engine->SetObjectType(rank, TYPEMETAL);
+//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen12.mod");
pModFile->CreateEngineObject(rank);
@@ -4152,7 +4132,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN13 ) // cardboard farm
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen13.mod");
pModFile->CreateEngineObject(rank);
@@ -4177,7 +4157,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN14 ) // open box
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen14.mod");
pModFile->CreateEngineObject(rank);
@@ -4202,7 +4182,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN15 ) // stack of cartons
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen15.mod");
pModFile->CreateEngineObject(rank);
@@ -4227,7 +4207,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN16 ) // watering can
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen16.mod");
pModFile->CreateEngineObject(rank);
@@ -4245,7 +4225,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN17 ) // wheel |
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen17.mod");
pModFile->CreateEngineObject(rank);
@@ -4261,7 +4241,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN18 ) // wheel /
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen18.mod");
pModFile->CreateEngineObject(rank);
@@ -4277,7 +4257,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN19 ) // wheel =
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen19.mod");
pModFile->CreateEngineObject(rank);
@@ -4293,7 +4273,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN20 ) // wall with shelf
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen20.mod");
pModFile->CreateEngineObject(rank);
@@ -4314,7 +4294,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN21 ) // wall with window
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen21.mod");
pModFile->CreateEngineObject(rank);
@@ -4326,7 +4306,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN22 ) // wall with door and shelf
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen22.mod");
pModFile->CreateEngineObject(rank);
@@ -4343,7 +4323,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN23 ) // skateboard on wheels
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen23.mod");
pModFile->CreateEngineObject(rank);
@@ -4364,13 +4344,13 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
CreateCrashSphere(Math::Vector( 23.0f, 2.0f, 0.0f), 3.0f, SOUND_BOUMm, 0.45f);
CreateCrashSphere(Math::Vector( 23.0f, 2.0f,-7.0f), 3.0f, SOUND_BOUMm, 0.45f);
- CreateShadowCircle(35.0f, 0.8f*fShadow, D3DSHADOWWORM);
+ CreateShadowCircle(35.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM);
}
if ( type == OBJECT_TEEN24 ) // skate /
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen24.mod");
pModFile->CreateEngineObject(rank);
@@ -4386,7 +4366,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN25 ) // skate /
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen25.mod");
pModFile->CreateEngineObject(rank);
@@ -4402,7 +4382,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN26 ) // ceiling lamp
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen26.mod");
pModFile->CreateEngineObject(rank);
@@ -4411,9 +4391,9 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
SetZoom(0, zoom);
SetFloorHeight(0.0f);
- mat = RetWorldMatrix(0);
+ mat = GetWorldMatrix(0);
pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f));
- m_particule->CreateParticule(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(100.0f, 100.0f), PARTISELY, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), Math::Point(100.0f, 100.0f), Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
pos = Math::Transform(*mat, Math::Vector(0.0f, 50.0f, 0.0f));
color.r = 4.0f;
@@ -4426,7 +4406,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN27 ) // large plant?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen27.mod");
pModFile->CreateEngineObject(rank);
@@ -4441,8 +4421,8 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN28 ) // bottle?
{
rank = m_engine->CreateObject();
-//? m_engine->SetObjectType(rank, TYPEFIX);
- m_engine->SetObjectType(rank, TYPEMETAL);
+//? m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_METAL);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen28.mod");
pModFile->CreateEngineObject(rank);
@@ -4457,7 +4437,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN29 ) // bridge?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen29.mod");
pModFile->CreateEngineObject(rank);
@@ -4470,7 +4450,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN30 ) // jump?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen30.mod");
pModFile->CreateEngineObject(rank);
@@ -4486,7 +4466,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN31 ) // basket?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen31.mod");
pModFile->CreateEngineObject(rank);
@@ -4505,7 +4485,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN32 ) // chair?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen32.mod");
pModFile->CreateEngineObject(rank);
@@ -4524,7 +4504,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN33 ) // panel?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen33.mod");
pModFile->CreateEngineObject(rank);
@@ -4539,7 +4519,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN34 ) // stone?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen34.mod");
pModFile->CreateEngineObject(rank);
@@ -4554,7 +4534,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN35 ) // pipe?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen35.mod");
pModFile->CreateEngineObject(rank);
@@ -4567,13 +4547,13 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
CreateCrashSphere(Math::Vector( 0.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f);
CreateCrashSphere(Math::Vector( 20.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f);
CreateCrashSphere(Math::Vector( 40.0f, 5.0f, 0.0f), 10.0f, SOUND_BOUM, 0.10f);
- CreateShadowCircle(40.0f, 0.8f*fShadow, D3DSHADOWWORM);
+ CreateShadowCircle(40.0f, 0.8f*fShadow, Gfx::ENG_SHADOW_WORM);
}
if ( type == OBJECT_TEEN36 ) // trunk?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen36.mod");
pModFile->CreateEngineObject(rank);
@@ -4586,7 +4566,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN37 ) // boat?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen37.mod");
pModFile->CreateEngineObject(rank);
@@ -4599,7 +4579,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN38 ) // fan?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen38a.mod");
pModFile->CreateEngineObject(rank);
@@ -4608,7 +4588,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
SetZoom(0, zoom);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\teen38b.mod"); // engine
@@ -4616,7 +4596,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
SetPosition(1, Math::Vector(0.0f, 30.0f, 0.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 1);
pModFile->ReadModel("objects\\teen38c.mod"); // propeller
@@ -4631,7 +4611,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN39 ) // potted plant?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen39.mod");
pModFile->CreateEngineObject(rank);
@@ -4647,7 +4627,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN40 ) // balloon?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen40.mod");
pModFile->CreateEngineObject(rank);
@@ -4663,7 +4643,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN41 ) // fence?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen41.mod");
pModFile->CreateEngineObject(rank);
@@ -4675,7 +4655,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN42 ) // clover?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen42.mod");
pModFile->CreateEngineObject(rank);
@@ -4690,7 +4670,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN43 ) // clover?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen43.mod");
pModFile->CreateEngineObject(rank);
@@ -4705,7 +4685,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
if ( type == OBJECT_TEEN44 ) // car?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\teen44.mod");
pModFile->CreateEngineObject(rank);
@@ -4718,7 +4698,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
CreateShadowCircle(55.0f, 1.0f*fShadow);
}
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
if ( bFloorAdjust )
@@ -4729,7 +4709,7 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
CreateOtherObject(type);
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos);
@@ -4742,20 +4722,18 @@ bool CObject::CreateTeen(Math::Vector pos, float angle, float zoom, float height
bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
float radius;
int rank;
- if ( m_engine->RetRestCreate() < 1 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
if ( type == OBJECT_QUARTZ0 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEQUARTZ);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\quartz0.mod");
pModFile->CreateEngineObject(rank);
@@ -4770,7 +4748,7 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
if ( type == OBJECT_QUARTZ1 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEQUARTZ);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\quartz1.mod");
pModFile->CreateEngineObject(rank);
@@ -4785,7 +4763,7 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
if ( type == OBJECT_QUARTZ2 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEQUARTZ);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\quartz2.mod");
pModFile->CreateEngineObject(rank);
@@ -4800,7 +4778,7 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
if ( type == OBJECT_QUARTZ3 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEQUARTZ);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_QUARTZ);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\quartz3.mod");
pModFile->CreateEngineObject(rank);
@@ -4813,13 +4791,13 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
CreateShadowCircle(10.0f, 0.5f);
}
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
SetFloorHeight(0.0f);
CreateOtherObject(type);
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos);
@@ -4843,8 +4821,8 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
pos.y += 16.0f;
radius = 8.0f;
}
- m_particule->CreateParticule(pos, pos, Math::Point(2.0f, 2.0f), PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
- m_particule->CreateParticule(pos, pos, Math::Point(2.0f, 2.0f), PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
+ m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
+ m_particle->CreateParticle(pos, pos, Math::Point(2.0f, 2.0f), Gfx::PARTIQUARTZ, 0.7f+Math::Rand()*0.7f, radius, 0.0f);
delete pModFile;
return true;
@@ -4855,19 +4833,17 @@ bool CObject::CreateQuartz(Math::Vector pos, float angle, float height,
bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank;
- if ( m_engine->RetRestCreate() < 1 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
if ( type == OBJECT_ROOT0 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\root0.mod");
pModFile->CreateEngineObject(rank);
@@ -4889,7 +4865,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
if ( type == OBJECT_ROOT1 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\root1.mod");
pModFile->CreateEngineObject(rank);
@@ -4911,7 +4887,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
if ( type == OBJECT_ROOT2 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\root2.mod");
pModFile->CreateEngineObject(rank);
@@ -4932,7 +4908,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
if ( type == OBJECT_ROOT3 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\root3.mod");
pModFile->CreateEngineObject(rank);
@@ -4955,7 +4931,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
if ( type == OBJECT_ROOT4 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\root4.mod");
pModFile->CreateEngineObject(rank);
@@ -4980,7 +4956,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
if ( type == OBJECT_ROOT5 ) // gravity root ?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\root4.mod");
pModFile->CreateEngineObject(rank);
@@ -4989,7 +4965,7 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
SetZoom(0, 2.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\root5.mod");
@@ -5013,13 +4989,13 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
CreateShadowCircle(30.0f, 0.5f);
}
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
SetFloorHeight(0.0f);
CreateOtherObject(type);
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos);
@@ -5032,19 +5008,17 @@ bool CObject::CreateRoot(Math::Vector pos, float angle, float height,
bool CObject::CreateHome(Math::Vector pos, float angle, float height,
ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank;
- if ( m_engine->RetRestCreate() < 1 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
if ( type == OBJECT_HOME1 )
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX);
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\home1.mod");
pModFile->CreateEngineObject(rank);
@@ -5057,13 +5031,13 @@ bool CObject::CreateHome(Math::Vector pos, float angle, float height,
CreateShadowCircle(16.0f, 0.5f);
}
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
SetFloorHeight(0.0f);
CreateOtherObject(type);
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos);
@@ -5076,18 +5050,16 @@ bool CObject::CreateHome(Math::Vector pos, float angle, float height,
bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
char name[50];
int rank;
- if ( m_engine->RetRestCreate() < 1+4 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX); // it is a stationary object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
name[0] = 0;
@@ -5115,7 +5087,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
{
// Creates the right-back wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(6, rank);
SetObjectParent(6, 0);
@@ -5127,7 +5099,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
// Creates the left-back wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(7, rank);
SetObjectParent(7, 0);
@@ -5140,7 +5112,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
// Creates the right-front wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(8, rank);
SetObjectParent(8, 0);
@@ -5152,7 +5124,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
// Creates the left-front wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(9, rank);
SetObjectParent(9, 0);
@@ -5173,7 +5145,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
{
// Creates the left-back wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(7, rank);
SetObjectParent(7, 0);
@@ -5186,7 +5158,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
// Creates the left-front wheel.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(9, rank);
SetObjectParent(9, 0);
@@ -5207,7 +5179,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
{
// Creates the cannon.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
@@ -5339,7 +5311,7 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
CreateShadowCircle(30.0f, 1.0f);
}
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); //to display the shadows immediately
SetFloorHeight(0.0f);
@@ -5352,145 +5324,145 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
FloorAdjust();
}
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += height;
SetPosition(0, pos); //to display the shadows immediately
if ( type == OBJECT_RUINmobilew1 )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y -= 0.5f;
SetPosition(0, pos);
- angle = RetAngleX(0)-0.1f;
+ angle = GetAngleX(0)-0.1f;
SetAngleX(0, angle);
}
if ( type == OBJECT_RUINmobilew2 )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y -= 1.5f;
SetPosition(0, pos);
- angle = RetAngleX(0)-0.9f;
+ angle = GetAngleX(0)-0.9f;
SetAngleX(0, angle);
- angle = RetAngleZ(0)-0.1f;
+ angle = GetAngleZ(0)-0.1f;
SetAngleZ(0, angle);
}
if ( type == OBJECT_RUINmobilet1 )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y -= 0.9f;
SetPosition(0, pos);
- angle = RetAngleX(0)-0.3f;
+ angle = GetAngleX(0)-0.3f;
SetAngleX(0, angle);
}
if ( type == OBJECT_RUINmobilet2 )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y -= 1.5f;
SetPosition(0, pos);
- angle = RetAngleX(0)-0.3f;
+ angle = GetAngleX(0)-0.3f;
SetAngleX(0, angle);
- angle = RetAngleZ(0)+0.8f;
+ angle = GetAngleZ(0)+0.8f;
SetAngleZ(0, angle);
}
if ( type == OBJECT_RUINmobiler1 )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += 4.0f;
SetPosition(0, pos);
- angle = RetAngleX(0)-Math::PI*0.6f;
+ angle = GetAngleX(0)-Math::PI*0.6f;
SetAngleX(0, angle);
- angle = RetAngleZ(0)-0.2f;
+ angle = GetAngleZ(0)-0.2f;
SetAngleZ(0, angle);
}
if ( type == OBJECT_RUINmobiler2 )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += 2.0f;
SetPosition(0, pos);
- angle = RetAngleX(0)-0.1f;
+ angle = GetAngleX(0)-0.1f;
SetAngleX(0, angle);
- angle = RetAngleZ(0)-0.3f;
+ angle = GetAngleZ(0)-0.3f;
SetAngleZ(0, angle);
}
if ( type == OBJECT_RUINdoor )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y -= 0.5f;
SetPosition(0, pos);
- angle = RetAngleZ(0)-0.1f;
+ angle = GetAngleZ(0)-0.1f;
SetAngleZ(0, angle);
}
if ( type == OBJECT_RUINsupport )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += 0.5f;
SetPosition(0, pos);
-//? angle = RetAngleY(0)+0.1f;
+//? angle = GetAngleY(0)+0.1f;
//? SetAngleY(0, angle);
- angle = RetAngleX(0)+0.1f;
+ angle = GetAngleX(0)+0.1f;
SetAngleX(0, angle);
- angle = RetAngleZ(0)+0.1f;
+ angle = GetAngleZ(0)+0.1f;
SetAngleZ(0, angle);
}
if ( type == OBJECT_RUINradar )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y -= 0.5f;
SetPosition(0, pos);
- angle = RetAngleX(0)+0.15f;
+ angle = GetAngleX(0)+0.15f;
SetAngleX(0, angle);
- angle = RetAngleZ(0)+0.1f;
+ angle = GetAngleZ(0)+0.1f;
SetAngleZ(0, angle);
}
if ( type == OBJECT_RUINconvert )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y -= 1.0f;
SetPosition(0, pos);
}
if ( type == OBJECT_RUINbase )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y -= 1.0f;
SetPosition(0, pos);
- angle = RetAngleX(0)+0.15f;
+ angle = GetAngleX(0)+0.15f;
SetAngleX(0, angle);
}
if ( type == OBJECT_RUINhead )
{
- pos = RetPosition(0);
+ pos = GetPosition(0);
pos.y += 8.0f;
SetPosition(0, pos);
- angle = RetAngleX(0)+Math::PI*0.4f;
+ angle = GetAngleX(0)+Math::PI*0.4f;
SetAngleX(0, angle);
}
@@ -5502,19 +5474,17 @@ bool CObject::CreateRuin(Math::Vector pos, float angle, float height,
bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
{
- CModFile* pModFile;
+ Gfx::CModelFile* pModFile;
int rank, i;
- if ( m_engine->RetRestCreate() < 6 ) return false;
-
- pModFile = new CModFile(m_iMan);
+ pModFile = new Gfx::CModelFile(m_iMan);
SetType(type);
if ( type == OBJECT_APOLLO1 ) // LEM ?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX); // it is a stationary object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\apollol1.mod");
pModFile->CreateEngineObject(rank);
@@ -5526,7 +5496,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
for ( i=0 ; i<4 ; i++ ) // creates feet
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(i+1, rank);
SetObjectParent(i+1, 0);
pModFile->ReadModel("objects\\apollol2.mod");
@@ -5535,7 +5505,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
}
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(5, rank);
SetObjectParent(5, 0);
pModFile->ReadModel("objects\\apollol3.mod"); // ladder
@@ -5557,7 +5527,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
if ( type == OBJECT_APOLLO2 ) // jeep
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX); //it is a stationary object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); //it is a stationary object
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\apolloj1.mod");
pModFile->CreateEngineObject(rank);
@@ -5567,7 +5537,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
// Wheels.
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\apolloj4.mod"); // wheel
@@ -5575,7 +5545,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
SetPosition(1, Math::Vector(-5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(2, rank);
SetObjectParent(2, 0);
pModFile->ReadModel("objects\\apolloj4.mod"); // wheel
@@ -5583,7 +5553,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
SetPosition(2, Math::Vector(-5.75f, 1.65f, 5.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(3, rank);
SetObjectParent(3, 0);
pModFile->ReadModel("objects\\apolloj4.mod"); // wheel
@@ -5591,7 +5561,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
SetPosition(3, Math::Vector(5.75f, 1.65f, -5.0f));
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(4, rank);
SetObjectParent(4, 0);
pModFile->ReadModel("objects\\apolloj4.mod"); // wheel
@@ -5600,7 +5570,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
// Accessories:
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(5, rank);
SetObjectParent(5, 0);
pModFile->ReadModel("objects\\apolloj2.mod"); // antenna
@@ -5610,7 +5580,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
SetAngleZ(5, 45.0f*Math::PI/180.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(6, rank);
SetObjectParent(6, 0);
pModFile->ReadModel("objects\\apolloj3.mod"); // camera
@@ -5630,7 +5600,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
if ( type == OBJECT_APOLLO3 ) // flag?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX); // it is a stationary object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\apollof.mod");
pModFile->CreateEngineObject(rank);
@@ -5645,7 +5615,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
if ( type == OBJECT_APOLLO4 ) // module?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX); // it is a stationary object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\apollom.mod");
pModFile->CreateEngineObject(rank);
@@ -5662,7 +5632,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
if ( type == OBJECT_APOLLO5 ) // antenna?
{
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEFIX); // it is a stationary object
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_FIX); // it is a stationary object
SetObjectRank(0, rank);
pModFile->ReadModel("objects\\apolloa.mod");
pModFile->CreateEngineObject(rank);
@@ -5671,7 +5641,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
SetFloorHeight(0.0f);
rank = m_engine->CreateObject();
- m_engine->SetObjectType(rank, TYPEDESCENDANT);
+ m_engine->SetObjectType(rank, Gfx::ENG_OBJTYPE_DESCENDANT);
SetObjectRank(1, rank);
SetObjectParent(1, 0);
pModFile->ReadModel("objects\\apolloj2.mod"); // antenna
@@ -5686,7 +5656,7 @@ bool CObject::CreateApollo(Math::Vector pos, float angle, ObjectType type)
CreateOtherObject(type);
- pos = RetPosition(0);
+ pos = GetPosition(0);
SetPosition(0, pos); // to display the shadows immediately
delete pModFile;
@@ -5804,7 +5774,7 @@ void CObject::CreateOtherObject(ObjectType type)
// Reads a program.
-bool CObject::ReadProgram(int rank, char* filename)
+bool CObject::ReadProgram(int rank, const char* filename)
{
if ( m_brain != 0 )
{
@@ -5845,7 +5815,7 @@ bool CObject::RunProgram(int rank)
// Calculates the matrix for transforming the object.
-// Returns true if the matrix has changed.
+// Geturns true if the matrix has changed.
// The rotations occur in the order Y, Z and X.
bool CObject::UpdateTransformObject(int part, bool bForceUpdate)
@@ -5916,7 +5886,7 @@ bool CObject::UpdateTransformObject(int part, bool bForceUpdate)
if ( part == 0 && m_truck != 0 ) // transported by a truck?
{
Math::Matrix* matWorldTruck;
- matWorldTruck = m_truck->RetWorldMatrix(m_truckLink);
+ matWorldTruck = m_truck->GetWorldMatrix(m_truckLink);
m_objectPart[part].matWorld = Math::MultiplyMatrices(*matWorldTruck,
m_objectPart[part].matTransform);
}
@@ -6043,7 +6013,7 @@ void CObject::FlatParent()
void CObject::UpdateEnergyMapping()
{
- D3DMATERIAL7 mat;
+ Gfx::Material mat;
float a, b, i, s, au, bu;
float limit[6];
int j;
@@ -6051,7 +6021,7 @@ void CObject::UpdateEnergyMapping()
if ( fabs(m_energy-m_lastEnergy) < 0.01f ) return;
m_lastEnergy = m_energy;
- ZeroMemory( &mat, sizeof(D3DMATERIAL7) );
+ memset(&mat, 0, sizeof(mat));
mat.diffuse.r = 1.0f;
mat.diffuse.g = 1.0f;
mat.diffuse.b = 1.0f; // white
@@ -6083,17 +6053,17 @@ void CObject::UpdateEnergyMapping()
bu = s-b*(s-i)/(b-a);
limit[0] = 0.0f;
- limit[1] = m_engine->RetLimitLOD(0);
+ limit[1] = m_engine->GetLimitLOD(0);
limit[2] = limit[1];
- limit[3] = m_engine->RetLimitLOD(1);
+ limit[3] = m_engine->GetLimitLOD(1);
limit[4] = limit[3];
limit[5] = 1000000.0f;
for ( j=0 ; j<3 ; j++ )
{
m_engine->ChangeTextureMapping(m_objectPart[0].object,
- mat, D3DSTATEPART3, "lemt.tga", "",
- limit[j*2+0], limit[j*2+1], D3DMAPPING1Y,
+ mat, Gfx::ENG_RSTATE_PART3, "lemt.png", "",
+ limit[j*2+0], limit[j*2+1], Gfx::ENG_TEX_MAPPING_1Y,
au, bu, 1.0f, 0.0f);
}
}
@@ -6103,7 +6073,7 @@ void CObject::UpdateEnergyMapping()
bool CObject::EventProcess(const Event &event)
{
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
#if ADJUST_ONBOARD
if ( m_bSelect )
@@ -6147,12 +6117,12 @@ bool CObject::EventProcess(const Event &event)
{
if ( !m_physics->EventProcess(event) ) // object destroyed?
{
- if ( RetSelect() &&
+ if ( GetSelect() &&
m_type != OBJECT_ANT &&
m_type != OBJECT_SPIDER &&
m_type != OBJECT_BEE )
{
- if ( !m_bDead ) m_camera->SetType(CAMERA_EXPLO);
+ if ( !m_bDead ) m_camera->SetType(Gfx::CAM_TYPE_EXPLO);
m_main->DeselectAll();
}
return false;
@@ -6163,7 +6133,7 @@ bool CObject::EventProcess(const Event &event)
{
m_auto->EventProcess(event);
- if ( event.event == EVENT_FRAME &&
+ if ( event.type == EVENT_FRAME &&
m_auto->IsEnded() != ERR_CONTINUE )
{
m_auto->DeleteObject();
@@ -6177,7 +6147,7 @@ bool CObject::EventProcess(const Event &event)
m_motion->EventProcess(event);
}
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
@@ -6190,13 +6160,13 @@ bool CObject::EventProcess(const Event &event)
bool CObject::EventFrame(const Event &event)
{
- if ( m_type == OBJECT_HUMAN && m_main->RetMainMovie() == MM_SATCOMopen )
+ if ( m_type == OBJECT_HUMAN && m_main->GetMainMovie() == MM_SATCOMopen )
{
UpdateTransformObject();
return true;
}
- if ( m_type != OBJECT_SHOW && m_engine->RetPause() ) return true;
+ if ( m_type != OBJECT_SHOW && m_engine->GetPause() ) return true;
m_aTime += event.rTime;
m_shotTime += event.rTime;
@@ -6206,23 +6176,23 @@ bool CObject::EventFrame(const Event &event)
UpdateMapping();
UpdateTransformObject();
- UpdateSelectParticule();
+ UpdateSelectParticle();
if ( m_bProxyActivate ) // active if it is near?
{
- CPyro* pyro;
+ Gfx::CPyro* pyro;
Math::Vector eye;
float dist;
- eye = m_engine->RetLookatPt();
- dist = Math::Distance(eye, RetPosition(0));
+ eye = m_engine->GetLookatPt();
+ dist = Math::Distance(eye, GetPosition(0));
if ( dist < m_proxyDistance )
{
m_bProxyActivate = false;
m_main->CreateShortcuts();
m_sound->Play(SOUND_FINDING);
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FINDING, this, 0.0f);
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FINDING, this, 0.0f);
m_displayText->DisplayError(INFO_FINDING, this);
}
}
@@ -6248,10 +6218,10 @@ void CObject::UpdateMapping()
void CObject::VirusFrame(float rTime)
{
- ParticuleType type;
+ Gfx::ParticleType type;
Math::Vector pos, speed;
Math::Point dim;
- int r;
+ int r;
if ( !m_bVirusMode ) return; // healthy object?
@@ -6261,23 +6231,23 @@ void CObject::VirusFrame(float rTime)
m_bVirusMode = false; // the virus is no longer active
}
- if ( m_lastVirusParticule+m_engine->ParticuleAdapt(0.2f) <= m_aTime )
+ if ( m_lastVirusParticle+m_engine->ParticleAdapt(0.2f) <= m_aTime )
{
- m_lastVirusParticule = m_aTime;
+ m_lastVirusParticle = m_aTime;
r = rand()%10;
- if ( r == 0 ) type = PARTIVIRUS1;
- if ( r == 1 ) type = PARTIVIRUS2;
- if ( r == 2 ) type = PARTIVIRUS3;
- if ( r == 3 ) type = PARTIVIRUS4;
- if ( r == 4 ) type = PARTIVIRUS5;
- if ( r == 5 ) type = PARTIVIRUS6;
- if ( r == 6 ) type = PARTIVIRUS7;
- if ( r == 7 ) type = PARTIVIRUS8;
- if ( r == 8 ) type = PARTIVIRUS9;
- if ( r == 9 ) type = PARTIVIRUS10;
-
- pos = RetPosition(0);
+ if ( r == 0 ) type = Gfx::PARTIVIRUS1;
+ if ( r == 1 ) type = Gfx::PARTIVIRUS2;
+ if ( r == 2 ) type = Gfx::PARTIVIRUS3;
+ if ( r == 3 ) type = Gfx::PARTIVIRUS4;
+ if ( r == 4 ) type = Gfx::PARTIVIRUS5;
+ if ( r == 5 ) type = Gfx::PARTIVIRUS6;
+ if ( r == 6 ) type = Gfx::PARTIVIRUS7;
+ if ( r == 7 ) type = Gfx::PARTIVIRUS8;
+ if ( r == 8 ) type = Gfx::PARTIVIRUS9;
+ if ( r == 9 ) type = Gfx::PARTIVIRUS10;
+
+ pos = GetPosition(0);
pos.x += (Math::Rand()-0.5f)*10.0f;
pos.z += (Math::Rand()-0.5f)*10.0f;
speed.x = (Math::Rand()-0.5f)*2.0f;
@@ -6286,7 +6256,7 @@ void CObject::VirusFrame(float rTime)
dim.x = Math::Rand()*0.3f+0.3f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, type, 3.0f);
+ m_particle->CreateParticle(pos, speed, dim, type, 3.0f);
}
}
@@ -6304,7 +6274,7 @@ void CObject::PartiFrame(float rTime)
channel = m_objectPart[i].masterParti;
if ( channel == -1 ) continue;
- if ( !m_particule->GetPosition(channel, pos) )
+ if ( !m_particle->GetPosition(channel, pos) )
{
m_objectPart[i].masterParti = -1; // particle no longer exists!
continue;
@@ -6322,7 +6292,7 @@ void CObject::PartiFrame(float rTime)
case 4: factor = Math::Vector( 0.4f, 0.1f,-0.7f); break;
}
- angle = RetAngle(i);
+ angle = GetAngle(i);
angle += rTime*Math::PI*factor;
SetAngle(i, angle);
}
@@ -6334,7 +6304,7 @@ void CObject::PartiFrame(float rTime)
void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
Math::Vector &lookat, Math::Vector &upVec,
- CameraType type)
+ Gfx::CameraType type)
{
float speed;
int part;
@@ -6429,7 +6399,7 @@ void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
m_engine->SetInfoText(4, s);
#endif
- if ( type == CAMERA_BACK )
+ if ( type == Gfx::CAM_TYPE_BACK )
{
eye.x -= 20.0f;
eye.y += 1.0f;
@@ -6446,20 +6416,20 @@ void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
upVec = Math::Vector(0.0f, 1.0f, 0.0f);
if ( m_physics != 0 )
{
- if ( m_physics->RetLand() ) // on ground?
+ if ( m_physics->GetLand() ) // on ground?
{
- speed = m_physics->RetLinMotionX(MO_REASPEED);
+ speed = m_physics->GetLinMotionX(MO_REASPEED);
lookat.y -= speed*0.002f;
- speed = m_physics->RetCirMotionY(MO_REASPEED);
+ speed = m_physics->GetCirMotionY(MO_REASPEED);
upVec.z -= speed*0.04f;
}
else // in flight?
{
- speed = m_physics->RetLinMotionX(MO_REASPEED);
+ speed = m_physics->GetLinMotionX(MO_REASPEED);
lookat.y += speed*0.002f;
- speed = m_physics->RetCirMotionY(MO_REASPEED);
+ speed = m_physics->GetCirMotionY(MO_REASPEED);
upVec.z += speed*0.08f;
}
}
@@ -6475,23 +6445,23 @@ void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
void CObject::SetCharacter(Character* character)
{
- CopyMemory(&m_character, character, sizeof(Character));
+ memcpy(&m_character, character, sizeof(m_character));
}
void CObject::GetCharacter(Character* character)
{
- CopyMemory(character, &m_character, sizeof(Character));
+ memcpy(character, &m_character, sizeof(character));
}
-Character* CObject::RetCharacter()
+Character* CObject::GetCharacter()
{
return &m_character;
}
-// Returns the absolute time.
+// Geturns the absolute time.
-float CObject::RetAbsTime()
+float CObject::GetAbsTime()
{
return m_aTime;
}
@@ -6507,7 +6477,7 @@ void CObject::SetEnergy(float level)
m_energy = level;
}
-float CObject::RetEnergy()
+float CObject::GetEnergy()
{
if ( m_type != OBJECT_POWER &&
m_type != OBJECT_ATOMIC &&
@@ -6526,7 +6496,7 @@ void CObject::SetCapacity(float capacity)
m_capacity = capacity;
}
-float CObject::RetCapacity()
+float CObject::GetCapacity()
{
return m_capacity;
}
@@ -6539,7 +6509,7 @@ void CObject::SetShield(float level)
m_shield = level;
}
-float CObject::RetShield()
+float CObject::GetShield()
{
if ( m_type == OBJECT_FRET ||
m_type == OBJECT_STONE ||
@@ -6582,7 +6552,7 @@ void CObject::SetRange(float delay)
m_range = delay;
}
-float CObject::RetRange()
+float CObject::GetRange()
{
return m_range;
}
@@ -6610,7 +6580,7 @@ void CObject::SetTransparency(float value)
}
}
-float CObject::RetTransparency()
+float CObject::GetTransparency()
{
return m_transparency;
}
@@ -6618,7 +6588,7 @@ float CObject::RetTransparency()
// Management of the object matter.
-ObjectMaterial CObject::RetMaterial()
+ObjectMaterial CObject::GetMaterial()
{
if ( m_type == OBJECT_HUMAN )
{
@@ -6642,7 +6612,7 @@ void CObject::SetGadget(bool bMode)
m_bGadget = bMode;
}
-bool CObject::RetGadget()
+bool CObject::GetGadget()
{
return m_bGadget;
}
@@ -6655,7 +6625,7 @@ void CObject::SetFixed(bool bFixed)
m_bFixed = bFixed;
}
-bool CObject::RetFixed()
+bool CObject::GetFixed()
{
return m_bFixed;
}
@@ -6668,7 +6638,7 @@ void CObject::SetClip(bool bClip)
m_bClip = bClip;
}
-bool CObject::RetClip()
+bool CObject::GetClip()
{
return m_bClip;
}
@@ -6696,7 +6666,7 @@ bool CObject::JostleObject(float force)
if ( m_auto != 0 ) return false;
m_auto = new CAutoJostle(m_iMan, this);
- pa = (CAutoJostle*)m_auto;
+ pa = static_cast<CAutoJostle*>(m_auto);
pa->Start(0, force);
}
@@ -6712,7 +6682,7 @@ void CObject::StartDetectEffect(CObject *target, bool bFound)
Math::Vector pos, goal;
Math::Point dim;
- mat = RetWorldMatrix(0);
+ mat = GetWorldMatrix(0);
pos = Math::Transform(*mat, Math::Vector(2.0f, 3.0f, 0.0f));
if ( target == 0 )
@@ -6721,24 +6691,24 @@ void CObject::StartDetectEffect(CObject *target, bool bFound)
}
else
{
- goal = target->RetPosition(0);
+ goal = target->GetPosition(0);
goal.y += 3.0f;
goal = Math::SegmentPoint(pos, goal, Math::Distance(pos, goal)-3.0f);
}
dim.x = 3.0f;
dim.y = dim.x;
- m_particule->CreateRay(pos, goal, PARTIRAY2, dim, 0.2f);
+ m_particle->CreateRay(pos, goal, Gfx::PARTIRAY2, dim, 0.2f);
if ( target != 0 )
{
- goal = target->RetPosition(0);
+ goal = target->GetPosition(0);
goal.y += 3.0f;
goal = Math::SegmentPoint(pos, goal, Math::Distance(pos, goal)-1.0f);
dim.x = 6.0f;
dim.y = dim.x;
- m_particule->CreateParticule(goal, Math::Vector(0.0f, 0.0f, 0.0f), dim,
- bFound?PARTIGLINT:PARTIGLINTr, 0.5f);
+ m_particle->CreateParticle(goal, Math::Vector(0.0f, 0.0f, 0.0f), dim,
+ bFound?Gfx::PARTIGLINT:Gfx::PARTIGLINTr, 0.5f);
}
m_sound->Play(bFound?SOUND_BUILD:SOUND_RECOVER);
@@ -6761,12 +6731,12 @@ void CObject::SetVirusMode(bool bEnable)
}
}
-bool CObject::RetVirusMode()
+bool CObject::GetVirusMode()
{
return m_bVirusMode;
}
-float CObject::RetVirusTime()
+float CObject::GetVirusTime()
{
return m_virusTime;
}
@@ -6774,12 +6744,12 @@ float CObject::RetVirusTime()
// Management mode of the camera.
-void CObject::SetCameraType(CameraType type)
+void CObject::SetCameraType(Gfx::CameraType type)
{
m_cameraType = type;
}
-CameraType CObject::RetCameraType()
+Gfx::CameraType CObject::GetCameraType()
{
return m_cameraType;
}
@@ -6789,7 +6759,7 @@ void CObject::SetCameraDist(float dist)
m_cameraDist = dist;
}
-float CObject::RetCameraDist()
+float CObject::GetCameraDist()
{
return m_cameraDist;
}
@@ -6799,7 +6769,7 @@ void CObject::SetCameraLock(bool bLock)
m_bCameraLock = bLock;
}
-bool CObject::RetCameraLock()
+bool CObject::GetCameraLock()
{
return m_bCameraLock;
}
@@ -6827,11 +6797,11 @@ void CObject::SetHilite(bool bMode)
}
list[j] = -1; // terminate
- m_engine->SetHiliteRank(list); // gives the list of selected parts
+ m_engine->SetHighlightRank(list); // gives the list of selected parts
}
}
-bool CObject::RetHilite()
+bool CObject::GetHilite()
{
return m_bHilite;
}
@@ -6855,7 +6825,7 @@ void CObject::SetSelect(bool bMode, bool bDisplayError)
m_auto->CreateInterface(m_bSelect);
}
- CreateSelectParticule(); // creates / removes particles
+ CreateSelectParticle(); // creates / removes particles
if ( !m_bSelect )
{
@@ -6866,11 +6836,11 @@ void CObject::SetSelect(bool bMode, bool bDisplayError)
err = ERR_OK;
if ( m_physics != 0 )
{
- err = m_physics->RetError();
+ err = m_physics->GetError();
}
if ( m_auto != 0 )
{
- err = m_auto->RetError();
+ err = m_auto->GetError();
}
if ( err != ERR_OK && bDisplayError )
{
@@ -6880,9 +6850,9 @@ void CObject::SetSelect(bool bMode, bool bDisplayError)
// Indicates whether the object is selected or not.
-bool CObject::RetSelect(bool bReal)
+bool CObject::GetSelect(bool bReal)
{
- if ( !bReal && m_main->RetFixScene() ) return false;
+ if ( !bReal && m_main->GetFixScene() ) return false;
return m_bSelect;
}
@@ -6896,7 +6866,7 @@ void CObject::SetSelectable(bool bMode)
// Indicates whether the object is selecionnable or not.
-bool CObject::RetSelectable()
+bool CObject::GetSelectable()
{
return m_bSelectable;
}
@@ -6912,11 +6882,11 @@ void CObject::SetActivity(bool bMode)
}
}
-bool CObject::RetActivity()
+bool CObject::GetActivity()
{
if ( m_brain != 0 )
{
- return m_brain->RetActivity();
+ return m_brain->GetActivity();
}
return false;
}
@@ -6931,7 +6901,7 @@ void CObject::SetCheckToken(bool bMode)
// Indicates if necessary to check the tokens of the object.
-bool CObject::RetCheckToken()
+bool CObject::GetCheckToken()
{
return m_bCheckToken;
}
@@ -6946,7 +6916,7 @@ void CObject::SetVisible(bool bVisible)
m_bVisible = bVisible;
}
-bool CObject::RetVisible()
+bool CObject::GetVisible()
{
return m_bVisible;
}
@@ -6962,7 +6932,7 @@ void CObject::SetEnable(bool bEnable)
m_bEnable = bEnable;
}
-bool CObject::RetEnable()
+bool CObject::GetEnable()
{
return m_bEnable;
}
@@ -6975,7 +6945,7 @@ void CObject::SetProxyActivate(bool bActivate)
m_bProxyActivate = bActivate;
}
-bool CObject::RetProxyActivate()
+bool CObject::GetProxyActivate()
{
return m_bProxyActivate;
}
@@ -6985,7 +6955,7 @@ void CObject::SetProxyDistance(float distance)
m_proxyDistance = distance;
}
-float CObject::RetProxyDistance()
+float CObject::GetProxyDistance()
{
return m_proxyDistance;
}
@@ -6998,7 +6968,7 @@ void CObject::SetMagnifyDamage(float factor)
m_magnifyDamage = factor;
}
-float CObject::RetMagnifyDamage()
+float CObject::GetMagnifyDamage()
{
return m_magnifyDamage;
}
@@ -7011,7 +6981,7 @@ void CObject::SetParam(float value)
m_param = value;
}
-float CObject::RetParam()
+float CObject::GetParam()
{
return m_param;
}
@@ -7026,7 +6996,7 @@ void CObject::SetLock(bool bLock)
m_bLock = bLock;
}
-bool CObject::RetLock()
+bool CObject::GetLock()
{
return m_bLock;
}
@@ -7039,7 +7009,7 @@ void CObject::SetExplo(bool bExplo)
m_bExplo = bExplo;
}
-bool CObject::RetExplo()
+bool CObject::GetExplo()
{
return m_bExplo;
}
@@ -7052,7 +7022,7 @@ void CObject::SetCargo(bool bCargo)
m_bCargo = bCargo;
}
-bool CObject::RetCargo()
+bool CObject::GetCargo()
{
return m_bCargo;
}
@@ -7071,7 +7041,7 @@ void CObject::SetBurn(bool bBurn)
//? }
}
-bool CObject::RetBurn()
+bool CObject::GetBurn()
{
return m_bBurn;
}
@@ -7092,17 +7062,17 @@ void CObject::SetDead(bool bDead)
//? }
}
-bool CObject::RetDead()
+bool CObject::GetDead()
{
return m_bDead;
}
-bool CObject::RetRuin()
+bool CObject::GetRuin()
{
return m_bBurn|m_bFlat;
}
-bool CObject::RetActif()
+bool CObject::GetActif()
{
return !m_bLock && !m_bBurn && !m_bFlat && m_bVisible && m_bEnable;
}
@@ -7178,12 +7148,12 @@ void CObject::SetGunGoalH(float gunGoal)
m_gunGoalH = gunGoal;
}
-float CObject::RetGunGoalV()
+float CObject::GetGunGoalV()
{
return m_gunGoalV;
}
-float CObject::RetGunGoalH()
+float CObject::GetGunGoalH()
{
return m_gunGoalH;
}
@@ -7196,7 +7166,7 @@ bool CObject::StartShowLimit()
{
if ( m_showLimitRadius == 0.0f ) return false;
- m_main->SetShowLimit(0, PARTILIMIT1, this, RetPosition(0), m_showLimitRadius);
+ m_main->SetShowLimit(0, Gfx::PARTILIMIT1, this, GetPosition(0), m_showLimitRadius);
m_bShowLimit = true;
return true;
}
@@ -7219,7 +7189,7 @@ bool CObject::IsProgram()
// Creates or removes particles associated to the object.
-void CObject::CreateSelectParticule()
+void CObject::CreateSelectParticle()
{
Math::Vector pos, speed;
Math::Point dim;
@@ -7230,7 +7200,7 @@ void CObject::CreateSelectParticule()
{
if ( m_partiSel[i] != -1 )
{
- m_particule->DeleteParticule(m_partiSel[i]);
+ m_particle->DeleteParticle(m_partiSel[i]);
m_partiSel[i] = -1;
}
}
@@ -7270,18 +7240,18 @@ void CObject::CreateSelectParticule()
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 0.0f;
dim.y = 0.0f;
- m_partiSel[0] = m_particule->CreateParticule(pos, speed, dim, PARTISELY, 1.0f, 0.0f, 0.0f);
- m_partiSel[1] = m_particule->CreateParticule(pos, speed, dim, PARTISELY, 1.0f, 0.0f, 0.0f);
- m_partiSel[2] = m_particule->CreateParticule(pos, speed, dim, PARTISELR, 1.0f, 0.0f, 0.0f);
- m_partiSel[3] = m_particule->CreateParticule(pos, speed, dim, PARTISELR, 1.0f, 0.0f, 0.0f);
- UpdateSelectParticule();
+ m_partiSel[0] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
+ m_partiSel[1] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISELY, 1.0f, 0.0f, 0.0f);
+ m_partiSel[2] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISELR, 1.0f, 0.0f, 0.0f);
+ m_partiSel[3] = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISELR, 1.0f, 0.0f, 0.0f);
+ UpdateSelectParticle();
}
}
}
// Updates the particles associated to the object.
-void CObject::UpdateSelectParticule()
+void CObject::UpdateSelectParticle()
{
Math::Vector pos[4];
Math::Point dim[4];
@@ -7405,7 +7375,7 @@ void CObject::UpdateSelectParticule()
pos[3] = Math::Vector(-5.3f, 2.7f, -1.8f);
}
- angle = RetAngleY(0)/Math::PI;
+ angle = GetAngleY(0)/Math::PI;
zoom[0] = 1.0f;
zoom[1] = 1.0f;
@@ -7426,7 +7396,7 @@ void CObject::UpdateSelectParticule()
{
pos[i] = Math::Transform(m_objectPart[0].matWorld, pos[i]);
dim[i].y = dim[i].x;
- m_particule->SetParam(m_partiSel[i], pos[i], dim[i], zoom[i], angle, 1.0f);
+ m_particle->SetParam(m_partiSel[i], pos[i], dim[i], zoom[i], angle, 1.0f);
}
}
@@ -7438,42 +7408,42 @@ void CObject::SetRunScript(CScript* script)
m_runScript = script;
}
-CScript* CObject::RetRunScript()
+CScript* CObject::GetRunScript()
{
return m_runScript;
}
-// Returns the variables of "this" for CBOT.
+// Geturns the variables of "this" for CBOT.
-CBotVar* CObject::RetBotVar()
+CBotVar* CObject::GetBotVar()
{
return m_botVar;
}
-// Returns the physics associated to the object.
+// Geturns the physics associated to the object.
-CPhysics* CObject::RetPhysics()
+CPhysics* CObject::GetPhysics()
{
return m_physics;
}
-// Returns the brain associated to the object.
+// Geturns the brain associated to the object.
-CBrain* CObject::RetBrain()
+CBrain* CObject::GetBrain()
{
return m_brain;
}
-// Returns the movement associated to the object.
+// Geturns the movement associated to the object.
-CMotion* CObject::RetMotion()
+CMotion* CObject::GetMotion()
{
return m_motion;
}
-// Returns the controller associated to the object.
+// Geturns the controller associated to the object.
-CAuto* CObject::RetAuto()
+CAuto* CObject::GetAuto()
{
return m_auto;
}
@@ -7492,7 +7462,7 @@ void CObject::SetDefRank(int rank)
m_defRank = rank;
}
-int CObject::RetDefRank()
+int CObject::GetDefRank()
{
return m_defRank;
}
@@ -7555,51 +7525,51 @@ void CObject::DeleteDeselList(CObject* pObj)
// Management of the state of the pencil drawing robot.
-bool CObject::RetTraceDown()
+bool CObject::GetTraceDown()
{
CMotionVehicle* mv;
if ( m_motion == 0 ) return false;
- mv = (CMotionVehicle*)m_motion;
- return mv->RetTraceDown();
+ mv = dynamic_cast<CMotionVehicle*>(m_motion);
+ return mv->GetTraceDown();
}
void CObject::SetTraceDown(bool bDown)
{
CMotionVehicle* mv;
if ( m_motion == 0 ) return;
- mv = (CMotionVehicle*)m_motion;
+ mv = dynamic_cast<CMotionVehicle*>(m_motion);
mv->SetTraceDown(bDown);
}
-int CObject::RetTraceColor()
+int CObject::GetTraceColor()
{
CMotionVehicle* mv;
if ( m_motion == 0 ) return 0;
- mv = (CMotionVehicle*)m_motion;
- return mv->RetTraceColor();
+ mv = dynamic_cast<CMotionVehicle*>(m_motion);
+ return mv->GetTraceColor();
}
void CObject::SetTraceColor(int color)
{
CMotionVehicle* mv;
if ( m_motion == 0 ) return;
- mv = (CMotionVehicle*)m_motion;
+ mv = dynamic_cast<CMotionVehicle*>(m_motion);
mv->SetTraceColor(color);
}
-float CObject::RetTraceWidth()
+float CObject::GetTraceWidth()
{
CMotionVehicle* mv;
if ( m_motion == 0 ) return 0.0f;
- mv = (CMotionVehicle*)m_motion;
- return mv->RetTraceWidth();
+ mv = dynamic_cast<CMotionVehicle*>(m_motion);
+ return mv->GetTraceWidth();
}
void CObject::SetTraceWidth(float width)
{
CMotionVehicle* mv;
if ( m_motion == 0 ) return;
- mv = (CMotionVehicle*)m_motion;
+ mv = dynamic_cast<CMotionVehicle*>(m_motion);
mv->SetTraceWidth(width);
}
diff --git a/src/object/object.h b/src/object/object.h
index 88ae486..1301768 100644
--- a/src/object/object.h
+++ b/src/object/object.h
@@ -35,7 +35,10 @@ class CRobotMain;
class CBotVar;
class CScript;
-
+namespace Ui
+{
+class CDisplayText;
+}
// The father of all parts must always be the part number zero!
@@ -46,69 +49,70 @@ const int OBJECTMAXDESELLIST = 10;
const int OBJECTMAXINFO = 10;
const int OBJECTMAXCMDLINE = 20;
+
enum ObjectMaterial
{
- OM_METAL = 0, // metal
- OM_PLASTIC = 1, // plastic
- OM_HUMAN = 2, // cosmonaut
- OM_ANIMAL = 3, // insect
- OM_VEGETAL = 4, // plant
- OM_MINERAL = 5, // stone
+ OM_METAL = 0, // metal
+ OM_PLASTIC = 1, // plastic
+ OM_HUMAN = 2, // cosmonaut
+ OM_ANIMAL = 3, // insect
+ OM_VEGETAL = 4, // plant
+ OM_MINERAL = 5, // stone
};
struct ObjectPart
{
- char bUsed;
- int object; // number of the object in CEngine
- int parentPart; // number of father part
- int masterParti; // master canal of the particle
- Math::Vector position;
- Math::Vector angle;
- Math::Vector zoom;
- char bTranslate;
- char bRotate;
- char bZoom;
- Math::Matrix matTranslate;
- Math::Matrix matRotate;
- Math::Matrix matTransform;
- Math::Matrix matWorld;
+ char bUsed;
+ int object; // number of the object in CEngine
+ int parentPart; // number of father part
+ int masterParti; // master canal of the particle
+ Math::Vector position;
+ Math::Vector angle;
+ Math::Vector zoom;
+ char bTranslate;
+ char bRotate;
+ char bZoom;
+ Math::Matrix matTranslate;
+ Math::Matrix matRotate;
+ Math::Matrix matTransform;
+ Math::Matrix matWorld;
};
struct Character
{
- float wheelFront; // position X of the front wheels
- float wheelBack; // position X of the back wheels
- float wheelLeft; // position Z of the left wheels
- float wheelRight; // position Z of the right wheels
- float height; // normal height on top of ground
- Math::Vector posPower; // position of the battery
+ float wheelFront; // position X of the front wheels
+ float wheelBack; // position X of the back wheels
+ float wheelLeft; // position Z of the left wheels
+ float wheelRight; // position Z of the right wheels
+ float height; // normal height on top of ground
+ Math::Vector posPower; // position of the battery
};
struct Info
{
- char name[20]; // name of the information
- float value; // value of the information
+ char name[20]; // name of the information
+ float value; // value of the information
};
enum ExploType
{
- EXPLO_BOUM = 1,
- EXPLO_BURN = 2,
- EXPLO_WATER = 3,
+ EXPLO_BOUM = 1,
+ EXPLO_BURN = 2,
+ EXPLO_WATER = 3,
};
enum ResetCap
{
- RESET_NONE = 0,
- RESET_MOVE = 1,
- RESET_DELETE = 2,
+ RESET_NONE = 0,
+ RESET_MOVE = 1,
+ RESET_DELETE = 2,
};
enum RadarFilter
{
- FILTER_NONE = 0,
- FILTER_ONLYLANDING = 1,
- FILTER_ONLYFLYING = 2,
+ FILTER_NONE = 0,
+ FILTER_ONLYLANDING = 1,
+ FILTER_ONLYFLYING = 2,
};
@@ -162,7 +166,7 @@ public:
bool CreateRuin(Math::Vector pos, float angle, float height, ObjectType type);
bool CreateApollo(Math::Vector pos, float angle, ObjectType type);
- bool ReadProgram(int rank, char* filename);
+ bool ReadProgram(int rank, const char* filename);
bool WriteProgram(int rank, char* filename);
bool RunProgram(int rank);
@@ -235,8 +239,8 @@ public:
void SetResetRun(int run);
int GetResetRun();
- void SetMasterParticule(int part, int parti);
- int GetMasterParticule(int part);
+ void SetMasterParticle(int part, int parti);
+ int GetMasterParticle(int part);
void SetPower(CObject* power);
CObject* GetPower();
@@ -252,8 +256,8 @@ public:
void SetInfo(int rank, Info info);
Info GetInfo(int rank);
int GetInfoTotal();
- void SetInfoGeturn(float value);
- float GetInfoGeturn();
+ void SetInfoReturn(float value);
+ float GetInfoReturn();
void SetInfoUpdate(bool bUpdate);
bool GetInfoUpdate();
@@ -370,7 +374,7 @@ public:
void StopShowLimit();
bool IsProgram();
- void CreateSelectParticule();
+ void CreateSelectParticle();
void SetRunScript(CScript* script);
CScript* GetRunScript();
@@ -414,25 +418,25 @@ protected:
void UpdateEnergyMapping();
bool UpdateTransformObject(int part, bool bForceUpdate);
bool UpdateTransformObject();
- void UpdateSelectParticule();
+ void UpdateSelectParticle();
protected:
- CInstanceManager* m_iMan;
- Gfx::CEngine* m_engine;
- Gfx::CLightManager* m_lightMan;
- Gfx::CTerrain* m_terrain;
- Gfx::CWater* m_water;
- Gfx::CCamera* m_camera;
- Gfx::CParticle* m_particle;
- CPhysics* m_physics;
- CBrain* m_brain;
- CMotion* m_motion;
- CAuto* m_auto;
- CDisplayText* m_displayText;
- CRobotMain* m_main;
- CSoundInterface* m_sound;
- CBotVar* m_botVar;
- CScript* m_runScript;
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ Gfx::CLightManager* m_lightMan;
+ Gfx::CTerrain* m_terrain;
+ Gfx::CWater* m_water;
+ Gfx::CCamera* m_camera;
+ Gfx::CParticle* m_particle;
+ CPhysics* m_physics;
+ CBrain* m_brain;
+ CMotion* m_motion;
+ CAuto* m_auto;
+ Ui::CDisplayText* m_displayText;
+ CRobotMain* m_main;
+ CSoundInterface* m_sound;
+ CBotVar* m_botVar;
+ CScript* m_runScript;
ObjectType m_type; // OBJECT_*
int m_id; // unique identifier
@@ -462,8 +466,8 @@ protected:
float m_shotTime; // time since last shot
bool m_bVirusMode; // virus activated/triggered
float m_virusTime; // lifetime of the virus
- float m_lastVirusParticule;
- float m_lastParticule;
+ float m_lastVirusParticle;
+ float m_lastParticle;
bool m_bHilite;
bool m_bSelect; // object selected
bool m_bSelectable; // selectable object
@@ -522,7 +526,7 @@ protected:
int m_infoTotal;
Info m_info[OBJECTMAXINFO];
- float m_infoGeturn;
+ float m_infoReturn;
bool m_bInfoUpdate;
float m_cmdLine[OBJECTMAXCMDLINE];
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index 83eca52..8048b5b 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -17,67 +17,67 @@
// robotmain.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
+#include "object/robotmain.h"
#include "CBot/CBotDll.h"
-#include "common/struct.h"
-#include "math/const.h"
-#include "math/geometry.h"
-#include "math/conv.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/language.h"
-#include "common/global.h"
+
+#include "app/app.h"
#include "common/event.h"
+#include "common/global.h"
+#include "common/iman.h"
#include "common/misc.h"
#include "common/profile.h"
-#include "common/iman.h"
#include "common/restext.h"
-#include "old/math3d.h"
-#include "old/light.h"
-#include "old/particule.h"
-#include "old/terrain.h"
-#include "old/water.h"
-#include "old/cloud.h"
-#include "old/blitz.h"
-#include "old/planet.h"
-#include "object/object.h"
+#include "graphics/engine/camera.h"
+#include "graphics/engine/cloud.h"
+#include "graphics/engine/engine.h"
+#include "graphics/engine/lightman.h"
+#include "graphics/engine/lightning.h"
+#include "graphics/engine/modelfile.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/planet.h"
+#include "graphics/engine/pyro.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/text.h"
+#include "graphics/engine/water.h"
+#include "math/const.h"
+#include "math/geometry.h"
+#include "object/auto/auto.h"
+#include "object/auto/autobase.h"
+#include "object/brain.h"
+#include "object/mainmovie.h"
#include "object/motion/motion.h"
-#include "object/motion/motiontoto.h"
#include "object/motion/motionhuman.h"
-#include "physics/physics.h"
-#include "object/brain.h"
-#include "old/pyro.h"
-#include "old/modfile.h"
-#include "old/model.h"
-#include "old/camera.h"
+#include "object/motion/motiontoto.h"
+#include "object/object.h"
#include "object/task/task.h"
-#include "object/task/taskmanip.h"
#include "object/task/taskbuild.h"
-#include "object/auto/auto.h"
-#include "object/auto/autobase.h"
+#include "object/task/taskmanip.h"
+#include "physics/physics.h"
+#include "script/cbottoken.h"
+#include "script/cmdtoken.h"
+#include "script/script.h"
+#include "sound/sound.h"
+#include "ui/button.h"
#include "ui/displayinfo.h"
+#include "ui/displaytext.h"
+#include "ui/edit.h"
#include "ui/interface.h"
-#include "ui/shortcut.h"
-#include "ui/map.h"
#include "ui/label.h"
-#include "ui/button.h"
-#include "ui/slider.h"
-#include "ui/window.h"
-#include "ui/edit.h"
-#include "ui/displaytext.h"
-#include "old/text.h"
-#include "old/sound.h"
-#include "script/cbottoken.h"
-#include "script/cmdtoken.h"
-#include "object/mainmovie.h"
#include "ui/maindialog.h"
-#include "ui/mainshort.h"
#include "ui/mainmap.h"
-#include "script/script.h"
-#include "object/robotmain.h"
+#include "ui/mainshort.h"
+#include "ui/map.h"
+#include "ui/shortcut.h"
+#include "ui/slider.h"
+#include "ui/window.h"
+
+
+template<> CRobotMain* CSingleton<CRobotMain>::mInstance = nullptr;
+
+
+// TODO: remove once using std::string
+const int MAX_FNAME = 255;
@@ -89,8 +89,8 @@ const float UNIT = 4.0f;
// Global variables.
long g_id; // unique identifier
-long g_build; // constructible buildings
-long g_researchDone; // research done
+int g_build; // constructible buildings
+int g_researchDone; // research done
long g_researchEnable; // research available
float g_unit; // conversion factor
@@ -109,9 +109,7 @@ static char* m_filesDir;
void PrepareFilename(CBotString &filename)
{
- int pos;
-
- pos = filename.ReverseFind('\\');
+ int pos = filename.ReverseFind('\\');
if ( pos > 0 )
{
filename = filename.Mid(pos+1); // Remove files with
@@ -176,7 +174,7 @@ bool rfconstruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exceptio
// save the channel file
pVar = pThis->GetItem("handle");
- pVar->SetValInt((long)pFile);
+ pVar->SetValInt(reinterpret_cast<long>(pFile));
}
return true;
@@ -219,7 +217,7 @@ bool rfdestruct (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception
// don't open? no problem :)
if ( pVar->GetInit() != IS_DEF) return true;
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
fclose(pFile);
m_CompteurFileOpen --;
@@ -286,7 +284,7 @@ bool rfopen (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
// Registered the channel file
pVar = pThis->GetItem("handle");
- pVar->SetValInt((long)pFile);
+ pVar->SetValInt(reinterpret_cast<long>(pFile));
pResult->SetValInt(true);
return true;
@@ -332,7 +330,7 @@ bool rfclose (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
fclose(pFile);
m_CompteurFileOpen --;
@@ -369,7 +367,7 @@ bool rfwrite (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
int res = fputs(param+CBotString("\n"), pFile);
@@ -408,7 +406,7 @@ bool rfread (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
char chaine[2000];
int i;
@@ -449,7 +447,7 @@ bool rfeof (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception)
if ( pVar->GetInit() != IS_DEF) { Exception = CBotErrNotOpen; return false; }
- FILE* pFile= (FILE*)pVar->GetValInt();
+ FILE* pFile= reinterpret_cast<FILE*>(pVar->GetValInt());
pResult->SetValInt( feof( pFile ) );
@@ -600,41 +598,36 @@ bool rPoint(CBotVar* pThis, CBotVar* var, CBotVar* pResult, int& Exception)
-// Constructor of robot application.
-
-CRobotMain::CRobotMain(CInstanceManager* iMan)
+//! Constructor of robot application
+CRobotMain::CRobotMain(CInstanceManager* iMan, CApplication* app)
{
- ObjectType type;
- float fValue;
- int iValue, i;
- char* token;
-
m_iMan = iMan;
m_iMan->AddInstance(CLASS_MAIN, this);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
- m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
- m_cloud = (CCloud*)m_iMan->SearchInstance(CLASS_CLOUD);
- m_blitz = (CBlitz*)m_iMan->SearchInstance(CLASS_BLITZ);
- m_planet = (CPlanet*)m_iMan->SearchInstance(CLASS_PLANET);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
-
- m_interface = new CInterface(m_iMan);
- m_terrain = new CTerrain(m_iMan);
- m_model = new CModel(m_iMan);
- m_camera = new CCamera(m_iMan);
- m_displayText = new CDisplayText(m_iMan);
+ m_app = app;
+
+ m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
+ m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_cloud = static_cast<Gfx::CCloud*>(m_iMan->SearchInstance(CLASS_CLOUD));
+ m_lightning = static_cast<Gfx::CLightning*>(m_iMan->SearchInstance(CLASS_BLITZ));
+ m_planet = static_cast<Gfx::CPlanet*>(m_iMan->SearchInstance(CLASS_PLANET));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+
+ m_interface = new Ui::CInterface();
+ m_terrain = new Gfx::CTerrain(m_iMan);
+ m_camera = new Gfx::CCamera(m_iMan);
+ m_displayText = new Ui::CDisplayText();
m_movie = new CMainMovie(m_iMan);
- m_dialog = new CMainDialog(m_iMan);
- m_short = new CMainShort(m_iMan);
- m_map = new CMainMap(m_iMan);
- m_displayInfo = 0;
+ m_dialog = new Ui::CMainDialog(m_iMan);
+ m_short = new Ui::CMainShort();
+ m_map = new Ui::CMainMap();
+ m_displayInfo = nullptr;
m_engine->SetTerrain(m_terrain);
- m_filesDir = m_dialog->RetFilesDir();
+ m_filesDir = m_dialog->GetFilesDir();
m_time = 0.0f;
m_gameTime = 0.0f;
@@ -646,32 +639,33 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
m_visitObject = 0;
m_visitArrow = 0;
m_audioTrack = 0;
- m_bAudioRepeat = true;
+ m_audioRepeat = true;
m_delayWriteMessage = 0;
m_selectObject = 0;
m_infoUsed = 0;
- m_bBeginSatCom = false;
- m_bMovieLock = false;
- m_bSatComLock = false;
- m_bEditLock = false;
- m_bEditFull = false;
- m_bPause = false;
- m_bHilite = false;
- m_bFreePhoto = false;
- m_bShowPos = false;
- m_bSelectInsect = false;
- m_bShowSoluce = false;
- m_bShowAll = false;
- m_bCheatRadar = false;
- m_bFixScene = false;
- m_bTrainerPilot = false;
- m_bSuspend = false;
- m_bFriendAim = false;
- m_bResetCreate = false;
- m_bShortCut = true;
-
- m_engine->SetMovieLock(m_bMovieLock);
+ m_immediatSatCom = false;
+ m_beginSatCom = false;
+ m_movieLock = false;
+ m_satComLock = false;
+ m_editLock = false;
+ m_editFull = false;
+ m_pause = false;
+ m_hilite = false;
+ m_freePhoto = false;
+ m_showPos = false;
+ m_selectInsect = false;
+ m_showSoluce = false;
+ m_showAll = false;
+ m_cheatRadar = false;
+ m_fixScene = false;
+ m_trainerPilot = false;
+ m_suspend = false;
+ m_friendAim = false;
+ m_resetCreate = false;
+ m_shortCut = true;
+
+ m_engine->SetMovieLock(m_movieLock);
m_movie->Flush();
m_movieInfoIndex = -1;
@@ -682,7 +676,10 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
m_endingWinRank = 0;
m_endingLostRank = 0;
- m_bWinTerminate = false;
+ m_winTerminate = false;
+
+ m_joystickDeadzone = 0.2f;
+ SetDefaultInputBindings();
FlushDisplayInfo();
@@ -690,22 +687,27 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
m_windowPos = Math::Point(0.15f, 0.17f);
m_windowDim = Math::Point(0.70f, 0.66f);
- if ( GetLocalProfileFloat("Edit", "FontSize", fValue) ) m_fontSize = fValue;
- if ( GetLocalProfileFloat("Edit", "WindowPos.x", fValue) ) m_windowPos.x = fValue;
- if ( GetLocalProfileFloat("Edit", "WindowPos.y", fValue) ) m_windowPos.y = fValue;
- if ( GetLocalProfileFloat("Edit", "WindowDim.x", fValue) ) m_windowDim.x = fValue;
- if ( GetLocalProfileFloat("Edit", "WindowDim.y", fValue) ) m_windowDim.y = fValue;
+ // TODO: profile
+ // float fValue;
+ // int iValue;
+
+ // if (GetLocalProfileFloat("Edit", "FontSize", fValue)) m_fontSize = fValue;
+ // if (GetLocalProfileFloat("Edit", "WindowPos.x", fValue)) m_windowPos.x = fValue;
+ // if (GetLocalProfileFloat("Edit", "WindowPos.y", fValue)) m_windowPos.y = fValue;
+ // if (GetLocalProfileFloat("Edit", "WindowDim.x", fValue)) m_windowDim.x = fValue;
+ // if (GetLocalProfileFloat("Edit", "WindowDim.y", fValue)) m_windowDim.y = fValue;
m_IOPublic = false;
m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f);
m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle
m_IOPos.y = (1.0f-m_IODim.y)/2.0f;
- if ( GetLocalProfileInt ("Edit", "IOPublic", iValue) ) m_IOPublic = iValue;
- if ( GetLocalProfileFloat("Edit", "IOPos.x", fValue) ) m_IOPos.x = fValue;
- if ( GetLocalProfileFloat("Edit", "IOPos.y", fValue) ) m_IOPos.y = fValue;
- if ( GetLocalProfileFloat("Edit", "IODim.x", fValue) ) m_IODim.x = fValue;
- if ( GetLocalProfileFloat("Edit", "IODim.y", fValue) ) m_IODim.y = fValue;
+ /* TODO: profile
+ if (GetLocalProfileInt ("Edit", "IOPublic", iValue)) m_IOPublic = iValue;
+ if (GetLocalProfileFloat("Edit", "IOPos.x", fValue)) m_IOPos.x = fValue;
+ if (GetLocalProfileFloat("Edit", "IOPos.y", fValue)) m_IOPos.y = fValue;
+ if (GetLocalProfileFloat("Edit", "IODim.x", fValue)) m_IODim.x = fValue;
+ if (GetLocalProfileFloat("Edit", "IODim.y", fValue)) m_IODim.y = fValue; */
m_short->FlushShortcuts();
InitEye();
@@ -722,14 +724,15 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
g_unit = 4.0f;
m_gamerName[0] = 0;
- GetProfile()->GetLocalProfileString("Gamer", "LastName", m_gamerName, 100);
+ /* TODO: profile
+ GetLocalProfileString("Gamer", "LastName", m_gamerName, 100); */
SetGlobalGamerName(m_gamerName);
ReadFreeParam();
m_dialog->SetupRecall();
- for ( i=0 ; i<MAXSHOWLIMIT ; i++ )
+ for (int i = 0; i < MAXSHOWLIMIT; i++)
{
- m_showLimit[i].bUsed = false;
+ m_showLimit[i].used = false;
m_showLimit[i].total = 0;
m_showLimit[i].link = 0;
}
@@ -737,19 +740,16 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
CBotProgram::SetTimer(100);
CBotProgram::Init();
- for ( i=0 ; i<OBJECT_MAX ; i++ )
+ for (int i = 0; i < OBJECT_MAX; i++)
{
- type = (ObjectType)i;
- token = RetObjectName(type);
- if ( token[0] != 0 )
- {
+ ObjectType type = static_cast<ObjectType>(i);
+ const char* token = GetObjectName(type);
+ if (token[0] != 0)
CBotProgram::DefineNum(token, type);
- }
- token = RetObjectAlias(type);
- if ( token[0] != 0 )
- {
+
+ token = GetObjectAlias(type);
+ if (token[0] != 0)
CBotProgram::DefineNum(token, type);
- }
}
CBotProgram::DefineNum("White", 0);
@@ -778,17 +778,18 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
CBotProgram::DefineNum("Behind", TMA_FBACK);
CBotProgram::DefineNum("EnergyCell", TMA_POWER);
- CBotProgram::DefineNum("DisplayError", TT_ERROR);
- CBotProgram::DefineNum("DisplayWarning", TT_WARNING);
- CBotProgram::DefineNum("DisplayInfo", TT_INFO);
- CBotProgram::DefineNum("DisplayMessage", TT_MESSAGE);
+ CBotProgram::DefineNum("DisplayError", Ui::TT_ERROR);
+ CBotProgram::DefineNum("DisplayWarning", Ui::TT_WARNING);
+ CBotProgram::DefineNum("DisplayInfo", Ui::TT_INFO);
+ CBotProgram::DefineNum("DisplayMessage", Ui::TT_MESSAGE);
CBotProgram::DefineNum("FilterNone", FILTER_NONE);
CBotProgram::DefineNum("FilterOnlyLanding", FILTER_ONLYLANDING);
CBotProgram::DefineNum("FilterOnlyFliying", FILTER_ONLYFLYING);
- // Add the class Point.
CBotClass* bc;
+
+ // Add the class Point.
bc = new CBotClass("point", NULL, true); // intrinsic class
bc->AddItem("x", CBotTypFloat);
bc->AddItem("y", CBotTypFloat);
@@ -817,68 +818,166 @@ CRobotMain::CRobotMain(CInstanceManager* iMan)
CScript::InitFonctions();
}
-// Destructor of robot application.
-
+//! Destructor of robot application
CRobotMain::~CRobotMain()
{
+ delete m_displayText;
+ m_displayText = nullptr;
+
+ delete m_interface;
+ m_interface = nullptr;
+
+ delete m_terrain;
+ m_terrain = nullptr;
+
+ delete m_camera;
+ m_camera = nullptr;
+
+ delete m_displayText;
+ m_displayText = nullptr;
+
delete m_movie;
+ m_movie = nullptr;
+
delete m_dialog;
+ m_dialog = nullptr;
+
delete m_short;
+ m_short = nullptr;
+
delete m_map;
- delete m_terrain;
- delete m_model;
-}
+ m_map = nullptr;
+ m_iMan = nullptr;
+ m_app = nullptr;
+}
-// Creates the file colobot.ini at the first time.
+//! Creates the file colobot.ini at the first time
void CRobotMain::CreateIni()
{
- int iValue;
+ /* TODO: profile
+ int iValue;
+ // colobot.ini doesn't exist?
+ if (!GetLocalProfileInt("Setup", "TotoMode", iValue))
+ m_dialog->SetupMemorize();*/
+}
- // colobot.ini don't exist?
- if ( !GetLocalProfileInt("Setup", "TotoMode", iValue) )
+void CRobotMain::SetDefaultInputBindings()
+{
+ for (int i = 0; i < INPUT_SLOT_MAX; i++)
{
- m_dialog->SetupMemorize();
+ m_inputBindings[i].key = m_inputBindings[i].joy = KEY_INVALID;
}
+
+ for (int i = 0; i < JOY_AXIS_SLOT_MAX; i++)
+ {
+ m_joyAxisBindings[i].axis = AXIS_INVALID;
+ m_joyAxisBindings[i].invert = false;
+ }
+
+ m_inputBindings[INPUT_SLOT_LEFT ].key = KEY(LEFT);
+ m_inputBindings[INPUT_SLOT_RIGHT ].key = KEY(RIGHT);
+ m_inputBindings[INPUT_SLOT_UP ].key = KEY(UP);
+ m_inputBindings[INPUT_SLOT_DOWN ].key = KEY(DOWN);
+ m_inputBindings[INPUT_SLOT_GUP ].key = VIRTUAL_KMOD(SHIFT);
+ m_inputBindings[INPUT_SLOT_GDOWN ].key = VIRTUAL_KMOD(CTRL);
+ m_inputBindings[INPUT_SLOT_CAMERA ].key = KEY(SPACE);
+ m_inputBindings[INPUT_SLOT_CAMERA ].joy = VIRTUAL_JOY(2);
+ m_inputBindings[INPUT_SLOT_DESEL ].key = KEY(KP0);
+ m_inputBindings[INPUT_SLOT_DESEL ].joy = VIRTUAL_JOY(6);
+ m_inputBindings[INPUT_SLOT_ACTION ].key = KEY(RETURN);
+ m_inputBindings[INPUT_SLOT_ACTION ].joy = VIRTUAL_JOY(1);
+ m_inputBindings[INPUT_SLOT_NEAR ].key = KEY(KP_PLUS);
+ m_inputBindings[INPUT_SLOT_NEAR ].joy = VIRTUAL_JOY(5);
+ m_inputBindings[INPUT_SLOT_AWAY ].key = KEY(KP_MINUS);
+ m_inputBindings[INPUT_SLOT_AWAY ].joy = VIRTUAL_JOY(4);
+ m_inputBindings[INPUT_SLOT_NEXT ].key = KEY(TAB);
+ m_inputBindings[INPUT_SLOT_NEXT ].joy = VIRTUAL_JOY(3);
+ m_inputBindings[INPUT_SLOT_HUMAN ].key = KEY(HOME);
+ m_inputBindings[INPUT_SLOT_HUMAN ].joy = VIRTUAL_JOY(7);
+ m_inputBindings[INPUT_SLOT_QUIT ].key = KEY(ESCAPE);
+ m_inputBindings[INPUT_SLOT_HELP ].key = KEY(F1);
+ m_inputBindings[INPUT_SLOT_PROG ].key = KEY(F2);
+ m_inputBindings[INPUT_SLOT_CBOT ].key = KEY(F3);
+ m_inputBindings[INPUT_SLOT_VISIT ].key = KEY(KP_PERIOD);
+ m_inputBindings[INPUT_SLOT_SPEED10].key = KEY(F4);
+ m_inputBindings[INPUT_SLOT_SPEED15].key = KEY(F5);
+ m_inputBindings[INPUT_SLOT_SPEED20].key = KEY(F6);
+
+ m_joyAxisBindings[JOY_AXIS_SLOT_X].axis = 0;
+ m_joyAxisBindings[JOY_AXIS_SLOT_Y].axis = 1;
+ m_joyAxisBindings[JOY_AXIS_SLOT_Z].axis = 2;
}
+void CRobotMain::SetInputBinding(InputSlot slot, InputBinding binding)
+{
+ unsigned int index = static_cast<unsigned int>(slot);
+ assert(index >= 0 && index < INPUT_SLOT_MAX);
+ m_inputBindings[index] = binding;
+}
-// Changes phase.
+const InputBinding& CRobotMain::GetInputBinding(InputSlot slot)
+{
+ unsigned int index = static_cast<unsigned int>(slot);
+ assert(index >= 0 && index < INPUT_SLOT_MAX);
+ return m_inputBindings[index];
+}
-void CRobotMain::ChangePhase(Phase phase)
+void CRobotMain::SetJoyAxisBinding(JoyAxisSlot slot, JoyAxisBinding binding)
+{
+ unsigned int index = static_cast<unsigned int>(slot);
+ assert(index >= 0 && index < JOY_AXIS_SLOT_MAX);
+ m_joyAxisBindings[index] = binding;
+}
+
+const JoyAxisBinding& CRobotMain::GetJoyAxisBinding(JoyAxisSlot slot)
+{
+ unsigned int index = static_cast<unsigned int>(slot);
+ assert(index >= 0 && index < JOY_AXIS_SLOT_MAX);
+ return m_joyAxisBindings[index];
+}
+
+void CRobotMain::SetJoystickDeadzone(float zone)
+{
+ m_joystickDeadzone = zone;
+}
+
+float CRobotMain::GetJoystickDeadzone()
{
- CEdit* pe;
- CButton* pb;
- D3DCOLORVALUE color;
- Math::Point pos, dim, ddim;
- float ox, oy, sx, sy;
- char* read;
- int rank, numTry;
- bool bLoading;
+ return m_joystickDeadzone;
+}
+
+void CRobotMain::ResetKeyStates()
+{
+ m_keyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
+ m_joyMotion = Math::Vector(0.0f, 0.0f, 0.0f);
+}
- if ( m_phase == PHASE_SIMUL ) // ends a simulation?
+//! Changes phase
+void CRobotMain::ChangePhase(Phase phase)
+{
+ if (m_phase == PHASE_SIMUL) // ends a simulation?
{
SaveAllScript();
m_sound->StopMusic();
- m_camera->SetObject(0);
+ m_camera->SetControllingObject(0);
-#if _SCHOOL
+/* TODO: #if _SCHOOL
if ( true )
-#else
- if ( m_gameTime > 10.0f ) // did you play at least 10 seconds?
-#endif
+#else*/
+ if (m_gameTime > 10.0f) // did you play at least 10 seconds?
{
- rank = m_dialog->RetSceneRank();
- numTry = m_dialog->RetGamerInfoTry(rank);
+ int rank = m_dialog->GetSceneRank();
+ int numTry = m_dialog->GetGamerInfoTry(rank);
m_dialog->SetGamerInfoTry(rank, numTry+1);
m_dialog->WriteGamerInfo();
}
}
- if ( phase == PHASE_WIN ) // wins a simulation?
+ if (phase == PHASE_WIN) // wins a simulation?
{
- rank = m_dialog->RetSceneRank();
+ int rank = m_dialog->GetSceneRank();
m_dialog->SetGamerInfoPassed(rank, true);
m_dialog->NextMission(); // passes to the next mission
m_dialog->WriteGamerInfo();
@@ -889,186 +988,119 @@ void CRobotMain::ChangePhase(Phase phase)
m_phase = phase;
m_winDelay = 0.0f;
m_lostDelay = 0.0f;
- m_bBeginSatCom = false;
- m_bMovieLock = false;
- m_bSatComLock = false;
- m_bEditLock = false;
- m_bFreePhoto = false;
- m_bResetCreate = false;
-
- m_engine->SetMovieLock(m_bMovieLock);
+ m_beginSatCom = false;
+ m_movieLock = false;
+ m_satComLock = false;
+ m_editLock = false;
+ m_freePhoto = false;
+ m_resetCreate = false;
+
+ m_engine->SetMovieLock(m_movieLock);
ChangePause(false);
FlushDisplayInfo();
m_engine->SetRankView(0);
m_engine->FlushObject();
- color.r = color.g = color.b = color.a = 0.0f;
- m_engine->SetWaterAddColor(color);
+ m_engine->SetWaterAddColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f));
m_engine->SetBackground("");
m_engine->SetBackForce(false);
- m_engine->SetFrontsizeName("");
+ m_engine->SetForegroundName("");
m_engine->SetOverColor();
- m_engine->GroundMarkDelete(0);
+ m_engine->DeleteGroundMark(0);
SetSpeed(1.0f);
m_terrain->SetWind(Math::Vector(0.0f, 0.0f, 0.0f));
m_terrain->FlushBuildingLevel();
m_terrain->FlushFlyingLimit();
- m_light->FlushLight();
- m_particule->FlushParticule();
+ m_lightMan->FlushLights();
+ m_particle->FlushParticle();
m_water->Flush();
m_cloud->Flush();
- m_blitz->Flush();
+ m_lightning->Flush();
m_planet->Flush();
m_iMan->Flush(CLASS_OBJECT);
m_iMan->Flush(CLASS_PHYSICS);
m_iMan->Flush(CLASS_BRAIN);
m_iMan->Flush(CLASS_PYRO);
- m_model->StopUserAction();
m_interface->Flush();
ClearInterface();
FlushNewScriptName();
m_sound->SetListener(Math::Vector(0.0f, 0.0f, 0.0f), Math::Vector(0.0f, 0.0f, 1.0f));
- m_camera->SetType(CAMERA_DIALOG);
+ m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
m_movie->Flush();
m_movieInfoIndex = -1;
m_cameraPan = 0.0f;
m_cameraZoom = 0.0f;
- m_bShortCut = true;
+ m_shortCut = true;
+
+ Math::Point dim, pos;
// Creates and hide the command console.
dim.x = 200.0f/640.0f;
dim.y = 18.0f/480.0f;
pos.x = 50.0f/640.0f;
pos.y = 452.0f/480.0f;
- pe = m_interface->CreateEdit(pos, dim, 0, EVENT_CMD);
- if ( pe == 0 ) return;
- pe->ClearState(STATE_VISIBLE);
- m_bCmdEdit = false; // hidden for now
+ Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->CreateEdit(pos, dim, 0, EVENT_CMD));
+ if (pe == nullptr) return;
+ pe->ClearState(Ui::STATE_VISIBLE);
+ m_cmdEdit = false; // hidden for now
// Creates the speedometer.
-#if _TEEN
+/* TODO: #if _TEEN
dim.x = 30.0f/640.0f;
dim.y = 20.0f/480.0f;
pos.x = 4.0f/640.0f;
pos.y = 454.0f/480.0f;
-#else
+#else*/
dim.x = 30.0f/640.0f;
dim.y = 20.0f/480.0f;
pos.x = 4.0f/640.0f;
pos.y = 426.0f/480.0f;
-#endif
- pb = m_interface->CreateButton(pos, dim, 0, EVENT_SPEED);
- if ( pb == 0 ) return;
- pb->SetState(STATE_SIMPLY);
- pb->ClearState(STATE_VISIBLE);
+
+ Ui::CButton* pb = m_interface->CreateButton(pos, dim, 0, EVENT_SPEED);
+ if (pb == nullptr) return;
+ pb->SetState(Ui::STATE_SIMPLY);
+ pb->ClearState(Ui::STATE_VISIBLE);
m_dialog->ChangePhase(m_phase);
dim.x = 32.0f/640.0f;
dim.y = 32.0f/480.0f;
- ox = 3.0f/640.0f;
- oy = 3.0f/480.0f;
- sx = (32.0f+2.0f)/640.0f;
- sy = (32.0f+2.0f)/480.0f;
+ float ox = 3.0f/640.0f;
+ float oy = 3.0f/480.0f;
+ float sx = (32.0f+2.0f)/640.0f;
+ float sy = (32.0f+2.0f)/480.0f;
- if ( m_phase != PHASE_PERSO )
+ if (m_phase != PHASE_PERSO)
{
m_engine->SetDrawWorld(true);
m_engine->SetDrawFront(false);
- m_bFixScene = false;
+ m_fixScene = false;
}
- if ( m_phase == PHASE_INIT )
+ if (m_phase == PHASE_INIT)
{
-#if _NEWLOOK
- m_engine->FreeTexture("generna.tga");
- m_engine->FreeTexture("genernb.tga");
- m_engine->FreeTexture("genernc.tga");
- m_engine->FreeTexture("genernd.tga");
-#else
-#if _FRENCH
-#if _DEMO
- m_engine->FreeTexture("genedfa.tga");
- m_engine->FreeTexture("genedfb.tga");
- m_engine->FreeTexture("genedfc.tga");
- m_engine->FreeTexture("genedfd.tga");
-#else
- m_engine->FreeTexture("generfa.tga");
- m_engine->FreeTexture("generfb.tga");
- m_engine->FreeTexture("generfc.tga");
- m_engine->FreeTexture("generfd.tga");
-#endif
-#endif
-#if _ENGLISH
-#if _DEMO
- m_engine->FreeTexture("genedea.tga");
- m_engine->FreeTexture("genedeb.tga");
- m_engine->FreeTexture("genedec.tga");
- m_engine->FreeTexture("geneded.tga");
-#else
- m_engine->FreeTexture("generea.tga");
- m_engine->FreeTexture("genereb.tga");
- m_engine->FreeTexture("generec.tga");
- m_engine->FreeTexture("genered.tga");
-#endif
-#endif
-#if _GERMAN
-#if _DEMO
- m_engine->FreeTexture("genedda.tga");
- m_engine->FreeTexture("geneddb.tga");
- m_engine->FreeTexture("geneddc.tga");
- m_engine->FreeTexture("geneddd.tga");
-#else
- m_engine->FreeTexture("generea.tga");
- m_engine->FreeTexture("genereb.tga");
- m_engine->FreeTexture("generec.tga");
- m_engine->FreeTexture("genered.tga");
-#endif
-#endif
-#if _WG
-#if _DEMO
- m_engine->FreeTexture("genedda.tga");
- m_engine->FreeTexture("geneddb.tga");
- m_engine->FreeTexture("geneddc.tga");
- m_engine->FreeTexture("geneddd.tga");
-#else
- m_engine->FreeTexture("generda.tga");
- m_engine->FreeTexture("generdb.tga");
- m_engine->FreeTexture("generdc.tga");
- m_engine->FreeTexture("generdd.tga");
-#endif
-#endif
-#if _POLISH
-#if _DEMO
- m_engine->FreeTexture("genedpa.tga");
- m_engine->FreeTexture("genedpb.tga");
- m_engine->FreeTexture("genedpc.tga");
- m_engine->FreeTexture("genedpd.tga");
-#else
- m_engine->FreeTexture("generpa.tga");
- m_engine->FreeTexture("generpb.tga");
- m_engine->FreeTexture("generpc.tga");
- m_engine->FreeTexture("generpd.tga");
-#endif
-#endif
-#endif
+ // TODO: replace with new textures once done
+ m_engine->DeleteTexture("generna.png");
+ m_engine->DeleteTexture("genernb.png");
+ m_engine->DeleteTexture("genernc.png");
+ m_engine->DeleteTexture("genernd.png");
}
- if ( m_phase == PHASE_SIMUL )
+ if (m_phase == PHASE_SIMUL)
{
- m_engine->FreeTexture("inter01a.tga");
- m_engine->FreeTexture("inter01b.tga");
- m_engine->FreeTexture("inter01c.tga");
- m_engine->FreeTexture("inter01d.tga");
+ m_engine->DeleteTexture("inter01a.png");
+ m_engine->DeleteTexture("inter01b.png");
+ m_engine->DeleteTexture("inter01c.png");
+ m_engine->DeleteTexture("inter01d.png");
- read = m_dialog->RetSceneRead();
- bLoading = (read[0] != 0);
+ char* read = m_dialog->GetSceneRead();
+ bool loading = (read[0] != 0);
m_map->CreateMap();
- CreateScene(m_dialog->RetSceneSoluce(), false, false); // interactive scene
- if ( m_bMapImage )
- {
+ CreateScene(m_dialog->GetSceneSoluce(), false, false); // interactive scene
+ if (m_mapImage)
m_map->SetFixImage(m_mapFilename);
- }
+
+ Math::Point ddim;
pos.x = 620.0f/640.0f;
pos.y = 460.0f/480.0f;
@@ -1076,41 +1108,40 @@ void CRobotMain::ChangePhase(Phase phase)
ddim.y = 20.0f/480.0f;
m_interface->CreateButton(pos, ddim, 11, EVENT_BUTTON_QUIT);
- if ( m_bImmediatSatCom && !bLoading &&
- m_infoFilename[SATCOM_HUSTON][0] != 0 )
- {
+ if (m_immediatSatCom && !loading &&
+ m_infoFilename[SATCOM_HUSTON][0] != 0)
StartDisplayInfo(SATCOM_HUSTON, false); // shows the instructions
- }
m_sound->StopMusic();
- if ( !m_bBase || bLoading ) StartMusic();
+ if (!m_base || loading) StartMusic();
}
- if ( m_phase == PHASE_WIN )
+ if (m_phase == PHASE_WIN)
{
- if ( m_endingWinRank == -1 )
+ if (m_endingWinRank == -1)
{
ChangePhase(PHASE_TERM);
}
else
{
-#if _TEEN
- m_bWinTerminate = (m_endingWinRank == 900);
+/* TODO: #if _TEEN
+ m_winTerminate = (m_endingWinRank == 900);
m_dialog->SetSceneName("teenw");
-#else
- m_bWinTerminate = (m_endingWinRank == 904);
+#else*/
+ m_winTerminate = (m_endingWinRank == 904);
m_dialog->SetSceneName("win");
-#endif
+
m_dialog->SetSceneRank(m_endingWinRank);
CreateScene(false, true, false); // sets scene
pos.x = ox+sx*1; pos.y = oy+sy*1;
+ Math::Point ddim;
ddim.x = dim.x*2; ddim.y = dim.y*2;
m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK);
- if ( m_bWinTerminate )
+ if (m_winTerminate)
{
-#if _TEEN
+/* TODO: #if _TEEN
pos.x = ox+sx*3; pos.y = oy+sy*1;
ddim.x = dim.x*15; ddim.y = dim.y*2;
pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0);
@@ -1118,16 +1149,16 @@ void CRobotMain::ChangePhase(Phase phase)
pe->SetEditCap(false);
pe->SetHiliteCap(false);
pe->ReadText("help\\teenw.txt");
-#else
+#else*/
+
pos.x = ox+sx*3; pos.y = oy+sy*0.2f;
ddim.x = dim.x*15; ddim.y = dim.y*3.0f;
pe = m_interface->CreateEdit(pos, ddim, 0, EVENT_EDIT0);
pe->SetGenericMode(true);
- pe->SetFontType(FONT_COLOBOT);
+ pe->SetFontType(Gfx::FONT_COLOBOT);
pe->SetEditCap(false);
pe->SetHiliteCap(false);
pe->ReadText("help\\win.txt");
-#endif
}
else
{
@@ -1138,20 +1169,21 @@ void CRobotMain::ChangePhase(Phase phase)
StartMusic();
}
- if ( m_phase == PHASE_LOST )
+ if (m_phase == PHASE_LOST)
{
- if ( m_endingLostRank == -1 )
+ if (m_endingLostRank == -1)
{
ChangePhase(PHASE_TERM);
}
else
{
- m_bWinTerminate = false;
+ m_winTerminate = false;
m_dialog->SetSceneName("lost");
m_dialog->SetSceneRank(m_endingLostRank);
CreateScene(false, true, false); // sets scene
pos.x = ox+sx*1; pos.y = oy+sy*1;
+ Math::Point ddim;
ddim.x = dim.x*2; ddim.y = dim.y*2;
m_interface->CreateButton(pos, ddim, 16, EVENT_BUTTON_OK);
m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f), 15.0f, 60.0f, 1000.0f);
@@ -1160,49 +1192,89 @@ void CRobotMain::ChangePhase(Phase phase)
StartMusic();
}
- if ( m_phase == PHASE_MODEL )
- {
- pos.x = ox+sx*0; pos.y = oy+sy*0;
- m_interface->CreateButton(pos, dim, 11, EVENT_BUTTON_CANCEL);
+ if (m_phase == PHASE_LOADING)
+ m_engine->SetMouseVisible(false);
+ else
+ m_engine->SetMouseVisible(true);
- CreateModel();
- }
+ m_engine->LoadAllTextures();
+}
+
+//! Processes an event
+bool CRobotMain::EventProcess(Event &event)
+{
+ /* Motion vector management */
- if ( m_phase == PHASE_LOADING )
+ if (event.type == EVENT_KEY_DOWN)
{
- m_engine->SetMouseHide(true);
+ if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).key) m_keyMotion.y = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).joy) m_keyMotion.y = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).key) m_keyMotion.y = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).joy) m_keyMotion.y = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).key) m_keyMotion.x = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).joy) m_keyMotion.x = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).key) m_keyMotion.x = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).joy) m_keyMotion.x = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).key) m_keyMotion.z = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).joy) m_keyMotion.z = 1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).key) m_keyMotion.z = -1.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).joy) m_keyMotion.z = -1.0f;
}
- else
+ else if (event.type == EVENT_KEY_UP)
{
- m_engine->SetMouseHide(false);
+ if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).key) m_keyMotion.y = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_UP ).joy) m_keyMotion.y = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).key) m_keyMotion.y = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DOWN ).joy) m_keyMotion.y = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).key) m_keyMotion.x = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_LEFT ).joy) m_keyMotion.x = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).key) m_keyMotion.x = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_RIGHT).joy) m_keyMotion.x = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).key) m_keyMotion.z = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GUP ).joy) m_keyMotion.z = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).key) m_keyMotion.z = 0.0f;
+ if (event.key.key == GetInputBinding(INPUT_SLOT_GDOWN).joy) m_keyMotion.z = 0.0f;
}
+ else if (event.type == EVENT_JOY_AXIS)
+ {
+ if (event.joyAxis.axis == GetJoyAxisBinding(JOY_AXIS_SLOT_X).axis)
+ {
+ m_joyMotion.x = Math::Neutral(event.joyAxis.value / 32768.0f, m_joystickDeadzone);
+ if (GetJoyAxisBinding(JOY_AXIS_SLOT_X).invert)
+ m_joyMotion.x *= -1.0f;
+ }
- m_engine->LoadAllTexture();
-}
+ if (event.joyAxis.axis == GetJoyAxisBinding(JOY_AXIS_SLOT_Y).axis)
+ {
+ m_joyMotion.y = Math::Neutral(event.joyAxis.value / 32768.0f, m_joystickDeadzone);
+ if (GetJoyAxisBinding(JOY_AXIS_SLOT_Y).invert)
+ m_joyMotion.y *= -1.0f;
+ }
+ if (event.joyAxis.axis == GetJoyAxisBinding(JOY_AXIS_SLOT_Z).axis)
+ {
+ m_joyMotion.z = Math::Neutral(event.joyAxis.value / 32768.0f, m_joystickDeadzone);
+ if (GetJoyAxisBinding(JOY_AXIS_SLOT_Z).invert)
+ m_joyMotion.z *= -1.0f;
+ }
+ }
+
+ event.motionInput = Math::Clamp(m_joyMotion + m_keyMotion, Math::Vector(-1.0f, -1.0f, -1.0f), Math::Vector(1.0f, 1.0f, 1.0f));
-// Processes an event.
-bool CRobotMain::EventProcess(const Event &event)
-{
- CEdit* pe;
- CObject* pObj;
- Event newEvent;
- MainMovieType type;
- int i;
- if ( event.event == EVENT_FRAME )
+ if (event.type == EVENT_FRAME)
{
- if ( !m_movie->EventProcess(event) ) // end of the movie?
+ if (!m_movie->EventProcess(event)) // end of the movie?
{
- type = m_movie->RetStopType();
- if ( type == MM_SATCOMopen )
+ MainMovieType type = m_movie->GetStopType();
+ if (type == MM_SATCOMopen)
{
ChangePause(false);
SelectObject(m_infoObject, false); // hands over the command buttons
- m_map->ShowMap(m_bMapShow);
+ m_map->ShowMap(m_mapShow);
m_displayText->HideText(false);
- i = m_movieInfoIndex;
+ int i = m_movieInfoIndex;
StartDisplayInfo(m_movieInfoIndex, false);
m_movieInfoIndex = i;
}
@@ -1213,59 +1285,48 @@ bool CRobotMain::EventProcess(const Event &event)
RemoteCamera(m_cameraPan, m_cameraZoom, event.rTime);
m_interface->EventProcess(event);
- if ( m_displayInfo != 0 ) // current edition?
- {
+ if (m_displayInfo != nullptr) // current edition?
m_displayInfo->EventProcess(event);
- }
+
return EventFrame(event);
}
// Management of the console.
-#if 0
- if ( m_phase != PHASE_NAME &&
- !m_movie->IsExist() &&
- event.event == EVENT_KEYDOWN &&
- event.param == VK_PAUSE &&
- (event.keyState&KS_CONTROL) != 0 )
-#else
- if ( m_phase != PHASE_NAME &&
- !m_movie->IsExist() &&
- event.event == EVENT_KEYDOWN &&
- event.param == VK_CANCEL ) // Ctrl+Pause ?
-#endif
- {
- pe = (CEdit*)m_interface->SearchControl(EVENT_CMD);
- if ( pe == 0 ) return false;
- pe->SetState(STATE_VISIBLE);
+ if (m_phase != PHASE_NAME &&
+ !m_movie->IsExist() &&
+ event.type == EVENT_KEY_DOWN &&
+ event.key.key == KEY(PAUSE)) // Pause ?
+ {
+ Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
+ if (pe == nullptr) return false;
+ pe->SetState(Ui::STATE_VISIBLE);
pe->SetFocus(true);
- if ( m_phase == PHASE_SIMUL ) ChangePause(true);
- m_bCmdEdit = true;
+ if (m_phase == PHASE_SIMUL) ChangePause(true);
+ m_cmdEdit = true;
return false;
}
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_RETURN && m_bCmdEdit )
+ if (event.type == EVENT_KEY_DOWN &&
+ event.key.key == KEY(RETURN) && m_cmdEdit)
{
- char cmd[50];
- pe = (CEdit*)m_interface->SearchControl(EVENT_CMD);
- if ( pe == 0 ) return false;
+ char cmd[50];
+ Ui::CEdit* pe = dynamic_cast<Ui::CEdit*>(m_interface->SearchControl(EVENT_CMD));
+ if (pe == nullptr) return false;
pe->GetText(cmd, 50);
pe->SetText("");
- pe->ClearState(STATE_VISIBLE);
- if ( m_phase == PHASE_SIMUL ) ChangePause(false);
+ pe->ClearState(Ui::STATE_VISIBLE);
+ if (m_phase == PHASE_SIMUL) ChangePause(false);
ExecuteCmd(cmd);
- m_bCmdEdit = false;
+ m_cmdEdit = false;
return false;
}
// Management of the speed change.
- if ( event.event == EVENT_SPEED )
- {
+ if (event.type == EVENT_SPEED)
SetSpeed(1.0f);
- }
- if ( !m_dialog->EventProcess(event) )
+ if (!m_dialog->EventProcess(event))
{
- if ( event.event == EVENT_MOUSEMOVE )
+ if (event.type == EVENT_MOUSE_MOVE)
{
m_lastMousePos = event.pos;
HiliteObject(event.pos);
@@ -1273,241 +1334,217 @@ bool CRobotMain::EventProcess(const Event &event)
return false;
}
- if ( !m_displayText->EventProcess(event) )
- {
+ if (!m_displayText->EventProcess(event))
return false;
- }
- if ( event.event == EVENT_MOUSEMOVE )
+ if (event.type == EVENT_MOUSE_MOVE)
{
m_lastMousePos = event.pos;
HiliteObject(event.pos);
}
- if ( m_displayInfo != 0 ) // current info?
+ if (m_displayInfo != nullptr) // current info?
{
m_displayInfo->EventProcess(event);
- if ( event.event == EVENT_KEYDOWN )
+ if (event.type == EVENT_KEY_DOWN)
{
- if ( event.param == m_engine->RetKey(KEYRANK_HELP, 0) ||
- event.param == m_engine->RetKey(KEYRANK_HELP, 1) ||
- event.param == m_engine->RetKey(KEYRANK_PROG, 0) ||
- event.param == m_engine->RetKey(KEYRANK_PROG, 1) ||
- event.param == VK_ESCAPE )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy ||
+ event.key.key == GetInputBinding(INPUT_SLOT_PROG).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy ||
+ event.key.key == KEY(ESCAPE))
{
StopDisplayInfo();
}
}
- if ( event.event == EVENT_OBJECT_INFOOK )
- {
+
+ if (event.type == EVENT_OBJECT_INFOOK)
StopDisplayInfo();
- }
+
return false;
}
+ CObject* obj;
+
// Simulation phase of the game
- if ( m_phase == PHASE_SIMUL )
+ if (m_phase == PHASE_SIMUL)
{
UpdateInfoText();
- if ( !m_bEditFull )
- {
+ if (!m_editFull)
m_camera->EventProcess(event);
- }
- switch( event.event )
+ switch (event.type)
{
- case EVENT_KEYDOWN:
- KeyCamera(event.event, event.param);
+ case EVENT_KEY_DOWN:
+ KeyCamera(event.type, event.key.key);
HiliteClear();
- if ( event.param == VK_F11 )
+ if (event.key.key == KEY(F11))
{
- m_particule->WriteWheelTrace("Savegame\\t.bmp", 256, 256, Math::Vector(16.0f, 0.0f, -368.0f), Math::Vector(140.0f, 0.0f, -248.0f));
+ m_particle->WriteWheelTrace("Savegame\\t.png", 256, 256, Math::Vector(16.0f, 0.0f, -368.0f), Math::Vector(140.0f, 0.0f, -248.0f));
return false;
}
- if ( m_bEditLock ) // current edition?
+ if (m_editLock) // current edition?
{
- if ( event.param == m_engine->RetKey(KEYRANK_HELP, 0) ||
- event.param == m_engine->RetKey(KEYRANK_HELP, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy)
{
StartDisplayInfo(SATCOM_HUSTON, false);
return false;
}
- if ( event.param == m_engine->RetKey(KEYRANK_PROG, 0) ||
- event.param == m_engine->RetKey(KEYRANK_PROG, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy)
{
StartDisplayInfo(SATCOM_PROG, false);
return false;
}
break;
}
- if ( m_bMovieLock ) // current movie?
+ if (m_movieLock) // current movie?
{
- if ( event.param == m_engine->RetKey(KEYRANK_QUIT, 0) ||
- event.param == m_engine->RetKey(KEYRANK_QUIT, 1) ||
- event.param == VK_ESCAPE )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy ||
+ event.key.key == KEY(ESCAPE))
{
AbortMovie();
}
return false;
}
- if ( m_camera->RetType() == CAMERA_VISIT )
+ if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
{
- if ( event.param == m_engine->RetKey(KEYRANK_VISIT, 0) ||
- event.param == m_engine->RetKey(KEYRANK_VISIT, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy)
{
StartDisplayVisit(EVENT_NULL);
}
- if ( event.param == m_engine->RetKey(KEYRANK_QUIT, 0) ||
- event.param == m_engine->RetKey(KEYRANK_QUIT, 1) ||
- event.param == VK_ESCAPE )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy ||
+ event.key.key == KEY(ESCAPE))
{
StopDisplayVisit();
}
return false;
}
- if ( event.param == m_engine->RetKey(KEYRANK_QUIT, 0) ||
- event.param == m_engine->RetKey(KEYRANK_QUIT, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_QUIT).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_QUIT).joy)
{
- if ( m_movie->IsExist() )
- {
+ if (m_movie->IsExist())
StartDisplayInfo(SATCOM_HUSTON, false);
- }
- else if ( m_winDelay > 0.0f )
- {
+ else if (m_winDelay > 0.0f)
ChangePhase(PHASE_WIN);
- }
- else if ( m_lostDelay > 0.0f )
- {
+ else if (m_lostDelay > 0.0f)
ChangePhase(PHASE_LOST);
- }
else
- {
m_dialog->StartAbort(); // do you want to leave?
- }
}
- if ( event.param == VK_PAUSE )
+ if (event.key.key == KEY(PAUSE))
{
- if ( !m_bMovieLock && !m_bEditLock && !m_bCmdEdit &&
- m_camera->RetType() != CAMERA_VISIT &&
- !m_movie->IsExist() )
+ if (!m_movieLock && !m_editLock && !m_cmdEdit &&
+ m_camera->GetType() != Gfx::CAM_TYPE_VISIT &&
+ !m_movie->IsExist())
{
- ChangePause(!m_engine->RetPause());
+ ChangePause(!m_engine->GetPause());
}
}
- if ( event.param == m_engine->RetKey(KEYRANK_CAMERA, 0) ||
- event.param == m_engine->RetKey(KEYRANK_CAMERA, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_CAMERA).joy)
{
ChangeCamera();
}
- if ( event.param == m_engine->RetKey(KEYRANK_DESEL, 0) ||
- event.param == m_engine->RetKey(KEYRANK_DESEL, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_DESEL).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_DESEL).joy)
{
- if ( m_bShortCut )
- {
+ if (m_shortCut)
DeselectObject();
- }
}
- if ( event.param == m_engine->RetKey(KEYRANK_HUMAN, 0) ||
- event.param == m_engine->RetKey(KEYRANK_HUMAN, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_HUMAN).joy)
{
SelectHuman();
}
- if ( event.param == m_engine->RetKey(KEYRANK_NEXT, 0) ||
- event.param == m_engine->RetKey(KEYRANK_NEXT, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_NEXT).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_NEXT).joy)
{
- if ( m_bShortCut )
- {
+ if (m_shortCut)
m_short->SelectNext();
- }
}
- if ( event.param == m_engine->RetKey(KEYRANK_HELP, 0) ||
- event.param == m_engine->RetKey(KEYRANK_HELP, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_HELP).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_HELP).joy)
{
StartDisplayInfo(SATCOM_HUSTON, true);
}
- if ( event.param == m_engine->RetKey(KEYRANK_PROG, 0) ||
- event.param == m_engine->RetKey(KEYRANK_PROG, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_PROG).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_PROG).joy)
{
StartDisplayInfo(SATCOM_PROG, true);
}
- if ( event.param == m_engine->RetKey(KEYRANK_VISIT, 0) ||
- event.param == m_engine->RetKey(KEYRANK_VISIT, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_VISIT).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_VISIT).joy)
{
StartDisplayVisit(EVENT_NULL);
}
- if ( event.param == m_engine->RetKey(KEYRANK_SPEED10, 0) ||
- event.param == m_engine->RetKey(KEYRANK_SPEED10, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_SPEED10).joy)
{
SetSpeed(1.0f);
}
- if ( event.param == m_engine->RetKey(KEYRANK_SPEED15, 0) ||
- event.param == m_engine->RetKey(KEYRANK_SPEED15, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_SPEED15).joy)
{
SetSpeed(1.5f);
}
- if ( event.param == m_engine->RetKey(KEYRANK_SPEED20, 0) ||
- event.param == m_engine->RetKey(KEYRANK_SPEED20, 1) )
+ if (event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).key ||
+ event.key.key == GetInputBinding(INPUT_SLOT_SPEED20).joy)
{
SetSpeed(2.0f);
}
- if ( event.param == m_engine->RetKey(KEYRANK_SPEED30, 0) ||
- event.param == m_engine->RetKey(KEYRANK_SPEED30, 1) )
- {
- SetSpeed(3.0f);
- }
break;
- case EVENT_KEYUP:
- KeyCamera(event.event, event.param);
+ case EVENT_KEY_UP:
+ KeyCamera(event.type, event.key.key);
break;
- case EVENT_LBUTTONDOWN:
- pObj = DetectObject(event.pos);
- if ( !m_bShortCut ) pObj = 0;
- if ( pObj != 0 && pObj->RetType() == OBJECT_TOTO )
+ case EVENT_MOUSE_BUTTON_DOWN:
+ if (event.mouseButton.button != 1) // only left mouse button
+ break;
+
+ obj = DetectObject(event.pos);
+ if (!m_shortCut) obj = nullptr;
+ if (obj != nullptr && obj->GetType() == OBJECT_TOTO)
{
- if ( m_displayInfo != 0 ) // current info?
+ if (m_displayInfo != nullptr) // current info?
{
StopDisplayInfo();
}
else
{
- if ( !m_bEditLock )
- {
+ if (!m_editLock)
StartDisplayInfo(SATCOM_HUSTON, true);
- }
}
}
else
- {
- SelectObject(pObj);
- }
+ SelectObject(obj);
break;
- case EVENT_LBUTTONUP:
+ case EVENT_MOUSE_BUTTON_UP:
+ if (event.mouseButton.button != 1) // only left mouse button
+ break;
+
m_cameraPan = 0.0f;
m_cameraZoom = 0.0f;
break;
case EVENT_BUTTON_QUIT:
- if ( m_movie->IsExist() )
- {
+ if (m_movie->IsExist())
StartDisplayInfo(SATCOM_HUSTON, false);
- }
- else if ( m_winDelay > 0.0f )
- {
+ else if (m_winDelay > 0.0f)
ChangePhase(PHASE_WIN);
- }
- else if ( m_lostDelay > 0.0f )
- {
+ else if (m_lostDelay > 0.0f)
+
ChangePhase(PHASE_LOST);
- }
else
- {
m_dialog->StartAbort(); // do you want to leave?
- }
break;
case EVENT_OBJECT_LIMIT:
@@ -1515,10 +1552,8 @@ bool CRobotMain::EventProcess(const Event &event)
break;
case EVENT_OBJECT_DESELECT:
- if ( m_bShortCut )
- {
+ if (m_shortCut)
DeselectObject();
- }
break;
case EVENT_OBJECT_HELP:
@@ -1563,7 +1598,7 @@ bool CRobotMain::EventProcess(const Event &event)
case EVENT_DT_VISIT2:
case EVENT_DT_VISIT3:
case EVENT_DT_VISIT4:
- StartDisplayVisit(event.event);
+ StartDisplayVisit(event.type);
break;
case EVENT_DT_END:
@@ -1590,7 +1625,7 @@ bool CRobotMain::EventProcess(const Event &event)
case EVENT_OBJECT_SHORTCUT17:
case EVENT_OBJECT_SHORTCUT18:
case EVENT_OBJECT_SHORTCUT19:
- m_short->SelectShortcut(event.event);
+ m_short->SelectShortcut(event.type);
break;
case EVENT_OBJECT_MOVIELOCK:
@@ -1604,74 +1639,46 @@ bool CRobotMain::EventProcess(const Event &event)
case EVENT_LOST:
ChangePhase(PHASE_LOST);
break;
+
+ default:
+ break;
}
EventObject(event);
return false;
}
- if ( m_phase == PHASE_PERSO )
- {
+ if (m_phase == PHASE_PERSO)
EventObject(event);
- }
- if ( m_phase == PHASE_WIN ||
- m_phase == PHASE_LOST )
+ if (m_phase == PHASE_WIN ||
+ m_phase == PHASE_LOST)
{
EventObject(event);
- switch( event.event )
+ switch (event.type)
{
- case EVENT_KEYDOWN:
- if ( event.param == VK_ESCAPE ||
- event.param == VK_RETURN )
+ case EVENT_KEY_DOWN:
+ if (event.key.key == KEY(ESCAPE) ||
+ event.key.key == KEY(RETURN))
{
- if ( m_bWinTerminate )
- {
+ if (m_winTerminate)
ChangePhase(PHASE_INIT);
- }
else
- {
ChangePhase(PHASE_TERM);
- }
}
break;
case EVENT_BUTTON_OK:
- if ( m_bWinTerminate )
- {
+ if (m_winTerminate)
ChangePhase(PHASE_INIT);
- }
else
- {
ChangePhase(PHASE_TERM);
- }
- break;
- }
- }
-
- if ( m_phase == PHASE_MODEL )
- {
- switch( event.event )
- {
- case EVENT_KEYDOWN:
- if ( event.param == VK_ESCAPE )
- {
- ChangePhase(PHASE_INIT);
- }
- if ( event.param == VK_HOME )
- {
- InitEye();
- }
break;
- case EVENT_BUTTON_CANCEL:
- ChangePhase(PHASE_INIT);
+ default:
break;
}
-
- m_model->EventProcess(event);
- return false;
}
return true;
@@ -1679,84 +1686,69 @@ bool CRobotMain::EventProcess(const Event &event)
-// Executes a command.
-
+//! Executes a command
void CRobotMain::ExecuteCmd(char *cmd)
{
- if ( cmd[0] == 0 ) return;
+ if (cmd[0] == 0) return;
- if ( m_phase == PHASE_SIMUL )
+ if (m_phase == PHASE_SIMUL)
{
- if ( strcmp(cmd, "winmission") == 0 )
- {
- Event newEvent;
- m_event->MakeEvent(newEvent, EVENT_WIN);
- m_event->AddEvent(newEvent);
- }
+ if (strcmp(cmd, "winmission") == 0)
+ m_eventQueue->AddEvent(Event(EVENT_WIN));
- if ( strcmp(cmd, "lostmission") == 0 )
- {
- Event newEvent;
- m_event->MakeEvent(newEvent, EVENT_LOST);
- m_event->AddEvent(newEvent);
- }
+ if (strcmp(cmd, "lostmission") == 0)
+ m_eventQueue->AddEvent(Event(EVENT_LOST));
- if ( strcmp(cmd, "trainerpilot") == 0 )
+ if (strcmp(cmd, "trainerpilot") == 0)
{
- m_bTrainerPilot = !m_bTrainerPilot;
+ m_trainerPilot = !m_trainerPilot;
return;
}
- if ( strcmp(cmd, "fly") == 0 )
+ if (strcmp(cmd, "fly") == 0)
{
- Event newEvent;
-
g_researchDone |= RESEARCH_FLY;
- m_event->MakeEvent(newEvent, EVENT_UPDINTERFACE);
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
return;
}
- if ( strcmp(cmd, "allresearch") == 0 )
+ if (strcmp(cmd, "allresearch") == 0)
{
- Event newEvent;
-
g_researchDone = -1; // all research are done
- m_event->MakeEvent(newEvent, EVENT_UPDINTERFACE);
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(Event(EVENT_UPDINTERFACE));
return;
}
- if ( strcmp(cmd, "nolimit") == 0 )
+ if (strcmp(cmd, "nolimit") == 0)
{
m_terrain->SetFlyingMaxHeight(280.0f);
return;
}
- if ( strcmp(cmd, "photo1") == 0 )
+ if (strcmp(cmd, "photo1") == 0)
{
- m_bFreePhoto = !m_bFreePhoto;
- if ( m_bFreePhoto )
+ m_freePhoto = !m_freePhoto;
+ if (m_freePhoto)
{
- m_camera->SetType(CAMERA_FREE);
+ m_camera->SetType(Gfx::CAM_TYPE_FREE);
ChangePause(true);
}
else
{
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
ChangePause(false);
}
return;
}
- if ( strcmp(cmd, "photo2") == 0 )
+ if (strcmp(cmd, "photo2") == 0)
{
- m_bFreePhoto = !m_bFreePhoto;
- if ( m_bFreePhoto )
+ m_freePhoto = !m_freePhoto;
+ if (m_freePhoto)
{
- m_camera->SetType(CAMERA_FREE);
+ m_camera->SetType(Gfx::CAM_TYPE_FREE);
ChangePause(true);
DeselectAll(); // removes the control buttons
m_map->ShowMap(false);
@@ -1764,246 +1756,202 @@ void CRobotMain::ExecuteCmd(char *cmd)
}
else
{
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
ChangePause(false);
- m_map->ShowMap(m_bMapShow);
+ m_map->ShowMap(m_mapShow);
m_displayText->HideText(false);
}
return;
}
- if ( strcmp(cmd, "noclip") == 0 )
+ if (strcmp(cmd, "noclip") == 0)
{
- CObject* object;
-
- object = RetSelect();
- if ( object != 0 )
- {
+ CObject* object = GetSelect();
+ if (object != nullptr)
object->SetClip(false);
- }
return;
}
- if ( strcmp(cmd, "clip") == 0 )
+ if (strcmp(cmd, "clip") == 0)
{
- CObject* object;
-
- object = RetSelect();
- if ( object != 0 )
- {
+ CObject* object = GetSelect();
+ if (object != nullptr)
object->SetClip(true);
- }
return;
}
- if ( strcmp(cmd, "addhusky") == 0 )
+ if (strcmp(cmd, "addhusky") == 0)
{
- CObject* object;
-
- object = RetSelect();
- if ( object != 0 )
- {
- object->SetMagnifyDamage(object->RetMagnifyDamage()*0.1f);
- }
+ CObject* object = GetSelect();
+ if (object != nullptr)
+ object->SetMagnifyDamage(object->GetMagnifyDamage()*0.1f);
return;
}
- if ( strcmp(cmd, "addfreezer") == 0 )
+ if (strcmp(cmd, "addfreezer") == 0)
{
- CObject* object;
-
- object = RetSelect();
- if ( object != 0 )
- {
- object->SetRange(object->RetRange()*10.0f);
- }
+ CObject* object = GetSelect();
+ if (object != nullptr)
+ object->SetRange(object->GetRange()*10.0f);
return;
}
- if ( strcmp(cmd, "fullpower") == 0 )
+ if (strcmp(cmd, "fullpower") == 0)
{
- CObject* object;
- CObject* power;
- CPhysics* physics;
-
- object = RetSelect();
- if ( object != 0 )
+ CObject* object = GetSelect();
+ if (object != nullptr)
{
- power = object->RetPower();
- if ( power != 0 )
- {
+ CObject* power = object->GetPower();
+ if (power != nullptr)
power->SetEnergy(1.0f);
- }
+
object->SetShield(1.0f);
- physics = object->RetPhysics();
- if ( physics != 0 )
- {
+ CPhysics* physics = object->GetPhysics();
+ if (physics != nullptr)
physics->SetReactorRange(1.0f);
- }
}
return;
}
- if ( strcmp(cmd, "fullenergy") == 0 )
+ if (strcmp(cmd, "fullenergy") == 0)
{
- CObject* object;
- CObject* power;
-
- object = RetSelect();
- if ( object != 0 )
+ CObject* object = GetSelect();
+ if (object != nullptr)
{
- power = object->RetPower();
- if ( power != 0 )
- {
+ CObject* power = object->GetPower();
+ if (power != nullptr)
power->SetEnergy(1.0f);
- }
}
return;
}
- if ( strcmp(cmd, "fullshield") == 0 )
+ if (strcmp(cmd, "fullshield") == 0)
{
- CObject* object;
-
- object = RetSelect();
- if ( object != 0 )
- {
+ CObject* object = GetSelect();
+ if (object != nullptr)
object->SetShield(1.0f);
- }
return;
}
- if ( strcmp(cmd, "fullrange") == 0 )
+ if (strcmp(cmd, "fullrange") == 0)
{
- CObject* object;
- CPhysics* physics;
-
- object = RetSelect();
- if ( object != 0 )
+ CObject* object = GetSelect();
+ if (object != nullptr)
{
- physics = object->RetPhysics();
- if ( physics != 0 )
- {
+ CPhysics* physics = object->GetPhysics();
+ if (physics != nullptr)
physics->SetReactorRange(1.0f);
- }
}
return;
}
}
- if ( strcmp(cmd, "debugmode") == 0 )
+ if (strcmp(cmd, "debugmode") == 0)
{
- m_engine->SetDebugMode(!m_engine->RetDebugMode());
+ m_app->SetDebugMode(!m_app->GetDebugMode());
return;
}
- if ( strcmp(cmd, "showstat") == 0 )
+ if (strcmp(cmd, "showstat") == 0)
{
- m_engine->SetShowStat(!m_engine->RetShowStat());
+ m_engine->SetShowStats(!m_engine->GetShowStats());
return;
}
- if ( strcmp(cmd, "invshadow") == 0 )
+ if (strcmp(cmd, "invshadow") == 0)
{
- m_engine->SetShadow(!m_engine->RetShadow());
+ m_engine->SetShadow(!m_engine->GetShadow());
return;
}
- if ( strcmp(cmd, "invdirty") == 0 )
+ if (strcmp(cmd, "invdirty") == 0)
{
- m_engine->SetDirty(!m_engine->RetDirty());
+ m_engine->SetDirty(!m_engine->GetDirty());
return;
}
- if ( strcmp(cmd, "invfog") == 0 )
+ if (strcmp(cmd, "invfog") == 0)
{
- m_engine->SetFog(!m_engine->RetFog());
+ m_engine->SetFog(!m_engine->GetFog());
return;
}
- if ( strcmp(cmd, "invlens") == 0 )
+ if (strcmp(cmd, "invlens") == 0)
{
- m_engine->SetLensMode(!m_engine->RetLensMode());
+ m_engine->SetLensMode(!m_engine->GetLensMode());
return;
}
- if ( strcmp(cmd, "invwater") == 0 )
+ if (strcmp(cmd, "invwater") == 0)
{
- m_engine->SetWaterMode(!m_engine->RetWaterMode());
+ m_engine->SetWaterMode(!m_engine->GetWaterMode());
return;
}
- if ( strcmp(cmd, "invsky") == 0 )
+ if (strcmp(cmd, "invsky") == 0)
{
- m_engine->SetSkyMode(!m_engine->RetSkyMode());
+ m_engine->SetSkyMode(!m_engine->GetSkyMode());
return;
}
- if ( strcmp(cmd, "invplanet") == 0 )
+ if (strcmp(cmd, "invplanet") == 0)
{
- m_engine->SetPlanetMode(!m_engine->RetPlanetMode());
+ m_engine->SetPlanetMode(!m_engine->GetPlanetMode());
return;
}
- if ( strcmp(cmd, "showpos") == 0 )
+ if (strcmp(cmd, "showpos") == 0)
{
- m_bShowPos = !m_bShowPos;
+ m_showPos = !m_showPos;
return;
}
- if ( strcmp(cmd, "selectinsect") == 0 )
+ if (strcmp(cmd, "selectinsect") == 0)
{
- m_bSelectInsect = !m_bSelectInsect;
+ m_selectInsect = !m_selectInsect;
return;
}
- if ( strcmp(cmd, "showsoluce") == 0 )
+ if (strcmp(cmd, "showsoluce") == 0)
{
- m_bShowSoluce = !m_bShowSoluce;
+ m_showSoluce = !m_showSoluce;
m_dialog->ShowSoluceUpdate();
return;
}
-#if _TEEN
- if ( strcmp(cmd, "allteens") == 0 )
-#else
- if ( strcmp(cmd, "allmission") == 0 )
-#endif
+/* TODO: #if _TEEN
+ if (strcmp(cmd, "allteens") == 0)
+#else*/
+ if (strcmp(cmd, "allmission") == 0)
{
- m_bShowAll = !m_bShowAll;
+ m_showAll = !m_showAll;
m_dialog->AllMissionUpdate();
return;
}
- if ( strcmp(cmd, "invradar") == 0 )
+ if (strcmp(cmd, "invradar") == 0)
{
- m_bCheatRadar = !m_bCheatRadar;
+ m_cheatRadar = !m_cheatRadar;
return;
}
- if ( m_phase == PHASE_SIMUL )
- {
+ if (m_phase == PHASE_SIMUL)
m_displayText->DisplayError(ERR_CMD, Math::Vector(0.0f,0.0f,0.0f));
- }
}
-// Returns the type of current movie.
-
-MainMovieType CRobotMain::RetMainMovie()
+//! Returns the type of current movie
+MainMovieType CRobotMain::GetMainMovie()
{
- return m_movie->RetType();
+ return m_movie->GetType();
}
-// Clears the display of instructions.
-
+//! Clears the display of instructions
void CRobotMain::FlushDisplayInfo()
{
- int i;
-
- for ( i=0 ; i<SATCOM_MAX ; i++ )
+ for (int i = 0; i < SATCOM_MAX; i++)
{
m_infoFilename[i][0] = 0;
m_infoPos[i] = 0;
@@ -2012,220 +1960,181 @@ void CRobotMain::FlushDisplayInfo()
m_infoIndex = 0;
}
-// Beginning of the displaying of instructions.
-// index: SATCOM_*
-
-void CRobotMain::StartDisplayInfo(int index, bool bMovie)
+//! Beginning of the displaying of instructions.
+//! index: SATCOM_*
+void CRobotMain::StartDisplayInfo(int index, bool movie)
{
- CObject* pObj;
- CMotion* motion;
- bool bHuman;
-
- if ( m_bCmdEdit || m_bSatComLock ) return;
+ if (m_cmdEdit || m_satComLock) return;
- pObj = RetSelect();
- bHuman = ( pObj != 0 && pObj->RetType() == OBJECT_HUMAN );
+ CObject* obj = GetSelect();
+ bool human = obj != nullptr && obj->GetType() == OBJECT_HUMAN;
- if ( !m_bEditLock && bMovie && !m_movie->IsExist() && bHuman )
+ if (!m_editLock && movie && !m_movie->IsExist() && human)
{
- motion = pObj->RetMotion();
- if ( motion != 0 && motion->RetAction() == -1 )
+ CMotion* motion = obj->GetMotion();
+ if (motion != nullptr && motion->GetAction() == -1)
{
m_movieInfoIndex = index;
m_movie->Start(MM_SATCOMopen, 2.5f);
ChangePause(true);
-//? m_map->ShowMap(false);
m_infoObject = DeselectAll(); // removes the control buttons
m_displayText->HideText(true);
return;
}
}
- if ( m_movie->IsExist() )
+ if (m_movie->IsExist())
{
m_movie->Stop();
ChangePause(false);
SelectObject(m_infoObject, false); // hands over the command buttons
-//? m_map->ShowMap(m_bMapShow);
m_displayText->HideText(false);
}
StartDisplayInfo(m_infoFilename[index], index);
}
-// Beginning of the displaying of instructions.
-
-void CRobotMain::StartDisplayInfo(char *filename, int index)
+//! Beginning of the displaying of instructions
+void CRobotMain::StartDisplayInfo(const char *filename, int index)
{
- CButton* pb;
- bool bSoluce;
-
- if ( m_bCmdEdit ) return;
+ if (m_cmdEdit) return;
m_movieInfoIndex = -1;
ClearInterface(); // removes setting evidence and tooltip
- if ( !m_bEditLock )
+ if (!m_editLock)
{
-//? m_map->ShowMap(false);
m_infoObject = DeselectAll(); // removes the control buttons
m_displayText->HideText(true);
m_sound->MuteAll(true);
}
- pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT);
- if ( pb != 0 )
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ if (pb != nullptr)
{
- pb->ClearState(STATE_VISIBLE);
+ pb->ClearState(Ui::STATE_VISIBLE);
}
- bSoluce = m_dialog->RetSceneSoluce();
+ bool soluce = m_dialog->GetSceneSoluce();
- m_displayInfo = new CDisplayInfo(m_iMan);
- m_displayInfo->StartDisplayInfo(filename, index, bSoluce);
+ m_displayInfo = new Ui::CDisplayInfo();
+ m_displayInfo->StartDisplayInfo(filename, index, soluce);
m_infoIndex = index;
- if ( index != -1 )
- {
+ if (index != -1)
m_displayInfo->SetPosition(m_infoPos[index]);
- }
}
-// End of displaying of instructions.
-
+//! End of displaying of instructions
void CRobotMain::StopDisplayInfo()
{
- CButton* pb;
-
- if ( m_movieInfoIndex != -1 ) // film to read the SatCom?
- {
+ if (m_movieInfoIndex != -1) // film to read the SatCom?
m_movie->Start(MM_SATCOMclose, 2.0f);
- }
- if ( m_infoIndex != -1 )
- {
- m_infoPos[m_infoIndex] = m_displayInfo->RetPosition();
- }
+ if (m_infoIndex != -1)
+ m_infoPos[m_infoIndex] = m_displayInfo->GetPosition();
+
m_displayInfo->StopDisplayInfo();
delete m_displayInfo;
- m_displayInfo = 0;
+ m_displayInfo = nullptr;
- if ( !m_bEditLock )
+ if (!m_editLock)
{
- pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT);
- if ( pb != 0 )
- {
- pb->SetState(STATE_VISIBLE);
- }
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ if (pb != nullptr)
+ pb->SetState(Ui::STATE_VISIBLE);
SelectObject(m_infoObject, false); // gives the command buttons
-//? m_map->ShowMap(m_bMapShow);
m_displayText->HideText(false);
m_sound->MuteAll(false);
}
- if ( m_infoUsed == 0 )
- {
+ if (m_infoUsed == 0)
m_displayText->ClearText(); // removes message "see SatCom ..."
- }
m_infoUsed ++;
}
-// Returns the name of the text display.
-
-char* CRobotMain::RetDisplayInfoName(int index)
+//! Returns the name of the text display
+char* CRobotMain::GetDisplayInfoName(int index)
{
return m_infoFilename[index];
}
-// Returns the name of the text display.
-
-int CRobotMain::RetDisplayInfoPosition(int index)
+//! Returns the name of the text display
+int CRobotMain::GetDisplayInfoPosition(int index)
{
return m_infoPos[index];
}
-// Returns the name of the text display.
-
+//! Returns the name of the text display
void CRobotMain::SetDisplayInfoPosition(int index, int pos)
{
m_infoPos[index] = pos;
}
-// Beginning of a dialogue during the game,
-
+//! Beginning of a dialogue during the game
void CRobotMain::StartSuspend()
{
- CButton* pb;
-
m_map->ShowMap(false);
m_infoObject = DeselectAll(); // removes the control buttons
m_displayText->HideText(true);
- pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT);
- if ( pb != 0 )
- {
- pb->ClearState(STATE_VISIBLE);
- }
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ if (pb != nullptr)
+ pb->ClearState(Ui::STATE_VISIBLE);
- m_bSuspend = true;
+ m_suspend = true;
}
-// End of dialogue during the game,
-
+//! End of dialogue during the game
void CRobotMain::StopSuspend()
{
- CButton* pb;
-
- pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT);
- if ( pb != 0 )
- {
- pb->SetState(STATE_VISIBLE);
- }
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
+ if (pb != nullptr)
+ pb->SetState(Ui::STATE_VISIBLE);
SelectObject(m_infoObject, false); // gives the command buttons
- m_map->ShowMap(m_bMapShow);
+ m_map->ShowMap(m_mapShow);
m_displayText->HideText(false);
- m_bSuspend = false;
+ m_suspend = false;
}
-// Returns the absolute time of the game
-
-float CRobotMain::RetGameTime()
+//! Returns the absolute time of the game
+float CRobotMain::GetGameTime()
{
return m_gameTime;
}
-// Managing the size of the default fonts.
-
+//! Managing the size of the default fonts
void CRobotMain::SetFontSize(float size)
{
m_fontSize = size;
- SetLocalProfileFloat("Edit", "FontSize", m_fontSize);
+ /* TODO: profile
+ SetLocalProfileFloat("Edit", "FontSize", m_fontSize); */
}
-float CRobotMain::RetFontSize()
+float CRobotMain::GetFontSize()
{
return m_fontSize;
}
-// Managing the size of the default window.
-
+//! Managing the size of the default window
void CRobotMain::SetWindowPos(Math::Point pos)
{
m_windowPos = pos;
+ /* TODO: profile
SetLocalProfileFloat("Edit", "WindowPos.x", m_windowPos.x);
- SetLocalProfileFloat("Edit", "WindowPos.y", m_windowPos.y);
+ SetLocalProfileFloat("Edit", "WindowPos.y", m_windowPos.y); */
}
-Math::Point CRobotMain::RetWindowPos()
+Math::Point CRobotMain::GetWindowPos()
{
return m_windowPos;
}
@@ -2233,25 +2142,26 @@ Math::Point CRobotMain::RetWindowPos()
void CRobotMain::SetWindowDim(Math::Point dim)
{
m_windowDim = dim;
+ /* TODO: profile
SetLocalProfileFloat("Edit", "WindowDim.x", m_windowDim.x);
- SetLocalProfileFloat("Edit", "WindowDim.y", m_windowDim.y);
+ SetLocalProfileFloat("Edit", "WindowDim.y", m_windowDim.y); */
}
-Math::Point CRobotMain::RetWindowDim()
+Math::Point CRobotMain::GetWindowDim()
{
return m_windowDim;
}
-// Managing windows open/save.
-
-void CRobotMain::SetIOPublic(bool bMode)
+//! Managing windows open/save
+void CRobotMain::SetIOPublic(bool mode)
{
- m_IOPublic = bMode;
- SetLocalProfileInt("Edit", "IOPublic", m_IOPublic);
+ m_IOPublic = mode;
+ /* TODO: profile
+ SetLocalProfileInt("Edit", "IOPublic", m_IOPublic); */
}
-bool CRobotMain::RetIOPublic()
+bool CRobotMain::GetIOPublic()
{
return m_IOPublic;
}
@@ -2259,11 +2169,12 @@ bool CRobotMain::RetIOPublic()
void CRobotMain::SetIOPos(Math::Point pos)
{
m_IOPos = pos;
+ /* TODO: profile
SetLocalProfileFloat("Edit", "IOPos.x", m_IOPos.x);
- SetLocalProfileFloat("Edit", "IOPos.y", m_IOPos.y);
+ SetLocalProfileFloat("Edit", "IOPos.y", m_IOPos.y); */
}
-Math::Point CRobotMain::RetIOPos()
+Math::Point CRobotMain::GetIOPos()
{
return m_IOPos;
}
@@ -2271,62 +2182,52 @@ Math::Point CRobotMain::RetIOPos()
void CRobotMain::SetIODim(Math::Point dim)
{
m_IODim = dim;
+ /* TODO: profile
SetLocalProfileFloat("Edit", "IODim.x", m_IODim.x);
- SetLocalProfileFloat("Edit", "IODim.y", m_IODim.y);
+ SetLocalProfileFloat("Edit", "IODim.y", m_IODim.y); */
}
-Math::Point CRobotMain::RetIODim()
+Math::Point CRobotMain::GetIODim()
{
return m_IODim;
}
-// Start of the visit instead of an error.
-
-void CRobotMain::StartDisplayVisit(EventMsg event)
+//! Start of the visit instead of an error
+void CRobotMain::StartDisplayVisit(EventType event)
{
- CWindow* pw;
- CButton* button;
- CGroup* group;
- Math::Vector goal;
- Math::Point pos, dim;
- int i, j;
-
- if ( m_bEditLock ) return;
+ if (m_editLock) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
- if ( pw == 0 ) return;
+ Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
+ if (pw == nullptr) return;
- if ( event == EVENT_NULL ) // visit by keyboard shortcut?
+ if (event == EVENT_NULL) // visit by keyboard shortcut?
{
- if ( m_visitLast != EVENT_NULL ) // already a current visit?
- {
+ int i;
+ if (m_visitLast != EVENT_NULL) // already a current visit?
i = m_visitLast-EVENT_DT_VISIT0;
- }
else
- {
- i = MAXDTLINE;
- }
+ i = Ui::MAXDTLINE;
// Seeks the last.
- for ( j=0 ; j<MAXDTLINE ; j++ )
+ for (int j = 0; j < Ui::MAXDTLINE; j++)
{
i --;
- if ( i < 0 ) i = MAXDTLINE-1;
+ if (i < 0) i = Ui::MAXDTLINE-1;
- button = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i));
- if ( button == 0 || !button->TestState(STATE_ENABLE) ) continue;
+ Ui::CButton* button = dynamic_cast<Ui::CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_VISIT0+i)));
+ if (button == nullptr || !button->TestState(Ui::STATE_ENABLE)) continue;
- group = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i));
- if ( group != 0 )
+ Ui::CGroup* group = dynamic_cast<Ui::CGroup*>(pw->SearchControl(static_cast<EventType>(EVENT_DT_GROUP0+i)));
+ if (group != nullptr)
{
- event = EventMsg(EVENT_DT_VISIT0+i);
+ event = static_cast<EventType>(EVENT_DT_VISIT0+i);
break;
}
}
}
- if ( event == EVENT_NULL )
+ if (event == EVENT_NULL)
{
m_sound->Play(SOUND_TZOING); // nothing to do!
return;
@@ -2336,7 +2237,7 @@ void CRobotMain::StartDisplayVisit(EventMsg event)
ClearInterface(); // removes setting evidence and tooltip
- if ( m_camera->RetType() == CAMERA_VISIT ) // already a current visit?
+ if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT) // already a current visit?
{
m_camera->StopVisit();
m_displayText->ClearVisit();
@@ -2347,8 +2248,9 @@ void CRobotMain::StartDisplayVisit(EventMsg event)
}
// Creates the "continue" button.
- if ( m_interface->SearchControl(EVENT_DT_END) == 0 )
+ if (m_interface->SearchControl(EVENT_DT_END) == 0)
{
+ Math::Point pos, dim;
pos.x = 10.0f/640.0f;
pos.y = 10.0f/480.0f;
dim.x = 50.0f/640.0f;
@@ -2357,67 +2259,63 @@ void CRobotMain::StartDisplayVisit(EventMsg event)
}
// Creates the arrow to show the place.
- if ( m_visitArrow != 0 )
+ if (m_visitArrow != 0)
{
m_visitArrow->DeleteObject();
delete m_visitArrow;
m_visitArrow = 0;
}
- goal = m_displayText->RetVisitGoal(event);
+
+ Math::Vector goal = m_displayText->GetVisitGoal(event);
m_visitArrow = CreateObject(goal, 0.0f, 1.0f, 10.0f, OBJECT_SHOW, false, false, 0);
- m_visitPos = m_visitArrow->RetPosition(0);
+ m_visitPos = m_visitArrow->GetPosition(0);
m_visitPosArrow = m_visitPos;
- m_visitPosArrow.y += m_displayText->RetVisitHeight(event);
+ m_visitPosArrow.y += m_displayText->GetVisitHeight(event);
m_visitArrow->SetPosition(0, m_visitPosArrow);
m_visitTime = 0.0;
- m_visitParticule = 0.0f;
+ m_visitParticle = 0.0f;
- m_particule->DeleteParticule(PARTISHOW);
+ m_particle->DeleteParticle(Gfx::PARTISHOW);
- m_camera->StartVisit(m_displayText->RetVisitGoal(event),
- m_displayText->RetVisitDist(event));
+ m_camera->StartVisit(m_displayText->GetVisitGoal(event),
+ m_displayText->GetVisitDist(event));
m_displayText->SetVisit(event);
ChangePause(true);
}
-// Move the arrow to visit.
-
+//! Move the arrow to visit
void CRobotMain::FrameVisit(float rTime)
{
- Math::Vector pos, speed;
- Math::Point dim;
- float level;
-
- if ( m_visitArrow == 0 ) return;
+ if (m_visitArrow == 0) return;
// Moves the arrow.
m_visitTime += rTime;
- pos = m_visitPosArrow;
+ Math::Vector pos = m_visitPosArrow;
pos.y += 1.5f+sinf(m_visitTime*4.0f)*4.0f;
m_visitArrow->SetPosition(0, pos);
m_visitArrow->SetAngleY(0, m_visitTime*2.0f);
// Manages the particles "arrows".
- m_visitParticule -= rTime;
- if ( m_visitParticule <= 0.0f )
+ m_visitParticle -= rTime;
+ if (m_visitParticle <= 0.0f)
{
- m_visitParticule = 1.5f;
+ m_visitParticle = 1.5f;
pos = m_visitPos;
- level = m_terrain->RetFloorLevel(pos)+2.0f;
- if ( pos.y < level ) pos.y = level; // not below the ground
- speed = Math::Vector(0.0f, 0.0f, 0.0f);
+ float level = m_terrain->GetFloorLevel(pos)+2.0f;
+ if (pos.y < level) pos.y = level; // not below the ground
+ Math::Vector speed(0.0f, 0.0f, 0.0f);
+ Math::Point dim;
dim.x = 30.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISHOW, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISHOW, 2.0f);
}
}
-// End of the visit instead of an error.
-
+//! End of the visit instead of an error
void CRobotMain::StopDisplayVisit()
{
m_visitLast = EVENT_NULL;
@@ -2426,20 +2324,20 @@ void CRobotMain::StopDisplayVisit()
m_interface->DeleteControl(EVENT_DT_END);
// Removes the arrow.
- if ( m_visitArrow != 0 )
+ if (m_visitArrow != nullptr)
{
m_visitArrow->DeleteObject();
delete m_visitArrow;
- m_visitArrow = 0;
+ m_visitArrow = nullptr;
}
// Removes particles "arrows".
- m_particule->DeleteParticule(PARTISHOW);
+ m_particle->DeleteParticle(Gfx::PARTISHOW);
m_camera->StopVisit();
m_displayText->ClearVisit();
ChangePause(false);
- if ( m_visitObject != 0 )
+ if (m_visitObject != 0)
{
SelectObject(m_visitObject, false); // gives the command buttons
m_visitObject = 0;
@@ -2448,53 +2346,41 @@ void CRobotMain::StopDisplayVisit()
-// Updates all the shortcuts.
-
+//! Updates all the shortcuts
void CRobotMain::UpdateShortcuts()
{
m_short->UpdateShortcuts();
}
-// Returns the object that default was select after the creation of a scene.
-
-CObject* CRobotMain::RetSelectObject()
+//! Returns the object that default was select after the creation of a scene
+CObject* CRobotMain::GetSelectObject()
{
- if ( m_selectObject != 0 ) return m_selectObject;
+ if (m_selectObject != nullptr) return m_selectObject;
return SearchHuman();
}
-// Deselects everything, and returns the object that was selected.
-
+//! Deselects everything, and returns the object that was selected
CObject* CRobotMain::DeselectAll()
{
- CObject* pObj;
- CObject* pPrev;
- int i;
-
- pPrev = 0;
- for ( i=0 ; i<1000000 ; i++ )
+ CObject* prev = nullptr;
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( pObj->RetSelect() ) pPrev = pObj;
- pObj->SetSelect(false);
+ if (obj->GetSelect()) prev = obj;
+ obj->SetSelect(false);
}
- return pPrev;
+ return prev;
}
-// Selects an object, without attending to deselect the rest.
-
-void CRobotMain::SelectOneObject(CObject* pObj, bool bDisplayError)
+//! Selects an object, without attending to deselect the rest
+void CRobotMain::SelectOneObject(CObject* obj, bool displayError)
{
- ObjectType type;
- CObject* toto;
- CMotionToto* mt;
+ obj->SetSelect(true, displayError);
+ m_camera->SetControllingObject(obj);
- pObj->SetSelect(true, bDisplayError);
- m_camera->SetObject(pObj);
-
- type = pObj->RetType();
+ ObjectType type = obj->GetType();
if ( type == OBJECT_HUMAN ||
type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
@@ -2524,271 +2410,205 @@ void CRobotMain::SelectOneObject(CObject* pObj, bool bDisplayError)
type == OBJECT_MOBILEdr ||
type == OBJECT_APOLLO2 )
{
- m_camera->SetType(pObj->RetCameraType());
- m_camera->SetDist(pObj->RetCameraDist());
+ m_camera->SetType(obj->GetCameraType());
+ m_camera->SetDist(obj->GetCameraDist());
}
else
{
- m_camera->SetType(CAMERA_BACK);
+ m_camera->SetType(Gfx::CAM_TYPE_BACK);
}
- toto = SearchToto();
- if ( toto != 0 )
+ CObject* toto = SearchToto();
+ if (toto != nullptr)
{
- mt = (CMotionToto*)toto->RetMotion();
- if ( mt != 0 )
- {
+ CMotionToto* mt = dynamic_cast<CMotionToto*>(toto->GetMotion());
+ if (mt != nullptr)
mt->SetLinkType(type);
- }
}
}
-// Selects the object aimed by the mouse.
-
-bool CRobotMain::SelectObject(CObject* pObj, bool bDisplayError)
+//! Selects the object aimed by the mouse
+bool CRobotMain::SelectObject(CObject* obj, bool displayError)
{
- CObject* pPrev;
-
- if ( m_camera->RetType() == CAMERA_VISIT )
- {
+ if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
StopDisplayVisit();
- }
- if ( m_bMovieLock || m_bEditLock || m_bPause ) return false;
- if ( m_movie->IsExist() ) return false;
- if ( pObj == 0 || !IsSelectable(pObj) ) return false;
+ if (m_movieLock || m_editLock || m_pause) return false;
+ if (m_movie->IsExist()) return false;
+ if (obj == nullptr || !IsSelectable(obj)) return false;
- pPrev = DeselectAll();
+ CObject* prev = DeselectAll();
- if ( pPrev != 0 && pPrev != pObj )
- {
- pObj->AddDeselList(pPrev);
- }
+ if (prev != nullptr && prev != obj)
+ obj->AddDeselList(prev);
- SelectOneObject(pObj, bDisplayError);
+ SelectOneObject(obj, displayError);
m_short->UpdateShortcuts();
return true;
}
-// Deselects the selected object.
-
+//! Deselects the selected object
bool CRobotMain::DeselectObject()
{
- CObject* pObj;
- CObject* pPrev;
+ CObject* obj = nullptr;
+ CObject* prev = DeselectAll();
- pPrev = DeselectAll();
-
- if ( pPrev == 0 )
- {
- pObj = SearchHuman();
- }
+ if (prev == nullptr)
+ obj = SearchHuman();
else
- {
- pObj = pPrev->SubDeselList();
- }
- if ( pObj == 0 )
- {
- pObj = SearchHuman();
- }
+ obj = prev->SubDeselList();
- if ( pObj != 0 )
- {
- SelectOneObject(pObj);
- }
+ if (obj == nullptr)
+ obj = SearchHuman();
+
+ if (obj != nullptr)
+ SelectOneObject(obj);
else
- {
- m_camera->SetType(CAMERA_FREE);
- }
+ m_camera->SetType(Gfx::CAM_TYPE_FREE);
m_short->UpdateShortcuts();
return true;
}
-// Quickly removes all objects.
-
+//! Quickly removes all objects
void CRobotMain::DeleteAllObjects()
{
- CPyro* pyro;
- CObject* pObj;
- int i;
-
// Removes all pyrotechnic effects in progress.
- while ( true )
+ while (true)
{
- pyro = (CPyro*)m_iMan->SearchInstance(CLASS_PYRO, 0);
- if ( pyro == 0 ) break;
+ Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, 0));
+ if (pyro == nullptr) break;
pyro->DeleteObject();
delete pyro;
}
// Removes the arrow.
- if ( m_visitArrow != 0 )
+ if (m_visitArrow != nullptr)
{
m_visitArrow->DeleteObject();
delete m_visitArrow;
- m_visitArrow = 0;
+ m_visitArrow = nullptr;
}
- for ( i=0 ; i<MAXSHOWLIMIT ; i++ )
- {
+ for (int i = 0; i < MAXSHOWLIMIT; i++)
FlushShowLimit(i);
- }
- while ( true )
+ while (true)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, 0);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, 0));
+ if (obj == nullptr) break;
- pObj->DeleteObject(true); // destroys rapidly
- delete pObj;
+ obj->DeleteObject(true); // destroys rapidly
+ delete obj;
}
}
-// Selects the human.
-
+//! Selects the human
void CRobotMain::SelectHuman()
{
SelectObject(SearchHuman());
}
-// Returns the object human.
-
+//! Returns the object human
CObject* CRobotMain::SearchHuman()
{
- ObjectType type;
- CObject* pObj;
- int i;
-
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == 0) break;
- type = pObj->RetType();
- if ( type == OBJECT_HUMAN )
- {
- return pObj;
- }
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_HUMAN)
+ return obj;
}
return 0;
}
-// Returns the object toto.
-
+//! Returns the object toto
CObject* CRobotMain::SearchToto()
{
- ObjectType type;
- CObject* pObj;
- int i;
-
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- type = pObj->RetType();
- if ( type == OBJECT_TOTO )
- {
- return pObj;
- }
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_TOTO)
+ return obj;
}
- return 0;
+ return nullptr;
}
-// Returns the nearest selectable object from a given position.
-
-CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* pExclu)
+//! Returns the nearest selectable object from a given position
+CObject* CRobotMain::SearchNearest(Math::Vector pos, CObject* exclu)
{
- ObjectType type;
- CObject *pObj, *pBest;
- Math::Vector oPos;
- float min, dist;
- int i;
-
- min = 100000.0f;
- pBest = 0;
- for ( i=0 ; i<1000000 ; i++ )
+ float min = 100000.0f;
+ CObject* best = 0;
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( pObj == pExclu ) continue;
- if ( !IsSelectable(pObj) ) continue;
+ if (obj == exclu) continue;
+ if (!IsSelectable(obj)) continue;
- type = pObj->RetType();
- if ( type == OBJECT_TOTO ) continue;
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_TOTO) continue;
- oPos = pObj->RetPosition(0);
- dist = Math::DistanceProjected(oPos, pos);
- if ( dist < min )
+ Math::Vector oPos = obj->GetPosition(0);
+ float dist = Math::DistanceProjected(oPos, pos);
+ if (dist < min)
{
min = dist;
- pBest = pObj;
+ best = obj;
}
}
- return pBest;
+ return best;
}
-// Returns the selected object.
-
-CObject* CRobotMain::RetSelect()
+//! Returns the selected object
+CObject* CRobotMain::GetSelect()
{
- CObject* pObj;
- int i;
-
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( pObj->RetSelect() )
- {
- return pObj;
- }
+ if (obj->GetSelect())
+ return obj;
}
- return 0;
+ return nullptr;
}
CObject* CRobotMain::SearchObject(ObjectType type)
{
- CObject* pObj;
- int i;
-
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( pObj->RetType() == type )
- {
- return pObj;
- }
+ if (obj->GetType() == type)
+ return obj;
}
- return 0;
+ return nullptr;
}
-// Detects the object aimed by the mouse.
-
+//! Detects the object aimed by the mouse
CObject* CRobotMain::DetectObject(Math::Point pos)
{
- ObjectType type;
- CObject *pObj, *pTarget;
- int objRank, i, j, rank;
-
- objRank = m_engine->DetectObject(pos);
+ int objRank = m_engine->DetectObject(pos);
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( !pObj->RetActif() ) continue;
- if ( pObj->RetProxyActivate() ) continue;
+ if (!obj->GetActif()) continue;
+ if (obj->GetProxyActivate()) continue;
- pTarget = 0;
- type = pObj->RetType();
+ CObject* target = nullptr;
+ ObjectType type = obj->GetType();
if ( type == OBJECT_PORTICO ||
type == OBJECT_BASE ||
type == OBJECT_DERRICK ||
@@ -2896,40 +2716,37 @@ CObject* CRobotMain::DetectObject(Math::Point pos)
type == OBJECT_APOLLO4 ||
type == OBJECT_APOLLO5 )
{
- pTarget = pObj;
+ target = obj;
}
- else if ( (type == OBJECT_POWER ||
- type == OBJECT_ATOMIC ) &&
- pObj->RetTruck() != 0 ) // battery used?
+ else if ((type == OBJECT_POWER ||
+ type == OBJECT_ATOMIC) &&
+ obj->GetTruck() != nullptr) // battery used?
{
- pTarget = pObj->RetTruck();
+ target = obj->GetTruck();
}
- else if ( type == OBJECT_POWER ||
- type == OBJECT_ATOMIC )
+ else if (type == OBJECT_POWER ||
+ type == OBJECT_ATOMIC)
{
- pTarget = pObj;
+ target = obj;
}
- for ( j=0 ; j<OBJECTMAXPART ; j++ )
+ for (int j = 0; j < OBJECTMAXPART; j++)
{
- rank = pObj->RetObjectRank(j);
- if ( rank == -1 ) continue;
- if ( rank != objRank ) continue;
- return pTarget;
+ int rank = obj->GetObjectRank(j);
+ if (rank == -1) continue;
+ if (rank != objRank) continue;
+ return target;
}
}
return 0;
}
-// Indicates whether an object is selectable.
-
-bool CRobotMain::IsSelectable(CObject* pObj)
+//! Indicates whether an object is selectable
+bool CRobotMain::IsSelectable(CObject* obj)
{
- ObjectType type;
-
- if ( !pObj->RetSelectable() ) return false;
+ if (!obj->GetSelectable()) return false;
- type = pObj->RetType();
+ ObjectType type = obj->GetType();
if ( type == OBJECT_HUMAN ||
type == OBJECT_TOTO ||
type == OBJECT_MOBILEfa ||
@@ -2980,7 +2797,7 @@ bool CRobotMain::IsSelectable(CObject* pObj)
return true;
}
- if ( m_bSelectInsect )
+ if (m_selectInsect)
{
if ( type == OBJECT_MOTHER ||
type == OBJECT_ANT ||
@@ -2997,151 +2814,138 @@ bool CRobotMain::IsSelectable(CObject* pObj)
}
-// Deletes the selected object.
-
+//! Deletes the selected object
bool CRobotMain::DeleteObject()
{
- CObject* pObj;
- CPyro* pyro;
-
- pObj = RetSelect();
- if ( pObj == 0 ) return false;
+ CObject* obj = GetSelect();
+ if (obj == nullptr) return false;
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FRAGT, pObj);
+ Gfx::CPyro* pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FRAGT, obj);
- pObj->SetSelect(false); // deselects the object
- m_camera->SetType(CAMERA_EXPLO);
+ obj->SetSelect(false); // deselects the object
+ m_camera->SetType(Gfx::CAM_TYPE_EXPLO);
DeselectAll();
- pObj->DeleteDeselList(pObj);
+ obj->DeleteDeselList(obj);
return true;
}
-// Removes setting evidence of the object with the mouse hovers over.
-
+//! Removes setting evidence of the object with the mouse hovers over
void CRobotMain::HiliteClear()
{
- CObject* pObj;
- int i;
-
ClearTooltip();
m_tooltipName[0] = 0; // really removes the tooltip
- if ( !m_bHilite ) return;
+ if (!m_hilite) return;
- i = -1;
- m_engine->SetHiliteRank(&i); // nothing more selected
+ int rank = -1;
+ m_engine->SetHighlightRank(&rank); // nothing more selected
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- pObj->SetHilite(false);
- m_map->SetHilite(0);
- m_short->SetHilite(0);
+ obj->SetHilite(false);
+ m_map->SetHighlight(0);
+ m_short->SetHighlight(0);
}
- m_bHilite = false;
+ m_hilite = false;
}
-// Highlights the object with the mouse hovers over.
-
+//! Highlights the object with the mouse hovers over
void CRobotMain::HiliteObject(Math::Point pos)
{
- CObject* pObj;
- char name[100];
- bool bInMap;
-
- if ( m_bFixScene && m_phase != PHASE_PERSO ) return;
- if ( m_bMovieLock ) return;
- if ( m_movie->IsExist() ) return;
- if ( m_engine->RetMouseHide() ) return;
+ if (m_fixScene && m_phase != PHASE_PERSO) return;
+ if (m_movieLock) return;
+ if (m_movie->IsExist()) return;
+ if (!m_engine->GetMouseVisible()) return;
ClearInterface(); // removes setting evidence and tooltip
- pObj = m_short->DetectShort(pos);
+ CObject* obj = m_short->DetectShort(pos);
- if ( m_dialog->RetTooltip() && m_interface->GetTooltip(pos, name) )
+ std::string nameStr;
+ if (m_dialog->GetTooltip() && m_interface->GetTooltip(pos, nameStr))
{
m_tooltipPos = pos;
- strcpy(m_tooltipName, name);
+ strcpy(m_tooltipName, nameStr.c_str());
m_tooltipTime = 0.0f;
- if ( pObj == 0 ) return;
+ if (obj == nullptr) return;
}
- if ( m_bSuspend ) return;
+ if (m_suspend) return;
- if ( pObj == 0 )
+ if (obj == nullptr)
{
- pObj = m_map->DetectMap(pos, bInMap);
- if ( pObj == 0 )
+ bool inMap = false;
+ obj = m_map->DetectMap(pos, inMap);
+ if (obj == nullptr)
{
- if ( bInMap ) return;
+ if (inMap) return;
- pObj = DetectObject(pos);
+ obj = DetectObject(pos);
- if ( m_camera->RetType() == CAMERA_ONBOARD &&
- m_camera->RetObject() == pObj )
- {
+ if ((m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD) &&
+ (m_camera->GetControllingObject() == obj))
return;
- }
}
}
- if ( pObj != 0 )
+ char name[100];
+ if (obj != nullptr)
{
- if ( m_dialog->RetTooltip() && pObj->GetTooltipName(name) )
+ if (m_dialog->GetTooltip() && obj->GetTooltipName(name))
{
m_tooltipPos = pos;
strcpy(m_tooltipName, name);
m_tooltipTime = 0.0f;
}
- if ( IsSelectable(pObj) )
+ if (IsSelectable(obj))
{
- pObj->SetHilite(true);
- m_map->SetHilite(pObj);
- m_short->SetHilite(pObj);
- m_bHilite = true;
+ obj->SetHilite(true);
+ m_map->SetHighlight(obj);
+ m_short->SetHighlight(obj);
+ m_hilite = true;
}
}
}
-// Highlights the object with the mouse hovers over.
-
+//! Highlights the object with the mouse hovers over
void CRobotMain::HiliteFrame(float rTime)
{
- if ( m_bFixScene && m_phase != PHASE_PERSO ) return;
- if ( m_bMovieLock ) return;
- if ( m_movie->IsExist() ) return;
+ if (m_fixScene && m_phase != PHASE_PERSO) return;
+ if (m_movieLock) return;
+ if (m_movie->IsExist()) return;
m_tooltipTime += rTime;
ClearTooltip();
- if ( m_tooltipTime >= 0.2f &&
- m_tooltipName[0] != 0 )
+ if (m_tooltipTime >= 0.2f &&
+ m_tooltipName[0] != 0)
{
CreateTooltip(m_tooltipPos, m_tooltipName);
}
}
-// Creates a tooltip.
-
-void CRobotMain::CreateTooltip(Math::Point pos, char* text)
+//! Creates a tooltip
+void CRobotMain::CreateTooltip(Math::Point pos, const char* text)
{
- CWindow* pw;
- Math::Point start, end, dim, offset, corner;
-
+ Math::Point corner;
corner.x = pos.x+0.022f;
corner.y = pos.y-0.052f;
- m_engine->RetText()->DimText(text, corner, 1,
- SMALLFONT, NORMSTRETCH, FONT_COLOBOT,
- start, end);
+ Math::Point start, end;
+
+ m_engine->GetText()->SizeText(text, Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL,
+ corner, Gfx::TEXT_ALIGN_LEFT,
+ start, end);
+
start.x -= 0.010f;
start.y -= 0.002f;
end.x += 0.010f;
@@ -3149,13 +2953,16 @@ void CRobotMain::CreateTooltip(Math::Point pos, char* text)
pos.x = start.x;
pos.y = start.y;
+
+ Math::Point dim;
dim.x = end.x-start.x;
dim.y = end.y-start.y;
+ Math::Point offset;
offset.x = 0.0f;
offset.y = 0.0f;
- if ( pos.x+dim.x > 1.0f ) offset.x = 1.0f-(pos.x+dim.x);
- if ( pos.y < 0.0f ) offset.y = -pos.y;
+ if (pos.x+dim.x > 1.0f) offset.x = 1.0f-(pos.x+dim.x);
+ if (pos.y < 0.0f) offset.y = -pos.y;
corner.x += offset.x;
corner.y += offset.y;
@@ -3164,62 +2971,51 @@ void CRobotMain::CreateTooltip(Math::Point pos, char* text)
m_interface->CreateWindows(pos, dim, 1, EVENT_TOOLTIP);
- pw = (CWindow*)m_interface->SearchControl(EVENT_TOOLTIP);
- if ( pw != 0 )
+ Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_TOOLTIP));
+ if (pw != nullptr)
{
- pw->SetState(STATE_SHADOW);
+ pw->SetState(Ui::STATE_SHADOW);
pw->SetTrashEvent(false);
- pos.y -= m_engine->RetText()->RetHeight(SMALLFONT, FONT_COLOBOT)/2.0f;
+ pos.y -= m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL) / 2.0f;
pw->CreateLabel(pos, dim, -1, EVENT_LABEL2, text);
}
}
-// Clears the previous tooltip.
-
+//! Clears the previous tooltip
void CRobotMain::ClearTooltip()
{
m_interface->DeleteControl(EVENT_TOOLTIP);
}
-// Displays help for an object.
-
+//! Displays help for an object
void CRobotMain::HelpObject()
{
- CObject* pObj;
- char* filename;
+ CObject* obj = GetSelect();
+ if (obj == nullptr) return;
- pObj = RetSelect();
- if ( pObj == 0 ) return;
-
- filename = RetHelpFilename(pObj->RetType());
- if ( filename[0] == 0 ) return;
+ const char* filename = GetHelpFilename(obj->GetType());
+ if (filename[0] == 0) return;
StartDisplayInfo(filename, -1);
}
-// Change the mode of the camera.
-
+//! Change the mode of the camera
void CRobotMain::ChangeCamera()
{
- CObject* pObj;
- ObjectType oType;
- CameraType type;
- int i;
-
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( pObj->RetSelect() )
+ if (obj->GetSelect())
{
- if ( pObj->RetCameraLock() ) return;
+ if (obj->GetCameraLock()) return;
- oType = pObj->RetType();
- type = pObj->RetCameraType();
+ ObjectType oType = obj->GetType();
+ Gfx::CameraType type = obj->GetCameraType();
if ( oType != OBJECT_MOBILEfa &&
oType != OBJECT_MOBILEta &&
@@ -3250,115 +3046,111 @@ void CRobotMain::ChangeCamera()
oType != OBJECT_MOBILEdr &&
oType != OBJECT_APOLLO2 ) return;
- if ( oType == OBJECT_MOBILEdr ) // designer?
+ if (oType == OBJECT_MOBILEdr) // designer?
{
- if ( type == CAMERA_PLANE ) type = CAMERA_BACK;
- else if ( type == CAMERA_BACK ) type = CAMERA_PLANE;
+ if (type == Gfx::CAM_TYPE_PLANE ) type = Gfx::CAM_TYPE_BACK;
+ else if (type == Gfx::CAM_TYPE_BACK ) type = Gfx::CAM_TYPE_PLANE;
}
- else if ( pObj->RetTrainer() ) // trainer?
+ else if (obj->GetTrainer()) // trainer?
{
- if ( type == CAMERA_ONBOARD ) type = CAMERA_FIX;
- else if ( type == CAMERA_FIX ) type = CAMERA_PLANE;
- else if ( type == CAMERA_PLANE ) type = CAMERA_BACK;
- else if ( type == CAMERA_BACK ) type = CAMERA_ONBOARD;
+ if (type == Gfx::CAM_TYPE_ONBOARD) type = Gfx::CAM_TYPE_FIX;
+ else if (type == Gfx::CAM_TYPE_FIX ) type = Gfx::CAM_TYPE_PLANE;
+ else if (type == Gfx::CAM_TYPE_PLANE ) type = Gfx::CAM_TYPE_BACK;
+ else if (type == Gfx::CAM_TYPE_BACK ) type = Gfx::CAM_TYPE_ONBOARD;
}
else
{
- if ( type == CAMERA_ONBOARD ) type = CAMERA_BACK;
- else if ( type == CAMERA_BACK ) type = CAMERA_ONBOARD;
+ if (type == Gfx::CAM_TYPE_ONBOARD) type = Gfx::CAM_TYPE_BACK;
+ else if (type == Gfx::CAM_TYPE_BACK ) type = Gfx::CAM_TYPE_ONBOARD;
}
- pObj->SetCameraType(type);
+ obj->SetCameraType(type);
m_camera->SetType(type);
}
}
}
-// Remote control the camera using the arrow keys.
-
-void CRobotMain::KeyCamera(EventMsg event, long param)
+//! Remote control the camera using the arrow keys
+void CRobotMain::KeyCamera(EventType type, unsigned int key)
{
- CObject* pObj;
+ // TODO: rewrite key handling to input bindings
- if ( event == EVENT_KEYUP )
+ if (type == EVENT_KEY_UP)
{
- if ( param == m_engine->RetKey(KEYRANK_LEFT, 0) ||
- param == m_engine->RetKey(KEYRANK_LEFT, 1) )
+ if (key == GetInputBinding(INPUT_SLOT_LEFT).key ||
+ key == GetInputBinding(INPUT_SLOT_LEFT).joy)
{
m_cameraPan = 0.0f;
}
- if ( param == m_engine->RetKey(KEYRANK_RIGHT, 0) ||
- param == m_engine->RetKey(KEYRANK_RIGHT, 1) )
+ if (key == GetInputBinding(INPUT_SLOT_RIGHT).key ||
+ key == GetInputBinding(INPUT_SLOT_RIGHT).joy)
{
m_cameraPan = 0.0f;
}
- if ( param == m_engine->RetKey(KEYRANK_UP, 0) ||
- param == m_engine->RetKey(KEYRANK_UP, 1) )
+ if (key == GetInputBinding(INPUT_SLOT_UP).key ||
+ key == GetInputBinding(INPUT_SLOT_UP).joy)
{
m_cameraZoom = 0.0f;
}
- if ( param == m_engine->RetKey(KEYRANK_DOWN, 0) ||
- param == m_engine->RetKey(KEYRANK_DOWN, 1) )
+ if (key == GetInputBinding(INPUT_SLOT_DOWN).key ||
+ key == GetInputBinding(INPUT_SLOT_DOWN).joy)
{
m_cameraZoom = 0.0f;
}
}
- if ( m_phase != PHASE_SIMUL ) return;
- if ( m_bEditLock ) return; // current edition?
- if ( m_bTrainerPilot ) return;
+ if (m_phase != PHASE_SIMUL) return;
+ if (m_editLock) return; // current edition?
+ if (m_trainerPilot) return;
- pObj = RetSelect();
- if ( pObj == 0 ) return;
- if ( !pObj->RetTrainer() ) return;
+ CObject* obj = GetSelect();
+ if (obj == nullptr) return;
+ if (!obj->GetTrainer()) return;
- if ( event == EVENT_KEYDOWN )
+ if (type == EVENT_KEY_DOWN)
{
- if ( param == m_engine->RetKey(KEYRANK_LEFT, 0) ||
- param == m_engine->RetKey(KEYRANK_LEFT, 1) )
+ if (key == GetInputBinding(INPUT_SLOT_LEFT).key ||
+ key == GetInputBinding(INPUT_SLOT_LEFT).joy)
{
m_cameraPan = -1.0f;
}
- if ( param == m_engine->RetKey(KEYRANK_RIGHT, 0) ||
- param == m_engine->RetKey(KEYRANK_RIGHT, 1) )
+ if (key == GetInputBinding(INPUT_SLOT_RIGHT).key ||
+ key == GetInputBinding(INPUT_SLOT_RIGHT).joy)
{
m_cameraPan = 1.0f;
}
- if ( param == m_engine->RetKey(KEYRANK_UP, 0) ||
- param == m_engine->RetKey(KEYRANK_UP, 1) )
+ if (key == GetInputBinding(INPUT_SLOT_UP).key ||
+ key == GetInputBinding(INPUT_SLOT_UP).joy)
{
m_cameraZoom = -1.0f;
}
- if ( param == m_engine->RetKey(KEYRANK_DOWN, 0) ||
- param == m_engine->RetKey(KEYRANK_DOWN, 1) )
+ if (key == GetInputBinding(INPUT_SLOT_DOWN).key ||
+ key == GetInputBinding(INPUT_SLOT_DOWN).joy)
{
m_cameraZoom = 1.0f;
}
}
}
-// Panned with the camera if a button is pressed.
-
+//! Panned with the camera if a button is pressed
void CRobotMain::RemoteCamera(float pan, float zoom, float rTime)
{
- float value;
-
- if ( pan != 0.0f )
+ if (pan != 0.0f)
{
- value = m_camera->RetRemotePan();
+ float value = m_camera->GetRemotePan();
value += pan*rTime*1.5f;
m_camera->SetRemotePan(value);
}
- if ( zoom != 0.0f )
+ if (zoom != 0.0f)
{
- value = m_camera->RetRemoteZoom();
+ float value = m_camera->GetRemoteZoom();
value += zoom*rTime*0.3f;
m_camera->SetRemoteZoom(value);
}
@@ -3366,199 +3158,155 @@ void CRobotMain::RemoteCamera(float pan, float zoom, float rTime)
-// Cancels the current movie.
-
+//! Cancels the current movie
void CRobotMain::AbortMovie()
{
- CObject* pObj;
- CAuto* automat;
- int i;
-
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- automat = pObj->RetAuto();
- if ( automat != 0 )
- {
+ CAuto* automat = obj->GetAuto();
+ if (automat != 0)
automat->Abort();
- }
}
- m_engine->SetMouseHide(false);
+ m_engine->SetMouseVisible(true);
}
-// Updates the text information.
-
+//! Updates the text information
void CRobotMain::UpdateInfoText()
{
- CObject* pObj;
- Math::Vector pos;
- char info[100];
-
- if ( m_bShowPos )
+ if (m_showPos)
{
- pObj = RetSelect();
- if ( pObj != 0 )
+ CObject* obj = GetSelect();
+ if (obj != nullptr)
{
- pos = pObj->RetPosition(0);
+ Math::Vector pos = obj->GetPosition(0);
+ char info[100];
sprintf(info, "Pos = %.2f ; %.2f", pos.x/g_unit, pos.z/g_unit);
- m_engine->SetInfoText(4, info);
+ //TODO: m_engine->SetInfoText(4, info);
}
}
}
-// Initializes the view.
-
+//! Initializes the view
void CRobotMain::InitEye()
{
- if ( m_phase == PHASE_SIMUL )
- {
+ if (m_phase == PHASE_SIMUL)
m_camera->Init(Math::Vector( 0.0f, 10.0f, 0.0f),
Math::Vector(10.0f, 5.0f, 0.0f), 0.0f);
- }
-
- if ( m_phase == PHASE_MODEL )
- {
- m_model->InitView();
- }
}
-// Advances the entire scene.
-
+//! Advances the entire scene
bool CRobotMain::EventFrame(const Event &event)
{
- ObjectType type;
- CObject *pObj, *toto;
- CPyro* pPyro;
- CWindow* pw;
- CMap* pm;
- int i;
-
m_time += event.rTime;
- if ( !m_bMovieLock ) m_gameTime += event.rTime;
+ if (!m_movieLock) m_gameTime += event.rTime;
- if ( !m_bImmediatSatCom && !m_bBeginSatCom &&
- m_gameTime > 0.1f && m_phase == PHASE_SIMUL )
+ if (!m_immediatSatCom && !m_beginSatCom &&
+ m_gameTime > 0.1f && m_phase == PHASE_SIMUL)
{
m_displayText->DisplayError(INFO_BEGINSATCOM, Math::Vector(0.0f,0.0f,0.0f));
- m_bBeginSatCom = true; // message appears
+ m_beginSatCom = true; // message appears
}
m_water->EventProcess(event);
m_cloud->EventProcess(event);
- m_blitz->EventProcess(event);
+ m_lightning->EventProcess(event);
m_planet->EventProcess(event);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 )
+ Ui::CMap* pm = nullptr;
+ Ui::CWindow* pw = dynamic_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
{
- pm = 0;
+ pm = nullptr;
}
else
{
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm != 0 ) pm->FlushObject();
+ pm = dynamic_cast<Ui::CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm != nullptr) pm->FlushObject();
}
- toto = 0;
- if ( !m_bFreePhoto )
+ CObject* toto = nullptr;
+ if (!m_freePhoto)
{
// Advances all the robots, but not toto.
- for ( i=0 ; i<1000000 ; i++ )
- {
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
- if ( pm != 0 ) pm->UpdateObject(pObj);
- if ( pObj->RetTruck() != 0 ) continue;
- type = pObj->RetType();
- if ( type == OBJECT_TOTO )
- {
- toto = pObj;
- }
+ for (int i = 0; i < 1000000; i++)
+ {
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
+ if (pm != nullptr) pm->UpdateObject(obj);
+ if (obj->GetTruck() != nullptr) continue;
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_TOTO)
+ toto = obj;
else
- {
- pObj->EventProcess(event);
- }
+ obj->EventProcess(event);
}
// Advances all objects transported by robots.
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
- if ( pObj->RetTruck() == 0 ) continue;
- pObj->EventProcess(event);
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
+ if (obj->GetTruck() == nullptr) continue;
+ obj->EventProcess(event);
}
// Advances pyrotechnic effects.
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pPyro = (CPyro*)m_iMan->SearchInstance(CLASS_PYRO, i);
- if ( pPyro == 0 ) break;
+ Gfx::CPyro* pyro = static_cast<Gfx::CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, i));
+ if (pyro == nullptr) break;
- pPyro->EventProcess(event);
- if ( pPyro->IsEnded() != ERR_CONTINUE )
+ pyro->EventProcess(event);
+ if (pyro->IsEnded() != ERR_CONTINUE)
{
- pPyro->DeleteObject();
- delete pPyro;
+ pyro->DeleteObject();
+ delete pyro;
}
}
}
// The camera follows the object, because its position
- // may depend on the selected object (CAMERA_ONBOARD or CAMERA_BACK).
- if ( m_phase == PHASE_SIMUL && !m_bEditFull )
+ // may depend on the selected object (Gfx::CAM_TYPE_ONBOARD or Gfx::CAM_TYPE_BACK).
+ if (m_phase == PHASE_SIMUL && !m_editFull)
{
m_camera->EventProcess(event);
- if ( m_engine->RetFog() )
- {
- m_camera->SetOverBaseColor(m_particule->RetFogColor(m_engine->RetEyePt()));
- }
+ if (m_engine->GetFog())
+ m_camera->SetOverBaseColor(m_particle->GetFogColor(m_engine->GetEyePt()));
}
- if ( m_phase == PHASE_PERSO ||
- m_phase == PHASE_WIN ||
- m_phase == PHASE_LOST )
+ if (m_phase == PHASE_PERSO ||
+ m_phase == PHASE_WIN ||
+ m_phase == PHASE_LOST)
{
m_camera->EventProcess(event);
}
// Advances toto following the camera, because its position depends on the camera.
- if ( toto != 0 )
- {
+ if (toto != nullptr)
toto->EventProcess(event);
- }
-
- // Advances model.
- if ( m_phase == PHASE_MODEL )
- {
- m_model->ViewMove(event, 2.0f);
- m_model->UpdateView();
- m_model->EventProcess(event);
- }
HiliteFrame(event.rTime);
// Moves the film indicator.
- if ( m_bMovieLock && !m_bEditLock ) // movie in progress?
+ if (m_movieLock && !m_editLock) // movie in progress?
{
- CControl* pc;
- Math::Point pos, dim;
- float zoom;
-
- pc = m_interface->SearchControl(EVENT_OBJECT_MOVIELOCK);
- if ( pc != 0 )
+ Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_MOVIELOCK);
+ if (pc != nullptr)
{
+ Math::Point pos, dim;
+
dim.x = 32.0f/640.0f;
dim.y = 32.0f/480.0f;
pos.x = 20.0f/640.0f;
pos.y = (480.0f-24.0f)/480.0f;
- zoom = 1.0f+sinf(m_time*6.0f)*0.1f; // 0.9 .. 1.1
+ float zoom = 1.0f+sinf(m_time*6.0f)*0.1f; // 0.9 .. 1.1
dim.x *= zoom;
dim.y *= zoom;
pos.x -= dim.x/2.0f;
@@ -3570,16 +3318,14 @@ bool CRobotMain::EventFrame(const Event &event)
}
// Moves edition indicator.
- if ( m_bEditLock || m_bPause ) // edition in progress?
+ if (m_editLock || m_pause) // edition in progress?
{
- CControl* pc;
- Math::Point pos, dim;
- float zoom;
-
- pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK);
- if ( pc != 0 )
+ Ui::CControl* pc = m_interface->SearchControl(EVENT_OBJECT_EDITLOCK);
+ if (pc != nullptr)
{
- if ( m_bEditFull || m_bEditLock )
+ Math::Point pos, dim;
+
+ if (m_editFull || m_editLock)
{
dim.x = 10.0f/640.0f;
dim.y = 10.0f/480.0f;
@@ -3593,7 +3339,7 @@ bool CRobotMain::EventFrame(const Event &event)
pos.x = 20.0f/640.0f;
pos.y = (480.0f-24.0f)/480.0f;
- zoom = 1.0f+sinf(m_time*6.0f)*0.1f; // 0.9 .. 1.1
+ float zoom = 1.0f+sinf(m_time*6.0f)*0.1f; // 0.9 .. 1.1
dim.x *= zoom;
dim.y *= zoom;
pos.x -= dim.x/2.0f;
@@ -3605,107 +3351,84 @@ bool CRobotMain::EventFrame(const Event &event)
}
// Will move the arrow to visit.
- if ( m_camera->RetType() == CAMERA_VISIT )
- {
+ if (m_camera->GetType() == Gfx::CAM_TYPE_VISIT)
FrameVisit(event.rTime);
- }
// Moves the boundaries.
FrameShowLimit(event.rTime);
- if ( m_phase == PHASE_SIMUL )
+ if (m_phase == PHASE_SIMUL)
{
- if ( !m_bEditLock && m_checkEndTime+1.0f < m_time )
+ if (!m_editLock && m_checkEndTime+1.0f < m_time)
{
m_checkEndTime = m_time;
CheckEndMission(true);
}
- if ( m_winDelay > 0.0f && !m_bEditLock )
+ if (m_winDelay > 0.0f && !m_editLock)
{
m_winDelay -= event.rTime;
- if ( m_winDelay <= 0.0f )
+ if (m_winDelay <= 0.0f)
{
- if ( m_bMovieLock )
- {
+ if (m_movieLock)
m_winDelay = 1.0f;
- }
else
- {
- Event newEvent;
- m_event->MakeEvent(newEvent, EVENT_WIN);
- m_event->AddEvent(newEvent);
- }
+ m_eventQueue->AddEvent(Event(EVENT_WIN));
}
}
- if ( m_lostDelay > 0.0f && !m_bEditLock )
+ if (m_lostDelay > 0.0f && !m_editLock)
{
m_lostDelay -= event.rTime;
- if ( m_lostDelay <= 0.0f )
+ if (m_lostDelay <= 0.0f)
{
- if ( m_bMovieLock )
- {
+ if (m_movieLock)
m_winDelay = 1.0f;
- }
else
- {
- Event newEvent;
- m_event->MakeEvent(newEvent, EVENT_LOST);
- m_event->AddEvent(newEvent);
- }
+ m_eventQueue->AddEvent(Event(EVENT_LOST));
}
}
}
- if ( m_delayWriteMessage > 0 )
+ if (m_delayWriteMessage > 0)
{
m_delayWriteMessage --;
- if ( m_delayWriteMessage == 0 )
+ if (m_delayWriteMessage == 0)
{
m_displayText->DisplayError(INFO_WRITEOK, Math::Vector(0.0f,0.0f,0.0f));
}
}
- return S_OK;
+ return true;
}
-// Makes the event for all robots.
-
+//! Makes the event for all robots
bool CRobotMain::EventObject(const Event &event)
{
- CObject* pObj;
- int i;
+ if (m_freePhoto) return true;
- if ( m_bFreePhoto ) return S_OK;
+ m_resetCreate = false;
- m_bResetCreate = false;
-
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- pObj->EventProcess(event);
+ obj->EventProcess(event);
}
- if ( m_bResetCreate )
- {
+ if (m_resetCreate)
ResetCreate();
- }
- return S_OK;
+ return true;
}
-// Calculates the point of arrival of the camera.
-
+//! Calculates the point of arrival of the camera
Math::Vector CRobotMain::LookatPoint(Math::Vector eye, float angleH, float angleV,
float length)
{
- Math::Vector lookat;
-
- lookat = eye;
+ Math::Vector lookat = eye;
lookat.z += length;
RotatePoint(eye, angleH, angleV, lookat);
@@ -3716,49 +3439,42 @@ Math::Vector CRobotMain::LookatPoint(Math::Vector eye, float angleH, float angle
char* SkipNum(char *p)
{
- while ( *p == ' ' || *p == '.' || *p == '-' || (*p >= '0' && *p <= '9') )
+ while (*p == ' ' || *p == '.' || *p == '-' || (*p >= '0' && *p <= '9'))
{
p++;
}
return p;
}
-// Conversion of units.
-
+//! Conversion of units
void CRobotMain::Convert()
{
- FILE* file = NULL;
- FILE* fileNew = NULL;
- char line[500];
- char lineNew[500];
- char s[200];
- char* base;
- char* p;
- int rank;
- Math::Vector pos;
- float value;
+ char* base = m_dialog->GetSceneName();
+ int rank = m_dialog->GetSceneRank();
- base = m_dialog->RetSceneName();
- rank = m_dialog->RetSceneRank();
+ char line[500];
m_dialog->BuildSceneName(line, base, rank);
- file = fopen(line, "r");
- if ( file == NULL ) return;
+ FILE* file = fopen(line, "r");
+ if (file == NULL) return;
strcpy(line+strlen(line)-4, ".new");
- fileNew = fopen(line, "w");
- if ( fileNew == NULL ) return;
+ FILE* fileNew = fopen(line, "w");
+ if (fileNew == NULL) return;
+
+ char lineNew[500];
+ char s[200];
- while ( fgets(line, 500, file) != NULL )
+ while (fgets(line, 500, file) != NULL)
{
strcpy(lineNew, line);
- if ( Cmd(line, "DeepView") )
+ if (Cmd(line, "DeepView"))
{
- p = strstr(line, "air=");
- if ( p != 0 )
+ char* p = strstr(line, "air=");
+ if (p != 0)
{
- value = OpFloat(line, "air", 500.0f);
+ float value = OpFloat(line, "air", 500.0f);
value /= g_unit;
p[0] = 0;
p = SkipNum(p+4);
@@ -3772,9 +3488,9 @@ void CRobotMain::Convert()
strcpy(line, lineNew);
p = strstr(line, "water=");
- if ( p != 0 )
+ if (p != 0)
{
- value = OpFloat(line, "water", 100.0f);
+ float value = OpFloat(line, "water", 100.0f);
value /= g_unit;
p[0] = 0;
p = SkipNum(p+6);
@@ -3788,12 +3504,12 @@ void CRobotMain::Convert()
strcpy(line, lineNew);
}
- if ( Cmd(line, "TerrainGenerate") )
+ if (Cmd(line, "TerrainGenerate"))
{
- p = strstr(line, "vision=");
- if ( p != 0 )
+ char* p = strstr(line, "vision=");
+ if (p != 0)
{
- value = OpFloat(line, "vision", 500.0f);
+ float value = OpFloat(line, "vision", 500.0f);
value /= g_unit;
p[0] = 0;
p = SkipNum(p+7);
@@ -3806,13 +3522,13 @@ void CRobotMain::Convert()
}
}
- if ( Cmd(line, "CreateObject") ||
- Cmd(line, "CreateSpot") )
+ if (Cmd(line, "CreateObject") ||
+ Cmd(line, "CreateSpot"))
{
- p = strstr(line, "pos=");
- if ( p != 0 )
+ char* p = strstr(line, "pos=");
+ if (p != 0)
{
- pos = OpPos(line, "pos");
+ Math::Vector pos = OpPos(line, "pos");
pos.x /= g_unit;
pos.y /= g_unit;
pos.z /= g_unit;
@@ -3831,12 +3547,12 @@ void CRobotMain::Convert()
}
}
- if ( Cmd(line, "EndMissionTake") )
+ if (Cmd(line, "EndMissionTake"))
{
- p = strstr(line, "pos=");
- if ( p != 0 )
+ char* p = strstr(line, "pos=");
+ if (p != 0)
{
- pos = OpPos(line, "pos");
+ Math::Vector pos = OpPos(line, "pos");
pos.x /= g_unit;
pos.y /= g_unit;
pos.z /= g_unit;
@@ -3856,9 +3572,9 @@ void CRobotMain::Convert()
strcpy(line, lineNew);
p = strstr(line, "dist=");
- if ( p != 0 )
+ if (p != 0)
{
- value = OpFloat(line, "dist", 32.0f);
+ float value = OpFloat(line, "dist", 32.0f);
value /= g_unit;
p[0] = 0;
p = SkipNum(p+5);
@@ -3872,12 +3588,12 @@ void CRobotMain::Convert()
strcpy(line, lineNew);
}
- if ( Cmd(line, "Camera") )
+ if (Cmd(line, "Camera"))
{
- p = strstr(line, "pos=");
- if ( p != 0 )
+ char* p = strstr(line, "pos=");
+ if (p != 0)
{
- pos = OpPos(line, "pos");
+ Math::Vector pos = OpPos(line, "pos");
pos.x /= g_unit;
pos.y /= g_unit;
pos.z /= g_unit;
@@ -3897,9 +3613,9 @@ void CRobotMain::Convert()
strcpy(line, lineNew);
p = strstr(line, "h=");
- if ( p != 0 )
+ if (p != 0)
{
- value = OpFloat(line, "h", 32.0f);
+ float value = OpFloat(line, "h", 32.0f);
value /= g_unit;
p[0] = 0;
p = SkipNum(p+2);
@@ -3920,19 +3636,16 @@ void CRobotMain::Convert()
fclose(file);
}
-// Load the scene for the character.
-
+//! Load the scene for the character
void CRobotMain::ScenePerso()
{
- CObject* pObj;
-
DeleteAllObjects(); // removes all the current 3D Scene
m_engine->FlushObject();
m_terrain->FlushRelief(); // all flat
m_terrain->FlushBuildingLevel();
m_terrain->FlushFlyingLimit();
- m_light->FlushLight();
- m_particule->FlushParticule();
+ m_lightMan->FlushLights();
+ m_particle->FlushParticle();
m_iMan->Flush(CLASS_OBJECT);
m_iMan->Flush(CLASS_PHYSICS);
m_iMan->Flush(CLASS_BRAIN);
@@ -3944,66 +3657,44 @@ void CRobotMain::ScenePerso()
m_engine->SetDrawWorld(false); // does not draw anything on the interface
m_engine->SetDrawFront(true); // draws on the human interface
- pObj = SearchHuman();
- if ( pObj != 0 )
+ CObject* obj = SearchHuman();
+ if (obj != nullptr)
{
- CMotionHuman* mh;
+ obj->SetDrawFront(true); // draws the interface
- pObj->SetDrawFront(true); // draws the interface
-
- mh = (CMotionHuman*)pObj->RetMotion();
- if ( mh != 0 )
- {
+ CMotionHuman* mh = static_cast<CMotionHuman*>(obj->GetMotion());
+ if (mh != nullptr)
mh->StartDisplayPerso();
- }
}
}
-// Creates the whole stage.
-
-void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
+//! Creates the whole scene
+void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
{
- CObject* pObj;
- CObject* pSel;
- CMotion* motion;
- FILE* file = NULL;
- char line[500];
- char name[200];
- char dir[100];
- char op[100];
- char* read;
- char* stack;
- char* base;
- D3DCOLORVALUE color;
- Math::Vector pos;
- int rank, obj, i, rankObj, rankGadget;
-
-//? Convert();
-
- base = m_dialog->RetSceneName();
- rank = m_dialog->RetSceneRank();
- read = m_dialog->RetSceneRead();
- stack = m_dialog->RetStackRead();
+ char* base = m_dialog->GetSceneName();
+ int rank = m_dialog->GetSceneRank();
+ char* read = m_dialog->GetSceneRead();
+ char* stack = m_dialog->GetStackRead();
m_dialog->SetUserDir(base, rank);
- m_bFixScene = bFixScene;
+ m_fixScene = fixScene;
g_id = 0;
- m_bBase = false;
+ m_base = false;
- if ( !bResetObject )
+ if (!resetObject)
{
g_build = 0;
g_researchDone = 0; // no research done
g_researchEnable = 0;
FlushDisplayInfo();
- m_terrain->LevelFlush();
+ m_terrain->FlushMaterials();
m_audioTrack = 0;
- m_bAudioRepeat = true;
+ m_audioRepeat = true;
m_displayText->SetDelay(1.0f);
m_displayText->SetEnable(true);
- m_bImmediatSatCom = false;
+ m_immediatSatCom = false;
m_endingWinRank = 0;
m_endingLostRank = 0;
m_endTakeTotal = 0;
@@ -4012,8 +3703,8 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
m_endTakeLostDelay = 2.0f;
m_obligatoryTotal = 0;
m_prohibitedTotal = 0;
- m_bMapShow = true;
- m_bMapImage = false;
+ m_mapShow = true;
+ m_mapImage = false;
m_mapFilename[0] = 0;
m_colorRefBot.r = 10.0f/256.0f;
@@ -4046,159 +3737,144 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
m_scriptFile[0] = 0;
}
+ char line[500];
+ char name[200];
+ char dir[100];
+ char op[100];
+
m_dialog->BuildSceneName(line, base, rank);
- file = fopen(line, "r");
- if ( file == NULL ) return;
+ FILE* file = fopen(line, "r");
+ if (file == NULL) return;
- rankObj = 0;
- rankGadget = 0;
- pSel = 0;
+ int rankObj = 0;
+ int rankGadget = 0;
+ CObject* sel = 0;
- while ( fgets(line, 500, file) != NULL )
+ while (fgets(line, 500, file) != NULL)
{
- for ( i=0 ; i<500 ; i++ )
+ for (int i = 0; i < 500; i++)
{
- if ( line[i] == '\t' ) line[i] = ' '; // replace tab by space
- if ( line[i] == '/' && line[i+1] == '/' )
+ if (line[i] == '\t' ) line[i] = ' '; // replace tab by space
+ if (line[i] == '/' && line[i+1] == '/')
{
line[i] = 0;
break;
}
}
- sprintf(op, "Title.%c", RetLanguageLetter());
- if ( Cmd(line, op) && !bResetObject )
- {
+ // TODO: language letters
+ sprintf(op, "Title.%c", 'E' /*GetLanguageLetter()*/);
+ if (Cmd(line, op) && !resetObject)
OpString(line, "text", m_title);
- }
- sprintf(op, "Resume.%c", RetLanguageLetter());
- if ( Cmd(line, op) && !bResetObject )
- {
+ sprintf(op, "Resume.%c", 'E' /*GetLanguageLetter()*/);
+ if (Cmd(line, op) && !resetObject)
OpString(line, "text", m_resume);
- }
- sprintf(op, "ScriptName.%c", RetLanguageLetter());
- if ( Cmd(line, op) && !bResetObject )
- {
+ sprintf(op, "ScriptName.%c", 'E' /*GetLanguageLetter()*/);
+ if (Cmd(line, op) && !resetObject)
OpString(line, "text", m_scriptName);
- }
- if ( Cmd(line, "ScriptFile") && !bResetObject )
- {
+ if (Cmd(line, "ScriptFile") && !resetObject)
OpString(line, "name", m_scriptFile);
- }
- if ( Cmd(line, "Instructions") && !bResetObject )
+ if (Cmd(line, "Instructions") && !resetObject)
{
OpString(line, "name", name);
-//? sprintf(m_infoFilename[SATCOM_HUSTON], "help\\%s", name);
UserDir(m_infoFilename[SATCOM_HUSTON], name, "help");
- m_bImmediatSatCom = OpInt(line, "immediat", 0);
+ m_immediatSatCom = OpInt(line, "immediat", 0);
}
- if ( Cmd(line, "Satellite") && !bResetObject )
+ if (Cmd(line, "Satellite") && !resetObject)
{
OpString(line, "name", name);
-//? sprintf(m_infoFilename[SATCOM_SAT], "help\\%s", name);
UserDir(m_infoFilename[SATCOM_SAT], name, "help");
}
- if ( Cmd(line, "Loading") && !bResetObject )
+ if (Cmd(line, "Loading") && !resetObject)
{
OpString(line, "name", name);
-//? sprintf(m_infoFilename[SATCOM_LOADING], "help\\%s", name);
UserDir(m_infoFilename[SATCOM_LOADING], name, "help");
}
- if ( Cmd(line, "HelpFile") && !bResetObject )
+ if (Cmd(line, "HelpFile") && !resetObject)
{
OpString(line, "name", name);
-//? sprintf(m_infoFilename[SATCOM_PROG], "help\\%s", name);
UserDir(m_infoFilename[SATCOM_PROG], name, "help");
}
- if ( Cmd(line, "SoluceFile") && !bResetObject )
+ if (Cmd(line, "SoluceFile") && !resetObject)
{
OpString(line, "name", name);
-//? sprintf(m_infoFilename[SATCOM_SOLUCE], "help\\%s", name);
UserDir(m_infoFilename[SATCOM_SOLUCE], name, "help");
}
- if ( Cmd(line, "EndingFile") && !bResetObject )
+ if (Cmd(line, "EndingFile") && !resetObject)
{
m_endingWinRank = OpInt(line, "win", 0);
m_endingLostRank = OpInt(line, "lost", 0);
}
- if ( Cmd(line, "MessageDelay") && !bResetObject )
+ if (Cmd(line, "MessageDelay") && !resetObject)
{
m_displayText->SetDelay(OpFloat(line, "factor", 1.0f));
}
- if ( Cmd(line, "Audio") && !bResetObject )
+ if (Cmd(line, "Audio") && !resetObject)
{
m_audioTrack = OpInt(line, "track", 0);
- m_bAudioRepeat = OpInt(line, "repeat", 1);
+ m_audioRepeat = OpInt(line, "repeat", 1);
}
- if ( Cmd(line, "AmbiantColor") && !bResetObject )
+ if (Cmd(line, "AmbientColor") && !resetObject)
{
- m_engine->SetAmbiantColor(OpColor(line, "air", 0x88888888), 0);
- m_engine->SetAmbiantColor(OpColor(line, "water", 0x88888888), 1);
+ m_engine->SetAmbientColor(OpColor(line, "air", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 0);
+ m_engine->SetAmbientColor(OpColor(line, "water", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 1);
}
- if ( Cmd(line, "FogColor") && !bResetObject )
+ if (Cmd(line, "FogColor") && !resetObject)
{
- m_engine->SetFogColor(OpColor(line, "air", 0x88888888), 0);
- m_engine->SetFogColor(OpColor(line, "water", 0x88888888), 1);
+ m_engine->SetFogColor(OpColor(line, "air", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 0);
+ m_engine->SetFogColor(OpColor(line, "water", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)), 1);
}
- if ( Cmd(line, "VehicleColor") && !bResetObject )
- {
- m_colorNewBot = RetColor(OpColor(line, "color", 0x88888888));
- }
+ if (Cmd(line, "VehicleColor") && !resetObject)
+ m_colorNewBot = OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f));
- if ( Cmd(line, "InsectColor") && !bResetObject )
- {
- m_colorNewAlien = RetColor(OpColor(line, "color", 0x88888888));
- }
+ if (Cmd(line, "InsectColor") && !resetObject)
+ m_colorNewAlien = OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f));
- if ( Cmd(line, "GreeneryColor") && !bResetObject )
- {
- m_colorNewGreen = RetColor(OpColor(line, "color", 0x88888888));
- }
+ if (Cmd(line, "GreeneryColor") && !resetObject)
+ m_colorNewGreen = OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f));
- if ( Cmd(line, "DeepView") && !bResetObject )
+ if (Cmd(line, "DeepView") && !resetObject)
{
m_engine->SetDeepView(OpFloat(line, "air", 500.0f)*UNIT, 0, true);
m_engine->SetDeepView(OpFloat(line, "water", 100.0f)*UNIT, 1, true);
}
- if ( Cmd(line, "FogStart") && !bResetObject )
+ if (Cmd(line, "FogStart") && !resetObject)
{
m_engine->SetFogStart(OpFloat(line, "air", 0.5f), 0);
m_engine->SetFogStart(OpFloat(line, "water", 0.5f), 1);
}
- if ( Cmd(line, "SecondTexture") && !bResetObject )
- {
+ if (Cmd(line, "SecondTexture") && !resetObject)
m_engine->SetSecondTexture(OpInt(line, "rank", 1));
- }
- if ( Cmd(line, "Background") && !bResetObject )
+ if (Cmd(line, "Background") && !resetObject)
{
OpString(line, "image", name);
UserDir(dir, name, "");
m_engine->SetBackground(dir,
- OpColor(line, "up", 0x00000000),
- OpColor(line, "down", 0x00000000),
- OpColor(line, "cloudUp", 0x00000000),
- OpColor(line, "cloudDown", 0x00000000),
+ OpColor(line, "up", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)),
+ OpColor(line, "down", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)),
+ OpColor(line, "cloudUp", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)),
+ OpColor(line, "cloudDown", Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)),
OpInt(line, "full", 0));
}
- if ( Cmd(line, "Planet") && !bResetObject )
+ if (Cmd(line, "Planet") && !resetObject)
{
Math::Vector ppos, uv1, uv2;
@@ -4217,21 +3893,21 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
Math::Point(uv2.x, uv2.z));
}
- if ( Cmd(line, "FrontsizeName") && !bResetObject )
+ if (Cmd(line, "FrontsizeName") && !resetObject)
{
OpString(line, "image", name);
UserDir(dir, name, "");
- m_engine->SetFrontsizeName(dir);
+ m_engine->SetForegroundName(dir);
}
- if ( Cmd(line, "Global") && !bResetObject )
+ if (Cmd(line, "Global") && !resetObject)
{
g_unit = OpFloat(line, "unitScale", 4.0f);
m_engine->SetTracePrecision(OpFloat(line, "traceQuality", 1.0f));
- m_bShortCut = OpInt(line, "shortcut", 1);
+ m_shortCut = OpInt(line, "shortcut", 1);
}
- if ( Cmd(line, "TerrainGenerate") && !bResetObject )
+ if (Cmd(line, "TerrainGenerate") && !resetObject)
{
m_terrain->Generate(OpInt(line, "mosaic", 20),
OpInt(line, "brick", 3),
@@ -4241,182 +3917,138 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
OpFloat(line, "hard", 0.5f));
}
- if ( Cmd(line, "TerrainWind") && !bResetObject )
- {
+ if (Cmd(line, "TerrainWind") && !resetObject)
m_terrain->SetWind(OpPos(line, "speed"));
- }
-
- if ( Cmd(line, "TerrainRelief") && !bResetObject )
- {
- OpString(line, "image", name);
- UserDir(dir, name, "textures");
- m_terrain->ReliefFromBMP(dir, OpFloat(line, "factor", 1.0f), OpInt(line, "border", 1));
- }
- if ( Cmd(line, "TerrainReliefDXF") && !bResetObject )
+ if (Cmd(line, "TerrainRelief") && !resetObject)
{
OpString(line, "image", name);
UserDir(dir, name, "textures");
- m_terrain->ReliefFromDXF(dir, OpFloat(line, "factor", 1.0f));
+ m_terrain->LoadRelief(dir, OpFloat(line, "factor", 1.0f), OpInt(line, "border", 1));
}
- if ( Cmd(line, "TerrainResource") && !bResetObject )
+ if (Cmd(line, "TerrainResource") && !resetObject)
{
OpString(line, "image", name);
UserDir(dir, name, "textures");
- m_terrain->ResFromBMP(dir);
+ m_terrain->LoadResources(dir);
}
- if ( Cmd(line, "TerrainWater") && !bResetObject )
+ if (Cmd(line, "TerrainWater") && !resetObject)
{
OpString(line, "image", name);
UserDir(dir, name, "");
+ Math::Vector pos;
pos.x = OpFloat(line, "moveX", 0.0f);
pos.y = OpFloat(line, "moveY", 0.0f);
pos.z = pos.x;
- m_water->Create(OpTypeWater(line, "air", WATER_TT),
- OpTypeWater(line, "water", WATER_TT),
+ m_water->Create(OpTypeWater(line, "air", Gfx::WATER_TT),
+ OpTypeWater(line, "water", Gfx::WATER_TT),
dir,
- RetColor(OpColor(line, "diffuse", 0xffffffff)),
- RetColor(OpColor(line, "ambiant", 0xffffffff)),
+ OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)),
+ OpColor(line, "ambiant", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)),
OpFloat(line, "level", 100.0f)*UNIT,
OpFloat(line, "glint", 1.0f),
pos);
- m_colorNewWater = RetColor(OpColor(line, "color", RetColor(m_colorRefWater)));
+ m_colorNewWater = OpColor(line, "color", m_colorRefWater);
m_colorShiftWater = OpFloat(line, "brightness", 0.0f);
}
- if ( Cmd(line, "TerrainLava") && !bResetObject )
- {
+ if (Cmd(line, "TerrainLava") && !resetObject)
m_water->SetLava(OpInt(line, "mode", 0));
- }
- if ( Cmd(line, "TerrainCloud") && !bResetObject )
+ if (Cmd(line, "TerrainCloud") && !resetObject)
{
OpString(line, "image", name);
UserDir(dir, name, "");
m_cloud->Create(dir,
- RetColor(OpColor(line, "diffuse", 0xffffffff)),
- RetColor(OpColor(line, "ambiant", 0xffffffff)),
- OpFloat(line, "level", 500.0f)*UNIT);
+ OpColor(line, "diffuse", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)),
+ OpColor(line, "ambiant", Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)),
+ OpFloat(line, "level", 500.0f) * UNIT);
}
- if ( Cmd(line, "TerrainBlitz") && !bResetObject )
+ if (Cmd(line, "TerrainBlitz") && !resetObject)
{
- m_blitz->Create(OpFloat(line, "sleep", 0.0f),
+ m_lightning->Create(OpFloat(line, "sleep", 0.0f),
OpFloat(line, "delay", 3.0f),
- OpFloat(line, "magnetic", 50.0f)*UNIT);
+ OpFloat(line, "magnetic", 50.0f) * UNIT);
}
- if ( Cmd(line, "TerrainInitTextures") && !bResetObject )
+ if (Cmd(line, "TerrainInitTextures") && !resetObject)
{
- int dx, dy, tt[100];
- char* op;
-
OpString(line, "image", name);
- AddExt(name, ".tga");
- dx = OpInt(line, "dx", 1);
- dy = OpInt(line, "dy", 1);
- op = SearchOp(line, "table");
- for ( i=0 ; i<dx*dy ; i++ )
- {
+ AddExt(name, ".png");
+ int dx = OpInt(line, "dx", 1);
+ int dy = OpInt(line, "dy", 1);
+ char* op = SearchOp(line, "table");
+ int tt[100];
+ for (int i = 0; i < dx*dy; i++)
tt[i] = GetInt(op, i, 0);
- }
- if ( strstr(name, "%user%") != 0 )
- {
+ if (strstr(name, "%user%") != 0)
CopyFileListToTemp(name, tt, dx*dy);
- }
m_terrain->InitTextures(name, tt, dx, dy);
}
- if ( Cmd(line, "TerrainInit") && !bResetObject )
- {
- m_terrain->LevelInit(OpInt(line, "id", 1));
- }
+ if (Cmd(line, "TerrainInit") && !resetObject)
+ m_terrain->InitMaterials(OpInt(line, "id", 1));
- if ( Cmd(line, "TerrainMaterial") && !bResetObject )
+ if (Cmd(line, "TerrainMaterial") && !resetObject)
{
OpString(line, "image", name);
- AddExt(name, ".tga");
- if ( strstr(name, "%user%") != 0 )
- {
+ AddExt(name, ".png");
+ if (strstr(name, "%user%") != 0)
CopyFileToTemp(name);
- }
- m_terrain->LevelMaterial(OpInt(line, "id", 0),
- name,
- OpFloat(line, "u", 0.0f),
- OpFloat(line, "v", 0.0f),
- OpInt(line, "up", 1),
- OpInt(line, "right", 1),
- OpInt(line, "down", 1),
- OpInt(line, "left", 1),
- OpFloat(line, "hard", 0.5f));
+ m_terrain->AddMaterial(OpInt(line, "id", 0),
+ name,
+ Math::Point(OpFloat(line, "u", 0.0f),
+ OpFloat(line, "v", 0.0f)),
+ OpInt(line, "up", 1),
+ OpInt(line, "right", 1),
+ OpInt(line, "down", 1),
+ OpInt(line, "left", 1),
+ OpFloat(line, "hard", 0.5f));
}
- if ( Cmd(line, "TerrainLevel") && !bResetObject )
+ if (Cmd(line, "TerrainLevel") && !resetObject)
{
- int id[50];
- char* op;
-
- op = SearchOp(line, "id");
- i = 0;
- while ( true )
+ char* op = SearchOp(line, "id");
+ int id[50];
+ int i = 0;
+ while (i < 50)
{
id[i] = GetInt(op, i, 0);
- if ( id[i++] == 0 ) break;
+ if (id[i++] == 0) break;
}
- m_terrain->LevelGenerate(id,
- OpFloat(line, "min", 0.0f)*UNIT,
- OpFloat(line, "max", 100.0f)*UNIT,
- OpFloat(line, "slope", 5.0f),
- OpFloat(line, "freq", 100.0f),
- OpPos(line, "center")*g_unit,
- OpFloat(line, "radius", 0.0f)*g_unit);
+ m_terrain->GenerateMaterials(id,
+ OpFloat(line, "min", 0.0f)*UNIT,
+ OpFloat(line, "max", 100.0f)*UNIT,
+ OpFloat(line, "slope", 5.0f),
+ OpFloat(line, "freq", 100.0f),
+ OpPos(line, "center")*g_unit,
+ OpFloat(line, "radius", 0.0f)*g_unit);
}
- if ( Cmd(line, "TerrainCreate") && !bResetObject )
- {
- m_terrain->CreateObjects(true);
- }
+ if (Cmd(line, "TerrainCreate") && !resetObject)
+ m_terrain->CreateObjects();
- if ( Cmd(line, "BeginObject") )
+ if (Cmd(line, "BeginObject"))
{
InitEye();
SetMovieLock(false);
- if ( !m_bFixScene )
- {
-//? CreateObject(Math::Vector(0.0f, 0.0f, 0.0f), 0.0f, 0.0f, OBJECT_TOTO);
- }
- if ( read[0] != 0 ) // loading file ?
- {
- pSel = IOReadScene(read, stack);
- }
+ if (read[0] != 0) // loading file ?
+ sel = IOReadScene(read, stack);
}
- if ( Cmd(line, "CreateObject") && read[0] == 0 )
+ if (Cmd(line, "CreateObject") && read[0] == 0)
{
- CObject* pObj;
- CBrain* pBrain;
- CAuto* pAuto;
- CPyro* pyro;
- ObjectType type;
- PyroType pType;
- CameraType cType;
- Info info;
- float dir;
- char op[20];
- char text[100];
- char* p;
- int run, gadget;
+ ObjectType type = OpTypeObject(line, "type", OBJECT_NULL);
- type = OpTypeObject(line, "type", OBJECT_NULL);
-
- gadget = OpInt(line, "gadget", -1);
+ int gadget = OpInt(line, "gadget", -1);
if ( gadget == -1 )
{
gadget = 0;
@@ -4445,270 +4077,238 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
}
}
}
- if ( gadget != 0 ) // is this a gadget?
+ if (gadget != 0) // is this a gadget?
{
- if ( !TestGadgetQuantity(rankGadget++) ) continue;
+ if (!TestGadgetQuantity(rankGadget++)) continue;
}
- pos = OpPos(line, "pos")*g_unit;
- dir = OpFloat(line, "dir", 0.0f)*Math::PI;
- pObj = CreateObject(pos, dir,
- OpFloat(line, "z", 1.0f),
- OpFloat(line, "h", 0.0f),
- type,
- OpFloat(line, "power", 1.0f),
- OpInt(line, "trainer", 0),
- OpInt(line, "toy", 0),
- OpInt(line, "option", 0));
-
- if ( pObj != 0 )
+ Math::Vector pos = OpPos(line, "pos")*g_unit;
+ float dir = OpFloat(line, "dir", 0.0f)*Math::PI;
+ CObject* obj = CreateObject(pos, dir,
+ OpFloat(line, "z", 1.0f),
+ OpFloat(line, "h", 0.0f),
+ type,
+ OpFloat(line, "power", 1.0f),
+ OpInt(line, "trainer", 0),
+ OpInt(line, "toy", 0),
+ OpInt(line, "option", 0));
+
+ if (obj != nullptr)
{
- pObj->SetDefRank(rankObj);
+ obj->SetDefRank(rankObj);
- if ( type == OBJECT_BASE ) m_bBase = true;
+ if (type == OBJECT_BASE) m_base = true;
- cType = OpCamera(line, "camera");
- if ( cType != CAMERA_NULL )
- {
- pObj->SetCameraType(cType);
- }
- pObj->SetCameraDist(OpFloat(line, "cameraDist", 50.0f));
- pObj->SetCameraLock(OpInt(line, "cameraLock", 0));
+ Gfx::CameraType cType = OpCamera(line, "camera");
+ if (cType != Gfx::CAM_TYPE_NULL)
+ obj->SetCameraType(cType);
+
+ obj->SetCameraDist(OpFloat(line, "cameraDist", 50.0f));
+ obj->SetCameraLock(OpInt(line, "cameraLock", 0));
- pType = OpPyro(line, "pyro");
- if ( pType != PT_NULL )
+ Gfx::PyroType pType = OpPyro(line, "pyro");
+ if (pType != Gfx::PT_NULL)
{
- pyro = new CPyro(m_iMan);
- pyro->Create(pType, pObj);
+ Gfx::CPyro* pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(pType, obj);
}
// Puts information in terminal (OBJECT_INFO).
- for ( i=0 ; i<OBJECTMAXINFO ; i++ )
+ for (int i = 0; i < OBJECTMAXINFO; i++)
{
sprintf(op, "info%d", i+1);
+ char text[100];
OpString(line, op, text);
- if ( text[0] == 0 ) break;
- p = strchr(text, '=');
- if ( p == 0 ) break;
+ if (text[0] == 0) break;
+ char* p = strchr(text, '=');
+ if (p == 0) break;
*p = 0;
+ Info info;
strcpy(info.name, text);
sscanf(p+1, "%f", &info.value);
- pObj->SetInfo(i, info);
+ obj->SetInfo(i, info);
}
// Sets the parameters of the command line.
- p = SearchOp(line, "cmdline");
- for ( i=0 ; i<OBJECTMAXCMDLINE ; i++ )
+ char* p = SearchOp(line, "cmdline");
+ for (int i = 0; i < OBJECTMAXCMDLINE; i++)
{
- float value;
- value = GetFloat(p, i, NAN);
- if ( value == NAN ) break;
- pObj->SetCmdLine(i, value);
+ float value = GetFloat(p, i, NAN);
+ if (value == NAN) break;
+ obj->SetCmdLine(i, value);
}
- if ( OpInt(line, "select", 0) == 1 )
+ if (OpInt(line, "select", 0) == 1)
{
- pSel = pObj;
+ sel = obj;
}
- pObj->SetSelectable(OpInt(line, "selectable", 1));
- pObj->SetEnable(OpInt(line, "enable", 1));
- pObj->SetProxyActivate(OpInt(line, "proxyActivate", 0));
- pObj->SetProxyDistance(OpFloat(line, "proxyDistance", 15.0f)*g_unit);
- pObj->SetRange(OpFloat(line, "range", 30.0f));
- pObj->SetShield(OpFloat(line, "shield", 1.0f));
- pObj->SetMagnifyDamage(OpFloat(line, "magnifyDamage", 1.0f));
- pObj->SetClip(OpInt(line, "clip", 1));
- pObj->SetCheckToken(OpInt(line, "checkToken", 1));
- pObj->SetManual(OpInt(line, "manual", 0));
-
- motion = pObj->RetMotion();
- if ( motion != 0 )
+ obj->SetSelectable(OpInt(line, "selectable", 1));
+ obj->SetEnable(OpInt(line, "enable", 1));
+ obj->SetProxyActivate(OpInt(line, "proxyActivate", 0));
+ obj->SetProxyDistance(OpFloat(line, "proxyDistance", 15.0f)*g_unit);
+ obj->SetRange(OpFloat(line, "range", 30.0f));
+ obj->SetShield(OpFloat(line, "shield", 1.0f));
+ obj->SetMagnifyDamage(OpFloat(line, "magnifyDamage", 1.0f));
+ obj->SetClip(OpInt(line, "clip", 1));
+ obj->SetCheckToken(OpInt(line, "checkToken", 1));
+ obj->SetManual(OpInt(line, "manual", 0));
+
+ CMotion* motion = obj->GetMotion();
+ if (motion != nullptr)
{
p = SearchOp(line, "param");
- for ( i=0 ; i<10 ; i++ )
+ for (int i = 0; i < 10; i++)
{
float value;
value = GetFloat(p, i, NAN);
- if ( value == NAN ) break;
+ if (value == NAN) break;
motion->SetParam(i, value);
}
}
- run = -1;
- pBrain = pObj->RetBrain();
- if ( pBrain != 0 )
+ int run = -1;
+ CBrain* brain = obj->GetBrain();
+ if (brain != nullptr)
{
- for ( i=0 ; i<10 ; i++ )
+ for (int i = 0; i < 10; i++)
{
sprintf(op, "script%d", i+1); // script1..script10
OpString(line, op, name);
-#if _SCHOOL
- if ( !m_dialog->RetSoluce4() && i == 3 ) continue;
-#endif
- if ( name[0] != 0 )
- {
- pBrain->SetScriptName(i, name);
- }
+/* TODO: #if _SCHOOL
+ if ( !m_dialog->GetSoluce4() && i == 3 ) continue;
+#endif*/
+ if (name[0] != 0)
+ brain->SetScriptName(i, name);
+
}
- i = OpInt(line, "run", 0);
- if ( i != 0 )
+ int i = OpInt(line, "run", 0);
+ if (i != 0)
{
run = i-1;
- pBrain->SetScriptRun(run);
+ brain->SetScriptRun(run);
}
}
- pAuto = pObj->RetAuto();
- if ( pAuto != 0 )
+ CAuto* automat = obj->GetAuto();
+ if (automat != nullptr)
{
type = OpTypeObject(line, "autoType", OBJECT_NULL);
- pAuto->SetType(type);
- for ( i=0 ; i<5 ; i++ )
+ automat->SetType(type);
+ for (int i = 0; i < 5; i++)
{
sprintf(op, "autoValue%d", i+1); // autoValue1..autoValue5
- pAuto->SetValue(i, OpFloat(line, op, 0.0f));
+ automat->SetValue(i, OpFloat(line, op, 0.0f));
}
OpString(line, "autoString", name);
- pAuto->SetString(name);
+ automat->SetString(name);
- i = OpInt(line, "run", -1);
- if ( i != -1 )
+ int i = OpInt(line, "run", -1);
+ if (i != -1)
{
- if ( i != PARAM_FIXSCENE &&
- !m_dialog->RetMovies() ) i = 0;
- pAuto->Start(i); // starts the film
+ if (i != PARAM_FIXSCENE &&
+ !m_dialog->GetMovies()) i = 0;
+ automat->Start(i); // starts the film
}
}
OpString(line, "soluce", name);
- if ( bSoluce && pBrain != 0 && name[0] != 0 )
- {
- pBrain->SetSoluceName(name);
- }
+ if (soluce && brain != 0 && name[0] != 0)
+ brain->SetSoluceName(name);
- pObj->SetResetPosition(pObj->RetPosition(0));
- pObj->SetResetAngle(pObj->RetAngle(0));
- pObj->SetResetRun(run);
+ obj->SetResetPosition(obj->GetPosition(0));
+ obj->SetResetAngle(obj->GetAngle(0));
+ obj->SetResetRun(run);
- if ( OpInt(line, "reset", 0) == 1 )
- {
- pObj->SetResetCap(RESET_MOVE);
- }
+ if (OpInt(line, "reset", 0) == 1)
+ obj->SetResetCap(RESET_MOVE);
}
rankObj ++;
}
- if ( Cmd(line, "CreateFog") && !bResetObject )
+ if (Cmd(line, "CreateFog") && !resetObject)
{
- ParticuleType type;
- Math::Point dim;
- float height, ddim, delay;
-
- type = (ParticuleType)(PARTIFOG0+OpInt(line, "type", 0));
- pos = OpPos(line, "pos")*g_unit;
- height = OpFloat(line, "height", 1.0f)*g_unit;
- ddim = OpFloat(line, "dim", 50.0f)*g_unit;
- delay = OpFloat(line, "delay", 2.0f);
- m_terrain->MoveOnFloor(pos);
+ Gfx::ParticleType type = static_cast<Gfx::ParticleType>((Gfx::PARTIFOG0+OpInt(line, "type", 0)));
+ Math::Vector pos = OpPos(line, "pos")*g_unit;
+ float height = OpFloat(line, "height", 1.0f)*g_unit;
+ float ddim = OpFloat(line, "dim", 50.0f)*g_unit;
+ float delay = OpFloat(line, "delay", 2.0f);
+ m_terrain->AdjustToFloor(pos);
pos.y += height;
+ Math::Point dim;
dim.x = ddim;
dim.y = dim.x;
- m_particule->CreateParticule(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, type, delay, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, type, delay, 0.0f, 0.0f);
}
- if ( Cmd(line, "CreateLight") && !bResetObject )
+ if (Cmd(line, "CreateLight") && !resetObject)
{
- D3DTypeObj type;
+ Gfx::EngineObjectType type;
- color.r = 0.5f;
- color.g = 0.5f;
- color.b = 0.5f;
- color.a = 1.0f;
- obj = CreateLight(OpDir(line, "dir"),
- OpColorValue(line, "color", color));
+ int lightRank = CreateLight(OpDir(line, "dir"),
+ OpColor(line, "color", Gfx::Color(0.5f, 0.5f, 0.5f, 1.0f)));
- type = OpTypeTerrain(line, "type", TYPENULL);
- if ( type == TYPETERRAIN )
- {
- m_light->SetLightIncluType(obj, TYPETERRAIN);
- }
- if ( type == TYPEQUARTZ )
- {
- m_light->SetLightIncluType(obj, TYPEQUARTZ);
- }
- if ( type == TYPEMETAL )
- {
- m_light->SetLightIncluType(obj, TYPEMETAL);
- }
- if ( type == TYPEFIX )
- {
- m_light->SetLightExcluType(obj, TYPETERRAIN);
- }
+ type = OpTypeTerrain(line, "type", Gfx::ENG_OBJTYPE_NULL);
+ if (type == Gfx::ENG_OBJTYPE_TERRAIN)
+ m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_TERRAIN);
+
+ if (type == Gfx::ENG_OBJTYPE_QUARTZ)
+ m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_QUARTZ);
+
+ if (type == Gfx::ENG_OBJTYPE_METAL)
+ m_lightMan->SetLightIncludeType(lightRank, Gfx::ENG_OBJTYPE_METAL);
+
+ if (type == Gfx::ENG_OBJTYPE_FIX)
+ m_lightMan->SetLightExcludeType(lightRank, Gfx::ENG_OBJTYPE_TERRAIN);
}
- if ( Cmd(line, "CreateSpot") && !bResetObject )
+ if (Cmd(line, "CreateSpot") && !resetObject)
{
- D3DTypeObj type;
+ Gfx::EngineObjectType type;
- color.r = 0.5f;
- color.g = 0.5f;
- color.b = 0.5f;
- color.a = 1.0f;
- obj = CreateSpot(OpDir(line, "pos")*g_unit,
- OpColorValue(line, "color", color));
+ int rankLight = CreateSpot(OpDir(line, "pos")*g_unit,
+ OpColor(line, "color", Gfx::Color(0.5f, 0.5f, 0.5f, 1.0f)));
- type = OpTypeTerrain(line, "type", TYPENULL);
- if ( type == TYPETERRAIN )
- {
- m_light->SetLightIncluType(obj, TYPETERRAIN);
- }
- if ( type == TYPEQUARTZ )
- {
- m_light->SetLightIncluType(obj, TYPEQUARTZ);
- }
- if ( type == TYPEMETAL )
- {
- m_light->SetLightIncluType(obj, TYPEMETAL);
- }
- if ( type == TYPEFIX )
- {
- m_light->SetLightExcluType(obj, TYPETERRAIN);
- }
+ type = OpTypeTerrain(line, "type", Gfx::ENG_OBJTYPE_NULL);
+ if (type == Gfx::ENG_OBJTYPE_TERRAIN)
+ m_lightMan->SetLightIncludeType(rankLight, Gfx::ENG_OBJTYPE_TERRAIN);
+
+ if (type == Gfx::ENG_OBJTYPE_QUARTZ)
+ m_lightMan->SetLightIncludeType(rankLight, Gfx::ENG_OBJTYPE_QUARTZ);
+
+ if (type == Gfx::ENG_OBJTYPE_METAL)
+ m_lightMan->SetLightIncludeType(rankLight, Gfx::ENG_OBJTYPE_METAL);
+
+ if (type == Gfx::ENG_OBJTYPE_FIX)
+ m_lightMan->SetLightExcludeType(rankLight, Gfx::ENG_OBJTYPE_TERRAIN);
}
- if ( Cmd(line, "GroundSpot") && !bResetObject )
+ if (Cmd(line, "GroundSpot") && !resetObject)
{
- rank = m_engine->GroundSpotCreate();
- if ( rank != -1 )
+ rank = m_engine->CreateGroundSpot();
+ if (rank != -1)
{
m_engine->SetObjectGroundSpotPos(rank, OpPos(line, "pos")*g_unit);
m_engine->SetObjectGroundSpotRadius(rank, OpFloat(line, "radius", 10.0f)*g_unit);
- m_engine->SetObjectGroundSpotColor(rank, RetColor(OpColor(line, "color", 0x88888888)));
+ m_engine->SetObjectGroundSpotColor(rank, OpColor(line, "color", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)));
m_engine->SetObjectGroundSpotSmooth(rank, OpFloat(line, "smooth", 1.0f));
m_engine->SetObjectGroundSpotMinMax(rank, OpFloat(line, "min", 0.0f)*g_unit,
OpFloat(line, "max", 0.0f)*g_unit);
}
}
- if ( Cmd(line, "WaterColor") && !bResetObject )
- {
- color.r = 0.0f;
- color.g = 0.0f;
- color.b = 0.0f;
- color.a = 1.0f;
- m_engine->SetWaterAddColor(OpColorValue(line, "color", color));
- }
+ if (Cmd(line, "WaterColor") && !resetObject)
+ m_engine->SetWaterAddColor(OpColor(line, "color", Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f)));
- if ( Cmd(line, "MapColor") && !bResetObject )
+ if (Cmd(line, "MapColor") && !resetObject)
{
- m_map->FloorColorMap(RetColor(OpColor(line, "floor", 0x88888888)),
- RetColor(OpColor(line, "water", 0x88888888)));
- m_bMapShow = OpInt(line, "show", 1);
- m_map->ShowMap(m_bMapShow);
+ m_map->FloorColorMap(OpColor(line, "floor", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)),
+ OpColor(line, "water", Gfx::Color(0.533f, 0.533f, 0.533f, 0.533f)));
+ m_mapShow = OpInt(line, "show", 1);
+ m_map->ShowMap(m_mapShow);
m_map->SetToy(OpInt(line, "toyIcon", 0));
- m_bMapImage = OpInt(line, "image", 0);
- if ( m_bMapImage )
+ m_mapImage = OpInt(line, "image", 0);
+ if (m_mapImage)
{
Math::Vector offset;
OpString(line, "filename", m_mapFilename);
@@ -4720,17 +4320,17 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
OpInt(line, "debug", 0));
}
}
- if ( Cmd(line, "MapZoom") && !bResetObject )
+ if (Cmd(line, "MapZoom") && !resetObject)
{
m_map->ZoomMap(OpFloat(line, "factor", 2.0f));
m_map->MapEnable(OpInt(line, "enable", 1));
}
- if ( Cmd(line, "MaxFlyingHeight") && !bResetObject )
+ if (Cmd(line, "MaxFlyingHeight") && !resetObject)
{
m_terrain->SetFlyingMaxHeight(OpFloat(line, "max", 280.0f)*g_unit);
}
- if ( Cmd(line, "AddFlyingHeight") && !bResetObject )
+ if (Cmd(line, "AddFlyingHeight") && !resetObject)
{
m_terrain->AddFlyingLimit(OpPos(line, "center")*g_unit,
OpFloat(line, "extRadius", 20.0f)*g_unit,
@@ -4738,23 +4338,22 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
OpFloat(line, "maxHeight", 200.0f));
}
- if ( Cmd(line, "Camera") )
+ if (Cmd(line, "Camera"))
{
m_camera->Init(OpDir(line, "eye")*g_unit,
OpDir(line, "lookat")*g_unit,
- bResetObject?0.0f:OpFloat(line, "delay", 0.0f));
+ resetObject?0.0f:OpFloat(line, "delay", 0.0f));
+
+ if (OpInt(line, "fadeIn", 0) == 1)
+ m_camera->StartOver(Gfx::CAM_OVER_EFFECT_FADEIN_WHITE, Math::Vector(0.0f, 0.0f, 0.0f), 1.0f);
- if ( OpInt(line, "fadeIn", 0) == 1 )
- {
- m_camera->StartOver(OE_FADEINw, Math::Vector(0.0f, 0.0f, 0.0f), 1.0f);
- }
m_camera->SetFixDirection(OpFloat(line, "fixDirection", 0.25f)*Math::PI);
}
- if ( Cmd(line, "EndMissionTake") && !bResetObject )
+ if (Cmd(line, "EndMissionTake") && !resetObject)
{
- i = m_endTakeTotal;
- if ( i < 10 )
+ int i = m_endTakeTotal;
+ if (i < 10)
{
m_endTake[i].pos = OpPos(line, "pos")*g_unit;
m_endTake[i].dist = OpFloat(line, "dist", 8.0f)*g_unit;
@@ -4762,56 +4361,51 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
m_endTake[i].min = OpInt(line, "min", 1);
m_endTake[i].max = OpInt(line, "max", 9999);
m_endTake[i].lost = OpInt(line, "lost", -1);
- m_endTake[i].bImmediat = OpInt(line, "immediat", 0);
+ m_endTake[i].immediat = OpInt(line, "immediat", 0);
OpString(line, "message", m_endTake[i].message);
m_endTakeTotal ++;
}
}
- if ( Cmd(line, "EndMissionDelay") && !bResetObject )
+ if (Cmd(line, "EndMissionDelay") && !resetObject)
{
m_endTakeWinDelay = OpFloat(line, "win", 2.0f);
m_endTakeLostDelay = OpFloat(line, "lost", 2.0f);
}
- if ( Cmd(line, "EndMissionResearch") && !bResetObject )
+ if (Cmd(line, "EndMissionResearch") && !resetObject)
{
m_endTakeResearch |= OpResearch(line, "type");
}
- if ( Cmd(line, "ObligatoryToken") && !bResetObject )
+ if (Cmd(line, "ObligatoryToken") && !resetObject)
{
- i = m_obligatoryTotal;
- if ( i < 100 )
+ int i = m_obligatoryTotal;
+ if (i < 100)
{
OpString(line, "text", m_obligatoryToken[i]);
m_obligatoryTotal ++;
}
}
- if ( Cmd(line, "ProhibitedToken") && !bResetObject )
+ if (Cmd(line, "ProhibitedToken") && !resetObject)
{
- i = m_prohibitedTotal;
- if ( i < 100 )
+ int i = m_prohibitedTotal;
+ if (i < 100)
{
OpString(line, "text", m_prohibitedToken[i]);
m_prohibitedTotal ++;
}
}
- if ( Cmd(line, "EnableBuild") && !bResetObject )
- {
+ if (Cmd(line, "EnableBuild") && !resetObject)
g_build |= OpBuild(line, "type");
- }
- if ( Cmd(line, "EnableResearch") && !bResetObject )
- {
+ if (Cmd(line, "EnableResearch") && !resetObject)
g_researchEnable |= OpResearch(line, "type");
- }
- if ( Cmd(line, "DoneResearch") && read[0] == 0 && !bResetObject ) // not loading file?
- {
+
+ if (Cmd(line, "DoneResearch") && read[0] == 0 && !resetObject) // not loading file?
g_researchDone |= OpResearch(line, "type");
- }
- if ( Cmd(line, "NewScript") && !bResetObject )
+ if (Cmd(line, "NewScript") && !resetObject)
{
OpString(line, "name", name);
AddNewScriptName(OpTypeObject(line, "type", OBJECT_NULL), name);
@@ -4820,16 +4414,13 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
fclose(file);
- if ( read[0] == 0 )
- {
- CompileScript(bSoluce); // compiles all scripts
- }
+ if (read[0] == 0)
+ CompileScript(soluce); // compiles all scripts
- if ( strcmp(base, "scene") == 0 && !bResetObject ) // mission?
- {
+ if (strcmp(base, "scene") == 0 && !resetObject) // mission?
WriteFreeParam();
- }
- if ( strcmp(base, "free") == 0 && !bResetObject ) // free play?
+
+ if (strcmp(base, "free") == 0 && !resetObject) // free play?
{
g_researchDone = m_freeResearch;
@@ -4841,7 +4432,7 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
g_build |= BUILD_FLAG;
}
- if ( !bResetObject )
+ if (!resetObject)
{
ChangeColor(); // changes the colors of texture
m_short->SetMode(false); // vehicles?
@@ -4849,70 +4440,64 @@ void CRobotMain::CreateScene(bool bSoluce, bool bFixScene, bool bResetObject)
CreateShortcuts();
m_map->UpdateMap();
- m_engine->TimeInit();
- m_engine->FlushPressKey();
+ // TODO: m_engine->TimeInit(); ??
+ m_app->ResetKeyStates();
m_time = 0.0f;
m_gameTime = 0.0f;
m_checkEndTime = 0.0f;
m_infoUsed = 0;
- m_selectObject = pSel;
+ m_selectObject = sel;
- if ( !m_bBase && // no main base?
- !m_bFixScene ) // interractive scene?
+ if (!m_base && // no main base?
+ !m_fixScene) // interractive scene?
{
- if ( pSel == 0 )
- {
- pObj = SearchHuman();
- }
+ CObject* obj;
+ if (sel == nullptr)
+ obj = SearchHuman();
else
+ obj = sel;
+
+ if (obj != nullptr)
{
- pObj = pSel;
- }
- if ( pObj != 0 )
- {
- SelectObject(pObj);
- m_camera->SetObject(pObj);
-//? m_camera->SetType(CAMERA_BACK);
- m_camera->SetType(pObj->RetCameraType());
+ SelectObject(obj);
+ m_camera->SetControllingObject(obj);
+ m_camera->SetType(obj->GetCameraType());
}
}
- if ( m_bFixScene )
- {
- m_camera->SetType(CAMERA_SCRIPT);
- }
- if ( read[0] != 0 && pSel != 0 ) // loading file?
+ if (m_fixScene)
+ m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
+
+ if (read[0] != 0 && sel != 0) // loading file?
{
- pos = pSel->RetPosition(0);
+ Math::Vector pos = sel->GetPosition(0);
m_camera->Init(pos, pos, 0.0f);
m_camera->FixCamera();
- SelectObject(pSel);
- m_camera->SetObject(pSel);
+ SelectObject(sel);
+ m_camera->SetControllingObject(sel);
- m_bBeginSatCom = true; // message already displayed
+ m_beginSatCom = true; // message already displayed
}
m_dialog->SetSceneRead("");
m_dialog->SetStackRead("");
}
-// Creates an object of decoration mobile or stationary.
-
+//! Creates an object of decoration mobile or stationary
CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, float height,
ObjectType type, float power,
- bool bTrainer, bool bToy,
+ bool trainer, bool toy,
int option)
{
- CObject* pObject = 0;
- CAuto* automat;
+ CObject* object = nullptr;
- if ( type == OBJECT_NULL ) return 0;
+ if ( type == OBJECT_NULL ) return nullptr;
if ( type == OBJECT_HUMAN ||
type == OBJECT_TECH )
{
- bTrainer = false; // necessarily
+ trainer = false; // necessarily
}
if ( type == OBJECT_PORTICO ||
@@ -4939,11 +4524,11 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_START ||
type == OBJECT_END )
{
- pObject = new CObject(m_iMan);
- pObject->CreateBuilding(pos, angle, height, type, power);
+ object = new CObject(m_iMan);
+ object->CreateBuilding(pos, angle, height, type, power);
- automat = pObject->RetAuto();
- if ( automat != 0 )
+ CAuto* automat = object->GetAuto();
+ if (automat != nullptr)
{
automat->Init();
}
@@ -4981,8 +4566,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_MARKKEYd ||
type == OBJECT_EGG )
{
- pObject = new CObject(m_iMan);
- pObject->CreateResource(pos, angle, type, power);
+ object = new CObject(m_iMan);
+ object->CreateResource(pos, angle, type, power);
}
else
if ( type == OBJECT_FLAGb ||
@@ -4991,8 +4576,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_FLAGy ||
type == OBJECT_FLAGv )
{
- pObject = new CObject(m_iMan);
- pObject->CreateFlag(pos, angle, type);
+ object = new CObject(m_iMan);
+ object->CreateFlag(pos, angle, type);
}
else
if ( type == OBJECT_BARRIER0 ||
@@ -5001,8 +4586,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_BARRIER3 ||
type == OBJECT_BARRIER4 )
{
- pObject = new CObject(m_iMan);
- pObject->CreateBarrier(pos, angle, height, type);
+ object = new CObject(m_iMan);
+ object->CreateBarrier(pos, angle, height, type);
}
else
if ( type == OBJECT_PLANT0 ||
@@ -5036,8 +4621,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_TREE8 ||
type == OBJECT_TREE9 )
{
- pObject = new CObject(m_iMan);
- pObject->CreatePlant(pos, angle, height, type);
+ object = new CObject(m_iMan);
+ object->CreatePlant(pos, angle, height, type);
}
else
if ( type == OBJECT_MUSHROOM0 ||
@@ -5051,8 +4636,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_MUSHROOM8 ||
type == OBJECT_MUSHROOM9 )
{
- pObject = new CObject(m_iMan);
- pObject->CreateMushroom(pos, angle, height, type);
+ object = new CObject(m_iMan);
+ object->CreateMushroom(pos, angle, height, type);
}
else
if ( type == OBJECT_TEEN0 ||
@@ -5106,9 +4691,9 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_TEEN48 ||
type == OBJECT_TEEN49 )
{
- pObject = new CObject(m_iMan);
- pObject->SetOption(option);
- pObject->CreateTeen(pos, angle, zoom, height, type);
+ object = new CObject(m_iMan);
+ object->SetOption(option);
+ object->CreateTeen(pos, angle, zoom, height, type);
}
else
if ( type == OBJECT_QUARTZ0 ||
@@ -5122,8 +4707,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_QUARTZ8 ||
type == OBJECT_QUARTZ9 )
{
- pObject = new CObject(m_iMan);
- pObject->CreateQuartz(pos, angle, height, type);
+ object = new CObject(m_iMan);
+ object->CreateQuartz(pos, angle, height, type);
}
else
if ( type == OBJECT_ROOT0 ||
@@ -5137,14 +4722,14 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_ROOT8 ||
type == OBJECT_ROOT9 )
{
- pObject = new CObject(m_iMan);
- pObject->CreateRoot(pos, angle, height, type);
+ object = new CObject(m_iMan);
+ object->CreateRoot(pos, angle, height, type);
}
else
if ( type == OBJECT_HOME1 )
{
- pObject = new CObject(m_iMan);
- pObject->CreateHome(pos, angle, height, type);
+ object = new CObject(m_iMan);
+ object->CreateHome(pos, angle, height, type);
}
else
if ( type == OBJECT_RUINmobilew1 ||
@@ -5161,8 +4746,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_RUINbase ||
type == OBJECT_RUINhead )
{
- pObject = new CObject(m_iMan);
- pObject->CreateRuin(pos, angle, height, type);
+ object = new CObject(m_iMan);
+ object->CreateRuin(pos, angle, height, type);
}
else
if ( type == OBJECT_APOLLO1 ||
@@ -5170,8 +4755,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_APOLLO4 ||
type == OBJECT_APOLLO5 )
{
- pObject = new CObject(m_iMan);
- pObject->CreateApollo(pos, angle, type);
+ object = new CObject(m_iMan);
+ object->CreateApollo(pos, angle, type);
}
else
if ( type == OBJECT_MOTHER ||
@@ -5180,8 +4765,8 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_BEE ||
type == OBJECT_WORM )
{
- pObject = new CObject(m_iMan);
- pObject->CreateInsect(pos, angle, type); // no eggs
+ object = new CObject(m_iMan);
+ object->CreateInsect(pos, angle, type); // no eggs
}
else
if ( type == OBJECT_HUMAN ||
@@ -5216,150 +4801,72 @@ CObject* CRobotMain::CreateObject(Math::Vector pos, float angle, float zoom, flo
type == OBJECT_MOBILEdr ||
type == OBJECT_APOLLO2 )
{
- pObject = new CObject(m_iMan);
- pObject->SetOption(option);
- pObject->CreateVehicle(pos, angle, type, power, bTrainer, bToy);
+ object = new CObject(m_iMan);
+ object->SetOption(option);
+ object->CreateVehicle(pos, angle, type, power, trainer, toy);
}
- if ( m_bFixScene && type == OBJECT_HUMAN )
+ if (m_fixScene && type == OBJECT_HUMAN)
{
- CMotion* motion;
-
- motion = pObject->RetMotion();
- if ( m_phase == PHASE_WIN ) motion->SetAction(MHS_WIN, 0.4f);
- if ( m_phase == PHASE_LOST ) motion->SetAction(MHS_LOST, 0.5f);
+ CMotion* motion = object->GetMotion();
+ if (m_phase == PHASE_WIN ) motion->SetAction(MHS_WIN, 0.4f);
+ if (m_phase == PHASE_LOST) motion->SetAction(MHS_LOST, 0.5f);
}
- return pObject;
-}
-
-
-// Creates the editable model.
-
-void CRobotMain::CreateModel()
-{
- Math::Vector direction;
- D3DCOLORVALUE color;
-
- m_engine->SetAmbiantColor(0xC0C0C0C0); // gray
- m_engine->SetBackground("", 0x80808080, 0x80808080, 0x80808080, 0x80808080);
- m_engine->SetFogColor(0x80808080);
- m_engine->SetDeepView(500.0f, 0);
- m_engine->SetDeepView(100.0f, 1);
- m_engine->SetFogStart(0.5f);
-
- m_model->StartUserAction();
-
- direction = Math::Vector(1.0f, -1.0f, 1.0f);
- color.r = 0.7f;
- color.g = 0.7f;
- color.b = 0.7f; // white
- CreateLight(direction, color);
-
- direction = Math::Vector(-1.0f, -1.0f, 1.0f);
- color.r = 0.7f;
- color.g = 0.7f;
- color.b = 0.7f; // white
- CreateLight(direction, color);
-
- direction = Math::Vector(1.0f, -1.0f, -1.0f);
- color.r = 0.7f;
- color.g = 0.7f;
- color.b = 0.7f; // white
- CreateLight(direction, color);
-
- direction = Math::Vector(-1.0f, -1.0f, -1.0f);
- color.r = 0.7f;
- color.g = 0.7f;
- color.b = 0.7f; // white
- CreateLight(direction, color);
-
- direction = Math::Vector(0.0f, 1.0f, 0.0f);
- color.r = 0.7f;
- color.g = 0.7f;
- color.b = 0.7f; // white
- CreateLight(direction, color);
-
- InitEye();
-
- m_engine->TimeInit();
- m_time = 0.0f;
- m_gameTime = 0.0f;
- m_checkEndTime = 0.0f;
+ return object;
}
-
-// Creates a directional light.
-
-int CRobotMain::CreateLight(Math::Vector direction, D3DCOLORVALUE color)
+//! Creates a directional light
+int CRobotMain::CreateLight(Math::Vector direction, Gfx::Color color)
{
- D3DLIGHT7 light;
- int obj;
-
- if ( direction.x == 0.0f &&
- direction.y == 0.0f &&
- direction.z == 0.0f )
+ if (direction.x == 0.0f &&
+ direction.y == 0.0f &&
+ direction.z == 0.0f)
{
direction.y = -1.0f;
}
- ZeroMemory(&light, sizeof(D3DLIGHT7));
- light.dltType = D3DLIGHT_DIRECTIONAL;
- light.dcvDiffuse.r = color.r;
- light.dcvDiffuse.g = color.g;
- light.dcvDiffuse.b = color.b;
- light.dvDirection = VEC_TO_D3DVEC(direction);
- obj = m_light->CreateLight();
- m_light->SetLight(obj, light);
+ Gfx::Light light;
+ light.type = Gfx::LIGHT_DIRECTIONAL;
+ light.diffuse = color;
+ light.direction = direction;
+ int obj = m_lightMan->CreateLight();
+ m_lightMan->SetLight(obj, light);
return obj;
}
-// Creates a light spot.
-
-int CRobotMain::CreateSpot(Math::Vector pos, D3DCOLORVALUE color)
+//! Creates a light spot
+int CRobotMain::CreateSpot(Math::Vector pos, Gfx::Color color)
{
- D3DLIGHT7 light;
- int obj;
+ if (!m_engine->GetLightMode()) return -1;
- if ( !m_engine->RetLightMode() ) return -1;
+ pos.y += m_terrain->GetFloorLevel(pos);
- pos.y += m_terrain->RetFloorLevel(pos);
-
- ZeroMemory(&light, sizeof(D3DLIGHT7));
- light.dltType = D3DLIGHT_SPOT;
- light.dcvDiffuse.r = color.r;
- light.dcvDiffuse.g = color.g;
- light.dcvDiffuse.b = color.b;
- light.dvPosition = VEC_TO_D3DVEC(pos);
- light.dvDirection = D3DVECTOR(0.0f, -1.0f, 0.0f);
- light.dvRange = D3DLIGHT_RANGE_MAX;
- light.dvFalloff = 1.0f;
- light.dvTheta = 10.0f*Math::PI/180.0f;
- light.dvPhi = 90.0f*Math::PI/180.0f;
- light.dvAttenuation0 = 2.0f;
- light.dvAttenuation1 = 0.0f;
- light.dvAttenuation2 = 0.0f;
- obj = m_light->CreateLight();
- m_light->SetLight(obj, light);
+ Gfx::Light light;
+ light.type = Gfx::LIGHT_SPOT;
+ light.diffuse = color;
+ light.position = pos;
+ light.direction = Math::Vector(0.0f, -1.0f, 0.0f);
+ light.spotIntensity = 1.0f;
+ light.spotAngle = 90.0f*Math::PI/180.0f;
+ light.attenuation0 = 2.0f;
+ light.attenuation1 = 0.0f;
+ light.attenuation2 = 0.0f;
+ int obj = m_lightMan->CreateLight();
+ m_lightMan->SetLight(obj, light);
return obj;
}
-// Change the colors and textures.
-
+//! Change the colors and textures
void CRobotMain::ChangeColor()
{
- D3DCOLORVALUE colorRef1, colorNew1, colorRef2, colorNew2;
- Math::Point ts, ti;
- Math::Point exclu[6];
- char name[100];
- int face;
- float tolerance;
+ Math::Point ts = Math::Point(0.0f, 0.0f);
+ Math::Point ti = Math::Point(1.0f, 1.0f); // the entire image
- ts = Math::Point(0.0f, 0.0f);
- ti = Math::Point(1.0f, 1.0f); // the entire image
+ Gfx::Color colorRef1, colorNew1, colorRef2, colorNew2;
colorRef1.a = 0.0f;
colorRef2.a = 0.0f;
@@ -5367,61 +4874,67 @@ void CRobotMain::ChangeColor()
colorRef1.r = 206.0f/256.0f;
colorRef1.g = 206.0f/256.0f;
colorRef1.b = 204.0f/256.0f; // ~white
- colorNew1 = m_dialog->RetGamerColorCombi();
+ colorNew1 = m_dialog->GetGamerColorCombi();
colorRef2.r = 255.0f/256.0f;
colorRef2.g = 132.0f/256.0f;
colorRef2.b = 1.0f/256.0f; // orange
- colorNew2 = m_dialog->RetGamerColorBand();
+ colorNew2 = m_dialog->GetGamerColorBand();
+
+ Math::Point exclu[6];
exclu[0] = Math::Point(192.0f/256.0f, 0.0f/256.0f);
exclu[1] = Math::Point(256.0f/256.0f, 64.0f/256.0f); // crystals + cylinders
exclu[2] = Math::Point(208.0f/256.0f, 224.0f/256.0f);
exclu[3] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom screen
exclu[4] = Math::Point(0.0f, 0.0f);
exclu[5] = Math::Point(0.0f, 0.0f); // terminator
- m_engine->ChangeColor("human.tga", colorRef1, colorNew1, colorRef2, colorNew2, 0.30f, 0.01f, ts, ti, exclu);
+ // TODO: m_engine->ChangeColor("human.png", colorRef1, colorNew1, colorRef2, colorNew2, 0.30f, 0.01f, ts, ti, exclu);
- face = RetGamerFace();
- if ( face == 0 ) // normal?
+ float tolerance;
+
+ int face = GetGamerFace();
+ if (face == 0) // normal?
{
colorRef1.r = 90.0f/256.0f;
colorRef1.g = 95.0f/256.0f;
colorRef1.b = 85.0f/256.0f; // black
tolerance = 0.15f;
}
- if ( face == 1 ) // bald?
+ if (face == 1) // bald?
{
colorRef1.r = 74.0f/256.0f;
colorRef1.g = 58.0f/256.0f;
colorRef1.b = 46.0f/256.0f; // brown
tolerance = 0.20f;
}
- if ( face == 2 ) // carlos?
+ if (face == 2) // carlos?
{
colorRef1.r = 70.0f/256.0f;
colorRef1.g = 40.0f/256.0f;
colorRef1.b = 8.0f/256.0f; // brown
tolerance = 0.30f;
}
- if ( face == 3 ) // blonde?
+ if (face == 3) // blonde?
{
colorRef1.r = 74.0f/256.0f;
colorRef1.g = 16.0f/256.0f;
colorRef1.b = 0.0f/256.0f; // yellow
tolerance = 0.20f;
}
- colorNew1 = m_dialog->RetGamerColorHair();
+ colorNew1 = m_dialog->GetGamerColorHair();
colorRef2.r = 0.0f;
colorRef2.g = 0.0f;
colorRef2.b = 0.0f;
colorNew2.r = 0.0f;
colorNew2.g = 0.0f;
colorNew2.b = 0.0f;
- sprintf(name, "face%.2d.tga", face+1);
+
+ char name[100];
+ sprintf(name, "face%.2d.png", face+1);
exclu[0] = Math::Point(105.0f/256.0f, 47.0f/166.0f);
exclu[1] = Math::Point(153.0f/256.0f, 79.0f/166.0f); // blue canister
exclu[2] = Math::Point(0.0f, 0.0f);
exclu[3] = Math::Point(0.0f, 0.0f); // terminator
- m_engine->ChangeColor(name, colorRef1, colorNew1, colorRef2, colorNew2, tolerance, 0.00f, ts, ti, exclu);
+ // TODO: m_engine->ChangeColor(name, colorRef1, colorNew1, colorRef2, colorNew2, tolerance, 0.00f, ts, ti, exclu);
colorRef2.r = 0.0f;
colorRef2.g = 0.0f;
@@ -5430,19 +4943,19 @@ void CRobotMain::ChangeColor()
colorNew2.g = 0.0f;
colorNew2.b = 0.0f;
- m_engine->ChangeColor("base1.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
- m_engine->ChangeColor("convert.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
- m_engine->ChangeColor("derrick.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
- m_engine->ChangeColor("factory.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
- m_engine->ChangeColor("lemt.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
- m_engine->ChangeColor("roller.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
- m_engine->ChangeColor("search.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
+ // TODO: m_engine->ChangeColor("base1.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
+ // TODO: m_engine->ChangeColor("convert.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
+ // TODO: m_engine->ChangeColor("derrick.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
+ // TODO: m_engine->ChangeColor("factory.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
+ // TODO: m_engine->ChangeColor("lemt.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
+ // TODO: m_engine->ChangeColor("roller.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
+ // TODO: m_engine->ChangeColor("search.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, 0, 0, true);
exclu[0] = Math::Point( 0.0f/256.0f, 160.0f/256.0f);
exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // pencils
exclu[2] = Math::Point(0.0f, 0.0f);
exclu[3] = Math::Point(0.0f, 0.0f); // terminator
- m_engine->ChangeColor("drawer.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true);
+ // TODO: m_engine->ChangeColor("drawer.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true);
exclu[0] = Math::Point(237.0f/256.0f, 176.0f/256.0f);
exclu[1] = Math::Point(256.0f/256.0f, 220.0f/256.0f); // blue canister
@@ -5450,35 +4963,31 @@ void CRobotMain::ChangeColor()
exclu[3] = Math::Point(130.0f/256.0f, 214.0f/256.0f); // safe location
exclu[4] = Math::Point(0.0f, 0.0f);
exclu[5] = Math::Point(0.0f, 0.0f); // terminator
- m_engine->ChangeColor("subm.tga", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true);
+ // TODO: m_engine->ChangeColor("subm.png", m_colorRefBot, m_colorNewBot, colorRef2, colorNew2, 0.10f, -1.0f, ts, ti, exclu, 0, true);
exclu[0] = Math::Point(128.0f/256.0f, 160.0f/256.0f);
exclu[1] = Math::Point(256.0f/256.0f, 256.0f/256.0f); // SatCom
exclu[2] = Math::Point(0.0f, 0.0f);
exclu[3] = Math::Point(0.0f, 0.0f); // terminator
- m_engine->ChangeColor("ant.tga", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti, exclu);
- m_engine->ChangeColor("mother.tga", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti);
+ // TODO: m_engine->ChangeColor("ant.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti, exclu);
+ // TODO: m_engine->ChangeColor("mother.png", m_colorRefAlien, m_colorNewAlien, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti);
- m_engine->ChangeColor("plant.tga", m_colorRefGreen, m_colorNewGreen, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti);
+ // TODO: m_engine->ChangeColor("plant.png", m_colorRefGreen, m_colorNewGreen, colorRef2, colorNew2, 0.50f, -1.0f, ts, ti);
// PARTIPLOUF0 and PARTIDROP :
ts = Math::Point(0.500f, 0.500f);
ti = Math::Point(0.875f, 0.750f);
- m_engine->ChangeColor("effect00.tga", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
+ // TODO: m_engine->ChangeColor("effect00.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
// PARTIFLIC :
ts = Math::Point(0.00f, 0.75f);
ti = Math::Point(0.25f, 1.00f);
- m_engine->ChangeColor("effect02.tga", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
+ // TODO: m_engine->ChangeColor("effect02.png", m_colorRefWater, m_colorNewWater, colorRef2, colorNew2, 0.20f, -1.0f, ts, ti, 0, m_colorShiftWater, true);
}
-// Updates the number of unnecessary objects.
-
+//! Updates the number of unnecessary objects
bool CRobotMain::TestGadgetQuantity(int rank)
{
- float percent;
- int *table;
-
static int table10[10] = {0,1,0,0,0,0,0,0,0,0};
static int table20[10] = {0,1,0,0,0,1,0,0,0,0};
static int table30[10] = {0,1,0,1,0,1,0,0,0,0};
@@ -5489,109 +4998,102 @@ bool CRobotMain::TestGadgetQuantity(int rank)
static int table80[10] = {0,1,1,1,1,1,0,1,1,1};
static int table90[10] = {0,1,1,1,1,1,1,1,1,1};
- percent = m_engine->RetGadgetQuantity();
- if ( percent == 0.0f ) return false;
- if ( percent == 1.0f ) return true;
-
- if ( percent <= 0.15f ) table = table10;
- else if ( percent <= 0.25f ) table = table20;
- else if ( percent <= 0.35f ) table = table30;
- else if ( percent <= 0.45f ) table = table40;
- else if ( percent <= 0.55f ) table = table50;
- else if ( percent <= 0.65f ) table = table60;
- else if ( percent <= 0.75f ) table = table70;
- else if ( percent <= 0.85f ) table = table80;
- else table = table90;
+ float percent = m_engine->GetGadgetQuantity();
+ if (percent == 0.0f) return false;
+ if (percent == 1.0f) return true;
+
+ int *table;
+ if (percent <= 0.15f) table = table10;
+ else if (percent <= 0.25f) table = table20;
+ else if (percent <= 0.35f) table = table30;
+ else if (percent <= 0.45f) table = table40;
+ else if (percent <= 0.55f) table = table50;
+ else if (percent <= 0.65f) table = table60;
+ else if (percent <= 0.75f) table = table70;
+ else if (percent <= 0.85f) table = table80;
+ else table = table90;
return table[rank%10];
}
-// Calculates the distance to the nearest object.
-
+//! Calculates the distance to the nearest object
float CRobotMain::SearchNearestObject(Math::Vector center, CObject *exclu)
{
- CObject* pObj;
- ObjectType type;
- Math::Vector oPos;
- float min, dist, oRadius;
- int i, j;
-
- min = 100000.0f;
- for ( i=0 ; i<1000000 ; i++ )
+ float min = 100000.0f;
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( !pObj->RetActif() ) continue; // inactive?
- if ( pObj->RetTruck() != 0 ) continue; // object carries?
- if ( pObj == exclu ) continue;
+ if (!obj->GetActif()) continue; // inactive?
+ if (obj->GetTruck() != nullptr) continue; // object carries?
+ if (obj == exclu) continue;
- type = pObj->RetType();
+ ObjectType type = obj->GetType();
- if ( type == OBJECT_BASE )
+ if (type == OBJECT_BASE)
{
- oPos = pObj->RetPosition(0);
- if ( oPos.x != center.x ||
- oPos.z != center.z )
+ Math::Vector oPos = obj->GetPosition(0);
+ if (oPos.x != center.x ||
+ oPos.z != center.z)
{
- dist = Math::Distance(center, oPos)-80.0f;
- if ( dist < 0.0f ) dist = 0.0f;
+ float dist = Math::Distance(center, oPos)-80.0f;
+ if (dist < 0.0f) dist = 0.0f;
min = Math::Min(min, dist);
continue;
}
}
- if ( type == OBJECT_STATION ||
- type == OBJECT_REPAIR ||
- type == OBJECT_DESTROYER )
+ if (type == OBJECT_STATION ||
+ type == OBJECT_REPAIR ||
+ type == OBJECT_DESTROYER)
{
- oPos = pObj->RetPosition(0);
- dist = Math::Distance(center, oPos)-8.0f;
- if ( dist < 0.0f ) dist = 0.0f;
+ Math::Vector oPos = obj->GetPosition(0);
+ float dist = Math::Distance(center, oPos)-8.0f;
+ if (dist < 0.0f) dist = 0.0f;
min = Math::Min(min, dist);
}
- j = 0;
- while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
+ int j = 0;
+ Math::Vector oPos;
+ float oRadius;
+ while (obj->GetCrashSphere(j++, oPos, oRadius))
{
- dist = Math::Distance(center, oPos)-oRadius;
- if ( dist < 0.0f ) dist = 0.0f;
+ float dist = Math::Distance(center, oPos)-oRadius;
+ if (dist < 0.0f) dist = 0.0f;
min = Math::Min(min, dist);
}
}
return min;
}
-// Calculates a free space.
-
+//! Calculates a free space
bool CRobotMain::FreeSpace(Math::Vector &center, float minRadius, float maxRadius,
float space, CObject *exclu)
{
- Math::Vector pos;
- Math::Point p;
- float radius, ia, angle, dist, flat;
-
- if ( minRadius < maxRadius ) // from internal to external?
+ if (minRadius < maxRadius) // from internal to external?
{
- for ( radius=minRadius ; radius<=maxRadius ; radius+=space )
+ for (float radius = minRadius; radius <= maxRadius; radius += space)
{
- ia = space/radius;
- for ( angle=0.0f ; angle<Math::PI*2.0f ; angle+=ia )
+ float ia = space/radius;
+ for (float angle = 0.0f; angle < Math::PI*2.0f; angle += ia)
{
+ Math::Point p;
p.x = center.x+radius;
p.y = center.z;
p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p);
+ Math::Vector pos;
pos.x = p.x;
pos.z = p.y;
pos.y = 0.0f;
- m_terrain->MoveOnFloor(pos, true);
- dist = SearchNearestObject(pos, exclu);
- if ( dist >= space )
+ m_terrain->AdjustToFloor(pos, true);
+ float dist = SearchNearestObject(pos, exclu);
+ if (dist >= space)
{
- flat = m_terrain->RetFlatZoneRadius(pos, dist/2.0f);
- if ( flat >= dist/2.0f )
+ float flat = m_terrain->GetFlatZoneRadius(pos, dist/2.0f);
+ if (flat >= dist/2.0f)
{
center = pos;
return true;
@@ -5602,23 +5104,25 @@ bool CRobotMain::FreeSpace(Math::Vector &center, float minRadius, float maxRadiu
}
else // from external to internal?
{
- for ( radius=maxRadius ; radius>=minRadius ; radius-=space )
+ for (float radius=maxRadius; radius >= minRadius; radius -= space)
{
- ia = space/radius;
- for ( angle=0.0f ; angle<Math::PI*2.0f ; angle+=ia )
+ float ia = space/radius;
+ for (float angle=0.0f ; angle<Math::PI*2.0f ; angle+=ia )
{
+ Math::Point p;
p.x = center.x+radius;
p.y = center.z;
p = Math::RotatePoint(Math::Point(center.x, center.z), angle, p);
+ Math::Vector pos;
pos.x = p.x;
pos.z = p.y;
pos.y = 0.0f;
- m_terrain->MoveOnFloor(pos, true);
- dist = SearchNearestObject(pos, exclu);
- if ( dist >= space )
+ m_terrain->AdjustToFloor(pos, true);
+ float dist = SearchNearestObject(pos, exclu);
+ if (dist >= space)
{
- flat = m_terrain->RetFlatZoneRadius(pos, dist/2.0f);
- if ( flat >= dist/2.0f )
+ float flat = m_terrain->GetFlatZoneRadius(pos, dist/2.0f);
+ if (flat >= dist/2.0f)
{
center = pos;
return true;
@@ -5630,79 +5134,71 @@ bool CRobotMain::FreeSpace(Math::Vector &center, float minRadius, float maxRadiu
return false;
}
-// Calculates the maximum radius of a free space.
-
-float CRobotMain::RetFlatZoneRadius(Math::Vector center, float maxRadius,
+//! Calculates the maximum radius of a free space
+float CRobotMain::GetFlatZoneRadius(Math::Vector center, float maxRadius,
CObject *exclu)
{
- float dist;
-
- dist = SearchNearestObject(center, exclu);
- if ( dist == 0.0f ) return 0.0f;
- if ( dist < maxRadius )
- {
+ float dist = SearchNearestObject(center, exclu);
+ if (dist == 0.0f) return 0.0f;
+ if (dist < maxRadius)
maxRadius = dist;
- }
- return m_terrain->RetFlatZoneRadius(center, maxRadius);
-}
+ return m_terrain->GetFlatZoneRadius(center, maxRadius);
+}
-// Hides buildable area when a cube of metal is taken up.
+//! Hides buildable area when a cube of metal is taken up
void CRobotMain::HideDropZone(CObject* metal)
{
- if ( m_showLimit[1].bUsed &&
- m_showLimit[1].link == metal )
+ if (m_showLimit[1].used &&
+ m_showLimit[1].link == metal)
{
FlushShowLimit(1);
}
- if ( m_showLimit[2].bUsed &&
- m_showLimit[2].link == metal )
+ if (m_showLimit[2].used &&
+ m_showLimit[2].link == metal)
{
FlushShowLimit(2);
}
}
-// Shows the buildable area when a cube of metal is deposited.
-
+//! Shows the buildable area when a cube of metal is deposited
void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
{
- CObject* pObj;
- ObjectType type;
- Math::Vector center, oPos;
- float oMax, tMax, dist, oRadius, radius;
- int i, j;
+ if (metal == nullptr) return;
- if ( metal == 0 ) return;
-
- center = metal->RetPosition(0);
+ Math::Vector center = metal->GetPosition(0);
// Calculates the maximum radius possible depending on other items.
- oMax = 30.0f; // radius to build the biggest building
- for ( i=0 ; i<1000000 ; i++ )
+ float oMax = 30.0f; // radius to build the biggest building
+ float tMax;
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( !pObj->RetActif() ) continue; // inactive?
- if ( pObj->RetTruck() != 0 ) continue; // object carried?
- if ( pObj == metal ) continue;
- if ( pObj == truck ) continue;
+ if (!obj->GetActif()) continue; // inactive?
+ if (obj->GetTruck() != nullptr) continue; // object carried?
+ if (obj == metal) continue;
+ if (obj == truck) continue;
- type = pObj->RetType();
- if ( type == OBJECT_BASE )
+ Math::Vector oPos;
+ float oRadius;
+
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_BASE)
{
- oPos = pObj->RetPosition(0);
- dist = Math::Distance(center, oPos)-80.0f;
+ oPos = obj->GetPosition(0);
+ float dist = Math::Distance(center, oPos)-80.0f;
oMax = Math::Min(oMax, dist);
}
else
{
- j = 0;
- while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
+ int j = 0;
+ while (obj->GetCrashSphere(j++, oPos, oRadius))
{
- dist = Math::Distance(center, oPos)-oRadius;
+ float dist = Math::Distance(center, oPos)-oRadius;
oMax = Math::Min(oMax, dist);
}
}
@@ -5726,70 +5222,58 @@ void CRobotMain::ShowDropZone(CObject* metal, CObject* truck)
type == OBJECT_SAFE ||
type == OBJECT_HUSTON ) // building?
{
- j = 0;
- while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
+ int j = 0;
+ while (obj->GetCrashSphere(j++, oPos, oRadius))
{
- dist = Math::Distance(center, oPos)-oRadius-BUILDMARGIN;
+ float dist = Math::Distance(center, oPos)-oRadius-BUILDMARGIN;
oMax = Math::Min(oMax, dist);
}
}
}
// Calculates the maximum possible radius depending on terrain.
- if ( oMax >= 2.0f )
- {
- tMax = m_terrain->RetFlatZoneRadius(center, 30.0f);
- }
+ if (oMax >= 2.0f)
+ tMax = m_terrain->GetFlatZoneRadius(center, 30.0f);
else
- {
tMax = 0.0f;
- }
- radius = Math::Min(oMax, tMax);
- if ( radius >= 2.0f )
- {
- SetShowLimit(1, PARTILIMIT2, metal, center, radius, 10.0f);
- }
+ float radius = Math::Min(oMax, tMax);
+ if (radius >= 2.0f)
+ SetShowLimit(1, Gfx::PARTILIMIT2, metal, center, radius, 10.0f);
}
-// Erases the boundaries shown.
-
+//! Erases the boundaries shown
void CRobotMain::FlushShowLimit(int i)
{
- int j;
-
- if ( m_showLimit[i].link != 0 )
+ if (m_showLimit[i].link != 0)
{
m_showLimit[i].link->StopShowLimit();
}
- for ( j=0 ; j<m_showLimit[i].total ; j++ )
+ for (int j = 0; j < m_showLimit[i].total; j++)
{
- if ( m_showLimit[i].parti[j] == 0 ) continue;
+ if (m_showLimit[i].parti[j] == 0) continue;
- m_particule->DeleteParticule(m_showLimit[i].parti[j]);
+ m_particle->DeleteParticle(m_showLimit[i].parti[j]);
m_showLimit[i].parti[j] = 0;
}
m_showLimit[i].total = 0;
m_showLimit[i].link = 0;
- m_showLimit[i].bUsed = false;
+ m_showLimit[i].used = false;
}
-// Specifies the boundaries to show.
-
-void CRobotMain::SetShowLimit(int i, ParticuleType parti, CObject *pObj,
+//! Specifies the boundaries to show
+void CRobotMain::SetShowLimit(int i, Gfx::ParticleType parti, CObject *obj,
Math::Vector pos, float radius, float duration)
{
- Math::Point dim;
- float dist;
- int j;
-
FlushShowLimit(i); // erases the current boundaries
- if ( radius <= 0.0f ) return;
+ if (radius <= 0.0f) return;
- if ( radius <= 50.0f )
+ Math::Point dim;
+ float dist;
+ if (radius <= 50.0f)
{
dim = Math::Point(0.3f, 0.3f);
dist = 2.5f;
@@ -5800,98 +5284,85 @@ void CRobotMain::SetShowLimit(int i, ParticuleType parti, CObject *pObj,
dist = 10.0f;
}
- m_showLimit[i].bUsed = true;
- m_showLimit[i].link = pObj;
+ m_showLimit[i].used = true;
+ m_showLimit[i].link = obj;
m_showLimit[i].pos = pos;
m_showLimit[i].radius = radius;
m_showLimit[i].duration = duration;
- m_showLimit[i].total = (int)((radius*2.0f*Math::PI)/dist);
- if ( m_showLimit[i].total > MAXSHOWPARTI ) m_showLimit[i].total = MAXSHOWPARTI;
+ m_showLimit[i].total = static_cast<int>((radius*2.0f*Math::PI)/dist);
+ if (m_showLimit[i].total > MAXSHOWPARTI) m_showLimit[i].total = MAXSHOWPARTI;
m_showLimit[i].time = 0.0f;
- for ( j=0 ; j<m_showLimit[i].total ; j++ )
+ for (int j = 0; j < m_showLimit[i].total; j++)
{
- m_showLimit[i].parti[j] = m_particule->CreateParticule(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, parti, duration);
+ m_showLimit[i].parti[j] = m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, parti, duration);
}
}
-// Adjusts the boundaries to show.
-
+//! Adjusts the boundaries to show
void CRobotMain::AdjustShowLimit(int i, Math::Vector pos)
{
m_showLimit[i].pos = pos;
}
-// Mount the boundaries of the selected object.
-
+//! Mount the boundaries of the selected object
void CRobotMain::StartShowLimit()
{
- CObject* pObj;
+ CObject* obj = GetSelect();
+ if (obj == nullptr) return;
- pObj = RetSelect();
- if ( pObj == 0 ) return;
-
- pObj->StartShowLimit();
+ obj->StartShowLimit();
}
-// Advances the boundaries shown.
-
+//! Advances the boundaries shown
void CRobotMain::FrameShowLimit(float rTime)
{
- Math::Vector pos;
- Math::Point center, rotate;
- float angle, factor, speed;
- int i, j;
-
- if ( m_engine->RetPause() ) return;
+ if (m_engine->GetPause()) return;
- for ( i=0 ; i<MAXSHOWLIMIT ; i++ )
+ for (int i = 0; i < MAXSHOWLIMIT; i++)
{
- if ( !m_showLimit[i].bUsed ) continue;
+ if (!m_showLimit[i].used) continue;
m_showLimit[i].time += rTime;
- if ( m_showLimit[i].time >= m_showLimit[i].duration )
+ if (m_showLimit[i].time >= m_showLimit[i].duration)
{
FlushShowLimit(i);
continue;
}
- if ( m_showLimit[i].time < 1.0f )
- {
+ float factor;
+ if (m_showLimit[i].time < 1.0f)
factor = m_showLimit[i].time;
- }
- else if ( m_showLimit[i].time > m_showLimit[i].duration-1.0f )
- {
+ else if (m_showLimit[i].time > m_showLimit[i].duration-1.0f)
factor = m_showLimit[i].duration-m_showLimit[i].time;
- }
else
- {
factor = 1.0f;
- }
- speed = 0.4f-m_showLimit[i].radius*0.001f;
- if ( speed < 0.1f ) speed = 0.1f;
- angle = m_showLimit[i].time*speed;
+ float speed = 0.4f-m_showLimit[i].radius*0.001f;
+ if (speed < 0.1f) speed = 0.1f;
+ float angle = m_showLimit[i].time*speed;
- for ( j=0 ; j<m_showLimit[i].total ; j++ )
+ for (int j = 0; j < m_showLimit[i].total; j++)
{
- if ( m_showLimit[i].parti[j] == 0 ) continue;
+ if (m_showLimit[i].parti[j] == 0) continue;
+ Math::Point center;
center.x = m_showLimit[i].pos.x;
center.y = m_showLimit[i].pos.z;
+ Math::Point rotate;
rotate.x = center.x+m_showLimit[i].radius*factor;
rotate.y = center.y;
rotate = Math::RotatePoint(center, angle, rotate);
+ Math::Vector pos;
pos.x = rotate.x;
pos.z = rotate.y;
pos.y = 0.0f;
- m_terrain->MoveOnFloor(pos, true);
- if ( m_showLimit[i].radius <= 50.0f ) pos.y += 0.5f;
- else pos.y += 2.0f;
- m_particule->SetPosition(m_showLimit[i].parti[j], pos);
-//? m_particule->SetAngle(m_showLimit[i].parti[j], angle-Math::PI/2.0f);
+ m_terrain->AdjustToFloor(pos, true);
+ if (m_showLimit[i].radius <= 50.0f) pos.y += 0.5f;
+ else pos.y += 2.0f;
+ m_particle->SetPosition(m_showLimit[i].parti[j], pos);
angle += (2.0f*Math::PI)/m_showLimit[i].total;
}
@@ -5900,77 +5371,72 @@ void CRobotMain::FrameShowLimit(float rTime)
-// Returns a pointer to the last backslash in a filename.
-
+//! Returns a pointer to the last backslash in a filename.
char* SearchLastDir(char *filename)
{
- char* p = filename;
+ char* p = filename;
- while ( *p++ != 0 );
+ while (*p++ != 0);
p --; // ^on the zero terminator
- while ( p != filename )
+ while (p != filename)
{
- if ( *(--p) == '\\' ) return p;
+ if (*(--p) == '\\') return p;
}
return 0;
}
-// Compiles all scripts of robots.
-
-void CRobotMain::CompileScript(bool bSoluce)
+//! Compiles all scripts of robots
+void CRobotMain::CompileScript(bool soluce)
{
- CObject* pObj;
- CBrain* brain;
- int i, j, nbError, lastError, run;
- char* name;
+ int nbError = 0;
+ int lastError = 0;
- nbError = 0;
do
{
lastError = nbError;
nbError = 0;
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
- if ( pObj->RetTruck() != 0 ) continue;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
+ if (obj->GetTruck() != nullptr) continue;
- brain = pObj->RetBrain();
- if ( brain == 0 ) continue;
+ CBrain* brain = obj->GetBrain();
+ if (brain == nullptr) continue;
- for ( j=0 ; j<10 ; j++ )
+ for (int j = 0; j < 10; j++)
{
- if ( brain->RetCompile(j) ) continue;
+ if (brain->GetCompile(j)) continue;
- name = brain->RetScriptName(j);
- if ( name[0] != 0 )
+ char* name = brain->GetScriptName(j);
+ if (name[0] != 0)
{
brain->ReadProgram(j, name);
- if ( !brain->RetCompile(j) ) nbError++;
+ if (!brain->GetCompile(j)) nbError++;
}
}
- LoadOneScript(pObj, nbError);
+ LoadOneScript(obj, nbError);
}
}
- while ( nbError > 0 && nbError != lastError );
+ while (nbError > 0 && nbError != lastError);
// Load all solutions.
- if ( bSoluce )
+ if (soluce)
{
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
- if ( pObj->RetTruck() != 0 ) continue;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == 0) break;
+ if (obj->GetTruck() != 0) continue;
- brain = pObj->RetBrain();
- if ( brain == 0 ) continue;
+ CBrain* brain = obj->GetBrain();
+ if (brain == 0) continue;
- name = brain->RetSoluceName();
- if ( name[0] != 0 )
+ char* name = brain->GetSoluceName();
+ if (name[0] != 0)
{
brain->ReadSoluce(name); // load solution
}
@@ -5978,241 +5444,189 @@ void CRobotMain::CompileScript(bool bSoluce)
}
// Start all programs according to the command "run".
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
- if ( pObj->RetTruck() != 0 ) continue;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
+ if (obj->GetTruck() != nullptr) continue;
- brain = pObj->RetBrain();
- if ( brain == 0 ) continue;
+ CBrain* brain = obj->GetBrain();
+ if (brain == nullptr) continue;
- run = brain->RetScriptRun();
- if ( run != -1 )
+ int run = brain->GetScriptRun();
+ if (run != -1)
{
brain->RunProgram(run); // starts the program
}
}
}
-// Load all programs of the robot.
-
-void CRobotMain::LoadOneScript(CObject *pObj, int &nbError)
+//! Load all programs of the robot
+void CRobotMain::LoadOneScript(CObject *obj, int &nbError)
{
- ObjectType type;
- CBrain* brain;
- char filename[_MAX_FNAME];
- char* name;
- int rank, i, objRank;
-
- brain = pObj->RetBrain();
- if ( brain == 0 ) return;
+ CBrain* brain = obj->GetBrain();
+ if (brain == nullptr) return;
- if ( !IsSelectable(pObj) ) return;
+ if (!IsSelectable(obj)) return;
- type = pObj->RetType();
- if ( type == OBJECT_HUMAN ) return;
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_HUMAN) return;
- objRank = pObj->RetDefRank();
- if ( objRank == -1 ) return;
+ int objRank = obj->GetDefRank();
+ if (objRank == -1) return;
- name = m_dialog->RetSceneName();
- rank = m_dialog->RetSceneRank();
+ char* name = m_dialog->GetSceneName();
+ int rank = m_dialog->GetSceneRank();
- for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
+ for (int i = 0; i < BRAINMAXSCRIPT; i++)
{
- if ( brain->RetCompile(i) ) continue;
-//? if ( brain->ProgramExist(i) ) continue;
+ if (brain->GetCompile(i)) continue;
+ char filename[MAX_FNAME];
sprintf(filename, "%s\\%s\\%c%.3d%.3d%.1d.txt",
- RetSavegameDir(), m_gamerName, name[0], rank, objRank, i);
+ GetSavegameDir(), m_gamerName, name[0], rank, objRank, i);
brain->ReadProgram(i, filename);
- if ( !brain->RetCompile(i) ) nbError++;
+ if (!brain->GetCompile(i)) nbError++;
}
}
-// Load all programs of the robot.
-
-void CRobotMain::LoadFileScript(CObject *pObj, char* filename, int objRank,
+//! Load all programs of the robot
+void CRobotMain::LoadFileScript(CObject *obj, char* filename, int objRank,
int &nbError)
{
- ObjectType type;
- CBrain* brain;
- char fn[_MAX_FNAME];
- char* ldir;
- char* name;
- int rank, i;
-
- if ( objRank == -1 ) return;
+ if (objRank == -1) return;
- brain = pObj->RetBrain();
- if ( brain == 0 ) return;
+ CBrain* brain = obj->GetBrain();
+ if (brain == nullptr) return;
- type = pObj->RetType();
- if ( type == OBJECT_HUMAN ) return;
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_HUMAN) return;
- name = m_dialog->RetSceneName();
- rank = m_dialog->RetSceneRank();
+ char fn[MAX_FNAME];
strcpy(fn, filename);
- ldir = SearchLastDir(fn);
- if ( ldir == 0 ) return;
+ char* ldir = SearchLastDir(fn);
+ if (ldir == 0) return;
- for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
+ for (int i = 0; i < BRAINMAXSCRIPT; i++)
{
- if ( brain->RetCompile(i) ) continue;
-//? if ( brain->ProgramExist(i) ) continue;
+ if (brain->GetCompile(i)) continue;
sprintf(ldir, "\\prog%.3d%.1d.txt", objRank, i);
brain->ReadProgram(i, fn);
- if ( !brain->RetCompile(i) ) nbError++;
+ if (!brain->GetCompile(i)) nbError++;
}
}
-// Saves all programs of all the robots.
-
+//! Saves all programs of all the robots
void CRobotMain::SaveAllScript()
{
- CObject* pObj;
- int i;
-
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- SaveOneScript(pObj);
+ SaveOneScript(obj);
}
}
-// Saves all programs of the robot.
-// If a program does not exist, the corresponding file is destroyed.
-
-void CRobotMain::SaveOneScript(CObject *pObj)
+//! Saves all programs of the robot.
+//! If a program does not exist, the corresponding file is destroyed.
+void CRobotMain::SaveOneScript(CObject *obj)
{
- ObjectType type;
- CBrain* brain;
- char filename[_MAX_FNAME];
- char* name;
- int rank, i, objRank;
+ CBrain* brain = obj->GetBrain();
+ if (brain == nullptr) return;
- brain = pObj->RetBrain();
- if ( brain == 0 ) return;
+ if (!IsSelectable(obj)) return;
- if ( !IsSelectable(pObj) ) return;
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_HUMAN) return;
- type = pObj->RetType();
- if ( type == OBJECT_HUMAN ) return;
+ int objRank = obj->GetDefRank();
+ if (objRank == -1) return;
- objRank = pObj->RetDefRank();
- if ( objRank == -1 ) return;
+ char* name = m_dialog->GetSceneName();
+ int rank = m_dialog->GetSceneRank();
- name = m_dialog->RetSceneName();
- rank = m_dialog->RetSceneRank();
-
- for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
+ for (int i = 0; i < BRAINMAXSCRIPT; i++)
{
+ char filename[MAX_FNAME];
sprintf(filename, "%s\\%s\\%c%.3d%.3d%.1d.txt",
- RetSavegameDir(), m_gamerName, name[0], rank, objRank, i);
+ GetSavegameDir(), m_gamerName, name[0], rank, objRank, i);
brain->WriteProgram(i, filename);
}
}
-// Saves all programs of the robot.
-// If a program does not exist, the corresponding file is destroyed.
-
-void CRobotMain::SaveFileScript(CObject *pObj, char* filename, int objRank)
+//! Saves all programs of the robot.
+//! If a program does not exist, the corresponding file is destroyed.
+void CRobotMain::SaveFileScript(CObject *obj, char* filename, int objRank)
{
- ObjectType type;
- CBrain* brain;
- char fn[_MAX_FNAME];
- char* ldir;
- char* name;
- int rank, i;
+ if (objRank == -1) return;
- if ( objRank == -1 ) return;
+ CBrain* brain = obj->GetBrain();
+ if (brain == nullptr) return;
- brain = pObj->RetBrain();
- if ( brain == 0 ) return;
-
- type = pObj->RetType();
- if ( type == OBJECT_HUMAN ) return;
-
- name = m_dialog->RetSceneName();
- rank = m_dialog->RetSceneRank();
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_HUMAN) return;
+ char fn[MAX_FNAME];
strcpy(fn, filename);
- ldir = SearchLastDir(fn);
- if ( ldir == 0 ) return;
+ char* ldir = SearchLastDir(fn);
+ if (ldir == 0) return;
- for ( i=0 ; i<BRAINMAXSCRIPT ; i++ )
+ for (int i = 0; i < BRAINMAXSCRIPT; i++)
{
sprintf(ldir, "\\prog%.3d%.1d.txt", objRank, i);
brain->WriteProgram(i, fn);
}
}
-// Saves the stack of the program in execution of a robot.
-
-bool CRobotMain::SaveFileStack(CObject *pObj, FILE *file, int objRank)
+//! Saves the stack of the program in execution of a robot
+bool CRobotMain::SaveFileStack(CObject *obj, FILE *file, int objRank)
{
- ObjectType type;
- CBrain* brain;
-
- if ( objRank == -1 ) return true;
+ if (objRank == -1) return true;
- brain = pObj->RetBrain();
- if ( brain == 0 ) return true;
+ CBrain* brain = obj->GetBrain();
+ if (brain == nullptr) return true;
- type = pObj->RetType();
- if ( type == OBJECT_HUMAN ) return true;
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_HUMAN) return true;
return brain->WriteStack(file);
}
-// Resumes the execution stack of the program in a robot.
-
-bool CRobotMain::ReadFileStack(CObject *pObj, FILE *file, int objRank)
+//! Resumes the execution stack of the program in a robot
+bool CRobotMain::ReadFileStack(CObject *obj, FILE *file, int objRank)
{
- ObjectType type;
- CBrain* brain;
+ if (objRank == -1) return true;
- if ( objRank == -1 ) return true;
+ CBrain* brain = obj->GetBrain();
+ if (brain == nullptr) return true;
- brain = pObj->RetBrain();
- if ( brain == 0 ) return true;
-
- type = pObj->RetType();
- if ( type == OBJECT_HUMAN ) return true;
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_HUMAN) return true;
return brain->ReadStack(file);
}
-// Empty the list.
-
+//! Empty the list
bool CRobotMain::FlushNewScriptName()
{
- int i;
+ for (int i = 0; i < MAXNEWSCRIPTNAME; i++)
+ m_newScriptName[i].used = false;
- for ( i=0 ; i<MAXNEWSCRIPTNAME ; i++ )
- {
- m_newScriptName[i].bUsed = false;
- }
return true;
}
-// Adds a script name.
-
+//! Adds a script name
bool CRobotMain::AddNewScriptName(ObjectType type, char *name)
{
- int i;
-
- for ( i=0 ; i<MAXNEWSCRIPTNAME ; i++ )
+ for (int i = 0; i < MAXNEWSCRIPTNAME; i++)
{
- if ( !m_newScriptName[i].bUsed )
+ if (!m_newScriptName[i].used)
{
- m_newScriptName[i].bUsed = true;
+ m_newScriptName[i].used = true;
m_newScriptName[i].type = type;
strcpy(m_newScriptName[i].name, name);
return true;
@@ -6221,20 +5635,17 @@ bool CRobotMain::AddNewScriptName(ObjectType type, char *name)
return false;
}
-// Seeks a script name for a given type.
-
-char* CRobotMain::RetNewScriptName(ObjectType type, int rank)
+//! Seeks a script name for a given type
+char* CRobotMain::GetNewScriptName(ObjectType type, int rank)
{
- int i;
-
- for ( i=0 ; i<MAXNEWSCRIPTNAME ; i++ )
+ for (int i = 0; i < MAXNEWSCRIPTNAME; i++)
{
- if ( m_newScriptName[i].bUsed &&
- (m_newScriptName[i].type == type ||
- m_newScriptName[i].type == OBJECT_NULL ) )
+ if (m_newScriptName[i].used &&
+ (m_newScriptName[i].type == type ||
+ m_newScriptName[i].type == OBJECT_NULL))
{
- if ( rank == 0 ) return m_newScriptName[i].name;
- else rank --;
+ if (rank == 0) return m_newScriptName[i].name;
+ else rank --;
}
}
@@ -6242,122 +5653,108 @@ char* CRobotMain::RetNewScriptName(ObjectType type, int rank)
}
-// Seeks if an object occupies in a spot, to prevent a backup of the game.
-
+//! Seeks if an object occupies in a spot, to prevent a backup of the game
bool CRobotMain::IsBusy()
{
- CObject* pObj;
- CBrain* pBrain;
-//? CAuto* pAuto;
- int i;
-
- if ( m_CompteurFileOpen > 0 ) return true;
+ if (m_CompteurFileOpen > 0) return true;
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- pBrain = pObj->RetBrain();
- if ( pBrain != 0 )
+ CBrain* brain = obj->GetBrain();
+ if (brain != nullptr)
{
- if ( pBrain->IsBusy() ) return true;
+ if (brain->IsBusy()) return true;
}
-
-//? pAuto = pObj->RetAuto();
-//? if ( pAuto != 0 )
-//? {
-//? if ( pAuto->RetBusy() ) return true;
-//? }
}
return false;
}
-// Writes an object into the backup file.
-
-void CRobotMain::IOWriteObject(FILE *file, CObject* pObj, char *cmd)
+//! Writes an object into the backup file
+void CRobotMain::IOWriteObject(FILE *file, CObject* obj, const char *cmd)
{
- Math::Vector pos;
- CBrain* pBrain;
- char line[3000];
- char name[100];
- int run, i;
+ if (obj->GetType() == OBJECT_FIX) return;
- if ( pObj->RetType() == OBJECT_FIX ) return;
+ char line[3000];
+ char name[100];
strcpy(line, cmd);
- sprintf(name, " type=%s", GetTypeObject(pObj->RetType()));
+ sprintf(name, " type=%s", GetTypeObject(obj->GetType()));
strcat(line, name);
- sprintf(name, " id=%d", pObj->RetID());
+ sprintf(name, " id=%d", obj->GetID());
strcat(line, name);
- pos = pObj->RetPosition(0)/g_unit;
+ Math::Vector pos;
+
+ pos = obj->GetPosition(0)/g_unit;
sprintf(name, " pos=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
strcat(line, name);
- pos = pObj->RetAngle(0)/(Math::PI/180.0f);
+ pos = obj->GetAngle(0)/(Math::PI/180.0f);
sprintf(name, " angle=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
strcat(line, name);
- pos = pObj->RetZoom(0);
+ pos = obj->GetZoom(0);
sprintf(name, " zoom=%.2f;%.2f;%.2f", pos.x, pos.y, pos.z);
strcat(line, name);
- for ( i=1 ; i<OBJECTMAXPART ; i++ )
+ for (int i = 1; i < OBJECTMAXPART; i++)
{
- if ( pObj->RetObjectRank(i) == -1 ) continue;
+ if (obj->GetObjectRank(i) == -1) continue;
- pos = pObj->RetPosition(i);
- if ( pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f )
+ pos = obj->GetPosition(i);
+ if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f)
{
pos /= g_unit;
sprintf(name, " p%d=%.2f;%.2f;%.2f", i, pos.x, pos.y, pos.z);
strcat(line, name);
}
- pos = pObj->RetAngle(i);
- if ( pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f )
+ pos = obj->GetAngle(i);
+ if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f)
{
pos /= (Math::PI/180.0f);
sprintf(name, " a%d=%.2f;%.2f;%.2f", i, pos.x, pos.y, pos.z);
strcat(line, name);
}
- pos = pObj->RetZoom(i);
- if ( pos.x != 1.0f || pos.y != 1.0f || pos.z != 1.0f )
+ pos = obj->GetZoom(i);
+ if (pos.x != 1.0f || pos.y != 1.0f || pos.z != 1.0f)
{
sprintf(name, " z%d=%.2f;%.2f;%.2f", i, pos.x, pos.y, pos.z);
strcat(line, name);
}
}
- sprintf(name, " trainer=%d", pObj->RetTrainer());
+ sprintf(name, " trainer=%d", obj->GetTrainer());
strcat(line, name);
- sprintf(name, " option=%d", pObj->RetOption());
+ sprintf(name, " option=%d", obj->GetOption());
strcat(line, name);
- if ( pObj == m_infoObject ) // selects object?
+ if (obj == m_infoObject) // selects object?
{
sprintf(name, " select=1");
strcat(line, name);
}
- pObj->Write(line);
+ obj->Write(line);
- if ( pObj->RetType() == OBJECT_BASE )
+ if (obj->GetType() == OBJECT_BASE)
{
sprintf(name, " run=3"); // stops and open (PARAM_FIXSCENE)
strcat(line, name);
}
- pBrain = pObj->RetBrain();
- if ( pBrain != 0 )
+ CBrain* brain = obj->GetBrain();
+ if (brain != nullptr)
{
- run = pBrain->RetProgram();
- if ( run != -1 )
+ int run = brain->GetProgram();
+ if (run != -1)
{
sprintf(name, " run=%d", run+1);
strcat(line, name);
@@ -6368,20 +5765,13 @@ void CRobotMain::IOWriteObject(FILE *file, CObject* pObj, char *cmd)
fputs(line, file);
}
-// Saves the current game.
-
+//! Saves the current game
bool CRobotMain::IOWriteScene(char *filename, char *filecbot, char *info)
{
- FILE* file;
- char line[500];
- char* name;
- CObject *pObj, *pPower, *pFret;
- float sleep, delay, magnetic, progress;
- int i, objRank;
- long version;
+ FILE* file = fopen(filename, "w");
+ if (file == NULL) return false;
- file = fopen(filename, "w");
- if ( file == NULL ) return false;
+ char line[500];
sprintf(line, "Title text=\"%s\"\n", info);
fputs(line, file);
@@ -6389,84 +5779,81 @@ bool CRobotMain::IOWriteScene(char *filename, char *filecbot, char *info)
sprintf(line, "Version maj=%d min=%d\n", 0, 1);
fputs(line, file);
- name = m_dialog->RetSceneName();
- if ( strcmp(name, "user") == 0 )
+ char* name = m_dialog->GetSceneName();
+ if (strcmp(name, "user") == 0)
{
- sprintf(line, "Mission base=\"%s\" rank=%.3d dir=\"%s\"\n", name, m_dialog->RetSceneRank(), m_dialog->RetSceneDir());
+ sprintf(line, "Mission base=\"%s\" rank=%.3d dir=\"%s\"\n", name, m_dialog->GetSceneRank(), m_dialog->GetSceneDir());
}
else
{
- sprintf(line, "Mission base=\"%s\" rank=%.3d\n", name, m_dialog->RetSceneRank());
+ sprintf(line, "Mission base=\"%s\" rank=%.3d\n", name, m_dialog->GetSceneRank());
}
fputs(line, file);
- sprintf(line, "Map zoom=%.2f\n", m_map->RetZoomMap());
+ sprintf(line, "Map zoom=%.2f\n", m_map->GetZoomMap());
fputs(line, file);
- sprintf(line, "DoneResearch bits=%d\n", g_researchDone);
+ sprintf(line, "DoneResearch bits=%d\n", static_cast<int>(g_researchDone));
fputs(line, file);
- if ( m_blitz->GetStatus(sleep, delay, magnetic, progress) )
+ float sleep, delay, magnetic, progress;
+ if (m_lightning->GetStatus(sleep, delay, magnetic, progress))
{
sprintf(line, "BlitzMode sleep=%.2f delay=%.2f magnetic=%.2f progress=%.2f\n", sleep, delay, magnetic/g_unit, progress);
fputs(line, file);
}
- objRank = 0;
- for ( i=0 ; i<1000000 ; i++ )
+ int objRank = 0;
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( pObj->RetType() == OBJECT_TOTO ) continue;
- if ( pObj->RetType() == OBJECT_FIX ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
- if ( pObj->RetBurn() ) continue;
- if ( pObj->RetDead() ) continue;
- if ( pObj->RetExplo() ) continue;
+ if (obj->GetType() == OBJECT_TOTO) continue;
+ if (obj->GetType() == OBJECT_FIX) continue;
+ if (obj->GetTruck() != nullptr) continue;
+ if (obj->GetBurn()) continue;
+ if (obj->GetDead()) continue;
+ if (obj->GetExplo()) continue;
- pPower = pObj->RetPower();
- pFret = pObj->RetFret();
+ CObject* power = obj->GetPower();
+ CObject* fret = obj->GetFret();
- if ( pFret != 0 ) // object transported?
- {
- IOWriteObject(file, pFret, "CreateFret");
- }
+ if (fret != nullptr) // object transported?
+ IOWriteObject(file, fret, "CreateFret");
- if ( pPower != 0 ) // battery transported?
- {
- IOWriteObject(file, pPower, "CreatePower");
- }
+ if (power != nullptr) // battery transported?
+ IOWriteObject(file, power, "CreatePower");
- IOWriteObject(file, pObj, "CreateObject");
+ IOWriteObject(file, obj, "CreateObject");
- SaveFileScript(pObj, filename, objRank++);
+ SaveFileScript(obj, filename, objRank++);
}
fclose(file);
#if CBOT_STACK
// Writes the file of stacks of execution.
file = fOpen(filecbot, "wb");
- if ( file == NULL ) return false;
+ if (file == NULL) return false;
- version = 1;
+ long version = 1;
fWrite(&version, sizeof(long), 1, file); // version of COLOBOT
version = CBotProgram::GetVersion();
fWrite(&version, sizeof(long), 1, file); // version of CBOT
objRank = 0;
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( pObj->RetType() == OBJECT_TOTO ) continue;
- if ( pObj->RetType() == OBJECT_FIX ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
- if ( pObj->RetBurn() ) continue;
- if ( pObj->RetDead() ) continue;
+ if (obj->GetType() == OBJECT_TOTO) continue;
+ if (obj->GetType() == OBJECT_FIX) continue;
+ if (obj->GetTruck() != nullptr) continue;
+ if (obj->GetBurn()) continue;
+ if (obj->GetDead()) continue;
- if ( !SaveFileStack(pObj, file, objRank++) ) break;
+ if (!SaveFileStack(obj, file, objRank++)) break;
}
CBotClass::SaveStaticState(file);
fClose(file);
@@ -6476,232 +5863,205 @@ bool CRobotMain::IOWriteScene(char *filename, char *filecbot, char *info)
return true;
}
-// Resumes the game.
-
+//! Resumes the game
CObject* CRobotMain::IOReadObject(char *line, char* filename, int objRank)
{
- CObject* pObj;
-//? CBrain* pBrain;
- CAuto* pAuto;
- Math::Vector pos, dir, zoom;
- ObjectType type;
- int id, run, trainer, toy, option, i;
- char op[10];
+ Math::Vector pos = OpDir(line, "pos")*g_unit;
+ Math::Vector dir = OpDir(line, "angle")*(Math::PI/180.0f);
+ Math::Vector zoom = OpDir(line, "zoom");
- pos = OpDir(line, "pos")*g_unit;
- dir = OpDir(line, "angle")*(Math::PI/180.0f);
- zoom = OpDir(line, "zoom");
- type = OpTypeObject(line, "type", OBJECT_NULL);
- id = OpInt(line, "id", 0);
- if ( type == OBJECT_NULL ) return 0;
- trainer = OpInt(line, "trainer", 0);
- toy = OpInt(line, "toy", 0);
- option = OpInt(line, "option", 0);
- pObj = CreateObject(pos, dir.y, 1.0f, 0.0f, type, 0.0f, trainer, toy, option);
- pObj->SetDefRank(objRank);
- pObj->SetPosition(0, pos);
- pObj->SetAngle(0, dir);
- pObj->SetID(id);
- if ( g_id < id ) g_id = id;
+ ObjectType type = OpTypeObject(line, "type", OBJECT_NULL);
+ int id = OpInt(line, "id", 0);
+ if (type == OBJECT_NULL)
+ return nullptr;
- if ( zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f )
- {
- pObj->SetZoom(0, zoom);
- }
+ int trainer = OpInt(line, "trainer", 0);
+ int toy = OpInt(line, "toy", 0);
+ int option = OpInt(line, "option", 0);
+
+ CObject* obj = CreateObject(pos, dir.y, 1.0f, 0.0f, type, 0.0f, trainer, toy, option);
+ obj->SetDefRank(objRank);
+ obj->SetPosition(0, pos);
+ obj->SetAngle(0, dir);
+ obj->SetID(id);
+ if (g_id < id) g_id = id;
+
+ if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
+ obj->SetZoom(0, zoom);
- for ( i=1 ; i<OBJECTMAXPART ; i++ )
+ for (int i = 1; i < OBJECTMAXPART; i++)
{
- if ( pObj->RetObjectRank(i) == -1 ) continue;
+ if (obj->GetObjectRank(i) == -1) continue;
+ char op[10];
sprintf(op, "p%d", i);
- pos = OpDir(line, op);
- if ( pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f )
+ pos = OpDir(line, op);
+ if (pos.x != 0.0f || pos.y != 0.0f || pos.z != 0.0f)
{
- pObj->SetPosition(i, pos*g_unit);
+ obj->SetPosition(i, pos*g_unit);
}
sprintf(op, "a%d", i);
- dir = OpDir(line, op);
- if ( dir.x != 0.0f || dir.y != 0.0f || dir.z != 0.0f )
+ dir = OpDir(line, op);
+ if (dir.x != 0.0f || dir.y != 0.0f || dir.z != 0.0f)
{
- pObj->SetAngle(i, dir*(Math::PI/180.0f));
+ obj->SetAngle(i, dir*(Math::PI/180.0f));
}
sprintf(op, "z%d", i);
zoom = OpDir(line, op);
- if ( zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f )
+ if (zoom.x != 0.0f || zoom.y != 0.0f || zoom.z != 0.0f)
{
- pObj->SetZoom(i, zoom);
+ obj->SetZoom(i, zoom);
}
}
- if ( type == OBJECT_BASE ) m_bBase = true;
+ if (type == OBJECT_BASE) m_base = true;
- pObj->Read(line);
+ obj->Read(line);
#if CBOT_STACK
#else
- LoadFileScript(pObj, filename, objRank, i);
+ LoadFileScript(obj, filename, objRank, i);
#endif
- run = OpInt(line, "run", -1);
- if ( run != -1 )
+ int run = OpInt(line, "run", -1);
+ if (run != -1)
{
#if CBOT_STACK
#else
- pBrain = pObj->RetBrain();
- if ( pBrain != 0 )
- {
- pBrain->RunProgram(run-1); // starts the program
- }
+ CBrain* brain = obj->GetBrain();
+ if (brain != nullptr)
+ brain->RunProgram(run-1); // starts the program
#endif
- pAuto = pObj->RetAuto();
- if ( pAuto != 0 )
- {
- pAuto->Start(run); // starts the film
- }
+ CAuto* automat = obj->GetAuto();
+ if (automat != nullptr)
+ automat->Start(run); // starts the film
}
- return pObj;
+ return obj;
}
-// Resumes some part of the game.
-
+//! Resumes some part of the game
CObject* CRobotMain::IOReadScene(char *filename, char *filecbot)
{
- FILE* file;
- CObject *pObj, *pPower, *pFret, *pSel;
- char line[3000];
- float sleep, delay, progress, magnetic;
- int i, objRank, nbError, lastError;
- long version;
+ m_base = false;
- m_bBase = false;
+ FILE* file = fopen(filename, "r");
+ if (file == NULL) return 0;
- file = fopen(filename, "r");
- if ( file == NULL ) return 0;
-
- pFret = 0;
- pPower = 0;
- pSel = 0;
- objRank = 0;
- while ( fgets(line, 3000, file) != NULL )
+ CObject* fret = nullptr;
+ CObject* power = nullptr;
+ CObject* sel = nullptr;
+ int objRank = 0;
+ char line[3000];
+ while (fgets(line, 3000, file) != NULL)
{
- for ( i=0 ; i<3000 ; i++ )
+ for (int i = 0; i < 3000; i++)
{
- if ( line[i] == '\t' ) line[i] = ' '; // replace tab by space
- if ( line[i] == '/' && line[i+1] == '/' )
+ if (line[i] == '\t') line[i] = ' '; // replace tab by space
+ if (line[i] == '/' && line[i+1] == '/')
{
line[i] = 0;
break;
}
}
- if ( Cmd(line, "Map") )
- {
+ if (Cmd(line, "Map"))
m_map->ZoomMap(OpFloat(line, "zoom", 1.0f));
- }
- if ( Cmd(line, "DoneResearch") )
- {
+ if (Cmd(line, "DoneResearch"))
g_researchDone = OpInt(line, "bits", 0);
- }
- if ( Cmd(line, "BlitzMode") )
+ if (Cmd(line, "BlitzMode"))
{
- sleep = OpFloat(line, "sleep", 0.0f);
- delay = OpFloat(line, "delay", 3.0f);
- magnetic = OpFloat(line, "magnetic", 50.0f)*g_unit;
- progress = OpFloat(line, "progress", 0.0f);
- m_blitz->SetStatus(sleep, delay, magnetic, progress);
+ float sleep = OpFloat(line, "sleep", 0.0f);
+ float delay = OpFloat(line, "delay", 3.0f);
+ float magnetic = OpFloat(line, "magnetic", 50.0f)*g_unit;
+ float progress = OpFloat(line, "progress", 0.0f);
+ m_lightning->SetStatus(sleep, delay, magnetic, progress);
}
- if ( Cmd(line, "CreateFret") )
- {
- pFret = IOReadObject(line, filename, -1);
- }
+ if (Cmd(line, "CreateFret"))
+ fret = IOReadObject(line, filename, -1);
- if ( Cmd(line, "CreatePower") )
- {
- pPower = IOReadObject(line, filename, -1);
- }
+ if (Cmd(line, "CreatePower"))
+ power = IOReadObject(line, filename, -1);
- if ( Cmd(line, "CreateObject") )
+ if (Cmd(line, "CreateObject"))
{
- pObj = IOReadObject(line, filename, objRank++);
+ CObject* obj = IOReadObject(line, filename, objRank++);
- if ( OpInt(line, "select", 0) )
- {
- pSel = pObj;
- }
+ if (OpInt(line, "select", 0))
+ sel = obj;
- if ( pFret != 0 )
+ if (fret != nullptr)
{
- CTaskManip* task;
-
- pObj->SetFret(pFret);
- task = new CTaskManip(m_iMan, pObj);
+ obj->SetFret(fret);
+ CTaskManip* task = new CTaskManip(m_iMan, obj);
task->Start(TMO_AUTO, TMA_GRAB); // holds the object!
delete task;
}
- if ( pPower != 0 )
+ if (power != nullptr)
{
- pObj->SetPower(pPower);
- pPower->SetTruck(pObj);
+ obj->SetPower(power);
+ power->SetTruck(obj);
}
- pFret = 0;
- pPower = 0;
+ fret = nullptr;
+ power = nullptr;
}
}
fclose(file);
#if CBOT_STACK
// Compiles scripts.
- nbError = 0;
+ int nbError = 0;
+ int lastError = 0;
do
{
lastError = nbError;
nbError = 0;
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
- if ( pObj->RetTruck() != 0 ) continue;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
+ if (obj->GetTruck() != nullptr) continue;
- objRank = pObj->RetDefRank();
- if ( objRank == -1 ) continue;
+ objRank = obj->GetDefRank();
+ if (objRank == -1) continue;
- LoadFileScript(pObj, filename, objRank, nbError);
+ LoadFileScript(obj, filename, objRank, nbError);
}
}
- while ( nbError > 0 && nbError != lastError );
+ while (nbError > 0 && nbError != lastError);
// Reads the file of stacks of execution.
file = fOpen(filecbot, "rb");
- if ( file != NULL )
+ if (file != NULL)
{
+ long version;
fRead(&version, sizeof(long), 1, file); // version of COLOBOT
- if ( version == 1 )
+ if (version == 1)
{
fRead(&version, sizeof(long), 1, file); // version of CBOT
- if ( version == CBotProgram::GetVersion() )
+ if (version == CBotProgram::GetVersion())
{
objRank = 0;
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- if ( pObj->RetType() == OBJECT_TOTO ) continue;
- if ( pObj->RetType() == OBJECT_FIX ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
- if ( pObj->RetBurn() ) continue;
- if ( pObj->RetDead() ) continue;
+ if (obj->GetType() == OBJECT_TOTO) continue;
+ if (obj->GetType() == OBJECT_FIX) continue;
+ if (obj->GetTruck() != nullptr) continue;
+ if (obj->GetBurn()) continue;
+ if (obj->GetDead()) continue;
- if ( !ReadFileStack(pObj, file, objRank++) ) break;
+ if (!ReadFileStack(obj, file, objRank++)) break;
}
}
}
@@ -6710,66 +6070,58 @@ CObject* CRobotMain::IOReadScene(char *filename, char *filecbot)
}
#endif
- return pSel;
+ return sel;
}
-// Writes the global parameters for free play.
-
+//! Writes the global parameters for free play
void CRobotMain::WriteFreeParam()
{
- FILE* file;
- char filename[_MAX_FNAME];
- char line[100];
-
m_freeResearch |= g_researchDone;
m_freeBuild |= g_build;
- if ( m_gamerName[0] == 0 ) return;
+ if (m_gamerName[0] == 0) return;
- sprintf(filename, "%s\\%s\\research.gam", RetSavegameDir(), m_gamerName);
- file = fopen(filename, "w");
- if ( file == NULL ) return;
+ char filename[MAX_FNAME];
+ sprintf(filename, "%s\\%s\\research.gam", GetSavegameDir(), m_gamerName);
+ FILE* file = fopen(filename, "w");
+ if (file == NULL) return;
+ char line[100];
sprintf(line, "research=%d build=%d\n", m_freeResearch, m_freeBuild);
fputs(line, file);
fclose(file);
}
-// Reads the global parameters for free play.
-
+//! Reads the global parameters for free play
void CRobotMain::ReadFreeParam()
{
- FILE* file;
- char filename[_MAX_FNAME];
- char line[100];
-
m_freeResearch = 0;
m_freeBuild = 0;
- if ( m_gamerName[0] == 0 ) return;
+ if (m_gamerName[0] == 0) return;
- sprintf(filename, "%s\\%s\\research.gam", RetSavegameDir(), m_gamerName);
- file = fopen(filename, "r");
- if ( file == NULL ) return;
+ char filename[MAX_FNAME];
+ sprintf(filename, "%s\\%s\\research.gam", GetSavegameDir(), m_gamerName);
+ FILE* file = fopen(filename, "r");
+ if (file == NULL) return;
- if ( fgets(line, 100, file) != NULL )
- {
+ char line[100];
+ if (fgets(line, 100, file) != NULL)
sscanf(line, "research=%d build=%d\n", &m_freeResearch, &m_freeBuild);
- }
fclose(file);
}
-// Resets all objects to their original position.
-
+//! Resets all objects to their original position
void CRobotMain::ResetObject()
{
+// TODO: ?
#if 0
- CObject* pObj;
- CObject* pTruck;
- CAuto* pAuto;
+ CObject* obj;
+ CObject* truck;
+ CAuto* objAuto;
CBrain* brain;
CPyro* pyro;
ResetCap cap;
@@ -6779,7 +6131,7 @@ void CRobotMain::ResetObject()
// Removes all pyrotechnic effects in progress.
while ( true )
{
- pyro = (CPyro*)m_iMan->SearchInstance(CLASS_PYRO, 0);
+ pyro = static_cast<CPyro*>(m_iMan->SearchInstance(CLASS_PYRO, 0));
if ( pyro == 0 ) break;
pyro->DeleteObject();
@@ -6787,179 +6139,166 @@ void CRobotMain::ResetObject()
}
// Removes all bullets in progress.
- m_particule->DeleteParticule(PARTIGUN1);
- m_particule->DeleteParticule(PARTIGUN2);
- m_particule->DeleteParticule(PARTIGUN3);
- m_particule->DeleteParticule(PARTIGUN4);
+ m_particle->DeleteParticle(PARTIGUN1);
+ m_particle->DeleteParticle(PARTIGUN2);
+ m_particle->DeleteParticle(PARTIGUN3);
+ m_particle->DeleteParticle(PARTIGUN4);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if ( obj == 0 ) break;
- cap = pObj->RetResetCap();
+ cap = obj->GetResetCap();
if ( cap == RESET_NONE ) continue;
if ( cap == RESET_DELETE )
{
- pTruck = pObj->RetTruck();
- if ( pTruck != 0 )
+ truck = obj->GetTruck();
+ if ( truck != 0 )
{
- pTruck->SetFret(0);
- pObj->SetTruck(0);
+ truck->SetFret(0);
+ obj->SetTruck(0);
}
- pObj->DeleteObject();
- delete pObj;
+ obj->DeleteObject();
+ delete obj;
i --;
continue;
}
- pAuto = pObj->RetAuto();
- if ( pAuto != 0 )
+ objAuto = obj->GetAuto();
+ if ( objAuto != 0 )
{
- pAuto->Abort();
+ objAuto->Abort();
}
- if ( pObj->RetEnable() ) // object still active?
+ if ( obj->GetEnable() ) // object still active?
{
- brain = pObj->RetBrain();
+ brain = obj->GetBrain();
if ( brain != 0 )
{
- pos = pObj->RetResetPosition();
- angle = pObj->RetResetAngle();
+ pos = obj->GetResetPosition();
+ angle = obj->GetResetAngle();
- if ( pos == pObj->RetPosition(0) &&
- angle == pObj->RetAngle(0) ) continue;
+ if ( pos == obj->GetPosition(0) &&
+ angle == obj->GetAngle(0) ) continue;
brain->StartTaskReset(pos, angle);
continue;
}
}
- pObj->SetEnable(true); // active again
+ obj->SetEnable(true); // active again
- pos = pObj->RetResetPosition();
- angle = pObj->RetResetAngle();
+ pos = obj->GetResetPosition();
+ angle = obj->GetResetAngle();
- if ( pos == pObj->RetPosition(0) &&
- angle == pObj->RetAngle(0) ) continue;
+ if ( pos == obj->GetPosition(0) &&
+ angle == obj->GetAngle(0) ) continue;
pyro = new CPyro(m_iMan);
- pyro->Create(PT_RESET, pObj);
+ pyro->Create(PT_RESET, obj);
- brain = pObj->RetBrain();
+ brain = obj->GetBrain();
if ( brain != 0 )
{
- brain->RunProgram(pObj->RetResetRun());
+ brain->RunProgram(obj->GetResetRun());
}
}
#else
- m_bResetCreate = true;
+ m_resetCreate = true;
#endif
}
-// Resets all objects to their original position.
-
+//! Resets all objects to their original position
void CRobotMain::ResetCreate()
{
- CObject* pObj;
- CPyro* pyro;
- ResetCap cap;
- int i;
-
SaveAllScript();
// Removes all bullets in progress.
- m_particule->DeleteParticule(PARTIGUN1);
- m_particule->DeleteParticule(PARTIGUN2);
- m_particule->DeleteParticule(PARTIGUN3);
- m_particule->DeleteParticule(PARTIGUN4);
+ m_particle->DeleteParticle(Gfx::PARTIGUN1);
+ m_particle->DeleteParticle(Gfx::PARTIGUN2);
+ m_particle->DeleteParticle(Gfx::PARTIGUN3);
+ m_particle->DeleteParticle(Gfx::PARTIGUN4);
DeselectAll(); // removes the control buttons
DeleteAllObjects(); // removes all the current 3D Scene
- m_particule->FlushParticule();
+ m_particle->FlushParticle();
m_terrain->FlushBuildingLevel();
m_iMan->Flush(CLASS_OBJECT);
m_iMan->Flush(CLASS_PHYSICS);
m_iMan->Flush(CLASS_BRAIN);
m_iMan->Flush(CLASS_PYRO);
- m_camera->SetType(CAMERA_DIALOG);
+ m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
- CreateScene(m_dialog->RetSceneSoluce(), false, true);
+ CreateScene(m_dialog->GetSceneSoluce(), false, true);
- if ( !RetNiceReset() ) return;
+ if (!GetNiceReset()) return;
- for ( i=0 ; i<1000000 ; i++ )
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- cap = pObj->RetResetCap();
- if ( cap == RESET_NONE ) continue;
+ ResetCap cap = obj->GetResetCap();
+ if (cap == RESET_NONE) continue;
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_RESET, pObj);
+ Gfx::CPyro* pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_RESET, obj);
}
}
-// Checks if the mission is over.
-
-Error CRobotMain::CheckEndMission(bool bFrame)
+//! Checks if the mission is over
+Error CRobotMain::CheckEndMission(bool frame)
{
- CObject* pObj;
- Math::Vector bPos, oPos;
- ObjectType type;
- int t, i, nb;
-
- for ( t=0 ; t<m_endTakeTotal ; t++ )
+ for (int t = 0; t < m_endTakeTotal; t++)
{
- if ( m_endTake[t].message[0] != 0 ) continue;
+ if (m_endTake[t].message[0] != 0) continue;
- bPos = m_endTake[t].pos;
+ Math::Vector bPos = m_endTake[t].pos;
bPos.y = 0.0f;
- nb = 0;
- for ( i=0 ; i<1000000 ; i++ )
+ Math::Vector oPos;
+
+ int nb = 0;
+ for (int i = 0; i < 1000000; i++)
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ CObject* obj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if (obj == nullptr) break;
- // Do not use RetActif () because an invisible worm (underground)
+ // Do not use GetActif () because an invisible worm (underground)
// should be regarded as existing here!
- if ( pObj->RetLock() ) continue;
- if ( pObj->RetRuin() ) continue;
- if ( !pObj->RetEnable() ) continue;
-
- type = pObj->RetType();
- if ( type == OBJECT_SCRAP2 ||
- type == OBJECT_SCRAP3 ||
- type == OBJECT_SCRAP4 ||
- type == OBJECT_SCRAP5 ) // wastes?
+ if (obj->GetLock()) continue;
+ if (obj->GetRuin()) continue;
+ if (!obj->GetEnable()) continue;
+
+ ObjectType type = obj->GetType();
+ if (type == OBJECT_SCRAP2 ||
+ type == OBJECT_SCRAP3 ||
+ type == OBJECT_SCRAP4 ||
+ type == OBJECT_SCRAP5) // wastes?
{
type = OBJECT_SCRAP1;
}
- if ( type != m_endTake[t].type ) continue;
- if ( pObj->RetTruck() == 0 )
- {
- oPos = pObj->RetPosition(0);
- }
+ if (type != m_endTake[t].type) continue;
+
+ if (obj->GetTruck() == 0)
+ oPos = obj->GetPosition(0);
else
- {
- oPos = pObj->RetTruck()->RetPosition(0);
- }
+ oPos = obj->GetTruck()->GetPosition(0);
+
oPos.y = 0.0f;
- if ( Math::DistanceProjected(oPos, bPos) <= m_endTake[t].dist )
- {
+
+ if (Math::DistanceProjected(oPos, bPos) <= m_endTake[t].dist)
nb ++;
- }
}
- if ( nb <= m_endTake[t].lost )
+ if (nb <= m_endTake[t].lost)
{
- if ( m_endTake[t].type == OBJECT_HUMAN )
+ if (m_endTake[t].type == OBJECT_HUMAN)
{
- if ( m_lostDelay == 0.0f )
+ if (m_lostDelay == 0.0f)
{
m_lostDelay = 0.1f; // lost immediately
m_winDelay = 0.0f;
@@ -6969,7 +6308,7 @@ Error CRobotMain::CheckEndMission(bool bFrame)
}
else
{
- if ( m_lostDelay == 0.0f )
+ if (m_lostDelay == 0.0f)
{
m_displayText->DisplayError(INFO_LOST, Math::Vector(0.0f,0.0f,0.0f));
m_lostDelay = m_endTakeLostDelay; // lost in 6 seconds
@@ -6979,15 +6318,15 @@ Error CRobotMain::CheckEndMission(bool bFrame)
return INFO_LOST;
}
}
- if ( nb < m_endTake[t].min ||
- nb > m_endTake[t].max )
+ if (nb < m_endTake[t].min ||
+ nb > m_endTake[t].max)
{
m_displayText->SetEnable(true);
return ERR_MISSION_NOTERM;
}
- if ( m_endTake[t].bImmediat )
+ if (m_endTake[t].immediat)
{
- if ( m_winDelay == 0.0f )
+ if (m_winDelay == 0.0f)
{
m_winDelay = m_endTakeWinDelay; // wins in x seconds
m_lostDelay = 0.0f;
@@ -6997,16 +6336,16 @@ Error CRobotMain::CheckEndMission(bool bFrame)
}
}
- if ( m_endTakeResearch != 0 )
+ if (m_endTakeResearch != 0)
{
- if ( m_endTakeResearch != (m_endTakeResearch&g_researchDone) )
+ if (m_endTakeResearch != (m_endTakeResearch&g_researchDone))
{
m_displayText->SetEnable(true);
return ERR_MISSION_NOTERM;
}
}
- if ( m_endTakeWinDelay == -1.0f )
+ if (m_endTakeWinDelay == -1.0f)
{
m_winDelay = 1.0f; // wins in one second
m_lostDelay = 0.0f;
@@ -7014,9 +6353,9 @@ Error CRobotMain::CheckEndMission(bool bFrame)
return ERR_OK; // mission ended
}
- if ( bFrame && m_bBase ) return ERR_MISSION_NOTERM;
+ if (frame && m_base) return ERR_MISSION_NOTERM;
- if ( m_winDelay == 0.0f )
+ if (m_winDelay == 0.0f)
{
m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f));
m_winDelay = m_endTakeWinDelay; // wins in two seconds
@@ -7026,17 +6365,14 @@ Error CRobotMain::CheckEndMission(bool bFrame)
return ERR_OK; // mission ended
}
-// Checks if the mission is finished after displaying a message.
-
-void CRobotMain::CheckEndMessage(char *message)
+//! Checks if the mission is finished after displaying a message
+void CRobotMain::CheckEndMessage(const char* message)
{
- int t;
-
- for ( t=0 ; t<m_endTakeTotal ; t++ )
+ for (int t = 0; t < m_endTakeTotal; t++)
{
- if ( m_endTake[t].message[0] == 0 ) continue;
+ if (m_endTake[t].message[0] == 0) continue;
- if ( strcmp(m_endTake[t].message, message) == 0 )
+ if (strcmp(m_endTake[t].message, message) == 0)
{
m_displayText->DisplayError(INFO_WIN, Math::Vector(0.0f,0.0f,0.0f));
m_winDelay = m_endTakeWinDelay; // wins in 2 seconds
@@ -7046,394 +6382,351 @@ void CRobotMain::CheckEndMessage(char *message)
}
-// Returns the number of instructions required.
-
-int CRobotMain::RetObligatoryToken()
+//! Returns the number of instructions required
+int CRobotMain::GetObligatoryToken()
{
return m_obligatoryTotal;
}
-// Returns the name of a required instruction.
-
-char* CRobotMain::RetObligatoryToken(int i)
+//! Returns the name of a required instruction
+char* CRobotMain::GetObligatoryToken(int i)
{
return m_obligatoryToken[i];
}
-// Checks if an instruction is part of the obligatory list.
-
-int CRobotMain::IsObligatoryToken(char *token)
+//! Checks if an instruction is part of the obligatory list
+int CRobotMain::IsObligatoryToken(const char* token)
{
- int i;
-
- for ( i=0 ; i<m_obligatoryTotal ; i++ )
+ for (int i = 0; i < m_obligatoryTotal; i++)
{
- if ( strcmp(token, m_obligatoryToken[i]) == 0 )
- {
+ if (strcmp(token, m_obligatoryToken[i]) == 0)
return i;
- }
}
return -1;
}
-// Checks if an instruction is not part of the banned list.
-
-bool CRobotMain::IsProhibitedToken(char *token)
+//! Checks if an instruction is not part of the banned list
+bool CRobotMain::IsProhibitedToken(const char* token)
{
- int i;
-
- for ( i=0 ; i<m_prohibitedTotal ; i++ )
+ for (int i = 0; i < m_prohibitedTotal; i++)
{
- if ( strcmp(token, m_prohibitedToken[i]) == 0 )
- {
+ if (strcmp(token, m_prohibitedToken[i]) == 0)
return false;
- }
}
return true;
}
-// Indicates whether it is possible to control a driving robot.
-
-bool CRobotMain::RetTrainerPilot()
+//! Indicates whether it is possible to control a driving robot
+bool CRobotMain::GetTrainerPilot()
{
- return m_bTrainerPilot;
+ return m_trainerPilot;
}
-// Indicates whether the scene is fixed, without interaction.
-
-bool CRobotMain::RetFixScene()
+//! Indicates whether the scene is fixed, without interaction
+bool CRobotMain::GetFixScene()
{
- return m_bFixScene;
+ return m_fixScene;
}
-char* CRobotMain::RetTitle()
+char* CRobotMain::GetTitle()
{
return m_title;
}
-char* CRobotMain::RetResume()
+char* CRobotMain::GetResume()
{
return m_resume;
}
-char* CRobotMain::RetScriptName()
+char* CRobotMain::GetScriptName()
{
return m_scriptName;
}
-char* CRobotMain::RetScriptFile()
+char* CRobotMain::GetScriptFile()
{
return m_scriptFile;
}
-bool CRobotMain::RetGlint()
+bool CRobotMain::GetGlint()
{
- return m_dialog->RetGlint();
+ return m_dialog->GetGlint();
}
-bool CRobotMain::RetSoluce4()
+bool CRobotMain::GetSoluce4()
{
- return m_dialog->RetSoluce4();
+ return m_dialog->GetSoluce4();
}
-bool CRobotMain::RetMovies()
+bool CRobotMain::GetMovies()
{
- return m_dialog->RetMovies();
+ return m_dialog->GetMovies();
}
-bool CRobotMain::RetNiceReset()
+bool CRobotMain::GetNiceReset()
{
- return m_dialog->RetNiceReset();
+ return m_dialog->GetNiceReset();
}
-bool CRobotMain::RetHimselfDamage()
+bool CRobotMain::GetHimselfDamage()
{
- return m_dialog->RetHimselfDamage();
+ return m_dialog->GetHimselfDamage();
}
-bool CRobotMain::RetShowSoluce()
+bool CRobotMain::GetShowSoluce()
{
- return m_bShowSoluce;
+ return m_showSoluce;
}
-bool CRobotMain::RetSceneSoluce()
+bool CRobotMain::GetSceneSoluce()
{
- if ( m_infoFilename[SATCOM_SOLUCE][0] == 0 ) return false;
- return m_dialog->RetSceneSoluce();
+ if (m_infoFilename[SATCOM_SOLUCE][0] == 0) return false;
+ return m_dialog->GetSceneSoluce();
}
-bool CRobotMain::RetShowAll()
+bool CRobotMain::GetShowAll()
{
- return m_bShowAll;
+ return m_showAll;
}
-bool CRobotMain::RetCheatRadar()
+bool CRobotMain::GetCheatRadar()
{
- return m_bCheatRadar;
+ return m_cheatRadar;
}
-char* CRobotMain::RetSavegameDir()
+char* CRobotMain::GetSavegameDir()
{
- return m_dialog->RetSavegameDir();
+ return m_dialog->GetSavegameDir();
}
-char* CRobotMain::RetPublicDir()
+char* CRobotMain::GetPublicDir()
{
- return m_dialog->RetPublicDir();
+ return m_dialog->GetPublicDir();
}
-char* CRobotMain::RetFilesDir()
+char* CRobotMain::GetFilesDir()
{
- return m_dialog->RetFilesDir();
+ return m_dialog->GetFilesDir();
}
-// Change the player's name.
-
-void CRobotMain::SetGamerName(char *name)
+//! Change the player's name
+void CRobotMain::SetGamerName(const char *name)
{
strcpy(m_gamerName, name);
SetGlobalGamerName(m_gamerName);
ReadFreeParam();
}
-// Getes the player's name.
-
-char* CRobotMain::RetGamerName()
+//! Getes the player's name
+char* CRobotMain::GetGamerName()
{
return m_gamerName;
}
-// Returns the representation to use for the player.
-
-int CRobotMain::RetGamerFace()
+//! Returns the representation to use for the player
+int CRobotMain::GetGamerFace()
{
- return m_dialog->RetGamerFace();
+ return m_dialog->GetGamerFace();
}
-// Returns the representation to use for the player.
-
-int CRobotMain::RetGamerGlasses()
+//! Returns the representation to use for the player
+int CRobotMain::GetGamerGlasses()
{
- return m_dialog->RetGamerGlasses();
+ return m_dialog->GetGamerGlasses();
}
-// Returns the mode with just the head.
-
-bool CRobotMain::RetGamerOnlyHead()
+//! Returns the mode with just the head
+bool CRobotMain::GetGamerOnlyHead()
{
- return m_dialog->RetGamerOnlyHead();
+ return m_dialog->GetGamerOnlyHead();
}
-// Returns the angle of presentation.
-
-float CRobotMain::RetPersoAngle()
+//! Returns the angle of presentation
+float CRobotMain::GetPersoAngle()
{
- return m_dialog->RetPersoAngle();
+ return m_dialog->GetPersoAngle();
}
-// Changes on the pause mode.
-
-void CRobotMain::ChangePause(bool bPause)
+//! Changes on the pause mode
+void CRobotMain::ChangePause(bool pause)
{
- m_bPause = bPause;
- m_engine->SetPause(m_bPause);
+ m_pause = pause;
+ m_engine->SetPause(m_pause);
- m_sound->MuteAll(m_bPause);
+ m_sound->MuteAll(m_pause);
CreateShortcuts();
- if ( m_bPause ) HiliteClear();
+ if (m_pause) HiliteClear();
}
-// Changes game speed
-
+//! Changes game speed
void CRobotMain::SetSpeed(float speed)
{
- CButton* pb;
- char text[10];
-
- m_engine->SetSpeed(speed);
+ // TODO: m_app->SetSimulationSpeed(speed);
- pb = (CButton*)m_interface->SearchControl(EVENT_SPEED);
- if ( pb != 0 )
+ Ui::CButton* pb = dynamic_cast<Ui::CButton*>(m_interface->SearchControl(EVENT_SPEED));
+ if (pb != nullptr)
{
- if ( speed == 1.0f )
+ if (speed == 1.0f)
{
- pb->ClearState(STATE_VISIBLE);
+ pb->ClearState(Ui::STATE_VISIBLE);
}
else
{
+ char text[10];
sprintf(text, "x%.1f", speed);
pb->SetName(text);
- pb->SetState(STATE_VISIBLE);
+ pb->SetState(Ui::STATE_VISIBLE);
}
}
}
-float CRobotMain::RetSpeed()
+float CRobotMain::GetSpeed()
{
- return m_engine->RetSpeed();
+ return m_app->GetSimulationSpeed();
}
-// Creates interface shortcuts to the units.
-
+//! Creates interface shortcuts to the units
bool CRobotMain::CreateShortcuts()
{
- if ( m_phase != PHASE_SIMUL ) return false;
- if ( !m_bShortCut ) return false;
+ if (m_phase != PHASE_SIMUL) return false;
+ if (!m_shortCut) return false;
return m_short->CreateShortcuts();
}
-// Updates the map.
-
+//! Updates the map
void CRobotMain::UpdateMap()
{
m_map->UpdateMap();
}
-// Indicates whether the mini-map is visible.
-
-bool CRobotMain::RetShowMap()
+//! Indicates whether the mini-map is visible
+bool CRobotMain::GetShowMap()
{
- return m_map->RetShowMap() && m_bMapShow;
+ return m_map->GetShowMap() && m_mapShow;
}
-// Management of the lock mode for movies.
-
-void CRobotMain::SetMovieLock(bool bLock)
+//! Management of the lock mode for movies
+void CRobotMain::SetMovieLock(bool lock)
{
- m_bMovieLock = bLock;
- m_engine->SetMovieLock(m_bMovieLock);
+ m_movieLock = lock;
+ m_engine->SetMovieLock(m_movieLock);
CreateShortcuts();
- m_map->ShowMap(!m_bMovieLock && m_bMapShow);
- if ( m_bMovieLock ) HiliteClear();
- m_engine->SetMouseHide(m_bMovieLock);
+ m_map->ShowMap(!m_movieLock && m_mapShow);
+ if (m_movieLock) HiliteClear();
+ m_engine->SetMouseVisible(! m_movieLock);
}
-bool CRobotMain::RetMovieLock()
+bool CRobotMain::GetMovieLock()
{
- return m_bMovieLock;
+ return m_movieLock;
}
-bool CRobotMain::RetInfoLock()
+bool CRobotMain::GetInfoLock()
{
- return ( m_displayInfo != 0 ); // info in progress?
+ return m_displayInfo != nullptr; // info in progress?
}
-// Management of the blocking of the call of SatCom.
-
-void CRobotMain::SetSatComLock(bool bLock)
+//! Management of the blocking of the call of SatCom
+void CRobotMain::SetSatComLock(bool lock)
{
- m_bSatComLock = bLock;
+ m_satComLock = lock;
}
-bool CRobotMain::RetSatComLock()
+bool CRobotMain::GetSatComLock()
{
- return m_bSatComLock;
+ return m_satComLock;
}
-// Management of the lock mode for the edition.
-
-void CRobotMain::SetEditLock(bool bLock, bool bEdit)
+//! Management of the lock mode for the edition
+void CRobotMain::SetEditLock(bool lock, bool edit)
{
- m_bEditLock = bLock;
+ m_editLock = lock;
CreateShortcuts();
// Do not remove the card if it contains a still image.
- if ( !bLock || !m_map->RetFixImage() )
- {
- m_map->ShowMap(!m_bEditLock && m_bMapShow);
- }
+ if (!lock || !m_map->GetFixImage())
+ m_map->ShowMap(!m_editLock && m_mapShow);
- m_displayText->HideText(bLock);
- m_engine->FlushPressKey();
+ m_displayText->HideText(lock);
+ m_app->ResetKeyStates();
- if ( m_bEditLock )
- {
+ if (m_editLock)
HiliteClear();
- }
else
- {
- m_bEditFull = false;
- }
+ m_editFull = false;
}
-bool CRobotMain::RetEditLock()
+bool CRobotMain::GetEditLock()
{
- return m_bEditLock;
+ return m_editLock;
}
-// Management of the fullscreen mode during editing.
-
-void CRobotMain::SetEditFull(bool bFull)
+//! Management of the fullscreen mode during editing
+void CRobotMain::SetEditFull(bool full)
{
- m_bEditFull = bFull;
+ m_editFull = full;
}
-bool CRobotMain::RetEditFull()
+bool CRobotMain::GetEditFull()
{
- return m_bEditFull;
+ return m_editFull;
}
-bool CRobotMain::RetFreePhoto()
+bool CRobotMain::GetFreePhoto()
{
- return m_bFreePhoto;
+ return m_freePhoto;
}
-// Indicates whether mouse is on an friend object, on which we should not shoot.
-
-void CRobotMain::SetFriendAim(bool bFriend)
+//! Indicates whether mouse is on an friend object, on which we should not shoot
+void CRobotMain::SetFriendAim(bool friendAim)
{
- m_bFriendAim = bFriend;
+ m_friendAim = friendAim;
}
-bool CRobotMain::RetFriendAim()
+bool CRobotMain::GetFriendAim()
{
- return m_bFriendAim;
+ return m_friendAim;
}
-// Management of the precision of drawing the ground.
-
+//! Management of the precision of drawing the ground
void CRobotMain::SetTracePrecision(float factor)
{
m_engine->SetTracePrecision(factor);
}
-float CRobotMain::RetTracePrecision()
+float CRobotMain::GetTracePrecision()
{
- return m_engine->RetTracePrecision();
+ return m_engine->GetTracePrecision();
}
-// Starts music with a mission.
-
+//! Starts music with a mission
void CRobotMain::StartMusic()
{
- if ( m_audioTrack != 0 )
+ if (m_audioTrack != 0)
{
m_sound->StopMusic();
- m_sound->PlayMusic(m_audioTrack, m_bAudioRepeat);
+ m_sound->PlayMusic(m_audioTrack, m_audioRepeat);
}
}
-// Removes hilite and tooltip.
-
+//! Removes hilite and tooltip
void CRobotMain::ClearInterface()
{
HiliteClear(); // removes setting evidence
m_tooltipName[0] = 0; // really removes the tooltip
}
-
-
diff --git a/src/object/robotmain.h b/src/object/robotmain.h
index 559453b..0a5a5a2 100644
--- a/src/object/robotmain.h
+++ b/src/object/robotmain.h
@@ -18,16 +18,15 @@
#pragma once
+#include "common/global.h"
+#include "common/singleton.h"
-#include <stdio.h>
+#include "graphics/engine/particle.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"
+#include <stdio.h>
enum Phase
{
@@ -69,36 +68,41 @@ enum Phase
class CInstanceManager;
-class CMainDialog;
-class CMainShort;
-class CMainMap;
-class CEvent;
-class CD3DEngine;
-class CLight;
+class CEventQueue;
+class CSoundInterface;
+
+namespace Gfx
+{
+class CEngine;
+class CLightManager;
class CWater;
class CCloud;
-class CBlitz;
+class CLightning;
class CPlanet;
class CTerrain;
-class CModel;
+};
+
+namespace Ui
+{
+class CMainDialog;
+class CMainShort;
+class CMainMap;
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];
+ Math::Vector pos;
+ float dist;
+ ObjectType type;
+ int min; // wins if>
+ int max; // wins if <
+ int lost; // lost if <=
+ bool immediat;
+ char message[100];
};
@@ -106,7 +110,7 @@ const int MAXNEWSCRIPTNAME = 20;
struct NewScriptName
{
- bool bUsed;
+ bool used;
ObjectType type;
char name[40];
};
@@ -118,8 +122,8 @@ const float SHOWLIMITTIME = 20.0f;
struct ShowLimit
{
- bool bUsed;
- Math::Vector pos;
+ bool used;
+ Math::Vector pos;
float radius;
int total;
int parti[MAXSHOWPARTI];
@@ -138,117 +142,169 @@ const int SATCOM_SOLUCE = 5;
const int SATCOM_MAX = 6;
+/**
+ * \struct InputBinding
+ * \brief Binding for input slot
+ */
+struct InputBinding
+{
+ //! Keyboard binding code (can be regular or virtual)
+ unsigned int key;
+ //! Joystick binding code (virtual)
+ unsigned int joy;
+
+ InputBinding() : key(KEY_INVALID), joy(KEY_INVALID) {}
+};
-class CRobotMain
+/**
+ * \struct JoyAxisBinding
+ * \brief Binding for joystick axis
+ */
+struct JoyAxisBinding
+{
+ //! Axis index or AXIS_INVALID
+ int axis;
+ //! True to invert axis value
+ bool invert;
+};
+
+//! Invalid value for axis binding (no axis assigned)
+const int AXIS_INVALID = -1;
+
+class CRobotMain : public CSingleton<CRobotMain>
{
public:
- CRobotMain(CInstanceManager* iMan);
+ CRobotMain(CInstanceManager* iMan, CApplication* app);
~CRobotMain();
void CreateIni();
+ //! Sets the default input bindings (key and axes)
+ void SetDefaultInputBindings();
+
+ //! Management of input bindings
+ //@{
+ void SetInputBinding(InputSlot slot, InputBinding binding);
+ const InputBinding& GetInputBinding(InputSlot slot);
+ //@}
+
+ //! Management of joystick axis bindings
+ //@{
+ void SetJoyAxisBinding(JoyAxisSlot slot, JoyAxisBinding binding);
+ const JoyAxisBinding& GetJoyAxisBinding(JoyAxisSlot slot);
+ //@}
+
+ //! Management of joystick deadzone
+ //@{
+ void SetJoystickDeadzone(float zone);
+ float GetJoystickDeadzone();
+ //@}
+
+ //! Resets tracked key states (motion vectors)
+ void ResetKeyStates();
+
void ChangePhase(Phase phase);
- bool EventProcess(const Event &event);
+ bool EventProcess(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 SetMovieLock(bool lock);
+ bool GetMovieLock();
+ bool GetInfoLock();
+ void SetSatComLock(bool lock);
+ bool GetSatComLock();
+ void SetEditLock(bool lock, bool edit);
+ bool GetEditLock();
+ void SetEditFull(bool full);
+ bool GetEditFull();
+ bool GetFreePhoto();
+ void SetFriendAim(bool friendAim);
+ bool GetFriendAim();
void SetTracePrecision(float factor);
- float RetTracePrecision();
+ float GetTracePrecision();
- void ChangePause(bool bPause);
+ void ChangePause(bool pause);
void SetSpeed(float speed);
- float RetSpeed();
+ float GetSpeed();
void UpdateShortcuts();
void SelectHuman();
CObject* SearchHuman();
CObject* SearchToto();
CObject* SearchNearest(Math::Vector pos, CObject* pExclu);
- bool SelectObject(CObject* pObj, bool bDisplayError=true);
- CObject* RetSelectObject();
+ bool SelectObject(CObject* pObj, bool displayError=true);
+ CObject* GetSelectObject();
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);
+ Error CheckEndMission(bool frame);
+ void CheckEndMessage(const char* message);
+ int GetObligatoryToken();
+ char* GetObligatoryToken(int i);
+ int IsObligatoryToken(const char* token);
+ bool IsProhibitedToken(const char* token);
void UpdateMap();
- bool RetShowMap();
+ bool GetShowMap();
- MainMovieType RetMainMovie();
+ MainMovieType GetMainMovie();
void FlushDisplayInfo();
- void StartDisplayInfo(int index, bool bMovie);
- void StartDisplayInfo(char *filename, int index);
+ void StartDisplayInfo(int index, bool movie);
+ void StartDisplayInfo(const char *filename, int index);
void StopDisplayInfo();
- char* RetDisplayInfoName(int index);
- int RetDisplayInfoPosition(int index);
+ char* GetDisplayInfoName(int index);
+ int GetDisplayInfoPosition(int index);
void SetDisplayInfoPosition(int index, int pos);
void StartSuspend();
void StopSuspend();
- float RetGameTime();
+ float GetGameTime();
void SetFontSize(float size);
- float RetFontSize();
+ float GetFontSize();
void SetWindowPos(Math::Point pos);
- Math::Point RetWindowPos();
+ Math::Point GetWindowPos();
void SetWindowDim(Math::Point dim);
- Math::Point RetWindowDim();
+ Math::Point GetWindowDim();
- void SetIOPublic(bool bMode);
- bool RetIOPublic();
+ void SetIOPublic(bool mode);
+ bool GetIOPublic();
void SetIOPos(Math::Point pos);
- Math::Point RetIOPos();
+ Math::Point GetIOPos();
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();
+ Math::Point GetIODim();
+
+ char* GetTitle();
+ char* GetResume();
+ char* GetScriptName();
+ char* GetScriptFile();
+ bool GetTrainerPilot();
+ bool GetFixScene();
+ bool GetGlint();
+ bool GetSoluce4();
+ bool GetMovies();
+ bool GetNiceReset();
+ bool GetHimselfDamage();
+ bool GetShowSoluce();
+ bool GetSceneSoluce();
+ bool GetShowAll();
+ bool GetCheatRadar();
+ char* GetSavegameDir();
+ char* GetPublicDir();
+ char* GetFilesDir();
+
+ void SetGamerName(const char *name);
+ char* GetGamerName();
+ int GetGamerFace();
+ int GetGamerGlasses();
+ bool GetGamerOnlyHead();
+ float GetPersoAngle();
void StartMusic();
void ClearInterface();
@@ -256,18 +312,19 @@ public:
float SearchNearestObject(Math::Vector center, CObject *exclu);
bool FreeSpace(Math::Vector &center, float minRadius, float maxRadius, float space, CObject *exclu);
- float RetFlatZoneRadius(Math::Vector center, float maxRadius, CObject *exclu);
+ float GetFlatZoneRadius(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 SetShowLimit(int i, Gfx::ParticleType 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 CompileScript(bool soluce);
+ void LoadOneScript(CObject *pObj, int &nerror);
+ void LoadFileScript(CObject *pObj, char* filename, int objRank, int &nerror);
void SaveAllScript();
void SaveOneScript(CObject *pObj);
void SaveFileScript(CObject *pObj, char* filename, int objRank);
@@ -276,7 +333,7 @@ public:
bool FlushNewScriptName();
bool AddNewScriptName(ObjectType type, char *name);
- char* RetNewScriptName(ObjectType type, int rank);
+ char* GetNewScriptName(ObjectType type, int rank);
void WriteFreeParam();
void ReadFreeParam();
@@ -284,10 +341,10 @@ public:
bool IsBusy();
bool IOWriteScene(char *filename, char *filecbot, char *info);
CObject* IOReadScene(char *filename, char *filecbot);
- void IOWriteObject(FILE *file, CObject* pObj, char *cmd);
+ void IOWriteObject(FILE *file, CObject* pObj, const char *cmd);
CObject* IOReadObject(char *line, char* filename, int objRank);
- int CreateSpot(Math::Vector pos, D3DCOLORVALUE color);
+ int CreateSpot(Math::Vector pos, Gfx::Color color);
protected:
bool EventFrame(const Event &event);
@@ -295,101 +352,113 @@ protected:
void InitEye();
void Convert();
- void CreateScene(bool bSoluce, bool bFixScene, bool bResetObject);
+ void CreateScene(bool soluce, bool fixScene, bool resetObject);
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);
+ 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 trainer=false, bool toy=false, int option=0);
+ int CreateLight(Math::Vector direction, Gfx::Color color);
void HiliteClear();
void HiliteObject(Math::Point pos);
void HiliteFrame(float rTime);
- void CreateTooltip(Math::Point pos, char* text);
+ void CreateTooltip(Math::Point pos, const 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 KeyCamera(EventType event, unsigned int key);
void AbortMovie();
bool IsSelectable(CObject* pObj);
- void SelectOneObject(CObject* pObj, bool bDisplayError=true);
+ void SelectOneObject(CObject* pObj, bool displayError=true);
void HelpObject();
bool DeselectObject();
void DeleteAllObjects();
void UpdateInfoText();
CObject* SearchObject(ObjectType type);
- CObject* RetSelect();
- void StartDisplayVisit(EventMsg event);
+ CObject* GetSelect();
+ void StartDisplayVisit(EventType 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;
+ CInstanceManager* m_iMan;
+ CApplication* m_app;
+ CEventQueue* m_eventQueue;
+ CMainMovie* m_movie;
+ Gfx::CEngine* m_engine;
+ Gfx::CParticle* m_particle;
+ Gfx::CWater* m_water;
+ Gfx::CCloud* m_cloud;
+ Gfx::CLightning* m_lightning;
+ Gfx::CPlanet* m_planet;
+ Gfx::CLightManager* m_lightMan;
+ Gfx::CTerrain* m_terrain;
+ Gfx::CCamera* m_camera;
+ Ui::CMainDialog* m_dialog;
+ Ui::CMainShort* m_short;
+ Ui::CMainMap* m_map;
+ Ui::CInterface* m_interface;
+ Ui::CDisplayText* m_displayText;
+ Ui::CDisplayInfo* m_displayInfo;
+ CSoundInterface* m_sound;
+
+ //! Bindings for user inputs
+ InputBinding m_inputBindings[INPUT_SLOT_MAX];
+ JoyAxisBinding m_joyAxisBindings[JOY_AXIS_SLOT_MAX];
+ float m_joystickDeadzone;
+ //! Motion vector set by keyboard or joystick buttons
+ Math::Vector m_keyMotion;
+ //! Motion vector set by joystick axes
+ Math::Vector m_joyMotion;
+
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;
+ bool m_fixScene; // scene fixed, no interraction
+ bool m_base; // 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;
+ Gfx::Color m_color;
+ bool m_freePhoto;
+ bool m_cmdEdit;
+ bool m_showPos;
+ bool m_selectInsect;
+ bool m_showSoluce;
+ bool m_showAll;
+ bool m_cheatRadar;
+ bool m_audioRepeat;
+ bool m_shortCut;
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;
+ bool m_immediatSatCom; // SatCom immediately?
+ bool m_beginSatCom; // messages SatCom poster?
+ bool m_movieLock; // movie in progress?
+ bool m_satComLock; // call of SatCom is possible?
+ bool m_editLock; // edition in progress?
+ bool m_editFull; // edition in full screen?
+ bool m_pause; // simulation paused
+ bool m_hilite;
+ bool m_trainerPilot; // remote trainer?
+ bool m_suspend;
+ bool m_friendAim;
+ bool m_resetCreate;
+ bool m_mapShow;
+ bool m_mapImage;
char m_mapFilename[100];
- Math::Point m_tooltipPos;
+ Math::Point m_tooltipPos;
char m_tooltipName[100];
float m_tooltipTime;
@@ -405,28 +474,28 @@ protected:
char m_scriptFile[100];
int m_endingWinRank;
int m_endingLostRank;
- bool m_bWinTerminate;
+ bool m_winTerminate;
float m_fontSize;
- Math::Point m_windowPos;
- Math::Point m_windowDim;
+ Math::Point m_windowPos;
+ Math::Point m_windowDim;
bool m_IOPublic;
- Math::Point m_IOPos;
- Math::Point m_IODim;
+ Math::Point m_IOPos;
+ Math::Point m_IODim;
NewScriptName m_newScriptName[MAXNEWSCRIPTNAME];
float m_cameraPan;
float m_cameraZoom;
- EventMsg m_visitLast;
+ EventType m_visitLast;
CObject* m_visitObject;
CObject* m_visitArrow;
float m_visitTime;
- float m_visitParticule;
- Math::Vector m_visitPos;
- Math::Vector m_visitPosArrow;
+ float m_visitParticle;
+ Math::Vector m_visitPos;
+ Math::Vector m_visitPosArrow;
int m_endTakeTotal;
EndTake m_endTake[10];
@@ -441,19 +510,19 @@ protected:
char m_gamerName[100];
- long m_freeBuild; // constructible buildings
- long m_freeResearch; // researches possible
+ int m_freeBuild; // constructible buildings
+ int 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;
+ Gfx::Color m_colorRefBot;
+ Gfx::Color m_colorNewBot;
+ Gfx::Color m_colorRefAlien;
+ Gfx::Color m_colorNewAlien;
+ Gfx::Color m_colorRefGreen;
+ Gfx::Color m_colorNewGreen;
+ Gfx::Color m_colorRefWater;
+ Gfx::Color m_colorNewWater;
float m_colorShiftWater;
};
diff --git a/src/object/task/task.cpp b/src/object/task/task.cpp
index f910ea2..b310fd5 100644
--- a/src/object/task/task.cpp
+++ b/src/object/task/task.cpp
@@ -17,7 +17,7 @@
// task.cpp
-#include <stdio.h>
+// #include <stdio.h>
#include "object/task/task.h"
@@ -32,20 +32,20 @@ CTask::CTask(CInstanceManager* iMan, CObject* object)
{
m_iMan = iMan;
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
- m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
- m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_displayText = (CDisplayText*)m_iMan->SearchInstance(CLASS_DISPLAYTEXT);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
+ m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_displayText = static_cast<Ui::CDisplayText*>(m_iMan->SearchInstance(CLASS_DISPLAYTEXT));
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_object = object;
- m_physics = m_object->RetPhysics();
- m_brain = m_object->RetBrain();
- m_motion = m_object->RetMotion();
+ m_physics = m_object->GetPhysics();
+ m_brain = m_object->GetBrain();
+ m_motion = m_object->GetMotion();
}
// Object's destructor.
diff --git a/src/object/task/task.h b/src/object/task/task.h
index a3ec62c..7239d48 100644
--- a/src/object/task/task.h
+++ b/src/object/task/task.h
@@ -19,24 +19,31 @@
#pragma once
-#include "common/misc.h"
+#include "common/event.h"
+#include "common/global.h"
#include "math/const.h"
class CInstanceManager;
-class CD3DEngine;
-class CLight;
-class CParticule;
-class CTerrain;
-class CWater;
-class CCamera;
class CBrain;
class CPhysics;
class CMotion;
class CObject;
class CRobotMain;
+class CSoundInterface;
+
+namespace Ui {
class CDisplayText;
-class CSound;
+} /* Ui */
+
+namespace Gfx {
+class CEngine;
+class CLightManager;
+class CParticle;
+class CTerrain;
+class CWater;
+class CCamera;
+} /* Gfx */
const float TAKE_DIST = 6.0f; // distance to an object to pick it
@@ -66,21 +73,19 @@ public:
virtual bool Abort();
protected:
-
-protected:
- CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CLight* m_light;
- CParticule* m_particule;
- CTerrain* m_terrain;
- CWater* m_water;
- CCamera* m_camera;
- CMotion* m_motion;
- CBrain* m_brain;
- CPhysics* m_physics;
- CObject* m_object;
- CRobotMain* m_main;
- CDisplayText* m_displayText;
- CSound* m_sound;
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ Gfx::CLightManager* m_lightMan;
+ Gfx::CParticle* m_particle;
+ Gfx::CTerrain* m_terrain;
+ Gfx::CWater* m_water;
+ Gfx::CCamera* m_camera;
+ CMotion* m_motion;
+ CBrain* m_brain;
+ CPhysics* m_physics;
+ CObject* m_object;
+ CRobotMain* m_main;
+ Ui::CDisplayText* m_displayText;
+ CSoundInterface* m_sound;
};
diff --git a/src/object/task/taskadvance.cpp b/src/object/task/taskadvance.cpp
index e50cb08..0d159d2 100644
--- a/src/object/task/taskadvance.cpp
+++ b/src/object/task/taskadvance.cpp
@@ -16,9 +16,6 @@
// taskadvance.cpp
-
-#include <stdio.h>
-
#include "object/task/taskadvance.h"
#include "math/geometry.h"
@@ -45,13 +42,13 @@ CTaskAdvance::~CTaskAdvance()
bool CTaskAdvance::EventProcess(const Event &event)
{
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_fixTime += event.rTime;
// Momentarily stationary object (ant on the back)?
- if ( m_object->RetFixed() )
+ if ( m_object->GetFixed() )
{
m_physics->SetMotorSpeedX(0.0f); // stops the advance
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
@@ -70,12 +67,12 @@ Error CTaskAdvance::Start(float length)
{
m_direction = (length>=0.0f)?1.0f:-1.0f;
m_totalLength = fabs(length);
- m_advanceLength = m_physics->RetLinLength(length);
- m_startPos = m_object->RetPosition(0);
+ m_advanceLength = m_physics->GetLinLength(length);
+ m_startPos = m_object->GetPosition(0);
m_lastDist = 0.0f;
m_fixTime = 0.0f;
- m_timeLimit = m_physics->RetLinTimeLength(m_totalLength, m_direction)*3.0f;
+ m_timeLimit = m_physics->GetLinTimeLength(m_totalLength, m_direction)*3.0f;
if ( m_timeLimit < 2.0f ) m_timeLimit = 2.0f;
m_physics->SetMotorSpeedX(m_direction*1.0f); // forward/backward
@@ -93,7 +90,7 @@ Error CTaskAdvance::IsEnded()
Math::Vector pos;
float length;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError )
{
@@ -106,7 +103,7 @@ Error CTaskAdvance::IsEnded()
return ERR_MOVE_IMPOSSIBLE;
}
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
length = Math::DistanceProjected(pos, m_startPos);
if ( length > m_lastDist ) // forward?
diff --git a/src/object/task/taskbuild.cpp b/src/object/task/taskbuild.cpp
index ecbf898..469e9cb 100644
--- a/src/object/task/taskbuild.cpp
+++ b/src/object/task/taskbuild.cpp
@@ -16,15 +16,14 @@
// taskbuild.cpp
-
-#include <stdio.h>
-
#include "object/task/taskbuild.h"
#include "common/iman.h"
-#include "old/light.h"
-#include "old/terrain.h"
-#include "old/water.h"
+#include "graphics/core/color.h"
+#include "graphics/core/light.h"
+#include "graphics/engine/lightman.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/water.h"
#include "math/geometry.h"
#include "object/auto/auto.h"
#include "object/motion/motionhuman.h"
@@ -32,8 +31,7 @@
#include "physics/physics.h"
#include "ui/displaytext.h"
-
-
+#include <string.h>
// Object's constructor.
@@ -68,7 +66,7 @@ CTaskBuild::~CTaskBuild()
for ( i=0 ; i<TBMAXLIGHT ; i++ )
{
if ( m_lightRank[i] == -1 ) continue;
- m_light->DeleteLight(m_lightRank[i]);
+ m_lightMan->DeleteLight(m_lightRank[i]);
}
}
@@ -102,7 +100,7 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
if ( m_type == OBJECT_INFO ) m_buildingHeight = 19.0f;
m_buildingHeight *= 0.25f;
- m_buildingPos = m_building->RetPosition(0);
+ m_buildingPos = m_building->GetPosition(0);
m_buildingPos.y -= m_buildingHeight;
m_building->SetPosition(0, m_buildingPos);
return true;
@@ -112,21 +110,21 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
void CTaskBuild::CreateLight()
{
- D3DLIGHT7 light;
- D3DCOLORVALUE color;
- Math::Vector center, pos, dir;
- Math::Point c, p;
- float angle;
- int i;
+ Gfx::Light light;
+ Gfx::Color color;
+ Math::Vector center, pos, dir;
+ Math::Point c, p;
+ float angle;
+ int i;
- if ( !m_engine->RetLightMode() ) return;
+ if ( !m_engine->GetLightMode() ) return;
- center = m_metal->RetPosition(0);
+ center = m_metal->GetPosition(0);
angle = 0;
for ( i=0 ; i<TBMAXLIGHT ; i++ )
{
- m_lightRank[i] = m_light->CreateLight();
+ m_lightRank[i] = m_lightMan->CreateLight();
if ( m_lightRank[i] == -1 ) continue;
c.x = center.x;
@@ -139,32 +137,32 @@ void CTaskBuild::CreateLight()
pos.y = center.y+40.0f;
dir = center-pos;
- ZeroMemory( &light, sizeof(light) );
- light.dltType = D3DLIGHT_SPOT;
- light.dcvDiffuse.r = 0.0f;
- light.dcvDiffuse.g = 0.0f;
- light.dcvDiffuse.b = 0.0f; // white (invisible)
- light.dvPosition.x = pos.x;
- light.dvPosition.y = pos.y;
- light.dvPosition.z = pos.z;
- light.dvDirection.x = dir.x;
- light.dvDirection.y = dir.y;
- light.dvDirection.z = dir.z;
- light.dvRange = D3DLIGHT_RANGE_MAX;
- light.dvFalloff = 1.0f;
- light.dvAttenuation0 = 1.0f;
- light.dvAttenuation1 = 0.0f;
- light.dvAttenuation2 = 0.0f;
- light.dvTheta = 0.0f;
- light.dvPhi = Math::PI/4.0f;
- m_light->SetLight(m_lightRank[i], light);
+ memset(&light, 0, sizeof(light));
+ light.type = Gfx::LIGHT_SPOT;
+ light.diffuse.r = 0.0f;
+ light.diffuse.g = 0.0f;
+ light.diffuse.b = 0.0f; // white (invisible)
+ light.position.x = pos.x;
+ light.position.y = pos.y;
+ light.position.z = pos.z;
+ light.direction.x = dir.x;
+ light.direction.y = dir.y;
+ light.direction.z = dir.z;
+ //TODO Is this value correct
+ light.spotIntensity = 128;
+ light.attenuation0 = 1.0f;
+ light.attenuation1 = 0.0f;
+ light.attenuation2 = 0.0f;
+ //TODO Is this value correct
+ light.spotAngle = 90;
+ m_lightMan->SetLight(m_lightRank[i], light);
color.r = -1.0f;
color.g = -1.0f;
color.b = -0.5f; // violet
color.a = 0.0f;
- m_light->SetLightColor(m_lightRank[i], color);
- m_light->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.25f));
+ m_lightMan->SetLightColor(m_lightRank[i], color);
+ m_lightMan->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.25f));
angle += (Math::PI*2.0f)/TBMAXLIGHT;
}
@@ -176,8 +174,8 @@ void CTaskBuild::CreateLight()
void CTaskBuild::BlackLight()
{
- D3DCOLORVALUE color;
- int i;
+ Gfx::Color color;
+ int i;
for ( i=0 ; i<TBMAXLIGHT ; i++ )
{
@@ -187,8 +185,8 @@ void CTaskBuild::BlackLight()
color.g = 0.0f;
color.b = 0.0f; // white (invisible)
color.a = 0.0f;
- m_light->SetLightColor(m_lightRank[i], color);
- m_light->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.75f));
+ m_lightMan->SetLightColor(m_lightRank[i], color);
+ m_lightMan->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.75f));
}
m_bBlack = true;
@@ -203,8 +201,8 @@ bool CTaskBuild::EventProcess(const Event &event)
Math::Point dim;
float a, g, cirSpeed, dist, linSpeed;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_time += event.rTime;
@@ -213,7 +211,7 @@ bool CTaskBuild::EventProcess(const Event &event)
if ( m_phase == TBP_TURN ) // preliminary rotation?
{
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = m_angleY;
cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
@@ -225,7 +223,7 @@ bool CTaskBuild::EventProcess(const Event &event)
if ( m_phase == TBP_MOVE ) // preliminary forward/backward?
{
- dist = Math::Distance(m_object->RetPosition(0), m_metal->RetPosition(0));
+ dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0));
linSpeed = 0.0f;
if ( dist > 30.0f ) linSpeed = 1.0f;
if ( dist < 30.0f ) linSpeed = -1.0f;
@@ -258,8 +256,8 @@ bool CTaskBuild::EventProcess(const Event &event)
{
m_bBuild = true;
- pos = m_metal->RetPosition(0);
- a = m_object->RetAngleY(0);
+ pos = m_metal->GetPosition(0);
+ a = m_object->GetAngleY(0);
if ( !CreateBuilding(pos, a+Math::PI) )
{
m_metal->SetLock(false); // usable again
@@ -270,7 +268,7 @@ bool CTaskBuild::EventProcess(const Event &event)
m_camera->FlushEffect();
Abort();
m_bError = true;
- m_displayText->DisplayError(ERR_TOOMANY, m_object->RetPosition(0));
+ m_displayText->DisplayError(ERR_TOOMANY, m_object->GetPosition(0));
return false;
}
CreateLight();
@@ -295,32 +293,32 @@ bool CTaskBuild::EventProcess(const Event &event)
BlackLight();
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- pos = m_metal->RetPosition(0);
+ pos = m_metal->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*20.0f;
speed.z = (Math::Rand()-0.5f)*20.0f;
speed.y = Math::Rand()*10.0f;
dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFIRE);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIRE);
pos = Math::Vector(0.0f, 0.5f, 0.0f);
- mat = m_object->RetWorldMatrix(14);
+ mat = m_object->GetWorldMatrix(14);
pos = Transform(*mat, pos);
- speed = m_metal->RetPosition(0);
+ speed = m_metal->GetPosition(0);
speed.x += (Math::Rand()-0.5f)*5.0f;
speed.z += (Math::Rand()-0.5f)*5.0f;
speed -= pos;
dim.x = 2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ);
if ( Math::Rand() < 0.3f )
{
- m_sound->Play(SOUND_BUILD, m_object->RetPosition(0), 0.5f, 1.0f*Math::Rand()*1.5f);
+ m_sound->Play(SOUND_BUILD, m_object->GetPosition(0), 0.5f, 1.0f*Math::Rand()*1.5f);
}
}
@@ -337,25 +335,25 @@ Error CTaskBuild::Start(ObjectType type)
float iAngle, oAngle;
m_type = type;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_progress = 0.0f;
- iAngle = m_object->RetAngleY(0);
+ iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
oAngle = iAngle;
m_bError = true; // operation impossible
- pos = m_object->RetPosition(0);
- if ( pos.y < m_water->RetLevel() ) return ERR_BUILD_WATER;
+ pos = m_object->GetPosition(0);
+ if ( pos.y < m_water->GetLevel() ) return ERR_BUILD_WATER;
- if ( !m_physics->RetLand() ) return ERR_BUILD_FLY;
+ if ( !m_physics->GetLand() ) return ERR_BUILD_FLY;
- speed = m_physics->RetMotorSpeed();
+ speed = m_physics->GetMotorSpeed();
if ( speed.x != 0.0f ||
speed.z != 0.0f ) return ERR_BUILD_MOTOR;
- if ( m_object->RetFret() != 0 ) return ERR_MANIP_BUSY;
+ if ( m_object->GetFret() != 0 ) return ERR_MANIP_BUSY;
m_metal = SearchMetalObject(oAngle, 2.0f, 100.0f, Math::PI*0.25f, err);
if ( err == ERR_BUILD_METALNEAR && m_metal != 0 )
@@ -375,9 +373,9 @@ Error CTaskBuild::Start(ObjectType type)
m_phase = TBP_TURN; // rotation necessary preliminary
m_angleY = oAngle; // angle was reached
- pv = m_object->RetPosition(0);
+ pv = m_object->GetPosition(0);
pv.y += 8.3f;
- pm = m_metal->RetPosition(0);
+ pm = m_metal->GetPosition(0);
m_angleZ = Math::RotateAngle(Math::DistanceProjected(pv, pm), fabs(pv.y-pm.y));
m_physics->SetFreeze(true); // it does not move
@@ -394,27 +392,27 @@ Error CTaskBuild::IsEnded()
CAuto* automat;
float angle, dist, time;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_phase == TBP_TURN ) // preliminary rotation?
{
- angle = m_object->RetAngleY(0);
+ angle = m_object->GetAngleY(0);
angle = Math::NormAngle(angle); // 0..2*Math::PI
if ( Math::TestAngle(angle, m_angleY-Math::PI*0.01f, m_angleY+Math::PI*0.01f) )
{
m_physics->SetMotorSpeedZ(0.0f);
- dist = Math::Distance(m_object->RetPosition(0), m_metal->RetPosition(0));
+ dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0));
if ( dist > 30.0f )
{
- time = m_physics->RetLinTimeLength(dist-30.0f, 1.0f);
+ time = m_physics->GetLinTimeLength(dist-30.0f, 1.0f);
m_speed = 1.0f/time;
}
else
{
- time = m_physics->RetLinTimeLength(30.0f-dist, -1.0f);
+ time = m_physics->GetLinTimeLength(30.0f-dist, -1.0f);
m_speed = 1.0f/time;
}
m_phase = TBP_MOVE;
@@ -425,7 +423,7 @@ Error CTaskBuild::IsEnded()
if ( m_phase == TBP_MOVE ) // preliminary forward/backward?
{
- dist = Math::Distance(m_object->RetPosition(0), m_metal->RetPosition(0));
+ dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0));
if ( dist >= 25.0f && dist <= 35.0f )
{
@@ -466,12 +464,12 @@ Error CTaskBuild::IsEnded()
{
if ( m_progress < 1.0f ) return ERR_CONTINUE;
- m_soundChannel = m_sound->Play(SOUND_TREMBLE, m_object->RetPosition(0), 0.0f, 1.0f, true);
+ m_soundChannel = m_sound->Play(SOUND_TREMBLE, m_object->GetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_soundChannel, 0.7f, 1.0f, 1.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.7f, 1.5f, 7.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 1.5f, 2.0f, SOPER_STOP);
- m_camera->StartEffect(CE_VIBRATION, m_metal->RetPosition(0), 1.0f);
+ m_camera->StartEffect(Gfx::CAM_EFFECT_VIBRATION, m_metal->GetPosition(0), 1.0f);
m_phase = TBP_BUILD;
m_speed = 1.0f/10.f; // duration of 10s
@@ -482,7 +480,7 @@ Error CTaskBuild::IsEnded()
{
if ( m_progress < 1.0f ) return ERR_CONTINUE;
- DeleteMark(m_metal->RetPosition(0), 20.0f);
+ DeleteMark(m_metal->GetPosition(0), 20.0f);
m_metal->DeleteObject(); // removes the metal
delete m_metal;
@@ -494,7 +492,7 @@ Error CTaskBuild::IsEnded()
m_main->CreateShortcuts();
m_displayText->DisplayError(INFO_BUILD, m_buildingPos, 10.0f, 50.0f);
- automat = m_building->RetAuto();
+ automat = m_building->GetAuto();
if ( automat != 0 )
{
automat->Init();
@@ -583,16 +581,16 @@ Error CTaskBuild::FlatFloor()
if ( m_type == OBJECT_INFO ) radius = 5.0f;
if ( radius == 0.0f ) return ERR_GENERIC;
- center = m_metal->RetPosition(0);
- angle = m_terrain->RetFineSlope(center);
- bLittleFlat = ( angle < FLATLIMIT );
+ center = m_metal->GetPosition(0);
+ angle = m_terrain->GetFineSlope(center);
+ bLittleFlat = ( angle < Gfx::TERRAIN_FLATLIMIT);
- max = m_terrain->RetFlatZoneRadius(center, radius);
+ max = m_terrain->GetFlatZoneRadius(center, radius);
if ( max < radius ) // area too small?
{
if ( bLittleFlat )
{
- m_main->SetShowLimit(1, PARTILIMIT3, m_metal, center, max, 10.0f);
+ m_main->SetShowLimit(1, Gfx::PARTILIMIT3, m_metal, center, max, 10.0f);
}
return bLittleFlat?ERR_BUILD_FLATLIT:ERR_BUILD_FLAT;
}
@@ -601,18 +599,18 @@ Error CTaskBuild::FlatFloor()
bBase = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetActif() ) continue; // inactive?
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue; // inactive?
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
if ( pObj == m_metal ) continue;
if ( pObj == m_object ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_BASE )
{
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(center, oPos)-80.0f;
if ( dist < max )
{
@@ -640,24 +638,24 @@ Error CTaskBuild::FlatFloor()
}
if ( max < radius )
{
- m_main->SetShowLimit(1, PARTILIMIT2, m_metal, center, max, 10.0f);
+ m_main->SetShowLimit(1, Gfx::PARTILIMIT2, m_metal, center, max, 10.0f);
if ( bRadius < 2.0f ) bRadius = 2.0f;
- m_main->SetShowLimit(2, PARTILIMIT3, m_metal, bPos, bRadius, 10.0f);
+ m_main->SetShowLimit(2, Gfx::PARTILIMIT3, m_metal, bPos, bRadius, 10.0f);
return bBase?ERR_BUILD_BASE:ERR_BUILD_BUSY;
}
max = 100000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetActif() ) continue; // inactive?
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue; // inactive?
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
if ( pObj == m_metal ) continue;
if ( pObj == m_object ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_DERRICK ||
type == OBJECT_FACTORY ||
type == OBJECT_STATION ||
@@ -691,8 +689,8 @@ Error CTaskBuild::FlatFloor()
}
if ( max-BUILDMARGIN < radius )
{
- m_main->SetShowLimit(1, PARTILIMIT2, m_metal, center, max-BUILDMARGIN, 10.0f);
- m_main->SetShowLimit(2, PARTILIMIT3, m_metal, bPos, bRadius+BUILDMARGIN, 10.0f);
+ m_main->SetShowLimit(1, Gfx::PARTILIMIT2, m_metal, center, max-BUILDMARGIN, 10.0f);
+ m_main->SetShowLimit(2, Gfx::PARTILIMIT3, m_metal, bPos, bRadius+BUILDMARGIN, 10.0f);
return bBase?ERR_BUILD_BASE:ERR_BUILD_NARROW;
}
@@ -711,8 +709,8 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
int i;
bool bMetal;
- iPos = m_object->RetPosition(0);
- iAngle = m_object->RetAngleY(0);
+ iPos = m_object->GetPosition(0);
+ iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
min = 1000000.0f;
@@ -720,18 +718,18 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
bMetal = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetActif() ) continue; // objet inactive?
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue; // objet inactive?
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_METAL ) continue;
bMetal = true; // metal exists
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
distance = Math::Distance(oPos, iPos);
a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW!
@@ -781,10 +779,10 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_MARKSTONE &&
type != OBJECT_MARKURANIUM &&
type != OBJECT_MARKKEYa &&
@@ -793,7 +791,7 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
type != OBJECT_MARKKEYd &&
type != OBJECT_MARKPOWER ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
distance = Math::Distance(oPos, pos);
if ( distance <= radius )
{
diff --git a/src/object/task/taskbuild.h b/src/object/task/taskbuild.h
index 682086d..25300b3 100644
--- a/src/object/task/taskbuild.h
+++ b/src/object/task/taskbuild.h
@@ -63,23 +63,23 @@ protected:
void DeleteMark(Math::Vector pos, float radius);
protected:
- ObjectType m_type; // type of construction
- CObject* m_metal; // transforms metal object
- CObject* m_power; // the vehicle battery
- CObject* m_building; // building built
- TaskBuildPhase m_phase; // phase of the operation
- bool m_bError; // true -> operation impossible
- bool m_bBuild; // true -> building built
- bool m_bBlack; // true -> lights black -> white
- float m_time; // absolute time
- float m_lastParticule; // time of generation last particle
- float m_progress; // progression (0..1)
- float m_speed; // speed of progression
- float m_angleY; // rotation angle of the vehicle
- float m_angleZ; // angle of rotation of the gun
- Math::Vector m_buildingPos; // initial position of the building
- float m_buildingHeight; // height of the building
- int m_lightRank[TBMAXLIGHT];// lights for the effects
- int m_soundChannel;
+ ObjectType m_type; // type of construction
+ CObject* m_metal; // transforms metal object
+ CObject* m_power; // the vehicle battery
+ CObject* m_building; // building built
+ TaskBuildPhase m_phase; // phase of the operation
+ bool m_bError; // true -> operation impossible
+ bool m_bBuild; // true -> building built
+ bool m_bBlack; // true -> lights black -> white
+ float m_time; // absolute time
+ float m_lastParticle; // time of generation last particle
+ float m_progress; // progression (0..1)
+ float m_speed; // speed of progression
+ float m_angleY; // rotation angle of the vehicle
+ float m_angleZ; // angle of rotation of the gun
+ Math::Vector m_buildingPos; // initial position of the building
+ float m_buildingHeight; // height of the building
+ int m_lightRank[TBMAXLIGHT]; // lights for the effects
+ int m_soundChannel;
};
diff --git a/src/object/task/taskfire.cpp b/src/object/task/taskfire.cpp
index 92c51da..99a88b8 100644
--- a/src/object/task/taskfire.cpp
+++ b/src/object/task/taskfire.cpp
@@ -16,12 +16,9 @@
// taskfire.cpp
-
-#include <stdio.h>
-
#include "object/task/taskfire.h"
-#include "old/particule.h"
+#include "graphics/engine/particle.h"
#include "math/geometry.h"
#include "physics/physics.h"
@@ -66,32 +63,32 @@ bool CTaskFire::EventProcess(const Event &event)
float energy, fire;
int i, channel;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_time += event.rTime;
m_lastSound -= event.rTime;
m_progress += event.rTime*m_speed;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
if ( m_bOrganic ) fire = ENERGY_FIREi;
else if ( m_bRay ) fire = ENERGY_FIREr;
else fire = ENERGY_FIRE;
- energy -= event.rTime*fire/power->RetCapacity();
+ energy -= event.rTime*fire/power->GetCapacity();
power->SetEnergy(energy);
}
- if ( m_lastParticule+0.05f <= m_time )
+ if ( m_lastParticle+0.05f <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
if ( m_bOrganic )
{
- mat = m_object->RetWorldMatrix(1); // insect-cannon
+ mat = m_object->GetWorldMatrix(1); // insect-cannon
for ( i=0 ; i<6 ; i++ )
{
@@ -100,10 +97,10 @@ bool CTaskFire::EventProcess(const Event &event)
speed = Math::Vector(200.0f, 0.0f, 0.0f);
- physics = m_object->RetPhysics();
+ physics = m_object->GetPhysics();
if ( physics != 0 )
{
- speed += physics->RetLinMotion(MO_REASPEED);
+ speed += physics->GetLinMotion(MO_REASPEED);
}
speed.x += (Math::Rand()-0.5f)*10.0f;
@@ -115,13 +112,13 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = Math::Rand()*0.5f+0.5f;
dim.y = dim.x;
- channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN4, 0.8f, 0.0f, 0.0f);
- m_particule->SetObjectFather(channel, m_object);
+ channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN4, 0.8f, 0.0f, 0.0f);
+ m_particle->SetObjectFather(channel, m_object);
}
}
else if ( m_bRay )
{
- mat = m_object->RetWorldMatrix(2); // cannon
+ mat = m_object->GetWorldMatrix(2); // cannon
for ( i=0 ; i<4 ; i++ )
{
@@ -139,9 +136,9 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = 1.0f;
dim.y = dim.x;
- channel = m_particule->CreateTrack(pos, speed, dim, PARTITRACK11,
+ channel = m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK11,
2.0f, 200.0f, 0.5f, 1.0f);
- m_particule->SetObjectFather(channel, m_object);
+ m_particle->SetObjectFather(channel, m_object);
speed = Math::Vector(5.0f, 0.0f, 0.0f);
speed.x += (Math::Rand()-0.5f)*1.0f;
@@ -153,20 +150,20 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = 2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE2, 2.0f, 0.0f, 0.5f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE2, 2.0f, 0.0f, 0.5f);
}
}
else
{
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_MOBILErc )
{
- mat = m_object->RetWorldMatrix(2); // cannon
+ mat = m_object->GetWorldMatrix(2); // cannon
}
else
{
- mat = m_object->RetWorldMatrix(1); // cannon
+ mat = m_object->GetWorldMatrix(1); // cannon
}
for ( i=0 ; i<3 ; i++ )
@@ -185,10 +182,10 @@ bool CTaskFire::EventProcess(const Event &event)
speed = Math::Vector(200.0f, 0.0f, 0.0f);
- physics = m_object->RetPhysics();
+ physics = m_object->GetPhysics();
if ( physics != 0 )
{
- speed += physics->RetLinMotion(MO_REASPEED);
+ speed += physics->GetLinMotion(MO_REASPEED);
}
speed.x += (Math::Rand()-0.5f)*3.0f;
@@ -200,8 +197,8 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = Math::Rand()*0.7f+0.7f;
dim.y = dim.x;
- channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN1, 0.8f, 0.0f, 0.0f);
- m_particule->SetObjectFather(channel, m_object);
+ channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN1, 0.8f, 0.0f, 0.0f);
+ m_particle->SetObjectFather(channel, m_object);
}
if ( type != OBJECT_MOBILErc &&
@@ -222,8 +219,8 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = Math::Rand()*1.2f+1.2f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.0f);
-//? m_particule->CreateParticule(pos, speed, dim, PARTISMOKE2, 4.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 0.0f);
+//? m_particle->CreateParticle(pos, speed, dim, PARTISMOKE2, 4.0f, 0.0f, 0.0f);
}
}
@@ -256,7 +253,7 @@ bool CTaskFire::EventProcess(const Event &event)
if ( m_bRay && m_lastSound <= 0.0f )
{
m_lastSound = Math::Rand()*0.4f+0.4f;
- m_sound->Play(SOUND_FIREp, m_object->RetPosition(0));
+ m_sound->Play(SOUND_FIREp, m_object->GetPosition(0));
}
return true;
@@ -274,7 +271,7 @@ Error CTaskFire::Start(float delay)
m_bError = true; // operation impossible
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type != OBJECT_MOBILEfc &&
type != OBJECT_MOBILEtc &&
type != OBJECT_MOBILEwc &&
@@ -285,9 +282,9 @@ Error CTaskFire::Start(float delay)
type != OBJECT_MOBILEii &&
type != OBJECT_MOBILErc ) return ERR_FIRE_VEH;
-//? if ( !m_physics->RetLand() ) return ERR_FIRE_FLY;
+//? if ( !m_physics->GetLand() ) return ERR_FIRE_FLY;
- speed = m_physics->RetMotorSpeed();
+ speed = m_physics->GetMotorSpeed();
//? if ( speed.x != 0.0f ||
//? speed.z != 0.0f ) return ERR_FIRE_MOTOR;
@@ -309,18 +306,18 @@ Error CTaskFire::Start(float delay)
}
m_delay = delay;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 ) return ERR_FIRE_ENERGY;
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
if ( m_bOrganic ) fire = m_delay*ENERGY_FIREi;
else if ( m_bRay ) fire = m_delay*ENERGY_FIREr;
else fire = m_delay*ENERGY_FIRE;
- if ( energy < fire/power->RetCapacity()+0.05f ) return ERR_FIRE_ENERGY;
+ if ( energy < fire/power->GetCapacity()+0.05f ) return ERR_FIRE_ENERGY;
m_speed = 1.0f/m_delay;
m_progress = 0.0f;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_lastSound = 0.0f;
m_bError = false; // ok
@@ -328,7 +325,7 @@ Error CTaskFire::Start(float delay)
if ( m_bOrganic )
{
- m_soundChannel = m_sound->Play(SOUND_FIREi, m_object->RetPosition(0), 1.0f, 1.0f, true);
+ m_soundChannel = m_sound->Play(SOUND_FIREi, m_object->GetPosition(0), 1.0f, 1.0f, true);
if ( m_soundChannel != -1 )
{
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, m_delay, SOPER_CONTINUE);
@@ -340,7 +337,7 @@ Error CTaskFire::Start(float delay)
}
else
{
- m_soundChannel = m_sound->Play(SOUND_FIRE, m_object->RetPosition(0), 1.0f, 1.0f, true);
+ m_soundChannel = m_sound->Play(SOUND_FIRE, m_object->GetPosition(0), 1.0f, 1.0f, true);
if ( m_soundChannel != -1 )
{
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, m_delay, SOPER_CONTINUE);
@@ -355,7 +352,7 @@ Error CTaskFire::Start(float delay)
Error CTaskFire::IsEnded()
{
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;
diff --git a/src/object/task/taskfire.h b/src/object/task/taskfire.h
index f06b9f6..5cf4f0c 100644
--- a/src/object/task/taskfire.h
+++ b/src/object/task/taskfire.h
@@ -45,7 +45,7 @@ protected:
bool m_bOrganic;
float m_time;
float m_speed;
- float m_lastParticule;
+ float m_lastParticle;
float m_lastSound;
int m_soundChannel;
};
diff --git a/src/object/task/taskfireant.cpp b/src/object/task/taskfireant.cpp
index 8eb2217..2044685 100644
--- a/src/object/task/taskfireant.cpp
+++ b/src/object/task/taskfireant.cpp
@@ -16,12 +16,9 @@
// taskfireant.cpp
-
-#include <stdio.h>
-
#include "object/task/taskfireant.h"
-#include "old/particule.h"
+#include "graphics/engine/particle.h"
#include "math/geometry.h"
#include "object/motion/motionant.h"
#include "physics/physics.h"
@@ -51,11 +48,11 @@ bool CTaskFireAnt::EventProcess(const Event &event)
Math::Vector dir, vib;
float a, g, cirSpeed;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
- if ( m_object->RetFixed() ) // insect on its back?
+ if ( m_object->GetFixed() ) // insect on its back?
{
m_bError = true;
return false;
@@ -66,7 +63,7 @@ bool CTaskFireAnt::EventProcess(const Event &event)
if ( m_phase == TFA_TURN ) // preliminary rotation?
{
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = m_angle;
cirSpeed = Math::Direction(a, g)*2.0f;
if ( cirSpeed > 2.0f ) cirSpeed = 2.0f;
@@ -89,24 +86,24 @@ Error CTaskFireAnt::Start(Math::Vector impact)
m_impact = impact;
m_bError = true; // operation impossible
- if ( !m_physics->RetLand() ) return ERR_FIRE_VEH;
+ if ( !m_physics->GetLand() ) return ERR_FIRE_VEH;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type != OBJECT_ANT ) return ERR_FIRE_VEH;
// Insect on its back?
- if ( m_object->RetFixed() ) return ERR_FIRE_VEH;
+ if ( m_object->GetFixed() ) return ERR_FIRE_VEH;
m_physics->SetMotorSpeed(Math::Vector(0.0f, 0.0f, 0.0f));
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
m_angle = Math::RotateAngle(m_impact.x-pos.x, pos.z-m_impact.z); // CW !
m_phase = TFA_TURN;
m_speed = 1.0f/1.0f;
m_progress = 0.0f;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_bError = false; // ok
m_bFire = false; // once!
@@ -123,13 +120,13 @@ Error CTaskFireAnt::IsEnded()
float angle, dist;
int i, channel;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
- if ( m_object->RetFixed() ) return ERR_STOP; // insect on its back?
+ if ( m_object->GetFixed() ) return ERR_STOP; // insect on its back?
if ( m_phase == TFA_TURN ) // rotation ?
{
- angle = m_object->RetAngleY(0);
+ angle = m_object->GetAngleY(0);
angle = Math::NormAngle(angle); // 0..2*Math::PI
if ( !Math::TestAngle(angle, m_angle-Math::PI*0.05f, m_angle+Math::PI*0.05f) ) return ERR_CONTINUE;
@@ -164,7 +161,7 @@ Error CTaskFireAnt::IsEnded()
for ( i=0 ; i<20 ; i++ )
{
pos = Math::Vector(-2.5f, -0.7f, 0.0f);
- mat = m_object->RetWorldMatrix(2);
+ mat = m_object->GetWorldMatrix(2);
pos = Math::Transform(*mat, pos);
dist = Math::Distance(pos, m_impact);
speed = m_impact-pos;
@@ -173,8 +170,8 @@ Error CTaskFireAnt::IsEnded()
speed.z += (Math::Rand()-0.5f)*dist*1.2f;
dim.x = 1.0f;
dim.y = dim.x;
- channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN2, 2.0f, 100.0f, 0.0f);
- m_particule->SetObjectFather(channel, m_object);
+ channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN2, 2.0f, 100.0f, 0.0f);
+ m_particle->SetObjectFather(channel, m_object);
}
}
diff --git a/src/object/task/taskfireant.h b/src/object/task/taskfireant.h
index 1d8ef62..4fa77b8 100644
--- a/src/object/task/taskfireant.h
+++ b/src/object/task/taskfireant.h
@@ -58,6 +58,6 @@ protected:
bool m_bError;
bool m_bFire;
float m_time;
- float m_lastParticule;
+ float m_lastParticle;
};
diff --git a/src/object/task/taskflag.cpp b/src/object/task/taskflag.cpp
index 7fba689..d45fff4 100644
--- a/src/object/task/taskflag.cpp
+++ b/src/object/task/taskflag.cpp
@@ -16,15 +16,13 @@
// taskflag.cpp
-
-#include <stdio.h>
-
#include "object/task/taskflag.h"
#include "math/geometry.h"
#include "common/iman.h"
-#include "old/water.h"
-#include "old/pyro.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/pyro.h"
+#include "graphics/engine/water.h"
#include "physics/physics.h"
#include "object/motion/motionhuman.h"
@@ -51,8 +49,8 @@ CTaskFlag::~CTaskFlag()
bool CTaskFlag::EventProcess(const Event &event)
{
if ( m_bError ) return true;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_time += event.rTime;
@@ -72,18 +70,18 @@ Error CTaskFlag::Start(TaskFlagOrder order, int rank)
m_time = 0.0f;
m_bError = true; // operation impossible
- if ( !m_physics->RetLand() )
+ if ( !m_physics->GetLand() )
{
- pos = m_object->RetPosition(0);
- if ( pos.y < m_water->RetLevel() ) return ERR_FLAG_WATER;
+ pos = m_object->GetPosition(0);
+ if ( pos.y < m_water->GetLevel() ) return ERR_FLAG_WATER;
return ERR_FLAG_FLY;
}
- speed = m_physics->RetMotorSpeed();
+ speed = m_physics->GetMotorSpeed();
if ( speed.x != 0.0f ||
speed.z != 0.0f ) return ERR_FLAG_MOTOR;
- if ( m_object->RetFret() != 0 ) return ERR_FLAG_BUSY;
+ if ( m_object->GetFret() != 0 ) return ERR_FLAG_BUSY;
if ( order == TFL_CREATE )
{
@@ -109,7 +107,7 @@ Error CTaskFlag::Start(TaskFlagOrder order, int rank)
Error CTaskFlag::IsEnded()
{
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_time < 2.0f ) return ERR_CONTINUE;
@@ -143,12 +141,12 @@ CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type)
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetEnable() ) continue;
+ if ( !pObj->GetEnable() ) continue;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( type == OBJECT_NULL )
{
if ( oType != OBJECT_FLAGb &&
@@ -162,7 +160,7 @@ CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type)
if ( oType != type ) continue;
}
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(oPos, pos);
if ( dist < min )
{
@@ -185,12 +183,12 @@ int CTaskFlag::CountObject(ObjectType type)
count = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetEnable() ) continue;
+ if ( !pObj->GetEnable() ) continue;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( type == OBJECT_NULL )
{
if ( oType != OBJECT_FLAGb &&
@@ -213,13 +211,13 @@ int CTaskFlag::CountObject(ObjectType type)
Error CTaskFlag::CreateFlag(int rank)
{
- CObject* pObj;
- CObject* pNew;
- CPyro* pyro;
- Math::Matrix* mat;
- Math::Vector pos;
- float dist;
- int i;
+ CObject* pObj;
+ CObject* pNew;
+ Gfx::CPyro* pyro;
+ Math::Matrix* mat;
+ Math::Vector pos;
+ float dist;
+ int i;
ObjectType table[5] =
{
@@ -230,13 +228,13 @@ Error CTaskFlag::CreateFlag(int rank)
OBJECT_FLAGv,
};
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, Math::Vector(4.0f, 0.0f, 0.0f));
pObj = SearchNearest(pos, OBJECT_NULL);
if ( pObj != 0 )
{
- dist = Math::Distance(pos, pObj->RetPosition(0));
+ dist = Math::Distance(pos, pObj->GetPosition(0));
if ( dist < 10.0f )
{
return ERR_FLAG_PROXY;
@@ -258,8 +256,8 @@ Error CTaskFlag::CreateFlag(int rank)
pNew->SetZoom(0, 0.0f);
m_sound->Play(SOUND_WAYPOINT, pos);
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FLCREATE, pNew);
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FLCREATE, pNew);
return ERR_OK;
}
@@ -268,13 +266,13 @@ Error CTaskFlag::CreateFlag(int rank)
Error CTaskFlag::DeleteFlag()
{
- CObject* pObj;
- CPyro* pyro;
- Math::Vector iPos, oPos;
- float iAngle, angle, aLimit, dist;
+ CObject* pObj;
+ Gfx::CPyro* pyro;
+ Math::Vector iPos, oPos;
+ float iAngle, angle, aLimit, dist;
- iPos = m_object->RetPosition(0);
- iAngle = m_object->RetAngleY(0);
+ iPos = m_object->GetPosition(0);
+ iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
pObj = SearchNearest(iPos, OBJECT_NULL);
@@ -282,13 +280,13 @@ Error CTaskFlag::DeleteFlag()
{
return ERR_FLAG_DELETE;
}
- dist = Math::Distance(iPos, pObj->RetPosition(0));
+ dist = Math::Distance(iPos, pObj->GetPosition(0));
if ( dist > 10.0f )
{
return ERR_FLAG_DELETE;
}
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
aLimit = 45.0f*Math::PI/180.0f;
if ( !Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
@@ -297,8 +295,8 @@ Error CTaskFlag::DeleteFlag()
}
m_sound->Play(SOUND_WAYPOINT, iPos);
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FLDELETE, pObj);
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FLDELETE, pObj);
return ERR_OK;
}
diff --git a/src/object/task/taskgoto.cpp b/src/object/task/taskgoto.cpp
index 5fd6cbe..ce778ef 100644
--- a/src/object/task/taskgoto.cpp
+++ b/src/object/task/taskgoto.cpp
@@ -23,11 +23,12 @@
#include "common/event.h"
#include "common/iman.h"
-#include "old/terrain.h"
-#include "old/water.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/water.h"
#include "math/geometry.h"
#include "physics/physics.h"
+#include <string.h>
const float FLY_DIST_GROUND = 80.0f; // minimum distance to remain on the ground
@@ -59,14 +60,14 @@ bool CTaskGoto::EventProcess(const Event &event)
{
Math::Vector pos, goal;
Math::Point rot, repulse;
- float a, g, dist, linSpeed, cirSpeed, h, hh, factor, dir;
- Error ret;
+ float a, g, dist, linSpeed, cirSpeed, h, hh, factor, dir;
+ Error ret;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
// Momentarily stationary object (ant on the back)?
- if ( m_object->RetFixed() )
+ if ( m_object->GetFixed() )
{
m_physics->SetMotorSpeedX(0.0f); // stops the advance
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
@@ -84,7 +85,7 @@ bool CTaskGoto::EventProcess(const Event &event)
{
m_leakTime += event.rTime;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
rot.x = m_leakPos.x-pos.x;
rot.y = m_leakPos.z-pos.z;
@@ -92,7 +93,7 @@ bool CTaskGoto::EventProcess(const Event &event)
rot.x /= dist;
rot.y /= dist;
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = Math::RotateAngle(rot.x, -rot.y); // CW !
a = Math::Direction(a, g)*1.0f;
cirSpeed = a;
@@ -126,10 +127,10 @@ bool CTaskGoto::EventProcess(const Event &event)
if ( m_bmStep == 0 )
{
// Frees the area around the departure.
- BitmapClearCircle(m_object->RetPosition(0), BM_DIM_STEP*1.8f);
+ BitmapClearCircle(m_object->GetPosition(0), BM_DIM_STEP*1.8f);
}
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
if ( m_bmFretObject == 0 )
{
@@ -140,44 +141,20 @@ bool CTaskGoto::EventProcess(const Event &event)
{
goal = m_goalObject;
dist = TAKE_DIST+2.0f;
- if ( m_bmFretObject->RetType() == OBJECT_BASE ) dist = 12.0f;
+ if ( m_bmFretObject->GetType() == OBJECT_BASE ) dist = 12.0f;
}
ret = BeamSearch(pos, goal, dist);
if ( ret == ERR_OK )
{
-#if 0
- Math::Vector min, max;
- min = pos;
- max = m_goal;
- if ( min.x > max.x ) Math::Swap(min.x, max.x);
- if ( min.z > max.z ) Math::Swap(min.z, max.z);
- min.x -= 50.0f;
- min.z -= 50.0f;
- max.x += 50.0f;
- max.z += 50.0f;
- BitmapDebug(min, max, m_object->RetPosition(0), m_goal);
-#endif
- if ( m_physics->RetLand() ) m_phase = TGP_BEAMWCOLD;
+ if ( m_physics->GetLand() ) m_phase = TGP_BEAMWCOLD;
else m_phase = TGP_BEAMGOTO;
m_bmIndex = 0;
- m_bmWatchDogPos = m_object->RetPosition(0);
+ m_bmWatchDogPos = m_object->GetPosition(0);
m_bmWatchDogTime = 0.0f;
}
if ( ret == ERR_GOTO_IMPOSSIBLE || ret == ERR_GOTO_ITER )
{
-#if 0
- Math::Vector min, max;
- min = pos;
- max = m_goal;
- if ( min.x > max.x ) Math::Swap(min.x, max.x);
- if ( min.z > max.z ) Math::Swap(min.z, max.z);
- min.x -= 50.0f;
- min.z -= 50.0f;
- max.x += 50.0f;
- max.z += 50.0f;
- BitmapDebug(min, max, m_object->RetPosition(0), m_goal);
-#endif
m_error = ret;
return false;
}
@@ -197,16 +174,16 @@ bool CTaskGoto::EventProcess(const Event &event)
if ( m_phase == TGP_BEAMGOTO ) // goto dot list? (?)
{
- if ( m_physics->RetCollision() ) // collision?
+ if ( m_physics->GetCollision() ) // collision?
{
m_physics->SetCollision(false); // there's more
}
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
- if ( m_physics->RetType() == TYPE_FLYING && m_altitude == 0.0f )
+ if ( m_physics->GetType() == TYPE_FLYING && m_altitude == 0.0f )
{
- if ( m_physics->RetLand() )
+ if ( m_physics->GetLand() )
{
m_physics->SetMotorSpeedY(0.0f);
}
@@ -216,21 +193,21 @@ bool CTaskGoto::EventProcess(const Event &event)
}
}
- if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f )
+ if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
{
goal = m_bmPoints[m_bmIndex];
goal.y = pos.y;
- h = m_terrain->RetFloorHeight(goal, true, true);
+ h = m_terrain->GetHeightToFloor(goal, true, true);
dist = Math::DistanceProjected(pos, goal);
if ( dist != 0.0f ) // anticipates?
{
- linSpeed = m_physics->RetLinMotionX(MO_REASPEED);
- linSpeed /= m_physics->RetLinMotionX(MO_ADVSPEED);
+ linSpeed = m_physics->GetLinMotionX(MO_REASPEED);
+ linSpeed /= m_physics->GetLinMotionX(MO_ADVSPEED);
goal.x = pos.x + (goal.x-pos.x)*linSpeed*20.0f/dist;
goal.z = pos.z + (goal.z-pos.z)*linSpeed*20.0f/dist;
}
goal.y = pos.y;
- hh = m_terrain->RetFloorHeight(goal, true, true);
+ hh = m_terrain->GetHeightToFloor(goal, true, true);
h = Math::Min(h, hh);
linSpeed = 0.0f;
if ( h < m_altitude-1.0f )
@@ -251,7 +228,7 @@ bool CTaskGoto::EventProcess(const Event &event)
rot.x /= dist;
rot.y /= dist;
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = Math::RotateAngle(rot.x, -rot.y); // CW !
cirSpeed = Math::Direction(a, g)*2.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
@@ -260,7 +237,7 @@ bool CTaskGoto::EventProcess(const Event &event)
if ( m_bmIndex == m_bmTotal ) // last point?
{
- linSpeed = dist/(m_physics->RetLinStopLength()*1.5f);
+ linSpeed = dist/(m_physics->GetLinStopLength()*1.5f);
if ( linSpeed > 1.0f ) linSpeed = 1.0f;
}
else
@@ -316,7 +293,7 @@ bool CTaskGoto::EventProcess(const Event &event)
{
if ( m_crashMode == TGC_HALT )
{
- if ( m_physics->RetCollision() ) // collision?
+ if ( m_physics->GetCollision() ) // collision?
{
m_physics->SetCollision(false); // there's more
m_error = ERR_STOP;
@@ -324,11 +301,11 @@ bool CTaskGoto::EventProcess(const Event &event)
}
}
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
if ( m_altitude > 0.0f )
{
- h = m_terrain->RetFloorHeight(pos, true, true);
+ h = m_terrain->GetHeightToFloor(pos, true, true);
linSpeed = 0.0f;
if ( h < m_altitude )
{
@@ -343,7 +320,7 @@ bool CTaskGoto::EventProcess(const Event &event)
rot.x = m_goal.x-pos.x;
rot.y = m_goal.z-pos.z;
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = Math::RotateAngle(rot.x, -rot.y); // CW !
cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
@@ -355,16 +332,16 @@ bool CTaskGoto::EventProcess(const Event &event)
}
if ( m_phase != TGP_TURN &&
- m_physics->RetType() == TYPE_FLYING &&
+ m_physics->GetType() == TYPE_FLYING &&
m_altitude > 0.0f )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
dist = Math::DistanceProjected(m_goal, pos);
factor = (dist-20.0f)/20.0f;
if ( factor < 0.0f ) factor = 0.0f;
if ( factor > 1.0f ) factor = 1.0f;
- h = m_terrain->RetFloorHeight(m_object->RetPosition(0), true, true);
+ h = m_terrain->GetHeightToFloor(m_object->GetPosition(0), true, true);
linSpeed = 0.0f;
if ( h < (m_altitude-0.5f)*factor && factor == 1.0f )
{
@@ -382,7 +359,7 @@ bool CTaskGoto::EventProcess(const Event &event)
if ( m_phase == TGP_ADVANCE ) // going towards the goal?
{
- if ( m_physics->RetCollision() ) // collision?
+ if ( m_physics->GetCollision() ) // collision?
{
m_physics->SetCollision(false); // there's more
m_time = 0.0f;
@@ -391,15 +368,15 @@ bool CTaskGoto::EventProcess(const Event &event)
}
#if 0
- pos = m_object->RetPosition(0);
- a = m_object->RetAngleY(0);
+ pos = m_object->GetPosition(0);
+ a = m_object->GetAngleY(0);
g = Math::RotateAngle(m_goal.x-pos.x, pos.z-m_goal.z); // CW !
cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
dist = Math::DistanceProjected(m_goal, pos);
- linSpeed = dist/(m_physics->RetLinStopLength()*1.5f);
+ linSpeed = dist/(m_physics->GetLinStopLength()*1.5f);
if ( linSpeed > 1.0f ) linSpeed = 1.0f;
if ( dist < 20.0f && fabs(cirSpeed) >= 0.5f )
@@ -407,7 +384,7 @@ bool CTaskGoto::EventProcess(const Event &event)
linSpeed = 0.0f; // turns first, then advance
}
#else
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
rot.x = m_goal.x-pos.x;
rot.y = m_goal.z-pos.z;
@@ -419,11 +396,11 @@ bool CTaskGoto::EventProcess(const Event &event)
rot.x += repulse.x*2.0f;
rot.y += repulse.y*2.0f;
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = Math::RotateAngle(rot.x, -rot.y); // CW !
cirSpeed = Math::Direction(a, g)*1.0f;
-//? if ( m_physics->RetType() == TYPE_FLYING &&
-//? m_physics->RetLand() ) // flying on the ground?
+//? if ( m_physics->GetType() == TYPE_FLYING &&
+//? m_physics->GetLand() ) // flying on the ground?
//? {
//? cirSpeed *= 4.0f; // more fishing
//? }
@@ -431,9 +408,9 @@ bool CTaskGoto::EventProcess(const Event &event)
if ( cirSpeed < -1.0f ) cirSpeed = -1.0f;
dist = Math::DistanceProjected(m_goal, pos);
- linSpeed = dist/(m_physics->RetLinStopLength()*1.5f);
-//? if ( m_physics->RetType() == TYPE_FLYING &&
-//? m_physics->RetLand() ) // flying on the ground?
+ linSpeed = dist/(m_physics->GetLinStopLength()*1.5f);
+//? if ( m_physics->GetType() == TYPE_FLYING &&
+//? m_physics->GetLand() ) // flying on the ground?
//? {
//? linSpeed *= 8.0f; // more fishing
//? }
@@ -455,7 +432,7 @@ bool CTaskGoto::EventProcess(const Event &event)
m_phase == TGP_CRTURN || // turns after collision?
m_phase == TGP_CLTURN ) // turns after collision?
{
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = m_angle;
cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
@@ -474,7 +451,7 @@ bool CTaskGoto::EventProcess(const Event &event)
if ( m_phase == TGP_CRADVANCE ) // advance after collision?
{
- if ( m_physics->RetCollision() ) // collision?
+ if ( m_physics->GetCollision() ) // collision?
{
m_physics->SetCollision(false); // there's more
m_time = 0.0f;
@@ -486,7 +463,7 @@ bool CTaskGoto::EventProcess(const Event &event)
if ( m_phase == TGP_CLADVANCE ) // advance after collision?
{
- if ( m_physics->RetCollision() ) // collision?
+ if ( m_physics->GetCollision() ) // collision?
{
m_physics->SetCollision(false); // there's more
m_time = 0.0f;
@@ -517,15 +494,15 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact)
float distance, min, radius;
int i;
- iPos = m_object->RetPosition(0);
+ iPos = m_object->GetPosition(0);
min = 1000000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType != OBJECT_MOBILEfa &&
oType != OBJECT_MOBILEta &&
oType != OBJECT_MOBILEwa &&
@@ -570,7 +547,7 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact)
oType != OBJECT_SAFE &&
oType != OBJECT_HUSTON ) continue;
- if ( pObj->RetVirusMode() ) continue; // object infected?
+ if ( pObj->GetVirusMode() ) continue; // object infected?
if ( !pObj->GetCrashSphere(0, oPos, radius) ) continue;
distance = Math::DistanceProjected(oPos, iPos);
@@ -582,7 +559,7 @@ CObject* CTaskGoto::WormSearch(Math::Vector &impact)
}
if ( pBest == 0 ) return 0;
- impact = pBest->RetPosition(0);
+ impact = pBest->GetPosition(0);
return pBest;
}
@@ -603,7 +580,7 @@ void CTaskGoto::WormFrame(float rTime)
pObj = WormSearch(impact);
if ( pObj != 0 )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
dist = Math::Distance(pos, impact);
if ( dist <= 15.0f )
{
@@ -627,7 +604,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude,
float dist;
int x, y;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( goalMode == TGG_DEFAULT )
{
@@ -668,7 +645,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude,
m_bmFretObject = 0;
m_bmFinalMove = 0.0f;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
dist = Math::DistanceProjected(pos, m_goal);
if ( dist < 10.0f && m_crashMode == TGC_BEAM )
{
@@ -703,7 +680,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude,
target = SearchTarget(goal, 1.0f);
if ( target != 0 )
{
- m_goal = target->RetPosition(0);
+ m_goal = target->GetPosition(0);
dist = 0.0f;
if ( !AdjustBuilding(m_goal, 1.0f, dist) )
{
@@ -722,7 +699,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude,
target = SearchTarget(goal, 1.0f);
if ( target != 0 )
{
- m_goal = target->RetPosition(0);
+ m_goal = target->GetPosition(0);
dist = 4.0f;
if ( AdjustBuilding(m_goal, 1.0f, dist) )
{
@@ -743,9 +720,9 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude,
m_bTake = true; // object was taken on arrival (final rotation)
}
- if ( m_physics->RetType() == TYPE_FLYING && m_altitude == 0.0f )
+ if ( m_physics->GetType() == TYPE_FLYING && m_altitude == 0.0f )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
dist = Math::DistanceProjected(pos, m_goal);
if ( dist > FLY_DIST_GROUND ) // over 20 meters?
{
@@ -757,22 +734,10 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude,
if ( m_bmFretObject == 0 )
{
- x = (int)((m_goal.x+1600.0f)/BM_DIM_STEP);
- y = (int)((m_goal.z+1600.0f)/BM_DIM_STEP);
+ x = static_cast<int>((m_goal.x+1600.0f)/BM_DIM_STEP);
+ y = static_cast<int>((m_goal.z+1600.0f)/BM_DIM_STEP);
if ( BitmapTestDot(0, x, y) ) // arrival occupied?
{
-#if 0
- Math::Vector min, max;
- min = m_object->RetPosition(0);
- max = m_goal;
- if ( min.x > max.x ) Math::Swap(min.x, max.x);
- if ( min.z > max.z ) Math::Swap(min.z, max.z);
- min.x -= 50.0f;
- min.z -= 50.0f;
- max.x += 50.0f;
- max.z += 50.0f;
- BitmapDebug(min, max, m_object->RetPosition(0), m_goal);
-#endif
m_error = ERR_GOTO_BUSY;
return m_error;
}
@@ -789,10 +754,10 @@ Error CTaskGoto::IsEnded()
Math::Vector pos;
float limit, angle, dist, h, level;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_error != ERR_OK ) return m_error;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
if ( m_phase == TGP_BEAMLEAK ) // leak?
{
@@ -814,17 +779,17 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_BEAMWCOLD ) // expects cool reactor?
{
if ( m_altitude != 0.0f &&
- m_physics->RetReactorRange() < 1.0f ) return ERR_CONTINUE;
+ m_physics->GetReactorRange() < 1.0f ) return ERR_CONTINUE;
m_phase = TGP_BEAMUP;
}
if ( m_phase == TGP_BEAMUP ) // off?
{
- if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f )
+ if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
{
- level = m_terrain->RetFloorLevel(pos, true, true);
+ level = m_terrain->GetFloorLevel(pos, true, true);
h = level+m_altitude-20.0f;
- limit = m_terrain->RetFlyingMaxHeight();
+ limit = m_terrain->GetFlyingMaxHeight();
if ( h > limit ) h = limit;
if ( pos.y < h-1.0f ) return ERR_CONTINUE;
@@ -836,7 +801,7 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_BEAMGOTO ) // goto dot list ?
{
if ( m_altitude != 0.0f &&
- m_physics->RetReactorRange() < 0.1f ) // overheating?
+ m_physics->GetReactorRange() < 0.1f ) // overheating?
{
m_physics->SetMotorSpeedX(0.0f); // stops the advance
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
@@ -845,7 +810,7 @@ Error CTaskGoto::IsEnded()
return ERR_CONTINUE;
}
- if ( m_physics->RetLand() ) // on the ground?
+ if ( m_physics->GetLand() ) // on the ground?
{
limit = 1.0f;
}
@@ -873,9 +838,9 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_BEAMDOWN ) // landed?
{
- if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f )
+ if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
{
- if ( !m_physics->RetLand() ) return ERR_CONTINUE;
+ if ( !m_physics->GetLand() ) return ERR_CONTINUE;
m_physics->SetMotorSpeedY(0.0f); // stops the descent
m_altitude = 0.0f;
@@ -909,7 +874,7 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_ADVANCE ) // going towards the goal?
{
- if ( m_physics->RetLand() ) limit = 0.1f; // on the ground
+ if ( m_physics->GetLand() ) limit = 0.1f; // on the ground
else limit = 1.0f; // flying
if ( m_bApprox ) limit = 2.0f;
@@ -924,9 +889,9 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_LAND ) // landed?
{
- if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f )
+ if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
{
- if ( !m_physics->RetLand() ) return ERR_CONTINUE;
+ if ( !m_physics->GetLand() ) return ERR_CONTINUE;
m_physics->SetMotorSpeedY(0.0f);
}
@@ -943,7 +908,7 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_TURN ) // turns to the object?
{
- angle = Math::NormAngle(m_object->RetAngleY(0));
+ angle = Math::NormAngle(m_object->GetAngleY(0));
limit = 0.02f;
if ( m_bApprox ) limit = 0.10f;
if ( fabs(angle-m_angle) < limit )
@@ -951,9 +916,9 @@ Error CTaskGoto::IsEnded()
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
if ( m_bmFinalMove == 0.0f ) return ERR_STOP;
- m_bmFinalPos = m_object->RetPosition(0);
- m_bmFinalDist = m_physics->RetLinLength(m_bmFinalMove);
- m_bmTimeLimit = m_physics->RetLinTimeLength(fabs(m_bmFinalMove))*1.5f;
+ m_bmFinalPos = m_object->GetPosition(0);
+ m_bmFinalDist = m_physics->GetLinLength(m_bmFinalMove);
+ m_bmTimeLimit = m_physics->GetLinTimeLength(fabs(m_bmFinalMove))*1.5f;
if ( m_bmTimeLimit < 0.5f ) m_bmTimeLimit = 0.5f;
m_phase = TGP_MOVE;
}
@@ -973,7 +938,7 @@ Error CTaskGoto::IsEnded()
if ( m_crashMode == TGC_RIGHTLEFT ||
m_crashMode == TGC_RIGHT ) angle = Math::PI/2.0f; // 90 deegres to the right
else angle = -Math::PI/2.0f; // 90 deegres to the left
- m_angle = Math::NormAngle(m_object->RetAngleY(0)+angle);
+ m_angle = Math::NormAngle(m_object->GetAngleY(0)+angle);
m_phase = TGP_CRTURN;
//? m_phase = TGP_ADVANCE;
}
@@ -981,7 +946,7 @@ Error CTaskGoto::IsEnded()
if ( m_phase == TGP_CRTURN ) // turns after collision?
{
- angle = Math::NormAngle(m_object->RetAngleY(0));
+ angle = Math::NormAngle(m_object->GetAngleY(0));
limit = 0.1f;
if ( fabs(angle-m_angle) < limit )
{
@@ -1007,14 +972,14 @@ Error CTaskGoto::IsEnded()
if ( m_crashMode == TGC_LEFTRIGHT ) angle = Math::PI;
if ( m_crashMode == TGC_RIGHT ) angle = Math::PI/2.0f;
if ( m_crashMode == TGC_LEFT ) angle = -Math::PI/2.0f;
- m_angle = Math::NormAngle(m_object->RetAngleY(0)+angle);
+ m_angle = Math::NormAngle(m_object->GetAngleY(0)+angle);
m_phase = TGP_CLTURN;
}
}
if ( m_phase == TGP_CLTURN ) // turns after collision?
{
- angle = Math::NormAngle(m_object->RetAngleY(0));
+ angle = Math::NormAngle(m_object->GetAngleY(0));
limit = 0.1f;
if ( fabs(angle-m_angle) < limit )
{
@@ -1042,7 +1007,7 @@ Error CTaskGoto::IsEnded()
return ERR_STOP;
}
- dist = Math::Distance(m_bmFinalPos, m_object->RetPosition(0));
+ dist = Math::Distance(m_bmFinalPos, m_object->GetPosition(0));
if ( dist < m_bmFinalDist ) return ERR_CONTINUE;
m_physics->SetMotorSpeedX(0.0f); // stops the advance
return ERR_STOP;
@@ -1065,13 +1030,13 @@ CObject* CTaskGoto::SearchTarget(Math::Vector pos, float margin)
min = 1000000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetActif() ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transtorted?
+ if ( !pObj->GetActif() ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transtorted?
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(pos, oPos);
if ( dist <= margin && dist <= min )
@@ -1095,15 +1060,15 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance)
Math::Vector goal;
float dist, suppl;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_BEE ||
type == OBJECT_WORM )
{
- pos = pObj->RetPosition(0);
+ pos = pObj->GetPosition(0);
return false; // single approach
}
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_FRET ||
type == OBJECT_STONE ||
@@ -1131,8 +1096,8 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance)
type == OBJECT_RUINmobiler1 ||
type == OBJECT_RUINmobiler2 )
{
- pos = m_object->RetPosition(0);
- goal = pObj->RetPosition(0);
+ pos = m_object->GetPosition(0);
+ goal = pObj->GetPosition(0);
dist = Math::Distance(goal, pos);
pos = (pos-goal)*(TAKE_DIST+distance)/dist + goal;
return true; // approach from all sites
@@ -1140,8 +1105,8 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance)
if ( type == OBJECT_BASE )
{
- pos = m_object->RetPosition(0);
- goal = pObj->RetPosition(0);
+ pos = m_object->GetPosition(0);
+ goal = pObj->GetPosition(0);
dist = Math::Distance(goal, pos);
pos = (pos-goal)*(TAKE_DIST+distance)/dist + goal;
return true; // approach from all sites
@@ -1175,10 +1140,10 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance)
type == OBJECT_MOBILEit ||
type == OBJECT_MOBILEdr )
{
- character = pObj->RetCharacter();
+ character = pObj->GetCharacter();
pos = character->posPower;
pos.x -= TAKE_DIST+TAKE_DIST_OTHER+distance;
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos = Transform(*mat, pos);
return false; // single approach
}
@@ -1190,7 +1155,7 @@ bool CTaskGoto::AdjustTarget(CObject* pObj, Math::Vector &pos, float &distance)
return false; // single approach
}
- pos = pObj->RetPosition(0);
+ pos = pObj->GetPosition(0);
distance = 0.0f;
return false; // single approach
}
@@ -1207,11 +1172,11 @@ bool CTaskGoto::AdjustBuilding(Math::Vector &pos, float margin, float &distance)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetActif() ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
if ( !GetHotPoint(pObj, oPos, false, 0.0f, suppl) ) continue;
dist = Math::DistanceProjected(pos, oPos);
@@ -1235,11 +1200,11 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
pos = Math::Vector(0.0f, 0.0f, 0.0f);
suppl = 0.0f;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_DERRICK )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 8.0f;
if ( bTake && distance != 0.0f ) suppl = 4.0f;
if ( bTake ) pos.x += TAKE_DIST+distance+suppl;
@@ -1249,7 +1214,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_CONVERT )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 0.0f;
if ( bTake && distance != 0.0f ) suppl = 4.0f;
if ( bTake ) pos.x += TAKE_DIST+distance+suppl;
@@ -1259,7 +1224,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_RESEARCH )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 10.0f;
if ( bTake && distance != 0.0f ) suppl = 2.5f;
if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance+suppl;
@@ -1269,7 +1234,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_ENERGY )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 6.0f;
if ( bTake && distance != 0.0f ) suppl = 6.0f;
if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance;
@@ -1279,7 +1244,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_TOWER )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 5.0f;
if ( bTake && distance != 0.0f ) suppl = 4.0f;
if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance+suppl;
@@ -1289,7 +1254,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_LABO )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 6.0f;
if ( bTake && distance != 0.0f ) suppl = 6.0f;
if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance;
@@ -1299,7 +1264,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_NUCLEAR )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 22.0f;
if ( bTake && distance != 0.0f ) suppl = 4.0f;
if ( bTake ) pos.x += TAKE_DIST+TAKE_DIST_OTHER+distance+suppl;
@@ -1309,7 +1274,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_FACTORY )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 4.0f;
if ( bTake && distance != 0.0f ) suppl = 6.0f;
if ( bTake ) pos.x += TAKE_DIST+distance+suppl;
@@ -1319,7 +1284,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_STATION )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 4.0f;
if ( bTake && distance != 0.0f ) suppl = 4.0f;
if ( bTake ) pos.x += distance;
@@ -1329,7 +1294,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_REPAIR )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 4.0f;
if ( bTake && distance != 0.0f ) suppl = 4.0f;
if ( bTake ) pos.x += distance;
@@ -1339,7 +1304,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
if ( type == OBJECT_DESTROYER )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
pos.x += 0.0f;
if ( bTake && distance != 0.0f ) suppl = 4.0f;
if ( bTake ) pos.x += TAKE_DIST+distance+suppl;
@@ -1347,9 +1312,9 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
return true;
}
- if ( type == OBJECT_PARA && m_physics->RetType() == TYPE_FLYING )
+ if ( type == OBJECT_PARA && m_physics->GetType() == TYPE_FLYING )
{
- mat = pObj->RetWorldMatrix(0);
+ mat = pObj->GetWorldMatrix(0);
if ( bTake && distance != 0.0f ) suppl = 20.0f;
if ( bTake ) pos.x += distance+suppl;
pos = Transform(*mat, pos);
@@ -1370,7 +1335,7 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
float iRadius, oRadius, bRadius, dist, min, dir;
int i, j;
- if ( !m_physics->RetLand() ) return false; // in flight?
+ if ( !m_physics->GetLand() ) return false; // in flight?
m_object->GetCrashSphere(0, iPos, iRadius);
@@ -1378,12 +1343,12 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
bRadius = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
- if ( !pObj->RetActif() ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
j = 0;
while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
@@ -1404,7 +1369,7 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
dist = 4.0f;
dir = 1.0f;
- if ( pObstacle->RetType() == OBJECT_FACTORY )
+ if ( pObstacle->GetType() == OBJECT_FACTORY )
{
dist = 16.0f;
dir = -1.0f;
@@ -1412,7 +1377,7 @@ bool CTaskGoto::LeakSearch(Math::Vector &pos, float &delay)
}
pos = bPos;
- delay = m_physics->RetLinTimeLength(dist, dir);
+ delay = m_physics->GetLinTimeLength(dist, dir);
return true;
}
@@ -1436,18 +1401,18 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, m_goalObject);
if ( dist <= 1.0f ) continue;
pObj->GetGlobalSphere(oPos, oRadius);
- oRadius += iRadius+m_physics->RetLinStopLength()*1.1f;
+ oRadius += iRadius+m_physics->GetLinStopLength()*1.1f;
dist = Math::DistanceProjected(oPos, iPos);
if ( dist <= oRadius )
{
@@ -1479,13 +1444,13 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
dir.y = 0.0f;
// The worm goes everywhere and through everything!
- iType = m_object->RetType();
+ iType = m_object->GetType();
if ( iType == OBJECT_WORM ) return;
m_object->GetCrashSphere(0, iPos, iRadius);
gDist = Math::Distance(iPos, m_goal);
- add = m_physics->RetLinStopLength()*1.1f; // braking distance
+ add = m_physics->GetLinStopLength()*1.1f; // braking distance
fac = 2.0f;
if ( iType == OBJECT_MOBILEwa ||
@@ -1513,7 +1478,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
iType == OBJECT_MOBILEfs ||
iType == OBJECT_MOBILEft ) // flying?
{
- if ( m_physics->RetLand() )
+ if ( m_physics->GetLand() )
{
add = 5.0f;
fac = 1.5f;
@@ -1535,7 +1500,7 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
}
if ( iType == OBJECT_BEE ) // wasp?
{
- if ( m_physics->RetLand() )
+ if ( m_physics->GetLand() )
{
add = 3.0f;
fac = 1.5f;
@@ -1559,13 +1524,13 @@ void CTaskGoto::ComputeRepulse(Math::Point &dir)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType == OBJECT_WORM ) continue;
@@ -1651,13 +1616,13 @@ void CTaskGoto::ComputeFlyingRepulse(float &dir)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType == OBJECT_WORM ) continue;
@@ -1712,7 +1677,7 @@ void CTaskGoto::BeamStart()
BitmapOpen();
BitmapObject();
- min = m_object->RetPosition(0);
+ min = m_object->GetPosition(0);
max = m_goal;
if ( min.x > max.x ) Math::Swap(min.x, max.x);
if ( min.z > max.z ) Math::Swap(min.z, max.z);
@@ -1890,84 +1855,6 @@ Math::Vector CTaskGoto::BeamPoint(const Math::Vector &startPoint,
return resPoint;
}
-// Displays a bitmap part.
-
-void CTaskGoto::BitmapDebug(const Math::Vector &min, const Math::Vector &max,
- const Math::Vector &start, const Math::Vector &goal)
-{
- int minx, miny, maxx, maxy, x, y, i ,n;
- char s[2000];
-
- minx = (int)((min.x+1600.0f)/BM_DIM_STEP);
- miny = (int)((min.z+1600.0f)/BM_DIM_STEP);
- maxx = (int)((max.x+1600.0f)/BM_DIM_STEP);
- maxy = (int)((max.z+1600.0f)/BM_DIM_STEP);
-
- if ( minx > maxx ) Math::Swap(minx, maxx);
- if ( miny > maxy ) Math::Swap(miny, maxy);
-
- OutputDebugString("Bitmap :\n");
- for ( y=miny ; y<=maxy ; y++ )
- {
- s[0] = 0;
- for ( x=minx ; x<=maxx ; x++ )
- {
- n = -1;
- for ( i=0 ; i<=m_bmTotal ; i++ )
- {
- if ( x == (int)((m_bmPoints[i].x+1600.0f)/BM_DIM_STEP) &&
- y == (int)((m_bmPoints[i].z+1600.0f)/BM_DIM_STEP) )
- {
- n = i;
- break;
- }
- }
-
- if ( BitmapTestDot(0, x,y) )
- {
- strcat(s, "o");
- }
- else
- {
- if ( BitmapTestDot(1, x,y) )
- {
- strcat(s, "-");
- }
- else
- {
- strcat(s, ".");
- }
- }
-
- if ( x == (int)((start.x+1600.0f)/BM_DIM_STEP) &&
- y == (int)((start.z+1600.0f)/BM_DIM_STEP) )
- {
- strcat(s, "s");
- }
- else
- if ( x == (int)((goal.x+1600.0f)/BM_DIM_STEP) &&
- y == (int)((goal.z+1600.0f)/BM_DIM_STEP) )
- {
- strcat(s, "g");
- }
- else
- if ( n != -1 )
- {
- char ss[2];
- ss[0] = 'A'+n;
- ss[1] = 0;
- strcat(s, ss);
- }
- else
- {
- strcat(s, " ");
- }
- }
- strcat(s, "\n");
- OutputDebugString(s);
- }
-}
-
// Tests if a path along a straight line is possible.
bool CTaskGoto::BitmapTestLine(const Math::Vector &start, const Math::Vector &goal,
@@ -1991,12 +1878,12 @@ bool CTaskGoto::BitmapTestLine(const Math::Vector &start, const Math::Vector &go
if ( bSecond )
{
- x = (int)((pos.x+1600.0f)/BM_DIM_STEP);
- y = (int)((pos.z+1600.0f)/BM_DIM_STEP);
+ x = static_cast<int>((pos.x+1600.0f)/BM_DIM_STEP);
+ y = static_cast<int>((pos.z+1600.0f)/BM_DIM_STEP);
BitmapSetDot(1, x, y); // puts the flag as the starting point
}
- max = (int)(dist/step);
+ max = static_cast<int>(dist/step);
if ( max == 0 ) max = 1;
distNoB2 = BM_DIM_STEP*sqrtf(2.0f)/sinf(stepAngle);
for ( i=0 ; i<max ; i++ )
@@ -2011,8 +1898,8 @@ bool CTaskGoto::BitmapTestLine(const Math::Vector &start, const Math::Vector &go
pos.z += inc.z;
}
- x = (int)((pos.x+1600.0f)/BM_DIM_STEP);
- y = (int)((pos.z+1600.0f)/BM_DIM_STEP);
+ x = static_cast<int>((pos.x+1600.0f)/BM_DIM_STEP);
+ y = static_cast<int>((pos.z+1600.0f)/BM_DIM_STEP);
if ( bSecond )
{
@@ -2043,17 +1930,17 @@ void CTaskGoto::BitmapObject()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( pObj == m_object ) continue;
if ( pObj == m_bmFretObject ) continue;
- if ( pObj->RetTruck() != 0 ) continue;
+ if ( pObj->GetTruck() != 0 ) continue;
- h = m_terrain->RetFloorLevel(pObj->RetPosition(0), false);
- if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f )
+ h = m_terrain->GetFloorLevel(pObj->GetPosition(0), false);
+ if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
{
h += m_altitude;
}
@@ -2061,7 +1948,7 @@ void CTaskGoto::BitmapObject()
j = 0;
while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
{
- if ( m_physics->RetType() == TYPE_FLYING && m_altitude > 0.0f ) // flying?
+ if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f ) // flying?
{
if ( oPos.y-oRadius > h+8.0f ||
oPos.y+oRadius < h-8.0f ) continue;
@@ -2083,10 +1970,10 @@ void CTaskGoto::BitmapTerrain(const Math::Vector &min, const Math::Vector &max)
{
int minx, miny, maxx, maxy;
- minx = (int)((min.x+1600.0f)/BM_DIM_STEP);
- miny = (int)((min.z+1600.0f)/BM_DIM_STEP);
- maxx = (int)((max.x+1600.0f)/BM_DIM_STEP);
- maxy = (int)((max.z+1600.0f)/BM_DIM_STEP);
+ minx = static_cast<int>((min.x+1600.0f)/BM_DIM_STEP);
+ miny = static_cast<int>((min.z+1600.0f)/BM_DIM_STEP);
+ maxx = static_cast<int>((max.x+1600.0f)/BM_DIM_STEP);
+ maxy = static_cast<int>((max.z+1600.0f)/BM_DIM_STEP);
BitmapTerrain(minx, miny, maxx, maxy);
}
@@ -2121,7 +2008,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
bAcceptWater = false;
bFly = false;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_MOBILEwa ||
type == OBJECT_MOBILEwc ||
@@ -2190,8 +2077,8 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
if ( bFly ) // flying robot?
{
- h = m_terrain->RetFloorLevel(p, true);
- if ( h >= m_terrain->RetFlyingMaxHeight()-5.0f )
+ h = m_terrain->GetFloorLevel(p, true);
+ if ( h >= m_terrain->GetFlyingMaxHeight()-5.0f )
{
BitmapSetDot(0, x, y);
}
@@ -2200,8 +2087,8 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
if ( !bAcceptWater ) // not going underwater?
{
- h = m_terrain->RetFloorLevel(p, true);
- if ( h < m_water->RetLevel()-2.0f ) // under water (*)?
+ h = m_terrain->GetFloorLevel(p, true);
+ if ( h < m_water->GetLevel()-2.0f ) // under water (*)?
{
//? BitmapSetDot(0, x, y);
BitmapSetCircle(p, BM_DIM_STEP*1.0f);
@@ -2209,7 +2096,7 @@ void CTaskGoto::BitmapTerrain(int minx, int miny, int maxx, int maxy)
}
}
- angle = m_terrain->RetFineSlope(p);
+ angle = m_terrain->GetFineSlope(p);
if ( angle > aLimit )
{
BitmapSetDot(0, x, y);
@@ -2231,9 +2118,9 @@ bool CTaskGoto::BitmapOpen()
{
BitmapClose();
- m_bmSize = (int)(3200.0f/BM_DIM_STEP);
- m_bmArray = (unsigned char*)malloc(m_bmSize*m_bmSize/8*2);
- ZeroMemory(m_bmArray, m_bmSize*m_bmSize/8*2);
+ m_bmSize = static_cast<int>(3200.0f/BM_DIM_STEP);
+ m_bmArray = static_cast<unsigned char*>(malloc(m_bmSize*m_bmSize/8*2));
+ memset(m_bmArray, 0, m_bmSize*m_bmSize/8*2);
m_bmOffset = m_bmSize/2;
m_bmLine = m_bmSize/8;
@@ -2262,15 +2149,15 @@ void CTaskGoto::BitmapSetCircle(const Math::Vector &pos, float radius)
float d, r;
int cx, cy, ix, iy;
- cx = (int)((pos.x+1600.0f)/BM_DIM_STEP);
- cy = (int)((pos.z+1600.0f)/BM_DIM_STEP);
+ cx = static_cast<int>((pos.x+1600.0f)/BM_DIM_STEP);
+ cy = static_cast<int>((pos.z+1600.0f)/BM_DIM_STEP);
r = radius/BM_DIM_STEP;
- for ( iy=cy-(int)r ; iy<=cy+(int)r ; iy++ )
+ for ( iy=cy-static_cast<int>(r) ; iy<=cy+static_cast<int>(r) ; iy++ )
{
- for ( ix=cx-(int)r ; ix<=cx+(int)r ; ix++ )
+ for ( ix=cx-static_cast<int>(r) ; ix<=cx+static_cast<int>(r) ; ix++ )
{
- d = Math::Point((float)(ix-cx), (float)(iy-cy)).Length();
+ d = Math::Point(static_cast<float>(ix-cx), static_cast<float>(iy-cy)).Length();
if ( d > r ) continue;
BitmapSetDot(0, ix, iy);
}
@@ -2278,21 +2165,21 @@ void CTaskGoto::BitmapSetCircle(const Math::Vector &pos, float radius)
}
// Removes a circle in the bitmap.
-
+//TODO this method is almost same as above one
void CTaskGoto::BitmapClearCircle(const Math::Vector &pos, float radius)
{
float d, r;
int cx, cy, ix, iy;
- cx = (int)((pos.x+1600.0f)/BM_DIM_STEP);
- cy = (int)((pos.z+1600.0f)/BM_DIM_STEP);
+ cx = static_cast<int>((pos.x+1600.0f)/BM_DIM_STEP);
+ cy = static_cast<int>((pos.z+1600.0f)/BM_DIM_STEP);
r = radius/BM_DIM_STEP;
- for ( iy=cy-(int)r ; iy<=cy+(int)r ; iy++ )
+ for ( iy=cy-static_cast<int>(r) ; iy<=cy+static_cast<int>(r) ; iy++ )
{
- for ( ix=cx-(int)r ; ix<=cx+(int)r ; ix++ )
+ for ( ix=cx-static_cast<int>(r) ; ix<=cx+static_cast<int>(r) ; ix++ )
{
- d = Math::Point((float)(ix-cx), (float)(iy-cy)).Length();
+ d = Math::Point(static_cast<float>(ix-cx), static_cast<float>(iy-cy)).Length();
if ( d > r ) continue;
BitmapClearDot(0, ix, iy);
}
diff --git a/src/object/task/taskgungoal.cpp b/src/object/task/taskgungoal.cpp
index e259ca8..aed3355 100644
--- a/src/object/task/taskgungoal.cpp
+++ b/src/object/task/taskgungoal.cpp
@@ -16,9 +16,6 @@
// taskgungoal.cpp
-
-#include <stdio.h>
-
#include "object/task/taskgungoal.h"
#include "object/object.h"
@@ -46,8 +43,8 @@ bool CTaskGunGoal::EventProcess(const Event &event)
{
float dir;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
@@ -82,9 +79,9 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
float speedV, speedH;
int i;
- m_initialDirV = m_object->RetGunGoalV();
+ m_initialDirV = m_object->GetGunGoalV();
m_object->SetGunGoalV(dirV);
- m_finalDirV = m_object->RetGunGoalV(); // possible direction
+ m_finalDirV = m_object->GetGunGoalV(); // possible direction
m_object->SetGunGoalV(m_initialDirV); // gives initial direction
if ( m_finalDirV == m_initialDirV )
@@ -96,9 +93,9 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
speedV = 1.0f/(fabs(m_finalDirV-m_initialDirV)*1.0f);
}
- m_initialDirH = m_object->RetGunGoalH();
+ m_initialDirH = m_object->GetGunGoalH();
m_object->SetGunGoalH(dirH);
- m_finalDirH = m_object->RetGunGoalH(); // possible direction
+ m_finalDirH = m_object->GetGunGoalH(); // possible direction
m_object->SetGunGoalH(m_initialDirH); // gives initial direction
if ( m_finalDirH == m_initialDirH )
@@ -115,7 +112,7 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
if ( m_finalDirV != m_initialDirV ||
m_finalDirH != m_initialDirH )
{
- i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.3f, 1.5f, true);
+ i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.3f, 1.5f, true);
m_sound->AddEnvelope(i, 0.3f, 1.5f, 1.0f/m_speed, SOPER_STOP);
}
@@ -128,7 +125,7 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
Error CTaskGunGoal::IsEnded()
{
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_initialDirV == m_finalDirV &&
m_initialDirH == m_finalDirH ) return ERR_STOP;
diff --git a/src/object/task/taskinfo.cpp b/src/object/task/taskinfo.cpp
index 6d1f486..4e64584 100644
--- a/src/object/task/taskinfo.cpp
+++ b/src/object/task/taskinfo.cpp
@@ -16,16 +16,13 @@
// taskinfo.cpp
-
-#include <stdio.h>
-
#include "object/task/taskinfo.h"
#include "common/iman.h"
-#include "old/particule.h"
+#include "graphics/engine/particle.h"
#include "object/auto/autoinfo.h"
-
+#include <string.h>
@@ -47,8 +44,8 @@ CTaskInfo::~CTaskInfo()
bool CTaskInfo::EventProcess(const Event &event)
{
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_progress += event.rTime*m_speed; // other advance
@@ -60,7 +57,7 @@ bool CTaskInfo::EventProcess(const Event &event)
// Assigns the goal was achieved.
-Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
+Error CTaskInfo::Start(const char *name, float value, float power, bool bSend)
{
CObject* pInfo;
CAutoInfo* pAuto;
@@ -77,7 +74,7 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
return ERR_INFO_NULL;
}
- pAuto = (CAutoInfo*)pInfo->RetAuto();
+ pAuto = static_cast<CAutoInfo*>(pInfo->GetAuto());
if ( pAuto == 0 )
{
return ERR_INFO_NULL;
@@ -86,10 +83,10 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
op = 1; // transmission impossible
if ( bSend ) // send?
{
- total = pInfo->RetInfoTotal();
+ total = pInfo->GetInfoTotal();
for ( i=0 ; i<total ; i++ )
{
- info = pInfo->RetInfo(i);
+ info = pInfo->GetInfo(i);
if ( strcmp(info.name, name) == 0 )
{
info.value = value;
@@ -114,10 +111,10 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
}
else // receive?
{
- total = pInfo->RetInfoTotal();
+ total = pInfo->GetInfoTotal();
for ( i=0 ; i<total ; i++ )
{
- info = pInfo->RetInfo(i);
+ info = pInfo->GetInfo(i);
if ( strcmp(info.name, name) == 0 )
{
m_object->SetInfoReturn(info.value);
@@ -134,19 +131,19 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
if ( op == 0 ) // transmission?
{
- pos = pInfo->RetPosition(0);
+ pos = pInfo->GetPosition(0);
pos.y += 9.5f;
- goal = m_object->RetPosition(0);
+ goal = m_object->GetPosition(0);
goal.y += 4.0f;
- m_particule->CreateRay(pos, goal, PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
+ m_particle->CreateRay(pos, goal, Gfx::PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
}
if ( op == 2 ) // reception?
{
- goal = pInfo->RetPosition(0);
+ goal = pInfo->GetPosition(0);
goal.y += 9.5f;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 4.0f;
- m_particule->CreateRay(pos, goal, PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
+ m_particle->CreateRay(pos, goal, Gfx::PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
}
m_progress = 0.0f;
@@ -162,7 +159,7 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
Error CTaskInfo::IsEnded()
{
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;
@@ -184,27 +181,27 @@ bool CTaskInfo::Abort()
CObject* CTaskInfo::SearchInfo(float power)
{
- CObject *pObj, *pBest;
- Math::Vector iPos, oPos;
- ObjectType type;
- float dist, min;
- int i;
+ CObject *pObj, *pBest;
+ Math::Vector iPos, oPos;
+ ObjectType type;
+ float dist, min;
+ int i;
- iPos = m_object->RetPosition(0);
+ iPos = m_object->GetPosition(0);
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_INFO ) continue;
- if ( !pObj->RetActif() ) continue;
+ if ( !pObj->GetActif() ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, iPos);
if ( dist > power ) continue; // too far?
if ( dist < min )
diff --git a/src/object/task/taskinfo.h b/src/object/task/taskinfo.h
index 21a4392..036b57d 100644
--- a/src/object/task/taskinfo.h
+++ b/src/object/task/taskinfo.h
@@ -31,7 +31,7 @@ public:
bool EventProcess(const Event &event);
- Error Start(char *name, float value, float power, bool bSend);
+ Error Start(const char *name, float value, float power, bool bSend);
Error IsEnded();
bool Abort();
diff --git a/src/object/task/taskmanager.cpp b/src/object/task/taskmanager.cpp
index d81fb5b..26e389d 100644
--- a/src/object/task/taskmanager.cpp
+++ b/src/object/task/taskmanager.cpp
@@ -67,7 +67,7 @@ CTaskManager::~CTaskManager()
Error CTaskManager::StartTaskWait(float time)
{
m_task = new CTaskWait(m_iMan, m_object);
- return ((CTaskWait*)m_task)->Start(time);
+ return (static_cast<CTaskWait*>(m_task))->Start(time);
}
// Advance straight ahead a certain distance.
@@ -75,7 +75,7 @@ Error CTaskManager::StartTaskWait(float time)
Error CTaskManager::StartTaskAdvance(float length)
{
m_task = new CTaskAdvance(m_iMan, m_object);
- return ((CTaskAdvance*)m_task)->Start(length);
+ return (static_cast<CTaskAdvance*>(m_task))->Start(length);
}
// Turns through an certain angle.
@@ -83,7 +83,7 @@ Error CTaskManager::StartTaskAdvance(float length)
Error CTaskManager::StartTaskTurn(float angle)
{
m_task = new CTaskTurn(m_iMan, m_object);
- return ((CTaskTurn*)m_task)->Start(angle);
+ return (static_cast<CTaskTurn*>(m_task))->Start(angle);
}
// Reaches a given position.
@@ -91,7 +91,7 @@ Error CTaskManager::StartTaskTurn(float angle)
Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal goalMode, TaskGotoCrash crashMode)
{
m_task = new CTaskGoto(m_iMan, m_object);
- return ((CTaskGoto*)m_task)->Start(pos, altitude, goalMode, crashMode);
+ return (static_cast<CTaskGoto*>(m_task))->Start(pos, altitude, goalMode, crashMode);
}
// Move the manipulator arm.
@@ -99,7 +99,7 @@ Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal
Error CTaskManager::StartTaskTake()
{
m_task = new CTaskTake(m_iMan, m_object);
- return ((CTaskTake*)m_task)->Start();
+ return (static_cast<CTaskTake*>(m_task))->Start();
}
// Move the manipulator arm.
@@ -107,7 +107,7 @@ Error CTaskManager::StartTaskTake()
Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
{
m_task = new CTaskManip(m_iMan, m_object);
- return ((CTaskManip*)m_task)->Start(order, arm);
+ return (static_cast<CTaskManip*>(m_task))->Start(order, arm);
}
// Puts or removes a flag.
@@ -115,7 +115,7 @@ Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank)
{
m_task = new CTaskFlag(m_iMan, m_object);
- return ((CTaskFlag*)m_task)->Start(order, rank);
+ return (static_cast<CTaskFlag*>(m_task))->Start(order, rank);
}
// Builds a building.
@@ -123,7 +123,7 @@ Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank)
Error CTaskManager::StartTaskBuild(ObjectType type)
{
m_task = new CTaskBuild(m_iMan, m_object);
- return ((CTaskBuild*)m_task)->Start(type);
+ return (static_cast<CTaskBuild*>(m_task))->Start(type);
}
// Probe the ground.
@@ -131,15 +131,15 @@ Error CTaskManager::StartTaskBuild(ObjectType type)
Error CTaskManager::StartTaskSearch()
{
m_task = new CTaskSearch(m_iMan, m_object);
- return ((CTaskSearch*)m_task)->Start();
+ return (static_cast<CTaskSearch*>(m_task))->Start();
}
// Reads an information terminal.
-Error CTaskManager::StartTaskInfo(char *name, float value, float power, bool bSend)
+Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bool bSend)
{
m_task = new CTaskInfo(m_iMan, m_object);
- return ((CTaskInfo*)m_task)->Start(name, value, power, bSend);
+ return (static_cast<CTaskInfo*>(m_task))->Start(name, value, power, bSend);
}
// Terraforms the ground.
@@ -147,7 +147,7 @@ Error CTaskManager::StartTaskInfo(char *name, float value, float power, bool bSe
Error CTaskManager::StartTaskTerraform()
{
m_task = new CTaskTerraform(m_iMan, m_object);
- return ((CTaskTerraform*)m_task)->Start();
+ return (static_cast<CTaskTerraform*>(m_task))->Start();
}
// Changes the pencil.
@@ -155,7 +155,7 @@ Error CTaskManager::StartTaskTerraform()
Error CTaskManager::StartTaskPen(bool bDown, int color)
{
m_task = new CTaskPen(m_iMan, m_object);
- return ((CTaskPen*)m_task)->Start(bDown, color);
+ return (static_cast<CTaskPen*>(m_task))->Start(bDown, color);
}
// Recovers a ruin.
@@ -163,7 +163,7 @@ Error CTaskManager::StartTaskPen(bool bDown, int color)
Error CTaskManager::StartTaskRecover()
{
m_task = new CTaskRecover(m_iMan, m_object);
- return ((CTaskRecover*)m_task)->Start();
+ return (static_cast<CTaskRecover*>(m_task))->Start();
}
// Deploys the shield.
@@ -173,15 +173,15 @@ Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay)
if ( mode == TSM_UP )
{
m_task = new CTaskShield(m_iMan, m_object);
- return ((CTaskShield*)m_task)->Start(mode, delay);
+ return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
}
if ( mode == TSM_DOWN && m_task != 0 )
{
- return ((CTaskShield*)m_task)->Start(mode, delay);
+ return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
}
if ( mode == TSM_UPDATE && m_task != 0 )
{
- return ((CTaskShield*)m_task)->Start(mode, delay);
+ return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
}
return ERR_GENERIC;
}
@@ -192,7 +192,7 @@ Error CTaskManager::StartTaskFire(float delay)
{
m_bPilot = true;
m_task = new CTaskFire(m_iMan, m_object);
- return ((CTaskFire*)m_task)->Start(delay);
+ return (static_cast<CTaskFire*>(m_task))->Start(delay);
}
// Shoots with the ant.
@@ -200,7 +200,7 @@ Error CTaskManager::StartTaskFire(float delay)
Error CTaskManager::StartTaskFireAnt(Math::Vector impact)
{
m_task = new CTaskFireAnt(m_iMan, m_object);
- return ((CTaskFireAnt*)m_task)->Start(impact);
+ return (static_cast<CTaskFireAnt*>(m_task))->Start(impact);
}
// Adjusts higher.
@@ -208,7 +208,7 @@ Error CTaskManager::StartTaskFireAnt(Math::Vector impact)
Error CTaskManager::StartTaskGunGoal(float dirV, float dirH)
{
m_task = new CTaskGunGoal(m_iMan, m_object);
- return ((CTaskGunGoal*)m_task)->Start(dirV, dirH);
+ return (static_cast<CTaskGunGoal*>(m_task))->Start(dirV, dirH);
}
// Suicide of the spider.
@@ -216,7 +216,7 @@ Error CTaskManager::StartTaskGunGoal(float dirV, float dirH)
Error CTaskManager::StartTaskSpiderExplo()
{
m_task = new CTaskSpiderExplo(m_iMan, m_object);
- return ((CTaskSpiderExplo*)m_task)->Start();
+ return (static_cast<CTaskSpiderExplo*>(m_task))->Start();
}
// Reset.
@@ -224,7 +224,7 @@ Error CTaskManager::StartTaskSpiderExplo()
Error CTaskManager::StartTaskReset(Math::Vector goal, Math::Vector angle)
{
m_task = new CTaskReset(m_iMan, m_object);
- return ((CTaskReset*)m_task)->Start(goal, angle);
+ return (static_cast<CTaskReset*>(m_task))->Start(goal, angle);
}
diff --git a/src/object/task/taskmanager.h b/src/object/task/taskmanager.h
index 14fc276..6ce023a 100644
--- a/src/object/task/taskmanager.h
+++ b/src/object/task/taskmanager.h
@@ -43,7 +43,7 @@ public:
Error StartTaskFlag(TaskFlagOrder order, int rank);
Error StartTaskBuild(ObjectType type);
Error StartTaskSearch();
- Error StartTaskInfo(char *name, float value, float power, bool bSend);
+ Error StartTaskInfo(const char *name, float value, float power, bool bSend);
Error StartTaskTerraform();
Error StartTaskPen(bool bDown, int color);
Error StartTaskRecover();
diff --git a/src/object/task/taskmanip.cpp b/src/object/task/taskmanip.cpp
index 456f274..b0b146c 100644
--- a/src/object/task/taskmanip.cpp
+++ b/src/object/task/taskmanip.cpp
@@ -16,14 +16,11 @@
// taskmanip.cpp
-
-#include <stdio.h>
-
#include "object/task/taskmanip.h"
#include "common/iman.h"
-#include "old/terrain.h"
-#include "old/pyro.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/pyro.h"
#include "math/geometry.h"
#include "object/robotmain.h"
#include "physics/physics.h"
@@ -65,8 +62,8 @@ bool CTaskManip::EventProcess(const Event &event)
float angle, a, g, cirSpeed, progress;
int i;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
if ( m_bBee ) // bee?
@@ -76,10 +73,10 @@ bool CTaskManip::EventProcess(const Event &event)
if ( m_bTurn ) // preliminary rotation?
{
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = m_angle;
cirSpeed = Math::Direction(a, g)*1.0f;
- if ( m_physics->RetType() == TYPE_FLYING ) // flying on the ground?
+ if ( m_physics->GetType() == TYPE_FLYING ) // flying on the ground?
{
cirSpeed *= 4.0f; // more fishing
}
@@ -107,23 +104,23 @@ bool CTaskManip::EventProcess(const Event &event)
{
if ( m_step == 0 ) // fall?
{
- pos = m_object->RetPosition(1);
+ pos = m_object->GetPosition(1);
pos.y = 3.0f-progress*2.0f;
m_object->SetPosition(1, pos);
}
if ( m_step == 1 ) // farm?
{
- pos = m_object->RetPosition(2);
+ pos = m_object->GetPosition(2);
pos.z = -1.5f+progress*0.5f;
m_object->SetPosition(2, pos);
- pos = m_object->RetPosition(3);
+ pos = m_object->GetPosition(3);
pos.z = 1.5f-progress*0.5f;
m_object->SetPosition(3, pos);
}
if ( m_step == 2 ) // up?
{
- pos = m_object->RetPosition(1);
+ pos = m_object->GetPosition(1);
pos.y = 3.0f-(1.0f-progress)*2.0f;
m_object->SetPosition(1, pos);
}
@@ -132,23 +129,23 @@ bool CTaskManip::EventProcess(const Event &event)
{
if ( m_step == 0 ) // fall?
{
- pos = m_object->RetPosition(1);
+ pos = m_object->GetPosition(1);
pos.y = 3.0f-progress*2.0f;
m_object->SetPosition(1, pos);
}
if ( m_step == 1 ) // farm?
{
- pos = m_object->RetPosition(2);
+ pos = m_object->GetPosition(2);
pos.z = -1.5f+(1.0f-progress)*0.5f;
m_object->SetPosition(2, pos);
- pos = m_object->RetPosition(3);
+ pos = m_object->GetPosition(3);
pos.z = 1.5f-(1.0f-progress)*0.5f;
m_object->SetPosition(3, pos);
}
if ( m_step == 2 ) // up?
{
- pos = m_object->RetPosition(1);
+ pos = m_object->GetPosition(1);
pos.y = 3.0f-(1.0f-progress)*2.0f;
m_object->SetPosition(1, pos);
}
@@ -238,7 +235,7 @@ void CTaskManip::InitAngle()
for ( i=0 ; i<5 ; i++ )
{
- m_initialAngle[i] = m_object->RetAngleZ(i+1);
+ m_initialAngle[i] = m_object->GetAngleZ(i+1);
}
max = 0.0f;
@@ -250,10 +247,10 @@ void CTaskManip::InitAngle()
if ( m_speed > 3.0f ) m_speed = 3.0f; // piano, ma non troppo (?)
energy = 0.0f;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
if ( energy == 0.0f )
@@ -288,12 +285,12 @@ bool TestFriend(ObjectType oType, ObjectType fType)
Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
{
- ObjectType type;
- CObject *front, *other, *power;
- CPyro *pyro;
- float iAngle, dist, len;
- float fDist, fAngle, oDist, oAngle, oHeight;
- Math::Vector pos, fPos, oPos;
+ ObjectType type;
+ CObject *front, *other, *power;
+ Gfx::CPyro *pyro;
+ float iAngle, dist, len;
+ float fDist, fAngle, oDist, oAngle, oHeight;
+ Math::Vector pos, fPos, oPos;
m_arm = arm;
m_height = 0.0f;
@@ -301,7 +298,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
m_progress = 0.0f;
m_speed = 1.0f/1.5f;
- iAngle = m_object->RetAngleY(0);
+ iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
oAngle = iAngle;
@@ -314,12 +311,12 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
m_physics->SetMotorSpeed(Math::Vector(0.0f, 0.0f, 0.0f));
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_BEE ) // bee?
{
- if ( m_object->RetFret() == 0 )
+ if ( m_object->GetFret() == 0 )
{
- if ( !m_physics->RetLand() ) return ERR_MANIP_FLY;
+ if ( !m_physics->GetLand() ) return ERR_MANIP_FLY;
other = SearchTakeUnderObject(m_targetPos, MARGIN_BEE);
if ( other == 0 ) return ERR_MANIP_NIL;
@@ -330,19 +327,19 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
else
{
- other = m_object->RetFret(); // other = ball
+ other = m_object->GetFret(); // other = ball
m_object->SetFret(0); // lick the ball
other->SetTruck(0);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y -= 3.0f;
other->SetPosition(0, pos);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y += 2.0f;
m_object->SetPosition(0, pos); // against the top of jump
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FALL, other); // the ball falls
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FALL, other); // the ball falls
}
m_bBee = true;
@@ -361,13 +358,13 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
m_energy = 0.0f;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- m_energy = power->RetEnergy();
+ m_energy = power->GetEnergy();
}
- if ( !m_physics->RetLand() ) return ERR_MANIP_FLY;
+ if ( !m_physics->GetLand() ) return ERR_MANIP_FLY;
if ( type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
@@ -385,7 +382,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
if ( order == TMO_AUTO )
{
- if ( m_object->RetFret() == 0 )
+ if ( m_object->GetFret() == 0 )
{
m_order = TMO_GRAB;
}
@@ -399,16 +396,16 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
m_order = order;
}
- if ( m_order == TMO_GRAB && m_object->RetFret() != 0 )
+ if ( m_order == TMO_GRAB && m_object->GetFret() != 0 )
{
return ERR_MANIP_BUSY;
}
- if ( m_order == TMO_DROP && m_object->RetFret() == 0 )
+ if ( m_order == TMO_DROP && m_object->GetFret() == 0 )
{
return ERR_MANIP_EMPTY;
}
-//? speed = m_physics->RetMotorSpeed();
+//? speed = m_physics->GetMotorSpeed();
//? if ( speed.x != 0.0f ||
//? speed.z != 0.0f ) return ERR_MANIP_MOTOR;
@@ -427,7 +424,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
else if ( other != 0 && oDist < fDist )
{
- if ( other->RetPower() == 0 ) return ERR_MANIP_NIL;
+ if ( other->GetPower() == 0 ) return ERR_MANIP_NIL;
m_targetPos = oPos;
m_angle = oAngle;
m_height = oHeight;
@@ -451,7 +448,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
if ( m_arm == TMA_POWER )
{
- if ( m_object->RetPower() == 0 ) return ERR_MANIP_NIL;
+ if ( m_object->GetPower() == 0 ) return ERR_MANIP_NIL;
}
}
@@ -460,7 +457,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
if ( m_arm == TMA_FFRONT )
{
other = SearchOtherObject(true, oPos, oDist, oAngle, oHeight);
- if ( other != 0 && other->RetPower() == 0 )
+ if ( other != 0 && other->GetPower() == 0 )
{
m_targetPos = oPos;
m_angle = oAngle;
@@ -479,27 +476,27 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
if ( m_arm == TMA_POWER )
{
- if ( m_object->RetPower() != 0 ) return ERR_MANIP_OCC;
+ if ( m_object->GetPower() != 0 ) return ERR_MANIP_OCC;
}
}
- dist = Math::Distance(m_object->RetPosition(0), m_targetPos);
+ dist = Math::Distance(m_object->GetPosition(0), m_targetPos);
len = dist-TAKE_DIST;
if ( m_arm == TMA_OTHER ) len -= TAKE_DIST_OTHER;
if ( len < 0.0f ) len = 0.0f;
if ( m_arm == TMA_FBACK ) len = -len;
- m_advanceLength = dist-m_physics->RetLinLength(len);
+ m_advanceLength = dist-m_physics->GetLinLength(len);
if ( dist <= m_advanceLength+0.2f ) m_move = 0.0f; // not necessary to advance
if ( m_energy == 0.0f ) m_move = 0.0f;
if ( m_move != 0.0f ) // forward or backward?
{
- m_timeLimit = m_physics->RetLinTimeLength(fabs(len))*1.5f;
+ m_timeLimit = m_physics->GetLinTimeLength(fabs(len))*1.5f;
if ( m_timeLimit < 0.5f ) m_timeLimit = 0.5f;
}
- if ( m_object->RetFret() == 0 ) // not carrying anything?
+ if ( m_object->GetFret() == 0 ) // not carrying anything?
{
m_hand = TMH_OPEN; // open clamp
}
@@ -540,7 +537,7 @@ Error CTaskManip::IsEnded()
float angle, dist;
int i;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_bBee ) // bee?
@@ -550,7 +547,7 @@ Error CTaskManip::IsEnded()
if ( m_bTurn ) // preliminary rotation?
{
- angle = m_object->RetAngleY(0);
+ angle = m_object->GetAngleY(0);
angle = Math::NormAngle(angle); // 0..2*Math::PI
if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) )
@@ -570,7 +567,7 @@ Error CTaskManip::IsEnded()
if ( m_timeLimit <= 0.0f )
{
//OK 1.9
- dist = Math::Distance(m_object->RetPosition(0), m_targetPos);
+ dist = Math::Distance(m_object->GetPosition(0), m_targetPos);
if ( dist <= m_advanceLength + 2.0f )
{
m_move = 0.0f; // advance ended
@@ -588,7 +585,7 @@ Error CTaskManip::IsEnded()
}
}
- dist = Math::Distance(m_object->RetPosition(0), m_targetPos);
+ dist = Math::Distance(m_object->GetPosition(0), m_targetPos);
if ( dist <= m_advanceLength )
{
m_move = 0.0f; // advance ended
@@ -624,7 +621,7 @@ Error CTaskManip::IsEnded()
{
if ( m_bSubm ) m_speed = 1.0f/1.5f;
if ( !TruckTakeObject() &&
- m_object->RetFret() == 0 )
+ m_object->GetFret() == 0 )
{
m_hand = TMH_OPEN; // reopens the clamp
m_arm = TMA_NEUTRAL;
@@ -638,7 +635,7 @@ Error CTaskManip::IsEnded()
(m_fretType == OBJECT_POWER ||
m_fretType == OBJECT_ATOMIC ) )
{
- m_sound->Play(SOUND_POWEROFF, m_object->RetPosition(0));
+ m_sound->Play(SOUND_POWEROFF, m_object->GetPosition(0));
}
m_arm = TMA_STOCK;
InitAngle();
@@ -653,7 +650,7 @@ Error CTaskManip::IsEnded()
if ( m_step == 1 )
{
if ( m_bSubm ) m_speed = 1.0f/0.7f;
- fret = m_object->RetFret();
+ fret = m_object->GetFret();
if ( TruckDeposeObject() )
{
if ( (m_arm == TMA_OTHER ||
@@ -661,7 +658,7 @@ Error CTaskManip::IsEnded()
(m_fretType == OBJECT_POWER ||
m_fretType == OBJECT_ATOMIC ) )
{
- m_sound->Play(SOUND_POWERON, m_object->RetPosition(0));
+ m_sound->Play(SOUND_POWERON, m_object->GetPosition(0));
}
if ( fret != 0 && m_fretType == OBJECT_METAL && m_arm == TMA_FFRONT )
{
@@ -693,7 +690,7 @@ bool CTaskManip::Abort()
{
int i;
- if ( m_object->RetFret() == 0 ) // not carrying anything?
+ if ( m_object->GetFret() == 0 ) // not carrying anything?
{
m_hand = TMH_OPEN; // open clamp
m_arm = TMA_NEUTRAL;
@@ -729,16 +726,16 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
float min, distance;
int i;
- iPos = m_object->RetPosition(0);
+ iPos = m_object->GetPosition(0);
min = 1000000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
@@ -754,11 +751,11 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
type != OBJECT_KEYd &&
type != OBJECT_TNT ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
- if ( pObj->RetLock() ) continue;
- if ( pObj->RetZoomY(0) != 1.0f ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
+ if ( pObj->GetLock() ) continue;
+ if ( pObj->GetZoomY(0) != 1.0f ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
distance = Math::Distance(oPos, iPos);
if ( distance <= dLimit &&
distance < min )
@@ -769,7 +766,7 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
}
if ( pBest != 0 )
{
- pos = pBest->RetPosition(0);
+ pos = pBest->GetPosition(0);
}
return pBest;
}
@@ -785,8 +782,8 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
float min, iAngle, bAngle, aLimit, dLimit, f;
int i;
- iPos = m_object->RetPosition(0);
- iAngle = m_object->RetAngleY(0);
+ iPos = m_object->GetPosition(0);
+ iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( bAdvance && m_energy > 0.0f )
@@ -806,10 +803,10 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
@@ -830,11 +827,11 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
type != OBJECT_SCRAP4 &&
type != OBJECT_SCRAP5 ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
- if ( pObj->RetLock() ) continue;
- if ( pObj->RetZoomY(0) != 1.0f ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
+ if ( pObj->GetLock() ) continue;
+ if ( pObj->GetZoomY(0) != 1.0f ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
distance = fabs(Math::Distance(oPos, iPos)-TAKE_DIST);
f = 1.0f-distance/50.0f;
if ( f < 0.5f ) f = 0.5f;
@@ -859,7 +856,7 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
}
else
{
- pos = pBest->RetPosition(0);
+ pos = pBest->GetPosition(0);
distance = min;
angle = bAngle;
}
@@ -877,8 +874,8 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
float min, iAngle, bAngle, aLimit, dLimit, f;
int i;
- iPos = m_object->RetPosition(0);
- iAngle = m_object->RetAngleY(0)+Math::PI;
+ iPos = m_object->GetPosition(0);
+ iAngle = m_object->GetAngleY(0)+Math::PI;
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( bAdvance && m_energy > 0.0f )
@@ -897,10 +894,10 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
@@ -921,11 +918,11 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
type != OBJECT_SCRAP4 &&
type != OBJECT_SCRAP5 ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
- if ( pObj->RetLock() ) continue;
- if ( pObj->RetZoomY(0) != 1.0f ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
+ if ( pObj->GetLock() ) continue;
+ if ( pObj->GetZoomY(0) != 1.0f ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
distance = fabs(Math::Distance(oPos, iPos)-TAKE_DIST);
f = 1.0f-distance/50.0f;
if ( f < 0.5f ) f = 0.5f;
@@ -950,7 +947,7 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
}
else
{
- pos = pBest->RetPosition(0);
+ pos = pBest->GetPosition(0);
distance = min;
angle = bAngle;
}
@@ -978,7 +975,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
if ( m_bSubm ) return 0; // impossible with the submarine
if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0;
- iAngle = m_object->RetAngleY(0);
+ iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( bAdvance && m_energy > 0.0f )
@@ -994,12 +991,12 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
type != OBJECT_MOBILEwa &&
@@ -1032,22 +1029,22 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
type != OBJECT_LABO &&
type != OBJECT_NUCLEAR ) continue;
- pPower = pObj->RetPower();
+ pPower = pObj->GetPower();
if ( pPower != 0 )
{
- if ( pPower->RetLock() ) continue;
- if ( pPower->RetZoomY(0) != 1.0f ) continue;
+ if ( pPower->GetLock() ) continue;
+ if ( pPower->GetZoomY(0) != 1.0f ) continue;
- powerType = pPower->RetType();
+ powerType = pPower->GetType();
if ( powerType == OBJECT_NULL ||
powerType == OBJECT_FIX ) continue;
}
- mat = pObj->RetWorldMatrix(0);
- character = pObj->RetCharacter();
+ mat = pObj->GetWorldMatrix(0);
+ character = pObj->GetCharacter();
oPos = Transform(*mat, character->posPower);
- oAngle = pObj->RetAngleY(0);
+ oAngle = pObj->GetAngleY(0);
if ( type == OBJECT_TOWER ||
type == OBJECT_RESEARCH )
{
@@ -1080,7 +1077,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
if ( Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
{
- character = pObj->RetCharacter();
+ character = pObj->GetCharacter();
height = character->posPower.y;
pos = oPos;
return pObj;
@@ -1105,12 +1102,12 @@ bool CTaskManip::TruckTakeObject()
if ( m_arm == TMA_GRAB ) // takes immediately?
{
- fret = m_object->RetFret();
+ fret = m_object->GetFret();
if ( fret == 0 ) return false; // nothing to take?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
- if ( m_object->RetType() == OBJECT_HUMAN ||
- m_object->RetType() == OBJECT_TECH )
+ if ( m_object->GetType() == OBJECT_HUMAN ||
+ m_object->GetType() == OBJECT_TECH )
{
fret->SetTruck(m_object);
fret->SetTruckPart(4); // takes with the hand
@@ -1150,7 +1147,7 @@ bool CTaskManip::TruckTakeObject()
{
fret = SearchTakeFrontObject(false, pos, dist, angle);
if ( fret == 0 ) return false; // nothing to take?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
if ( m_bSubm )
{
@@ -1182,7 +1179,7 @@ bool CTaskManip::TruckTakeObject()
{
fret = SearchTakeBackObject(false, pos, dist, angle);
if ( fret == 0 ) return false; // nothing to take?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
fret->SetTruck(m_object);
fret->SetTruckPart(3); // takes with the hand
@@ -1198,9 +1195,9 @@ bool CTaskManip::TruckTakeObject()
if ( m_arm == TMA_POWER ) // takes battery in the back?
{
- fret = m_object->RetPower();
+ fret = m_object->GetPower();
if ( fret == 0 ) return false; // no battery?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
pos = Math::Vector(4.7f, 0.0f, 0.0f); // relative to the hand (lem4)
fret->SetPosition(0, pos);
@@ -1218,9 +1215,9 @@ bool CTaskManip::TruckTakeObject()
other = SearchOtherObject(false, pos, dist, angle, m_height);
if ( other == 0 ) return false;
- fret = other->RetPower();
+ fret = other->GetPower();
if ( fret == 0 ) return false; // the other does not have a battery?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
other->SetPower(0);
fret->SetTruck(m_object);
@@ -1251,15 +1248,15 @@ bool CTaskManip::TruckDeposeObject()
if ( m_arm == TMA_FFRONT ) // deposits on the ground in front?
{
- fret = m_object->RetFret();
+ fret = m_object->GetFret();
if ( fret == 0 ) return false; // nothing transported?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
- mat = fret->RetWorldMatrix(0);
+ mat = fret->GetWorldMatrix(0);
pos = Transform(*mat, Math::Vector(0.0f, 1.0f, 0.0f));
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
fret->SetPosition(0, pos);
- fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f);
+ fret->SetAngleY(0, m_object->GetAngleY(0)+Math::PI/2.0f);
fret->SetAngleX(0, 0.0f);
fret->SetAngleZ(0, 0.0f);
fret->FloorAdjust(); // plate well on the ground
@@ -1270,15 +1267,15 @@ bool CTaskManip::TruckDeposeObject()
if ( m_arm == TMA_FBACK ) // deposited on the ground behind?
{
- fret = m_object->RetFret();
+ fret = m_object->GetFret();
if ( fret == 0 ) return false; // nothing transported?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
- mat = fret->RetWorldMatrix(0);
+ mat = fret->GetWorldMatrix(0);
pos = Transform(*mat, Math::Vector(0.0f, 1.0f, 0.0f));
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
fret->SetPosition(0, pos);
- fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f);
+ fret->SetAngleY(0, m_object->GetAngleY(0)+Math::PI/2.0f);
fret->SetAngleX(0, 0.0f);
fret->SetAngleZ(0, 0.0f);
@@ -1288,16 +1285,16 @@ bool CTaskManip::TruckDeposeObject()
if ( m_arm == TMA_POWER ) // deposits battery in the back?
{
- fret = m_object->RetFret();
+ fret = m_object->GetFret();
if ( fret == 0 ) return false; // nothing transported?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
- if ( m_object->RetPower() != 0 ) return false;
+ if ( m_object->GetPower() != 0 ) return false;
fret->SetTruck(m_object);
fret->SetTruckPart(0); // carried by the base
- character = m_object->RetCharacter();
+ character = m_object->GetCharacter();
fret->SetPosition(0, character->posPower);
fret->SetAngleY(0, 0.0f);
fret->SetAngleX(0, 0.0f);
@@ -1312,17 +1309,17 @@ bool CTaskManip::TruckDeposeObject()
other = SearchOtherObject(false, pos, dist, angle, m_height);
if ( other == 0 ) return false;
- fret = other->RetPower();
+ fret = other->GetPower();
if ( fret != 0 ) return false; // the other already has a battery?
- fret = m_object->RetFret();
+ fret = m_object->GetFret();
if ( fret == 0 ) return false;
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
other->SetPower(fret);
fret->SetTruck(other);
- character = other->RetCharacter();
+ character = other->GetCharacter();
fret->SetPosition(0, character->posPower);
fret->SetAngleY(0, 0.0f);
fret->SetAngleX(0, 0.0f);
@@ -1345,17 +1342,17 @@ bool CTaskManip::IsFreeDeposeObject(Math::Vector pos)
float oRadius;
int i, j;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
iPos = Transform(*mat, pos);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
- if ( !pObj->RetActif() ) continue; // inactive?
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue; // inactive?
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
j = 0;
while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
@@ -1375,7 +1372,7 @@ void CTaskManip::SoundManip(float time, float amplitude, float frequency)
{
int i;
- i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f*frequency, true);
+ i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f*frequency, true);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, 0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, time-0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.3f*frequency, 0.1f, SOPER_STOP);
diff --git a/src/object/task/taskpen.cpp b/src/object/task/taskpen.cpp
index c3a9aef..6e04233 100644
--- a/src/object/task/taskpen.cpp
+++ b/src/object/task/taskpen.cpp
@@ -16,12 +16,9 @@
// taskpen.cpp
-
-#include <stdio.h>
-
#include "object/task/taskpen.h"
-#include "old/particule.h"
+#include "graphics/engine/particle.h"
#include "math/geometry.h"
#include "object/object.h"
@@ -49,8 +46,8 @@ bool CTaskPen::EventProcess(const Event &event)
Math::Point dim;
int i;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
if ( m_delay == 0.0f )
@@ -67,17 +64,17 @@ bool CTaskPen::EventProcess(const Event &event)
if ( m_phase == TPP_UP ) // back the pencil
{
- i = AngleToRank(m_object->RetAngleY(1));
- pos = m_object->RetPosition(10+i);
+ i = AngleToRank(m_object->GetAngleY(1));
+ pos = m_object->GetPosition(10+i);
pos.y = -3.2f*(1.0f-m_progress);
m_object->SetPosition(10+i, pos);
}
if ( m_phase == TPP_TURN ) // turns the carousel?
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_supportPos;
pos.x += (Math::Rand()-0.5f)*5.0f;
@@ -87,7 +84,7 @@ bool CTaskPen::EventProcess(const Event &event)
speed.y = Math::Rand()*2.0f;
dim.x = Math::Rand()*1.5f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f);
}
m_object->SetAngleY(1, m_oldAngle+(m_newAngle-m_oldAngle)*m_progress);
@@ -95,9 +92,9 @@ bool CTaskPen::EventProcess(const Event &event)
if ( m_phase == TPP_DOWN ) // down the pencil?
{
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_supportPos;
pos.x += (Math::Rand()-0.5f)*5.0f;
@@ -107,11 +104,11 @@ bool CTaskPen::EventProcess(const Event &event)
speed.y = Math::Rand()*5.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIVAPOR, 4.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIVAPOR, 4.0f);
}
- i = AngleToRank(m_object->RetAngleY(1));
- pos = m_object->RetPosition(10+i);
+ i = AngleToRank(m_object->GetAngleY(1));
+ pos = m_object->GetPosition(10+i);
if ( m_timeDown == 0.0f )
{
pos.y = 0.0f;
@@ -138,16 +135,16 @@ Error CTaskPen::Start(bool bDown, int color)
m_bError = true; // operation impossible
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type != OBJECT_MOBILEdr ) return ERR_FIRE_VEH;
m_bError = false; // ok
- m_oldAngle = m_object->RetAngleY(1);
+ m_oldAngle = m_object->GetAngleY(1);
m_newAngle = ColorToAngle(color);
i = AngleToRank(m_oldAngle);
- pos = m_object->RetPosition(10+i);
+ pos = m_object->GetPosition(10+i);
if ( pos.y == 0.0f ) // pencil at the top?
{
@@ -167,7 +164,7 @@ Error CTaskPen::Start(bool bDown, int color)
m_timeDown = 0.0f;
}
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(-3.0f, 7.0f, 0.0f);
pos = Math::Transform(*mat, pos); // position of carousel
m_supportPos = pos;
@@ -182,7 +179,7 @@ Error CTaskPen::Start(bool bDown, int color)
SoundManip(m_timeUp, 1.0f, 0.5f);
}
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
//? m_camera->StartCentering(m_object, Math::PI*0.60f, 99.9f, 5.0f, 0.5f);
@@ -193,7 +190,7 @@ Error CTaskPen::Start(bool bDown, int color)
Error CTaskPen::IsEnded()
{
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;
@@ -205,7 +202,7 @@ Error CTaskPen::IsEnded()
m_progress = 0.0f;
m_delay = fabs(m_oldAngle-m_newAngle)/Math::PI;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
if ( m_delay > 0.0f )
{
SoundManip(m_delay, 1.0f, 1.0f);
@@ -220,7 +217,7 @@ Error CTaskPen::IsEnded()
m_progress = 0.0f;
m_delay = m_timeDown;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
return ERR_CONTINUE;
}
@@ -243,7 +240,7 @@ void CTaskPen::SoundManip(float time, float amplitude, float frequency)
{
int i;
- i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f*frequency, true);
+ i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f*frequency, true);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, 0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, time-0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.3f*frequency, 0.1f, SOPER_STOP);
@@ -257,7 +254,7 @@ int CTaskPen::AngleToRank(float angle)
//? return (int)(angle/(-45.0f*Math::PI/180.0f));
angle = -angle;
angle += (45.0f*Math::PI/180.0f)/2.0f;
- return (int)(angle/(45.0f*Math::PI/180.0f));
+ return static_cast<int>(angle/(45.0f*Math::PI/180.0f));
}
// Converting a color to the angle of carousel of pencils.
diff --git a/src/object/task/taskpen.h b/src/object/task/taskpen.h
index b41c513..0974322 100644
--- a/src/object/task/taskpen.h
+++ b/src/object/task/taskpen.h
@@ -57,8 +57,8 @@ protected:
float m_progress;
float m_delay;
float m_time;
- float m_lastParticule;
- Math::Vector m_supportPos;
+ float m_lastParticle;
+ Math::Vector m_supportPos;
float m_timeUp;
float m_oldAngle;
diff --git a/src/object/task/taskrecover.cpp b/src/object/task/taskrecover.cpp
index 02cefb8..4c8ead8 100644
--- a/src/object/task/taskrecover.cpp
+++ b/src/object/task/taskrecover.cpp
@@ -23,7 +23,7 @@
#include "math/geometry.h"
#include "common/iman.h"
-#include "old/particule.h"
+#include "graphics/engine/particle.h"
#include "physics/physics.h"
#include "ui/displaytext.h"
@@ -58,13 +58,13 @@ bool CTaskRecover::EventProcess(const Event &event)
Math::Point dim;
float a, g, cirSpeed, angle, energy, dist, linSpeed;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
if ( m_phase == TRP_TURN ) // preliminary rotation?
{
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = m_angle;
cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
@@ -90,7 +90,7 @@ bool CTaskRecover::EventProcess(const Event &event)
if ( m_phase == TRP_MOVE ) // preliminary forward/backward?
{
- dist = Math::Distance(m_object->RetPosition(0), m_ruin->RetPosition(0));
+ dist = Math::Distance(m_object->GetPosition(0), m_ruin->GetPosition(0));
linSpeed = 0.0f;
if ( dist > RECOVER_DIST ) linSpeed = 1.0f;
if ( dist < RECOVER_DIST ) linSpeed = -1.0f;
@@ -100,10 +100,10 @@ bool CTaskRecover::EventProcess(const Event &event)
if ( m_phase == TRP_OPER )
{
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
power->SetEnergy(energy-ENERGY_RECOVER*event.rTime*m_speed);
}
@@ -122,9 +122,9 @@ bool CTaskRecover::EventProcess(const Event &event)
m_metal->SetZoom(0, (m_progress-0.5f)/0.3f);
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.02f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.02f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_recoverPos;
pos.x += (Math::Rand()-0.5f)*8.0f*(1.0f-m_progress);
@@ -135,7 +135,7 @@ bool CTaskRecover::EventProcess(const Event &event)
speed.y = Math::Rand()*15.0f;
dim.x = Math::Rand()*2.0f+1.5f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIRECOVER, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIRECOVER, 1.0f, 0.0f, 0.0f);
}
}
@@ -149,9 +149,9 @@ bool CTaskRecover::EventProcess(const Event &event)
m_object->SetAngleZ(3, angle);
m_object->SetAngleZ(5, angle);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.02f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.02f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_recoverPos;
pos.y -= 4.0f;
@@ -160,7 +160,7 @@ bool CTaskRecover::EventProcess(const Event &event)
speed.y = Math::Rand()*15.0f;
dim.x = Math::Rand()*2.0f+1.5f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIRECOVER, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIRECOVER, 1.0f, 0.0f, 0.0f);
}
}
@@ -180,17 +180,17 @@ Error CTaskRecover::Start()
ObjectType type;
m_bError = true; // operation impossible
- if ( !m_physics->RetLand() ) return ERR_RECOVER_VEH;
+ if ( !m_physics->GetLand() ) return ERR_RECOVER_VEH;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type != OBJECT_MOBILErr ) return ERR_RECOVER_VEH;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 ) return ERR_RECOVER_ENERGY;
- energy = power->RetEnergy();
- if ( energy < ENERGY_RECOVER/power->RetCapacity()+0.05f ) return ERR_RECOVER_ENERGY;
+ energy = power->GetEnergy();
+ if ( energy < ENERGY_RECOVER/power->GetCapacity()+0.05f ) return ERR_RECOVER_ENERGY;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(RECOVER_DIST, 3.3f, 0.0f);
pos = Transform(*mat, pos); // position in front
m_recoverPos = pos;
@@ -199,8 +199,8 @@ Error CTaskRecover::Start()
if ( m_ruin == 0 ) return ERR_RECOVER_NULL;
m_ruin->SetLock(true); // ruin no longer usable
- iPos = m_object->RetPosition(0);
- oPos = m_ruin->RetPosition(0);
+ iPos = m_object->GetPosition(0);
+ oPos = m_ruin->GetPosition(0);
m_angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
m_metal = 0;
@@ -209,7 +209,7 @@ Error CTaskRecover::Start()
m_progress = 0.0f;
m_speed = 1.0f/1.0f;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_bError = false; // ok
@@ -227,27 +227,27 @@ Error CTaskRecover::IsEnded()
float angle, dist, time;
int i;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_phase == TRP_TURN ) // preliminary rotation?
{
- angle = m_object->RetAngleY(0);
+ angle = m_object->GetAngleY(0);
angle = Math::NormAngle(angle); // 0..2*Math::PI
if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) )
{
m_physics->SetMotorSpeedZ(0.0f);
- dist = Math::Distance(m_object->RetPosition(0), m_ruin->RetPosition(0));
+ dist = Math::Distance(m_object->GetPosition(0), m_ruin->GetPosition(0));
if ( dist > RECOVER_DIST )
{
- time = m_physics->RetLinTimeLength(dist-RECOVER_DIST, 1.0f);
+ time = m_physics->GetLinTimeLength(dist-RECOVER_DIST, 1.0f);
m_speed = 1.0f/time;
}
else
{
- time = m_physics->RetLinTimeLength(RECOVER_DIST-dist, -1.0f);
+ time = m_physics->GetLinTimeLength(RECOVER_DIST-dist, -1.0f);
m_speed = 1.0f/time;
}
m_phase = TRP_MOVE;
@@ -258,19 +258,19 @@ Error CTaskRecover::IsEnded()
if ( m_phase == TRP_MOVE ) // preliminary advance?
{
- dist = Math::Distance(m_object->RetPosition(0), m_ruin->RetPosition(0));
+ dist = Math::Distance(m_object->GetPosition(0), m_ruin->GetPosition(0));
if ( dist >= RECOVER_DIST-1.0f &&
dist <= RECOVER_DIST+1.0f )
{
m_physics->SetMotorSpeedX(0.0f);
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(RECOVER_DIST, 3.3f, 0.0f);
pos = Transform(*mat, pos); // position in front
m_recoverPos = pos;
- i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.9f, true);
+ i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.9f, true);
m_sound->AddEnvelope(i, 1.0f, 1.5f, 0.3f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 1.0f, 1.5f, 1.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.9f, 0.3f, SOPER_STOP);
@@ -310,15 +310,15 @@ Error CTaskRecover::IsEnded()
m_metal->SetLock(true); // metal not yet usable
m_metal->SetZoom(0, 0.0f);
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(RECOVER_DIST, 3.1f, 3.9f);
pos = Transform(*mat, pos);
goal = Math::Vector(RECOVER_DIST, 3.1f, -3.9f);
goal = Transform(*mat, goal);
- m_particule->CreateRay(pos, goal, PARTIRAY2,
+ m_particle->CreateRay(pos, goal, Gfx::PARTIRAY2,
Math::Point(2.0f, 2.0f), 8.0f);
- m_soundChannel = m_sound->Play(SOUND_RECOVER, m_ruin->RetPosition(0), 0.0f, 1.0f, true);
+ m_soundChannel = m_sound->Play(SOUND_RECOVER, m_ruin->GetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_soundChannel, 0.6f, 1.0f, 2.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.6f, 1.0f, 4.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.7f, 2.0f, SOPER_STOP);
@@ -338,7 +338,7 @@ Error CTaskRecover::IsEnded()
m_soundChannel = -1;
- i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.9f, true);
+ i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.9f, true);
m_sound->AddEnvelope(i, 1.0f, 1.5f, 0.3f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 1.0f, 1.5f, 1.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.9f, 0.3f, SOPER_STOP);
@@ -389,10 +389,10 @@ CObject* CTaskRecover::SearchRuin()
min = 100000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_RUINmobilew1 ||
type == OBJECT_RUINmobilew2 ||
type == OBJECT_RUINmobilet1 ||
@@ -400,7 +400,7 @@ CObject* CTaskRecover::SearchRuin()
type == OBJECT_RUINmobiler1 ||
type == OBJECT_RUINmobiler2 ) // vehicle in ruin?
{
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, m_recoverPos);
if ( dist > 40.0f ) continue;
diff --git a/src/object/task/taskrecover.h b/src/object/task/taskrecover.h
index 8af6353..151ab6b 100644
--- a/src/object/task/taskrecover.h
+++ b/src/object/task/taskrecover.h
@@ -56,11 +56,11 @@ protected:
float m_speed;
float m_time;
float m_angle;
- float m_lastParticule;
+ float m_lastParticle;
bool m_bError;
CObject* m_ruin;
CObject* m_metal;
- Math::Vector m_recoverPos;
+ Math::Vector m_recoverPos;
int m_soundChannel;
};
diff --git a/src/object/task/taskreset.cpp b/src/object/task/taskreset.cpp
index 2366fea..7e097bf 100644
--- a/src/object/task/taskreset.cpp
+++ b/src/object/task/taskreset.cpp
@@ -16,9 +16,6 @@
// taskreset.cpp
-
-#include <stdio.h>
-
#include "object/task/taskreset.h"
#include "common/iman.h"
@@ -55,8 +52,8 @@ bool CTaskReset::EventProcess(const Event &event)
Math::Point dim;
float angle, duration;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_time += event.rTime;
@@ -69,9 +66,9 @@ bool CTaskReset::EventProcess(const Event &event)
m_object->SetAngleY(0, angle);
m_object->SetZoom(0, 1.0f-m_progress);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_begin;
pos.x += (Math::Rand()-0.5f)*5.0f;
@@ -81,7 +78,7 @@ bool CTaskReset::EventProcess(const Event &event)
speed.y = 5.0f+Math::Rand()*5.0f;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f);
pos = m_begin;
speed.x = (Math::Rand()-0.5f)*20.0f;
@@ -94,7 +91,7 @@ bool CTaskReset::EventProcess(const Event &event)
dim.y = dim.x;
pos.y += dim.y;
duration = Math::Rand()*1.5f+1.5f;
- m_particule->CreateTrack(pos, speed, dim, PARTITRACK6,
+ m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
duration, 0.0f,
duration*0.9f, 0.7f);
}
@@ -105,9 +102,9 @@ bool CTaskReset::EventProcess(const Event &event)
pos = m_begin+(m_goal-m_begin)*m_progress;
m_object->SetPosition(0, pos);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos.x += (Math::Rand()-0.5f)*5.0f;
pos.z += (Math::Rand()-0.5f)*5.0f;
@@ -116,7 +113,7 @@ bool CTaskReset::EventProcess(const Event &event)
speed.y = 2.0f+Math::Rand()*2.0f;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f);
}
}
@@ -127,9 +124,9 @@ bool CTaskReset::EventProcess(const Event &event)
m_object->SetAngleY(0, angle);
m_object->SetZoom(0, m_progress);
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_goal;
pos.x += (Math::Rand()-0.5f)*5.0f;
@@ -139,7 +136,7 @@ bool CTaskReset::EventProcess(const Event &event)
speed.y = 5.0f+Math::Rand()*5.0f;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f);
pos = m_goal;
speed.x = (Math::Rand()-0.5f)*20.0f;
@@ -150,7 +147,7 @@ bool CTaskReset::EventProcess(const Event &event)
dim.y = dim.x;
pos.y += dim.y;
duration = Math::Rand()*1.5f+1.5f;
- m_particule->CreateTrack(pos, speed, dim, PARTITRACK6,
+ m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
duration, 0.0f,
duration*0.9f, 0.7f);
}
@@ -168,24 +165,24 @@ Error CTaskReset::Start(Math::Vector goal, Math::Vector angle)
CObject* fret;
int i;
- fret = m_object->RetFret();
- if ( fret != 0 && fret->RetResetCap() == RESET_MOVE )
+ fret = m_object->GetFret();
+ if ( fret != 0 && fret->GetResetCap() == RESET_MOVE )
{
fret->SetTruck(0);
m_object->SetFret(0); // does nothing
}
- if ( !m_main->RetNiceReset() ) // quick return?
+ if ( !m_main->GetNiceReset() ) // quick return?
{
m_object->SetPosition(0, goal);
m_object->SetAngle(0, angle);
- m_brain->RunProgram(m_object->RetResetRun());
+ m_brain->RunProgram(m_object->GetResetRun());
m_bError = false;
return ERR_OK;
}
- m_begin = m_object->RetPosition(0);
+ m_begin = m_object->GetPosition(0);
m_goal = goal;
m_angle = angle;
@@ -195,12 +192,12 @@ Error CTaskReset::Start(Math::Vector goal, Math::Vector angle)
return ERR_RESET_NEAR;
}
- m_iAngle = m_object->RetAngleY(0);
+ m_iAngle = m_object->GetAngleY(0);
m_time = 0.0f;
m_phase = TRSP_ZOUT;
m_speed = 1.0f/RESET_DELAY_ZOOM;
m_progress = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_object->SetResetBusy(true);
@@ -219,12 +216,12 @@ Error CTaskReset::IsEnded()
float dist;
int i;
- if ( !m_main->RetNiceReset() ) // quick return?
+ if ( !m_main->GetNiceReset() ) // quick return?
{
return ERR_STOP;
}
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;
@@ -254,13 +251,13 @@ Error CTaskReset::IsEnded()
m_object->SetAngle(0, m_angle);
m_object->SetZoom(0, 1.0f);
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- power->SetEnergy(power->RetCapacity()); // refueling
+ power->SetEnergy(power->GetCapacity()); // refueling
}
- m_brain->RunProgram(m_object->RetResetRun());
+ m_brain->RunProgram(m_object->GetResetRun());
m_object->SetResetBusy(false);
return ERR_STOP;
}
@@ -278,12 +275,12 @@ bool CTaskReset::SearchVehicle()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_HUMAN &&
type != OBJECT_TECH &&
type != OBJECT_MOBILEfa &&
diff --git a/src/object/task/taskreset.h b/src/object/task/taskreset.h
index 17a4441..e3dacf7 100644
--- a/src/object/task/taskreset.h
+++ b/src/object/task/taskreset.h
@@ -57,7 +57,7 @@ protected:
float m_time;
float m_speed;
float m_progress;
- float m_lastParticule; // time of generation last particle
+ float m_lastParticle; // time of generation last particle
float m_iAngle;
};
diff --git a/src/object/task/tasksearch.cpp b/src/object/task/tasksearch.cpp
index 8c083dd..578b41e 100644
--- a/src/object/task/tasksearch.cpp
+++ b/src/object/task/tasksearch.cpp
@@ -16,15 +16,12 @@
// tasksearch.cpp
-
-#include <stdio.h>
-
#include "object/task/tasksearch.h"
#include "math/geometry.h"
#include "common/iman.h"
-#include "old/particule.h"
-#include "old/terrain.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/terrain.h"
#include "physics/physics.h"
#include "ui/displaytext.h"
@@ -56,8 +53,8 @@ bool CTaskSearch::EventProcess(const Event &event)
float angle;
int i;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_progress += event.rTime*m_speed; // others advance
@@ -75,11 +72,11 @@ bool CTaskSearch::EventProcess(const Event &event)
}
if ( m_phase == TSP_SEARCH &&
- m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(6.5f, 0.2f, 0.0f);
pos = Math::Transform(*mat, pos); // sensor position
@@ -88,7 +85,7 @@ bool CTaskSearch::EventProcess(const Event &event)
speed.y = 0.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIGAS);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGAS);
}
return true;
@@ -116,7 +113,7 @@ void CTaskSearch::InitAngle()
for ( i=0 ; i<3 ; i++ )
{
- m_initialAngle[i] = m_object->RetAngleZ(i+1);
+ m_initialAngle[i] = m_object->GetAngleZ(i+1);
}
}
@@ -130,13 +127,13 @@ Error CTaskSearch::Start()
int i;
m_bError = true;
- if ( !m_physics->RetLand() ) return ERR_SEARCH_FLY;
+ if ( !m_physics->GetLand() ) return ERR_SEARCH_FLY;
- speed = m_physics->RetMotorSpeed();
+ speed = m_physics->GetMotorSpeed();
if ( speed.x != 0.0f ||
speed.z != 0.0f ) return ERR_SEARCH_MOTOR;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type != OBJECT_MOBILEfs &&
type != OBJECT_MOBILEts &&
type != OBJECT_MOBILEws &&
@@ -147,14 +144,14 @@ Error CTaskSearch::Start()
m_progress = 0.0f;
m_speed = 1.0f/1.0f;
m_time = 0.0f;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
InitAngle();
m_bError = false; // ok
m_camera->StartCentering(m_object, Math::PI*0.50f, 99.9f, 0.0f, 1.0f);
- i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f, true);
+ i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f, true);
m_sound->AddEnvelope(i, 0.5f, 1.0f, 0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.5f, 1.0f, 0.9f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.3f, 0.1f, SOPER_STOP);
@@ -170,7 +167,7 @@ Error CTaskSearch::IsEnded()
{
int i;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;
@@ -187,7 +184,7 @@ Error CTaskSearch::IsEnded()
if ( m_phase == TSP_DOWN )
{
- m_sound->Play(SOUND_REPAIR, m_object->RetPosition(0));
+ m_sound->Play(SOUND_REPAIR, m_object->GetPosition(0));
m_phase = TSP_SEARCH;
m_speed = 1.0f/4.0f;
@@ -201,7 +198,7 @@ Error CTaskSearch::IsEnded()
m_hand = TSH_UP;
InitAngle();
- i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f, true);
+ i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f, true);
m_sound->AddEnvelope(i, 0.5f, 1.0f, 0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.5f, 1.0f, 0.9f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.3f, 0.1f, SOPER_STOP);
@@ -229,52 +226,52 @@ bool CTaskSearch::Abort()
bool CTaskSearch::CreateMark()
{
- CObject* fret;
- ObjectType type;
+ CObject* fret;
+ ObjectType type;
Math::Matrix* mat;
Math::Vector pos;
- TerrainRes res;
- Error info;
+ Gfx::TerrainRes res;
+ Error info;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(7.5f, 0.0f, 0.0f);
pos = Math::Transform(*mat, pos); // sensor position
- res = m_terrain->RetResource(pos);
- if ( res == TR_NULL ) return false;
+ res = m_terrain->GetResource(pos);
+ if ( res == Gfx::TR_NULL ) return false;
type = OBJECT_NULL;
- if ( res == TR_STONE )
+ if ( res == Gfx::TR_STONE )
{
type = OBJECT_MARKSTONE;
info = INFO_MARKSTONE;
}
- if ( res == TR_URANIUM )
+ if ( res == Gfx::TR_URANIUM )
{
type = OBJECT_MARKURANIUM;
info = INFO_MARKURANIUM;
}
- if ( res == TR_POWER )
+ if ( res == Gfx::TR_POWER )
{
type = OBJECT_MARKPOWER;
info = INFO_MARKPOWER;
}
- if ( res == TR_KEYa )
+ if ( res == Gfx::TR_KEY_A )
{
type = OBJECT_MARKKEYa;
info = INFO_MARKKEYa;
}
- if ( res == TR_KEYb )
+ if ( res == Gfx::TR_KEY_B )
{
type = OBJECT_MARKKEYb;
info = INFO_MARKKEYb;
}
- if ( res == TR_KEYc )
+ if ( res == Gfx::TR_KEY_C )
{
type = OBJECT_MARKKEYc;
info = INFO_MARKKEYc;
}
- if ( res == TR_KEYd )
+ if ( res == Gfx::TR_KEY_D )
{
type = OBJECT_MARKKEYd;
info = INFO_MARKKEYd;
@@ -306,10 +303,10 @@ void CTaskSearch::DeleteMark(ObjectType type)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( type == pObj->RetType() )
+ if ( type == pObj->GetType() )
{
pObj->DeleteObject(); // removes the mark
delete pObj;
diff --git a/src/object/task/tasksearch.h b/src/object/task/tasksearch.h
index 304473d..bffec16 100644
--- a/src/object/task/tasksearch.h
+++ b/src/object/task/tasksearch.h
@@ -62,7 +62,7 @@ protected:
float m_progress;
float m_speed;
float m_time;
- float m_lastParticule;
+ float m_lastParticle;
float m_initialAngle[3];
float m_finalAngle[3];
bool m_bError;
diff --git a/src/object/task/taskshield.cpp b/src/object/task/taskshield.cpp
index aa62f7b..682bcb1 100644
--- a/src/object/task/taskshield.cpp
+++ b/src/object/task/taskshield.cpp
@@ -16,18 +16,17 @@
// taskshield.cpp
-
-#include <stdio.h>
-
#include "object/task/taskshield.h"
#include "common/iman.h"
-#include "old/light.h"
-#include "old/particule.h"
+#include "graphics/core/light.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/lightman.h"
#include "math/geometry.h"
#include "object/brain.h"
#include "physics/physics.h"
+#include <string.h>
const float ENERGY_TIME = 20.0f; // maximum duration if full battery
@@ -56,32 +55,32 @@ CTaskShield::~CTaskShield()
bool CTaskShield::EventProcess(const Event &event)
{
CObject* power;
- Math::Matrix* mat;
- Math::Matrix matrix;
- Math::Vector pos, speed, goal, angle;
- D3DCOLORVALUE color;
- Math::Point dim;
+ Math::Matrix* mat;
+ Math::Matrix matrix;
+ Math::Vector pos, speed, goal, angle;
+ Gfx::Color color;
+ Math::Point dim;
float energy;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_progress += event.rTime*m_speed; // others advance
m_time += event.rTime;
m_delay -= event.rTime;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(7.0f, 15.0f, 0.0f);
pos = Math::Transform(*mat, pos); // sphere position
m_shieldPos = pos;
if ( m_rankSphere != -1 )
{
- m_particule->SetPosition(m_rankSphere, m_shieldPos);
- dim.x = RetRadius();
+ m_particle->SetPosition(m_rankSphere, m_shieldPos);
+ dim.x = GetRadius();
dim.y = dim.x;
- m_particule->SetDimension(m_rankSphere, dim);
+ m_particle->SetDimension(m_rankSphere, dim);
}
if ( m_phase == TS_UP1 )
@@ -103,11 +102,11 @@ bool CTaskShield::EventProcess(const Event &event)
if ( m_phase == TS_SHIELD )
{
energy = (1.0f/ENERGY_TIME)*event.rTime;
- energy *= RetRadius()/RADIUS_SHIELD_MAX;
- power = m_object->RetPower();
+ energy *= GetRadius()/RADIUS_SHIELD_MAX;
+ power = m_object->GetPower();
if ( power != 0 )
{
- power->SetEnergy(power->RetEnergy()-energy/power->RetCapacity());
+ power->SetEnergy(power->GetEnergy()-energy/power->GetCapacity());
}
m_energyUsed += energy;
@@ -123,25 +122,25 @@ bool CTaskShield::EventProcess(const Event &event)
}
pos = m_shieldPos;
- pos.y += RetRadius()*(2.0f+sinf(m_time*9.0f)*0.2f);
+ pos.y += GetRadius()*(2.0f+sinf(m_time*9.0f)*0.2f);
if ( m_effectLight == -1 )
{
CreateLight(pos);
}
else
{
- m_light->SetLightPos(m_effectLight, pos);
+ m_lightMan->SetLightPos(m_effectLight, pos);
color.r = 0.0f+sinf(m_time*33.2f)*0.2f;
color.g = 0.5f+sinf(m_time*20.0f)*0.5f;
color.b = 0.5f+sinf(m_time*21.3f)*1.0f;
color.a = 0.0f;
- m_light->SetLightColor(m_effectLight, color);
+ m_lightMan->SetLightColor(m_effectLight, color);
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_shieldPos;
pos.x += (Math::Rand()-0.5f)*5.0f;
@@ -151,23 +150,23 @@ bool CTaskShield::EventProcess(const Event &event)
speed.y = Math::Rand()*15.0f;
dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLUE, 1.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLUE, 1.0f, 0.0f, 0.0f);
}
- if ( m_lastRay+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastRay+m_engine->ParticleAdapt(0.05f) <= m_time )
{
m_lastRay = m_time;
pos = m_shieldPos;
- dim.x = RetRadius()/20.0f;
+ dim.x = GetRadius()/20.0f;
dim.y = dim.x;
angle.x = (Math::Rand()-0.5f)*Math::PI*1.2f;
angle.y = 0.0f;
angle.z = (Math::Rand()-0.5f)*Math::PI*1.2f;
Math::LoadRotationXZYMatrix(matrix, angle);
- goal = Math::Transform(matrix, Math::Vector(0.0f, RetRadius()-dim.x, 0.0f));
+ goal = Math::Transform(matrix, Math::Vector(0.0f, GetRadius()-dim.x, 0.0f));
goal += pos;
- m_particule->CreateRay(pos, goal, PARTIRAY2, dim, 0.3f);
+ m_particle->CreateRay(pos, goal, Gfx::PARTIRAY2, dim, 0.3f);
}
if ( m_lastIncrease+0.2f <= m_time )
@@ -186,9 +185,9 @@ bool CTaskShield::EventProcess(const Event &event)
m_soundChannel = -1;
}
- if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
+ if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
pos = m_shieldPos;
pos.x += (Math::Rand()-0.5f)*5.0f;
@@ -198,7 +197,7 @@ bool CTaskShield::EventProcess(const Event &event)
speed.y = (Math::Rand()-0.5f)*3.0f;
dim.x = Math::Rand()*1.5f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f);
}
}
@@ -240,25 +239,25 @@ Error CTaskShield::Start(TaskShieldMode mode, float delay)
if ( mode == TSM_UPDATE )
{
- if ( m_object->RetSelect() )
+ if ( m_object->GetSelect() )
{
m_brain->UpdateInterface();
}
return ERR_OK;
}
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type != OBJECT_MOBILErs ) return ERR_SHIELD_VEH;
m_bError = true; // operation impossible
- if ( !m_physics->RetLand() ) return ERR_SHIELD_VEH;
+ if ( !m_physics->GetLand() ) return ERR_SHIELD_VEH;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 ) return ERR_SHIELD_ENERGY;
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
if ( energy == 0.0f ) return ERR_SHIELD_ENERGY;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(7.0f, 15.0f, 0.0f);
pos = Transform(*mat, pos); // sphere position
m_shieldPos = pos;
@@ -270,18 +269,18 @@ Error CTaskShield::Start(TaskShieldMode mode, float delay)
m_speed = 1.0f/1.0f;
m_time = 0.0f;
m_delay = delay;
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_lastRay = 0.0f;
m_lastIncrease = 0.0f;
m_energyUsed = 0.0f;
m_bError = false; // ok
- if ( m_object->RetSelect() )
+ if ( m_object->GetSelect() )
{
m_brain->UpdateInterface();
}
-//? m_camera->StartCentering(m_object, Math::PI*0.85f, -Math::PI*0.15f, RetRadius()+40.0f, 3.0f);
+//? m_camera->StartCentering(m_object, Math::PI*0.85f, -Math::PI*0.15f, GetRadius()+40.0f, 3.0f);
return ERR_OK;
}
@@ -297,13 +296,13 @@ Error CTaskShield::Stop()
if ( m_rankSphere != -1 )
{
- m_particule->SetPhase(m_rankSphere, PARPHEND, 3.0f);
+ m_particle->SetPhase(m_rankSphere, Gfx::PARPHEND, 3.0f);
m_rankSphere = -1;
}
if ( m_effectLight != -1 )
{
- m_light->DeleteLight(m_effectLight);
+ m_lightMan->DeleteLight(m_effectLight);
m_effectLight = -1;
}
@@ -316,7 +315,7 @@ Error CTaskShield::Stop()
m_camera->StopCentering(m_object, 4.0f);
- if ( m_object->RetSelect() )
+ if ( m_object->GetSelect() )
{
m_brain->UpdateInterface();
}
@@ -335,21 +334,21 @@ Error CTaskShield::IsEnded()
Math::Point dim;
float energy;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_phase == TS_SHIELD )
{
- m_object->SetShieldRadius(RetRadius());
+ m_object->SetShieldRadius(GetRadius());
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 )
{
energy = 0.0f;
}
else
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
if ( energy == 0.0f || m_delay <= 0.0f )
@@ -383,18 +382,18 @@ Error CTaskShield::IsEnded()
pos.z = 0.0f;
m_object->SetPosition(3, pos);
- m_object->SetShieldRadius(RetRadius());
+ m_object->SetShieldRadius(GetRadius());
pos = m_shieldPos;
speed = Math::Vector(0.0f, 0.0f, 0.0f);
- dim.x = RetRadius();
+ dim.x = GetRadius();
dim.y = dim.x;
- m_rankSphere = m_particule->CreateParticule(pos, speed, dim, PARTISPHERE3, 2.0f, 0.0f, 0.0f);
+ m_rankSphere = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISPHERE3, 2.0f, 0.0f, 0.0f);
m_phase = TS_SHIELD;
m_speed = 1.0f/999.9f;
- if ( m_object->RetSelect() )
+ if ( m_object->GetSelect() )
{
m_brain->UpdateInterface();
}
@@ -462,13 +461,13 @@ bool CTaskShield::Abort()
if ( m_rankSphere != -1 )
{
- m_particule->SetPhase(m_rankSphere, PARPHEND, 3.0f);
+ m_particle->SetPhase(m_rankSphere, Gfx::PARPHEND, 3.0f);
m_rankSphere = -1;
}
if ( m_effectLight != -1 )
{
- m_light->DeleteLight(m_effectLight);
+ m_lightMan->DeleteLight(m_effectLight);
m_effectLight = -1;
}
@@ -481,34 +480,32 @@ bool CTaskShield::Abort()
bool CTaskShield::CreateLight(Math::Vector pos)
{
- D3DLIGHT7 light;
-
- if ( !m_engine->RetLightMode() ) return true;
-
- ZeroMemory( &light, sizeof(light) );
- light.dltType = D3DLIGHT_SPOT;
- light.dcvDiffuse.r = 0.0f;
- light.dcvDiffuse.g = 1.0f;
- light.dcvDiffuse.b = 2.0f;
- light.dvPosition.x = pos.x;
- light.dvPosition.y = pos.y;
- light.dvPosition.z = pos.z;
- light.dvDirection.x = 0.0f;
- light.dvDirection.y = -1.0f; // against the bottom
- light.dvDirection.z = 0.0f;
- light.dvRange = D3DLIGHT_RANGE_MAX;
- light.dvFalloff = 1.0f;
- light.dvAttenuation0 = 1.0f;
- light.dvAttenuation1 = 0.0f;
- light.dvAttenuation2 = 0.0f;
- light.dvTheta = 0.0f;
- light.dvPhi = Math::PI/4.0f;
-
- m_effectLight = m_light->CreateLight();
+ Gfx::Light light;
+
+ if ( !m_engine->GetLightMode() ) return true;
+
+ memset(&light, 0, sizeof(light));
+ light.type = Gfx::LIGHT_SPOT;
+ light.diffuse.r = 0.0f;
+ light.diffuse.g = 1.0f;
+ light.diffuse.b = 2.0f;
+ light.position.x = pos.x;
+ light.position.y = pos.y;
+ light.position.z = pos.z;
+ light.direction.x = 0.0f;
+ light.direction.y = -1.0f; // against the bottom
+ light.direction.z = 0.0f;
+ light.spotIntensity = 128;
+ light.attenuation0 = 1.0f;
+ light.attenuation1 = 0.0f;
+ light.attenuation2 = 0.0f;
+ light.spotAngle = 90;
+
+ m_effectLight = m_lightMan->CreateLight();
if ( m_effectLight == -1 ) return false;
- m_light->SetLight(m_effectLight, light);
- m_light->SetLightIntensity(m_effectLight, 1.0f);
+ m_lightMan->SetLight(m_effectLight, light);
+ m_lightMan->SetLightIntensity(m_effectLight, 1.0f);
return true;
}
@@ -526,21 +523,21 @@ void CTaskShield::IncreaseShield()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_MOTHER ||
type == OBJECT_ANT ||
type == OBJECT_SPIDER ||
type == OBJECT_BEE ||
type == OBJECT_WORM ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, m_shieldPos);
- if ( dist <= RetRadius()+10.0f )
+ if ( dist <= GetRadius()+10.0f )
{
- shield = pObj->RetShield();
+ shield = pObj->GetShield();
shield += 0.1f;
if ( shield > 1.0f ) shield = 1.0f;
pObj->SetShield(shield);
@@ -551,9 +548,9 @@ void CTaskShield::IncreaseShield()
// Returns the radius of the shield.
-float CTaskShield::RetRadius()
+float CTaskShield::GetRadius()
{
- return RADIUS_SHIELD_MIN + (RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)*m_object->RetParam();
+ return RADIUS_SHIELD_MIN + (RADIUS_SHIELD_MAX-RADIUS_SHIELD_MIN)*m_object->GetParam();
}
diff --git a/src/object/task/taskshield.h b/src/object/task/taskshield.h
index 5842ae0..4a6811c 100644
--- a/src/object/task/taskshield.h
+++ b/src/object/task/taskshield.h
@@ -63,7 +63,7 @@ protected:
Error Stop();
bool CreateLight(Math::Vector pos);
void IncreaseShield();
- float RetRadius();
+ float GetRadius();
protected:
TaskShieldPhase m_phase;
@@ -71,12 +71,12 @@ protected:
float m_speed;
float m_time;
float m_delay;
- float m_lastParticule;
+ float m_lastParticle;
float m_lastRay;
float m_lastIncrease;
float m_energyUsed;
bool m_bError;
- Math::Vector m_shieldPos;
+ Math::Vector m_shieldPos;
int m_rankSphere;
int m_soundChannel;
int m_effectLight;
diff --git a/src/object/task/taskspiderexplo.cpp b/src/object/task/taskspiderexplo.cpp
index fa505b1..8110870 100644
--- a/src/object/task/taskspiderexplo.cpp
+++ b/src/object/task/taskspiderexplo.cpp
@@ -16,12 +16,9 @@
// taskspiderexplo.cpp
-
-#include <stdio.h>
-
#include "object/task/taskspiderexplo.h"
-#include "old/pyro.h"
+#include "graphics/engine/pyro.h"
#include "object/motion/motionspider.h"
#include "physics/physics.h"
@@ -48,11 +45,11 @@ CTaskSpiderExplo::~CTaskSpiderExplo()
bool CTaskSpiderExplo::EventProcess(const Event &event)
{
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
// Momentarily stationary object (ant on the back)?
- if ( m_object->RetFixed() )
+ if ( m_object->GetFixed() )
{
m_bError = true;
return true;
@@ -82,9 +79,9 @@ Error CTaskSpiderExplo::Start()
Error CTaskSpiderExplo::IsEnded()
{
- CPyro* pyro;
+ Gfx::CPyro* pyro;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError )
{
@@ -94,8 +91,8 @@ Error CTaskSpiderExplo::IsEnded()
if ( m_time < 1.0f ) return ERR_CONTINUE;
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_SPIDER, m_object); // the spider explodes (suicide)
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_SPIDER, m_object); // the spider explodes (suicide)
Abort();
return ERR_STOP;
diff --git a/src/object/task/tasktake.cpp b/src/object/task/tasktake.cpp
index 1a50f06..2737324 100644
--- a/src/object/task/tasktake.cpp
+++ b/src/object/task/tasktake.cpp
@@ -16,14 +16,11 @@
// tasktake.cpp
-
-#include <stdio.h>
-
#include "object/task/tasktake.h"
#include "common/iman.h"
-#include "old/terrain.h"
-#include "old/water.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/water.h"
#include "math/geometry.h"
#include "object/motion/motionhuman.h"
#include "object/robotmain.h"
@@ -37,7 +34,7 @@
CTaskTake::CTaskTake(CInstanceManager* iMan, CObject* object)
: CTask(iMan, object)
{
- m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
+ m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
m_arm = TTA_NEUTRAL;
}
@@ -55,13 +52,13 @@ bool CTaskTake::EventProcess(const Event &event)
{
float a, g, cirSpeed;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
if ( m_bTurn ) // preliminary rotation?
{
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
g = m_angle;
cirSpeed = Math::Direction(a, g)*2.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
@@ -92,26 +89,26 @@ Error CTaskTake::Start()
m_step = 0;
m_progress = 0.0f;
- iAngle = m_object->RetAngleY(0);
+ iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
oAngle = iAngle;
m_bError = true; // operation impossible
- if ( !m_physics->RetLand() )
+ if ( !m_physics->GetLand() )
{
- pos = m_object->RetPosition(0);
- h = m_water->RetLevel(m_object);
+ pos = m_object->GetPosition(0);
+ h = m_water->GetLevel(m_object);
if ( pos.y < h ) return ERR_MANIP_WATER; // impossible under water
return ERR_MANIP_FLY;
}
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type != OBJECT_HUMAN &&
type != OBJECT_TECH ) return ERR_MANIP_VEH;
m_physics->SetMotorSpeed(Math::Vector(0.0f, 0.0f, 0.0f));
- if ( m_object->RetFret() == 0 )
+ if ( m_object->GetFret() == 0 )
{
m_order = TTO_TAKE;
}
@@ -122,14 +119,14 @@ Error CTaskTake::Start()
if ( m_order == TTO_TAKE )
{
- pos = m_object->RetPosition(0);
- h = m_water->RetLevel(m_object);
+ pos = m_object->GetPosition(0);
+ h = m_water->GetLevel(m_object);
if ( pos.y < h ) return ERR_MANIP_WATER; // impossible under water
other = SearchFriendObject(oAngle, 1.5f, Math::PI*0.50f);
- if ( other != 0 && other->RetPower() != 0 )
+ if ( other != 0 && other->GetPower() != 0 )
{
- type = other->RetPower()->RetType();
+ type = other->GetPower()->GetType();
if ( type == OBJECT_URANIUM ) return ERR_MANIP_RADIO;
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
@@ -150,7 +147,7 @@ Error CTaskTake::Start()
{
other = SearchTakeObject(oAngle, 1.5f, Math::PI*0.45f);
if ( other == 0 ) return ERR_MANIP_NIL;
- type = other->RetType();
+ type = other->GetType();
if ( type == OBJECT_URANIUM ) return ERR_MANIP_RADIO;
//? m_camera->StartCentering(m_object, Math::PI*0.3f, 99.9f, 0.0f, 0.8f);
m_arm = TTA_FFRONT;
@@ -160,12 +157,12 @@ Error CTaskTake::Start()
if ( m_order == TTO_DEPOSE )
{
-//? speed = m_physics->RetMotorSpeed();
+//? speed = m_physics->GetMotorSpeed();
//? if ( speed.x != 0.0f ||
//? speed.z != 0.0f ) return ERR_MANIP_MOTOR;
other = SearchFriendObject(oAngle, 1.5f, Math::PI*0.50f);
- if ( other != 0 && other->RetPower() == 0 )
+ if ( other != 0 && other->GetPower() == 0 )
{
//? m_camera->StartCentering(m_object, Math::PI*0.3f, -Math::PI*0.1f, 0.0f, 0.8f);
m_arm = TTA_FRIEND;
@@ -194,12 +191,12 @@ Error CTaskTake::IsEnded()
CObject* fret;
float angle;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_bTurn ) // preliminary rotation?
{
- angle = m_object->RetAngleY(0);
+ angle = m_object->GetAngleY(0);
angle = Math::NormAngle(angle); // 0..2*Math::PI
if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) )
@@ -243,7 +240,7 @@ Error CTaskTake::IsEnded()
(m_fretType == OBJECT_POWER ||
m_fretType == OBJECT_ATOMIC ) )
{
- m_sound->Play(SOUND_POWEROFF, m_object->RetPosition(0));
+ m_sound->Play(SOUND_POWEROFF, m_object->GetPosition(0));
}
}
m_motion->SetAction(MHS_UPRIGHT, 0.4f); // gets up
@@ -258,13 +255,13 @@ Error CTaskTake::IsEnded()
{
if ( m_step == 1 )
{
- fret = m_object->RetFret();
+ fret = m_object->GetFret();
TruckDeposeObject();
if ( m_arm == TTA_FRIEND &&
(m_fretType == OBJECT_POWER ||
m_fretType == OBJECT_ATOMIC ) )
{
- m_sound->Play(SOUND_POWERON, m_object->RetPosition(0));
+ m_sound->Play(SOUND_POWERON, m_object->GetPosition(0));
}
if ( fret != 0 && m_fretType == OBJECT_METAL && m_arm == TTA_FFRONT )
{
@@ -304,8 +301,8 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
float min, iAngle, bAngle, a, distance;
int i;
- iPos = m_object->RetPosition(0);
- iAngle = m_object->RetAngleY(0);
+ iPos = m_object->GetPosition(0);
+ iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
min = 1000000.0f;
@@ -313,10 +310,10 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
@@ -332,11 +329,11 @@ CObject* CTaskTake::SearchTakeObject(float &angle,
type != OBJECT_KEYd &&
type != OBJECT_TNT ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
- if ( pObj->RetLock() ) continue;
- if ( pObj->RetZoomY(0) != 1.0f ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
+ if ( pObj->GetLock() ) continue;
+ if ( pObj->GetZoomY(0) != 1.0f ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
distance = Math::Distance(oPos, iPos);
if ( distance >= 4.0f-dLimit &&
distance <= 4.0f+dLimit )
@@ -374,17 +371,17 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
int i;
if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0;
- iAngle = m_object->RetAngleY(0);
+ iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
type != OBJECT_MOBILEwa &&
@@ -417,19 +414,19 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
type != OBJECT_LABO &&
type != OBJECT_NUCLEAR ) continue;
- pPower = pObj->RetPower();
+ pPower = pObj->GetPower();
if ( pPower != 0 )
{
- if ( pPower->RetLock() ) continue;
- if ( pPower->RetZoomY(0) != 1.0f ) continue;
+ if ( pPower->GetLock() ) continue;
+ if ( pPower->GetZoomY(0) != 1.0f ) continue;
- powerType = pPower->RetType();
+ powerType = pPower->GetType();
if ( powerType == OBJECT_NULL ||
powerType == OBJECT_FIX ) continue;
}
- mat = pObj->RetWorldMatrix(0);
- character = pObj->RetCharacter();
+ mat = pObj->GetWorldMatrix(0);
+ character = pObj->GetCharacter();
oPos = Transform(*mat, character->posPower);
distance = fabs(Math::Distance(oPos, iPos) - (iRad+1.0f));
@@ -438,7 +435,7 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
if ( Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
{
- character = pObj->RetCharacter();
+ character = pObj->GetCharacter();
m_height = character->posPower.y;
return pObj;
}
@@ -452,17 +449,17 @@ CObject* CTaskTake::SearchFriendObject(float &angle,
bool CTaskTake::TruckTakeObject()
{
- CObject* fret;
- CObject* other;
- Math::Matrix matRotate;
- float angle;
+ CObject* fret;
+ CObject* other;
+ Math::Matrix matRotate;
+ float angle;
if ( m_arm == TTA_FFRONT ) // takes on the ground in front?
{
//? fret = SearchTakeObject(angle, 1.5f, Math::PI*0.04f);
fret = SearchTakeObject(angle, 1.5f, Math::PI*0.15f); //OK 1.9
if ( fret == 0 ) return false; // rien � prendre ?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
fret->SetTruck(m_object);
fret->SetTruckPart(4); // takes with the hand
@@ -481,9 +478,9 @@ bool CTaskTake::TruckTakeObject()
other = SearchFriendObject(angle, 1.5f, Math::PI*0.04f);
if ( other == 0 ) return false;
- fret = other->RetPower();
+ fret = other->GetPower();
if ( fret == 0 ) return false; // the other does not have a battery?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
other->SetPower(0);
fret->SetTruck(m_object);
@@ -514,15 +511,15 @@ bool CTaskTake::TruckDeposeObject()
if ( m_arm == TTA_FFRONT ) // deposes on the ground in front?
{
- fret = m_object->RetFret();
+ fret = m_object->GetFret();
if ( fret == 0 ) return false; // does nothing?
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
- mat = fret->RetWorldMatrix(0);
+ mat = fret->GetWorldMatrix(0);
pos = Transform(*mat, Math::Vector(-0.5f, 1.0f, 0.0f));
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
fret->SetPosition(0, pos);
- fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f);
+ fret->SetAngleY(0, m_object->GetAngleY(0)+Math::PI/2.0f);
fret->SetAngleX(0, 0.0f);
fret->SetAngleZ(0, 0.0f);
fret->FloorAdjust(); // plate well on the ground
@@ -536,17 +533,17 @@ bool CTaskTake::TruckDeposeObject()
other = SearchFriendObject(angle, 1.5f, Math::PI*0.04f);
if ( other == 0 ) return false;
- fret = other->RetPower();
+ fret = other->GetPower();
if ( fret != 0 ) return false; // the other already has a battery?
- fret = m_object->RetFret();
+ fret = m_object->GetFret();
if ( fret == 0 ) return false;
- m_fretType = fret->RetType();
+ m_fretType = fret->GetType();
other->SetPower(fret);
fret->SetTruck(other);
- character = other->RetCharacter();
+ character = other->GetCharacter();
fret->SetPosition(0, character->posPower);
fret->SetAngleY(0, 0.0f);
fret->SetAngleX(0, 0.0f);
@@ -569,17 +566,17 @@ bool CTaskTake::IsFreeDeposeObject(Math::Vector pos)
float oRadius;
int i, j;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
iPos = Transform(*mat, pos);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
- if ( !pObj->RetActif() ) continue; // inactive?
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue; // inactive?
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
j = 0;
while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
diff --git a/src/object/task/tasktake.h b/src/object/task/tasktake.h
index b0553a0..c7950fe 100644
--- a/src/object/task/tasktake.h
+++ b/src/object/task/tasktake.h
@@ -59,7 +59,8 @@ protected:
bool IsFreeDeposeObject(Math::Vector pos);
protected:
- CTerrain* m_terrain;
+ //TODO this is same member as in base class, probable should be deleted
+ Gfx::CTerrain* m_terrain;
TaskTakeOrder m_order;
TaskTakeArm m_arm;
diff --git a/src/object/task/taskterraform.cpp b/src/object/task/taskterraform.cpp
index 3a16008..6afece4 100644
--- a/src/object/task/taskterraform.cpp
+++ b/src/object/task/taskterraform.cpp
@@ -23,10 +23,10 @@
#include "math/geometry.h"
#include "common/iman.h"
-#include "old/particule.h"
-#include "old/terrain.h"
+#include "graphics/engine/pyro.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/terrain.h"
#include "physics/physics.h"
-#include "old/pyro.h"
#include "object/brain.h"
#include "object/motion/motionant.h"
#include "object/motion/motionspider.h"
@@ -42,7 +42,7 @@ const float ACTION_RADIUS = 400.0f;
CTaskTerraform::CTaskTerraform(CInstanceManager* iMan, CObject* object)
: CTask(iMan, object)
{
- m_lastParticule = 0.0f;
+ m_lastParticle = 0.0f;
m_soundChannel = -1;
}
@@ -63,8 +63,8 @@ bool CTaskTerraform::EventProcess(const Event &event)
Math::Point dim;
float energy;
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_progress += event.rTime*m_speed; // others advance
@@ -75,11 +75,11 @@ bool CTaskTerraform::EventProcess(const Event &event)
if ( m_soundChannel == -1 )
{
#if _TEEN
- m_soundChannel = m_sound->Play(SOUND_GGG, m_object->RetPosition(0), 1.0f, 0.5f, true);
+ m_soundChannel = m_sound->Play(SOUND_GGG, m_object->GetPosition(0), 1.0f, 0.5f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 2.0f, 1.5f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.5f, 0.5f, SOPER_STOP);
#else
- m_soundChannel = m_sound->Play(SOUND_GGG, m_object->RetPosition(0), 1.0f, 0.5f, true);
+ m_soundChannel = m_sound->Play(SOUND_GGG, m_object->GetPosition(0), 1.0f, 0.5f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 2.0f, 4.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.5f, 0.5f, SOPER_STOP);
#endif
@@ -92,13 +92,13 @@ bool CTaskTerraform::EventProcess(const Event &event)
m_object->SetZoom(0, 1.0f+m_progress*0.2f);
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
power->SetZoom(0, 1.0f+m_progress*1.0f);
- energy = power->RetEnergy();
- energy -= event.rTime*ENERGY_TERRA/power->RetCapacity()/4.0f;
+ energy = power->GetEnergy();
+ energy -= event.rTime*ENERGY_TERRA/power->GetCapacity()/4.0f;
if ( energy < 0.0f ) energy = 0.0f;
power->SetEnergy(energy);
}
@@ -131,18 +131,18 @@ bool CTaskTerraform::EventProcess(const Event &event)
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = 0.0f;
- pos = m_object->RetPosition(2);
+ pos = m_object->GetPosition(2);
if ( pos.y < 0.0f )
{
dir.z = -atanf((pos.y/2.0f)/9.0f);
}
m_object->SetInclinaison(dir);
- if ( m_time-m_lastParticule >= m_engine->ParticuleAdapt(0.05f) )
+ if ( m_time-m_lastParticle >= m_engine->ParticleAdapt(0.05f) )
{
- m_lastParticule = m_time;
+ m_lastParticle = m_time;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
if ( m_phase == TTP_CHARGE )
{
@@ -156,7 +156,7 @@ bool CTaskTerraform::EventProcess(const Event &event)
speed.y = 6.0f+Math::Rand()*4.0f*(1.0f+m_progress*2.0f);
dim.x = 0.5f+1.5f*m_progress;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ, 2.0f, 20.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLITZ, 2.0f, 20.0f);
}
if ( m_phase != TTP_CHARGE )
@@ -170,10 +170,10 @@ bool CTaskTerraform::EventProcess(const Event &event)
speed.z = Math::Rand()*2.0f;
speed.y = 2.5f+Math::Rand()*1.0f;
speed = Math::Transform(*mat, speed);
- speed -= m_object->RetPosition(0);
+ speed -= m_object->GetPosition(0);
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 3.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE1, 3.0f);
// Right grid.
pos = Math::Vector(-1.0f, 5.8f, -3.5f);
@@ -184,10 +184,10 @@ bool CTaskTerraform::EventProcess(const Event &event)
speed.z = -Math::Rand()*2.0f;
speed.y = 2.5f+Math::Rand()*1.0f;
speed = Math::Transform(*mat, speed);
- speed -= m_object->RetPosition(0);
+ speed -= m_object->GetPosition(0);
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 3.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE1, 3.0f);
}
}
@@ -207,21 +207,21 @@ Error CTaskTerraform::Start()
ObjectType type;
m_bError = true; // operation impossible
- if ( !m_physics->RetLand() ) return ERR_TERRA_VEH;
+ if ( !m_physics->GetLand() ) return ERR_TERRA_VEH;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type != OBJECT_MOBILErt ) return ERR_TERRA_VEH;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power == 0 ) return ERR_TERRA_ENERGY;
- energy = power->RetEnergy();
- if ( energy < ENERGY_TERRA/power->RetCapacity()+0.05f ) return ERR_TERRA_ENERGY;
+ energy = power->GetEnergy();
+ if ( energy < ENERGY_TERRA/power->GetCapacity()+0.05f ) return ERR_TERRA_ENERGY;
- speed = m_physics->RetMotorSpeed();
+ speed = m_physics->GetMotorSpeed();
if ( speed.x != 0.0f ||
speed.z != 0.0f ) return ERR_MANIP_MOTOR;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(9.0f, 0.0f, 0.0f);
pos = Math::Transform(*mat, pos); // battery position
m_terraPos = pos;
@@ -251,7 +251,7 @@ Error CTaskTerraform::IsEnded()
float dist, duration;
int i, max;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;
@@ -277,24 +277,24 @@ Error CTaskTerraform::IsEnded()
m_object->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetZoom(0, 1.0f);
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
power->SetZoom(0, 1.0f);
}
- max= (int)(50.0f*m_engine->RetParticuleDensity());
+ max= static_cast<int>(50.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<max ; i++ )
{
pos.x = m_terraPos.x+(Math::Rand()-0.5f)*80.0f;
pos.z = m_terraPos.z+(Math::Rand()-0.5f)*80.0f;
pos.y = m_terraPos.y;
- m_terrain->MoveOnFloor(pos);
+ m_terrain->AdjustToFloor(pos);
dist = Math::Distance(pos, m_terraPos);
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 2.0f+(40.0f-dist)/(1.0f+Math::Rand()*4.0f);
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
pos = m_terraPos;
speed.x = (Math::Rand()-0.5f)*40.0f;
@@ -304,7 +304,7 @@ Error CTaskTerraform::IsEnded()
dim.y = dim.x;
pos.y += dim.y;
duration = Math::Rand()*3.0f+3.0f;
- m_particule->CreateTrack(pos, speed, dim, PARTITRACK5,
+ m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK5,
duration, Math::Rand()*10.0f+15.0f,
duration*0.2f, 1.0f);
}
@@ -343,7 +343,7 @@ bool CTaskTerraform::Abort()
m_object->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f));
m_object->SetZoom(0, 1.0f);
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
power->SetZoom(0, 1.0f);
@@ -361,49 +361,49 @@ bool CTaskTerraform::Terraform()
CObject* pObj;
CBrain* brain;
CMotion* motion;
- CPyro* pyro;
+ Gfx::CPyro* pyro;
ObjectType type;
float dist;
int i;
- m_camera->StartEffect(CE_TERRAFORM, m_terraPos, 1.0f);
+ m_camera->StartEffect(Gfx::CAM_EFFECT_TERRAFORM, m_terraPos, 1.0f);
m_sound->Play(SOUND_THUMP, m_terraPos);
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_NULL ) continue;
if ( type == OBJECT_TEEN34 ) // stone?
{
- dist = Math::Distance(m_terraPos, pObj->RetPosition(0));
+ dist = Math::Distance(m_terraPos, pObj->GetPosition(0));
if ( dist > 20.0f ) continue;
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FRAGT, pObj);
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FRAGT, pObj);
}
else
{
- motion = pObj->RetMotion();
+ motion = pObj->GetMotion();
if ( motion == 0 ) continue;
- dist = Math::Distance(m_terraPos, pObj->RetPosition(0));
+ dist = Math::Distance(m_terraPos, pObj->GetPosition(0));
if ( dist > ACTION_RADIUS ) continue;
if ( type == OBJECT_ANT )
{
- brain = pObj->RetBrain();
+ brain = pObj->GetBrain();
if ( brain != 0 ) brain->StopTask();
motion->SetAction(MAS_BACK1, 0.8f+Math::Rand()*0.3f);
pObj->SetFixed(true); // not moving
}
if ( type == OBJECT_SPIDER )
{
- brain = pObj->RetBrain();
+ brain = pObj->GetBrain();
if ( brain != 0 ) brain->StopTask();
motion->SetAction(MSS_BACK1, 0.8f+Math::Rand()*0.3f);
pObj->SetFixed(true); // not moving
diff --git a/src/object/task/taskterraform.h b/src/object/task/taskterraform.h
index 5c9c114..91526b6 100644
--- a/src/object/task/taskterraform.h
+++ b/src/object/task/taskterraform.h
@@ -54,9 +54,9 @@ protected:
float m_progress;
float m_speed;
float m_time;
- float m_lastParticule;
+ float m_lastParticle;
int m_soundChannel;
bool m_bError;
- Math::Vector m_terraPos;
+ Math::Vector m_terraPos;
};
diff --git a/src/object/task/taskturn.cpp b/src/object/task/taskturn.cpp
index f8bf26c..8f4bbd2 100644
--- a/src/object/task/taskturn.cpp
+++ b/src/object/task/taskturn.cpp
@@ -16,12 +16,9 @@
// taskturn.cpp
-
-#include <stdio.h>
-
#include "object/task/taskturn.h"
-#include "old/terrain.h"
+#include "graphics/engine/terrain.h"
#include "physics/physics.h"
@@ -45,11 +42,11 @@ CTaskTurn::~CTaskTurn()
bool CTaskTurn::EventProcess(const Event &event)
{
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
// Momentarily stationary object (ant on the back)?
- if ( m_object->RetFixed() )
+ if ( m_object->GetFixed() )
{
m_physics->SetMotorSpeedX(0.0f); // stops the advance
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
@@ -66,18 +63,18 @@ bool CTaskTurn::EventProcess(const Event &event)
Error CTaskTurn::Start(float angle)
{
- m_startAngle = m_object->RetAngleY(0);
+ m_startAngle = m_object->GetAngleY(0);
m_finalAngle = m_startAngle+angle;
if ( angle < 0.0f )
{
- m_angle = angle+m_physics->RetCirStopLength();
+ m_angle = angle+m_physics->GetCirStopLength();
m_physics->SetMotorSpeedZ(-1.0f); // turns left
m_bLeft = true;
}
else
{
- m_angle = angle-m_physics->RetCirStopLength();
+ m_angle = angle-m_physics->GetCirStopLength();
m_physics->SetMotorSpeedZ(1.0f); // turns right
m_bLeft = false;
}
@@ -94,14 +91,14 @@ Error CTaskTurn::IsEnded()
{
float angle;
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError )
{
return ERR_STOP;
}
- angle = m_object->RetAngleY(0);
+ angle = m_object->GetAngleY(0);
if ( m_bLeft )
{
diff --git a/src/object/task/taskwait.cpp b/src/object/task/taskwait.cpp
index 03bddcb..f612c24 100644
--- a/src/object/task/taskwait.cpp
+++ b/src/object/task/taskwait.cpp
@@ -16,14 +16,9 @@
// taskwait.cpp
-
-#include <stdio.h>
-
#include "object/task/taskwait.h"
-#include "old/d3dengine.h"
-
-
+#include "graphics/engine/engine.h"
// Object's constructor.
@@ -43,8 +38,8 @@ CTaskWait::~CTaskWait()
bool CTaskWait::EventProcess(const Event &event)
{
- if ( m_engine->RetPause() ) return true;
- if ( event.event != EVENT_FRAME ) return true;
+ if ( m_engine->GetPause() ) return true;
+ if ( event.type != EVENT_FRAME ) return true;
m_passTime += event.rTime;
m_bEnded = (m_passTime >= m_waitTime);
@@ -66,7 +61,7 @@ Error CTaskWait::Start(float time)
Error CTaskWait::IsEnded()
{
- if ( m_engine->RetPause() ) return ERR_CONTINUE;
+ if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bEnded ) return ERR_STOP;
return ERR_CONTINUE;
}
diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp
index 873979f..40dbdc7 100644
--- a/src/physics/physics.cpp
+++ b/src/physics/physics.cpp
@@ -17,35 +17,25 @@
// physics.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
+#include <cstring>
+#include <cstdio>
-#include "common/struct.h"
-#include "math/const.h"
#include "math/geometry.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/language.h"
+#include "graphics/engine/engine.h"
#include "common/global.h"
#include "common/event.h"
-#include "common/misc.h"
#include "common/iman.h"
-#include "old/math3d.h"
-#include "old/light.h"
-#include "old/particule.h"
-#include "old/terrain.h"
-#include "old/water.h"
-#include "old/camera.h"
-#include "object/object.h"
-#include "old/pyro.h"
+#include "graphics/engine/lightman.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/water.h"
+#include "graphics/engine/camera.h"
+#include "graphics/engine/pyro.h"
+#include "script/cmdtoken.h"
+#include "physics/physics.h"
#include "object/brain.h"
#include "object/motion/motion.h"
#include "object/motion/motionhuman.h"
-#include "old/sound.h"
#include "object/task/task.h"
-#include "script/cmdtoken.h"
-#include "physics/physics.h"
@@ -64,13 +54,13 @@ CPhysics::CPhysics(CInstanceManager* iMan, CObject* object)
m_iMan->AddInstance(CLASS_PHYSICS, this, 100);
m_object = object;
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
- m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
- m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_lightMan = static_cast<Gfx::CLightManager*>(m_iMan->SearchInstance(CLASS_LIGHT));
+ m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_brain = 0;
m_motion = 0;
@@ -88,14 +78,14 @@ CPhysics::CPhysics(CInstanceManager* iMan, CObject* object)
m_linVibrationFactor = 1.0f;
m_cirVibrationFactor = 1.0f;
m_inclinaisonFactor = 1.0f;
- m_lastPowerParticule = 0.0f;
- m_lastSlideParticule = 0.0f;
- m_lastMotorParticule = 0.0f;
- m_lastWaterParticule = 0.0f;
- m_lastUnderParticule = 0.0f;
- m_lastPloufParticule = 0.0f;
- m_lastFlameParticule = 0.0f;
- m_bWheelParticuleBrake = false;
+ m_lastPowerParticle = 0.0f;
+ m_lastSlideParticle = 0.0f;
+ m_lastMotorParticle = 0.0f;
+ m_lastWaterParticle = 0.0f;
+ m_lastUnderParticle = 0.0f;
+ m_lastPloufParticle = 0.0f;
+ m_lastFlameParticle = 0.0f;
+ m_bWheelParticleBrake = false;
m_absorbWater = 0.0f;
m_reactorTemperature = 0.0f;
m_reactorRange = 1.0f;
@@ -103,7 +93,7 @@ CPhysics::CPhysics(CInstanceManager* iMan, CObject* object)
m_lastEnergy = 0.0f;
m_lastSoundWater = 0.0f;
m_lastSoundInsect = 0.0f;
- m_restBreakParticule = 0.0f;
+ m_restBreakParticle = 0.0f;
m_floorHeight = 0.0f;
m_soundChannel = -1;
m_soundChannelSlide = -1;
@@ -115,8 +105,8 @@ CPhysics::CPhysics(CInstanceManager* iMan, CObject* object)
m_bForceUpdate = true;
m_bLowLevel = false;
- ZeroMemory(&m_linMotion, sizeof(Motion));
- ZeroMemory(&m_cirMotion, sizeof(Motion));
+ memset(&m_linMotion, 0, sizeof(Motion));
+ memset(&m_cirMotion, 0,sizeof(Motion));
}
// Object's destructor.
@@ -164,7 +154,7 @@ void CPhysics::SetType(PhysicsType type)
m_type = type;
}
-PhysicsType CPhysics::RetType()
+PhysicsType CPhysics::GetType()
{
return m_type;
}
@@ -182,10 +172,10 @@ bool CPhysics::Write(char *line)
if ( m_type == TYPE_FLYING )
{
- sprintf(name, " reactorRange=%.2f", RetReactorRange());
+ sprintf(name, " reactorRange=%.2f", GetReactorRange());
strcat(line, name);
- sprintf(name, " land=%d", RetLand());
+ sprintf(name, " land=%d", GetLand());
strcat(line, name);
}
@@ -216,7 +206,7 @@ void CPhysics::SetGravity(float value)
m_gravity = value;
}
-float CPhysics::RetGravity()
+float CPhysics::GetGravity()
{
return m_gravity;
}
@@ -224,7 +214,7 @@ float CPhysics::RetGravity()
// Returns the height above the ground.
-float CPhysics::RetFloorHeight()
+float CPhysics::GetFloorHeight()
{
return m_floorHeight;
}
@@ -238,15 +228,15 @@ void CPhysics::SetMotor(bool bState)
m_bMotor = bState;
- light = m_object->RetShadowLight();
+ light = m_object->GetShadowLight();
if ( light != -1 )
{
- m_light->SetLightIntensity(light, m_bMotor?1.0f:0.0f);
- m_light->SetLightIntensitySpeed(light, 3.0f);
+ m_lightMan->SetLightIntensity(light, m_bMotor?1.0f:0.0f);
+ m_lightMan->SetLightIntensitySpeed(light, 3.0f);
}
}
-bool CPhysics::RetMotor()
+bool CPhysics::GetMotor()
{
return m_bMotor;
}
@@ -260,7 +250,7 @@ void CPhysics::SetLand(bool bState)
SetMotor(!bState); // lights if you leave the reactor in flight
}
-bool CPhysics::RetLand()
+bool CPhysics::GetLand()
{
return m_bLand;
}
@@ -277,7 +267,7 @@ void CPhysics::SetSwim(bool bState)
m_bSwim = bState;
}
-bool CPhysics::RetSwim()
+bool CPhysics::GetSwim()
{
return m_bSwim;
}
@@ -290,7 +280,7 @@ void CPhysics::SetCollision(bool bCollision)
m_bCollision = bCollision;
}
-bool CPhysics::RetCollision()
+bool CPhysics::GetCollision()
{
return m_bCollision;
}
@@ -303,7 +293,7 @@ void CPhysics::SetFreeze(bool bFreeze)
m_bFreeze = bFreeze;
}
-bool CPhysics::RetFreeze()
+bool CPhysics::GetFreeze()
{
return m_bFreeze;
}
@@ -316,7 +306,7 @@ void CPhysics::SetReactorRange(float range)
m_reactorRange = range;
}
-float CPhysics::RetReactorRange()
+float CPhysics::GetReactorRange()
{
return m_reactorRange;
}
@@ -359,22 +349,22 @@ void CPhysics::SetMotorSpeedZ(float speed)
m_motorSpeed.z = speed;
}
-Math::Vector CPhysics::RetMotorSpeed()
+Math::Vector CPhysics::GetMotorSpeed()
{
return m_motorSpeed;
}
-float CPhysics::RetMotorSpeedX()
+float CPhysics::GetMotorSpeedX()
{
return m_motorSpeed.x;
}
-float CPhysics::RetMotorSpeedY()
+float CPhysics::GetMotorSpeedY()
{
return m_motorSpeed.y;
}
-float CPhysics::RetMotorSpeedZ()
+float CPhysics::GetMotorSpeedZ()
{
return m_motorSpeed.z;
}
@@ -399,7 +389,7 @@ void CPhysics::SetLinMotion(PhysicsMode mode, Math::Vector value)
if ( mode == MO_REASPEED ) m_linMotion.realSpeed = value;
}
-Math::Vector CPhysics::RetLinMotion(PhysicsMode mode)
+Math::Vector CPhysics::GetLinMotion(PhysicsMode mode)
{
if ( mode == MO_ADVACCEL ) return m_linMotion.advanceAccel;
if ( mode == MO_RECACCEL ) return m_linMotion.recedeAccel;
@@ -432,7 +422,7 @@ void CPhysics::SetLinMotionX(PhysicsMode mode, float value)
if ( mode == MO_REASPEED ) m_linMotion.realSpeed.x = value;
}
-float CPhysics::RetLinMotionX(PhysicsMode mode)
+float CPhysics::GetLinMotionX(PhysicsMode mode)
{
if ( mode == MO_ADVACCEL ) return m_linMotion.advanceAccel.x;
if ( mode == MO_RECACCEL ) return m_linMotion.recedeAccel.x;
@@ -467,7 +457,7 @@ void CPhysics::SetLinMotionY(PhysicsMode mode, float value)
if ( mode == MO_REASPEED ) m_linMotion.realSpeed.y = value;
}
-float CPhysics::RetLinMotionY(PhysicsMode mode)
+float CPhysics::GetLinMotionY(PhysicsMode mode)
{
if ( mode == MO_ADVACCEL ) return m_linMotion.advanceAccel.y;
if ( mode == MO_RECACCEL ) return m_linMotion.recedeAccel.y;
@@ -502,7 +492,7 @@ void CPhysics::SetLinMotionZ(PhysicsMode mode, float value)
if ( mode == MO_REASPEED ) m_linMotion.realSpeed.z = value;
}
-float CPhysics::RetLinMotionZ(PhysicsMode mode)
+float CPhysics::GetLinMotionZ(PhysicsMode mode)
{
if ( mode == MO_ADVACCEL ) return m_linMotion.advanceAccel.z;
if ( mode == MO_RECACCEL ) return m_linMotion.recedeAccel.z;
@@ -537,7 +527,7 @@ void CPhysics::SetCirMotion(PhysicsMode mode, Math::Vector value)
if ( mode == MO_REASPEED ) m_cirMotion.realSpeed = value;
}
-Math::Vector CPhysics::RetCirMotion(PhysicsMode mode)
+Math::Vector CPhysics::GetCirMotion(PhysicsMode mode)
{
if ( mode == MO_ADVACCEL ) return m_cirMotion.advanceAccel;
if ( mode == MO_RECACCEL ) return m_cirMotion.recedeAccel;
@@ -570,7 +560,7 @@ void CPhysics::SetCirMotionX(PhysicsMode mode, float value)
if ( mode == MO_REASPEED ) m_cirMotion.realSpeed.x = value;
}
-float CPhysics::RetCirMotionX(PhysicsMode mode)
+float CPhysics::GetCirMotionX(PhysicsMode mode)
{
if ( mode == MO_ADVACCEL ) return m_cirMotion.advanceAccel.x;
if ( mode == MO_RECACCEL ) return m_cirMotion.recedeAccel.x;
@@ -605,7 +595,7 @@ void CPhysics::SetCirMotionY(PhysicsMode mode, float value)
if ( mode == MO_REASPEED ) m_cirMotion.realSpeed.y = value;
}
-float CPhysics::RetCirMotionY(PhysicsMode mode)
+float CPhysics::GetCirMotionY(PhysicsMode mode)
{
if ( mode == MO_ADVACCEL ) return m_cirMotion.advanceAccel.y;
if ( mode == MO_RECACCEL ) return m_cirMotion.recedeAccel.y;
@@ -640,7 +630,7 @@ void CPhysics::SetCirMotionZ(PhysicsMode mode, float value)
if ( mode == MO_REASPEED ) m_cirMotion.realSpeed.z = value;
}
-float CPhysics::RetCirMotionZ(PhysicsMode mode)
+float CPhysics::GetCirMotionZ(PhysicsMode mode)
{
if ( mode == MO_ADVACCEL ) return m_cirMotion.advanceAccel.z;
if ( mode == MO_RECACCEL ) return m_cirMotion.recedeAccel.z;
@@ -664,12 +654,12 @@ float CPhysics::RetCirMotionZ(PhysicsMode mode)
// d = -----
// 2a
-float CPhysics::RetLinStopLength(PhysicsMode sMode, PhysicsMode aMode)
+float CPhysics::GetLinStopLength(PhysicsMode sMode, PhysicsMode aMode)
{
float speed, accel;
- speed = RetLinMotionX(sMode); // MO_ADVSPEED/MO_RECSPEED
- accel = RetLinMotionX(aMode); // MO_ADVACCEL/MO_RECACCEL/MO_STOACCEL
+ speed = GetLinMotionX(sMode); // MO_ADVSPEED/MO_RECSPEED
+ accel = GetLinMotionX(aMode); // MO_ADVACCEL/MO_RECACCEL/MO_STOACCEL
if ( m_type == TYPE_FLYING && m_bLand ) // flying on the ground?
{
@@ -682,7 +672,7 @@ float CPhysics::RetLinStopLength(PhysicsMode sMode, PhysicsMode aMode)
// Returns the angle of circular braking.
-float CPhysics::RetCirStopLength()
+float CPhysics::GetCirStopLength()
{
return m_cirMotion.advanceSpeed.y * m_cirMotion.advanceSpeed.y /
m_cirMotion.stopAccel.y / 2.0f;
@@ -690,7 +680,7 @@ float CPhysics::RetCirStopLength()
// Returns the length advanced into a second, on the ground, maximum speed.
-float CPhysics::RetLinMaxLength(float dir)
+float CPhysics::GetLinMaxLength(float dir)
{
float dist;
@@ -707,36 +697,36 @@ float CPhysics::RetLinMaxLength(float dir)
// Returns the time needed to travel some distance.
-float CPhysics::RetLinTimeLength(float dist, float dir)
+float CPhysics::GetLinTimeLength(float dist, float dir)
{
float accel, decel, dps;
if ( dir > 0.0f )
{
- accel = RetLinStopLength(MO_ADVSPEED, MO_ADVACCEL);
- decel = RetLinStopLength(MO_ADVSPEED, MO_STOACCEL);
+ accel = GetLinStopLength(MO_ADVSPEED, MO_ADVACCEL);
+ decel = GetLinStopLength(MO_ADVSPEED, MO_STOACCEL);
}
else
{
- accel = RetLinStopLength(MO_RECSPEED, MO_RECACCEL);
- decel = RetLinStopLength(MO_RECSPEED, MO_STOACCEL);
+ accel = GetLinStopLength(MO_RECSPEED, MO_RECACCEL);
+ decel = GetLinStopLength(MO_RECSPEED, MO_STOACCEL);
}
- dps = RetLinMaxLength(dir);
+ dps = GetLinMaxLength(dir);
return (dist+accel+decel)/dps;
}
// Returns the length for a forward travel some distance, taking into account the accelerations / decelerations.
-float CPhysics::RetLinLength(float dist)
+float CPhysics::GetLinLength(float dist)
{
float accDist, desDist;
if ( dist > 0.0f )
{
- accDist = RetLinStopLength(MO_ADVSPEED, MO_ADVACCEL);
- desDist = RetLinStopLength(MO_ADVSPEED, MO_STOACCEL);
+ accDist = GetLinStopLength(MO_ADVSPEED, MO_ADVACCEL);
+ desDist = GetLinStopLength(MO_ADVSPEED, MO_STOACCEL);
if ( dist > accDist+desDist )
{
@@ -749,8 +739,8 @@ float CPhysics::RetLinLength(float dist)
else
{
dist = -dist;
- accDist = RetLinStopLength(MO_RECSPEED, MO_RECACCEL);
- desDist = RetLinStopLength(MO_RECSPEED, MO_STOACCEL);
+ accDist = GetLinStopLength(MO_RECSPEED, MO_RECACCEL);
+ desDist = GetLinStopLength(MO_RECSPEED, MO_STOACCEL);
if ( dist > accDist+desDist )
{
@@ -768,14 +758,14 @@ float CPhysics::RetLinLength(float dist)
bool CPhysics::EventProcess(const Event &event)
{
- if ( !m_object->RetEnable() ) return true;
+ if ( !m_object->GetEnable() ) return true;
if ( m_brain != 0 )
{
m_brain->EventProcess(event);
}
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
return EventFrame(event);
}
@@ -792,7 +782,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
Math::Vector pos, motorSpeed;
float energy, speed, factor, h;
- type = m_object->RetType();
+ type = m_object->GetType();
motorSpeed = m_motorSpeed;
@@ -810,8 +800,8 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
type == OBJECT_TECH )
{
power = 0;
- if ( m_object->RetFret() != 0 && // carries something?
- !m_object->RetCargo() )
+ if ( m_object->GetFret() != 0 && // carries something?
+ !m_object->GetCargo() )
{
motorSpeed.x *= 0.7f; // forward more slowly
motorSpeed.z *= 0.5f;
@@ -825,7 +815,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
motorSpeed.z *= 0.5f;
motorSpeed.y *= 0.5f;
- if ( m_object->RetFret() != 0 ) // carries something?
+ if ( m_object->GetFret() != 0 ) // carries something?
{
motorSpeed.x *= 0.2f;
motorSpeed.z *= 0.9f;
@@ -842,8 +832,8 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
}
else
{
- power = m_object->RetPower(); // searches for the object battery uses
- if ( power == 0 || power->RetEnergy() == 0.0f ) // no battery or flat?
+ power = m_object->GetPower(); // searches for the object battery uses
+ if ( power == 0 || power->GetEnergy() == 0.0f ) // no battery or flat?
{
motorSpeed.x = 0.0f;
motorSpeed.z = 0.0f;
@@ -859,11 +849,11 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
}
}
- if ( m_object->RetDead() ) // dead man?
+ if ( m_object->GetDead() ) // dead man?
{
motorSpeed.x = 0.0f;
motorSpeed.z = 0.0f;
- if ( m_motion->RetAction() == MHS_DEADw ) // drowned?
+ if ( m_motion->GetAction() == MHS_DEADw ) // drowned?
{
motorSpeed.y = 0.0f; // this is MHS_DEADw going back
}
@@ -876,9 +866,9 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
if ( m_type == TYPE_FLYING && !m_bLand && motorSpeed.y > 0.0f )
{
- pos = m_object->RetPosition(0);
- h = m_terrain->RetFlyingLimit(pos, type==OBJECT_BEE);
- h += m_object->RetCharacter()->height;
+ pos = m_object->GetPosition(0);
+ h = m_terrain->GetFlyingLimit(pos, type==OBJECT_BEE);
+ h += m_object->GetCharacter()->height;
if ( pos.y > h-40.0f ) // almost at the top?
{
factor = 1.0f-(pos.y-(h-40.0f))/40.0f;
@@ -889,7 +879,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
}
if ( type != OBJECT_BEE &&
- m_object->RetRange() > 0.0f ) // limited flight range?
+ m_object->GetRange() > 0.0f ) // limited flight range?
{
if ( m_bLand || m_bSwim || m_bObstacle ) // on the ground or in the water?
{
@@ -900,9 +890,9 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
if ( m_reactorRange > 1.0f )
{
m_reactorRange = 1.0f;
- if ( m_bLowLevel && m_object->RetSelect() ) // beep cool?
+ if ( m_bLowLevel && m_object->GetSelect() ) // beep cool?
{
- m_sound->Play(SOUND_INFO, m_object->RetPosition(0), 1.0f, 2.0f);
+ m_sound->Play(SOUND_INFO, m_object->GetPosition(0), 1.0f, 2.0f);
m_bLowLevel = false;
}
}
@@ -910,7 +900,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
}
else // in flight?
{
- m_reactorRange -= rTime*(1.0f/m_object->RetRange());
+ m_reactorRange -= rTime*(1.0f/m_object->GetRange());
if ( m_reactorRange < 0.0f ) m_reactorRange = 0.0f;
if ( m_reactorRange < 0.5f ) m_bLowLevel = true;
}
@@ -921,7 +911,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
}
}
-//? MotorParticule(aTime);
+//? MotorParticle(aTime);
// Forward/backward.
if ( motorSpeed.x > 0.0f )
@@ -991,9 +981,9 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
m_linMotion.motorAccel.x = m_linMotion.stopAccel.x*factor;
m_cirMotion.motorAccel.y = m_cirMotion.stopAccel.y*factor;
- pos = m_object->RetPosition(0);
- h = m_terrain->RetFlyingLimit(pos, type==OBJECT_BEE);
- h += m_object->RetCharacter()->height;
+ pos = m_object->GetPosition(0);
+ h = m_terrain->GetFlyingLimit(pos, type==OBJECT_BEE);
+ h += m_object->GetCharacter()->height;
if ( motorSpeed.y > 0.0f && m_reactorRange > 0.1f && pos.y < h )
{
m_bLand = false; // take off
@@ -1024,9 +1014,9 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
type == OBJECT_MOBILEic ||
type == OBJECT_MOBILEii ) factor = 0.5f;
- factor /= power->RetCapacity();
+ factor /= power->GetCapacity();
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
energy -= fabs(motorSpeed.x)*rTime*factor*0.005f;
energy -= fabs(motorSpeed.z)*rTime*factor*0.005f;
@@ -1050,21 +1040,21 @@ void CPhysics::EffectUpdate(float aTime, float rTime)
ObjectType type;
bool bOnBoard;
- if ( !m_engine->IsVisiblePoint(m_object->RetPosition(0)) ) return;
+ if ( !m_engine->IsVisiblePoint(m_object->GetPosition(0)) ) return;
- type = m_object->RetType();
- character = m_object->RetCharacter();
+ type = m_object->GetType();
+ character = m_object->GetCharacter();
bOnBoard = false;
- if ( m_object->RetSelect() &&
- m_camera->RetType() == CAMERA_ONBOARD )
+ if ( m_object->GetSelect() &&
+ m_camera->GetType() == Gfx::CAM_TYPE_ONBOARD )
{
bOnBoard = true;
}
- vibLin = m_motion->RetLinVibration();
- vibCir = m_motion->RetCirVibration();
- incl = m_motion->RetInclinaison();
+ vibLin = m_motion->GetLinVibration();
+ vibCir = m_motion->GetCirVibration();
+ incl = m_motion->GetInclinaison();
if ( type == OBJECT_HUMAN || // human?
type == OBJECT_TECH )
@@ -1175,6 +1165,7 @@ void CPhysics::EffectUpdate(float aTime, float rTime)
else
{
m_motion->SetLinVibration(Math::Vector(0.0f, 0.0f, 0.0f));
+
//? m_motion->SetCirVibration(Math::Vector(0.0f, 0.0f, 0.0f));
//? m_motion->SetInclinaison(Math::Vector(0.0f, 0.0f, 0.0f));
}
@@ -1475,24 +1466,24 @@ bool CPhysics::EventFrame(const Event &event)
float h, w;
int i;
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
m_time += event.rTime;
m_timeUnderWater += event.rTime;
m_soundTimeJostle += event.rTime;
- type = m_object->RetType();
+ type = m_object->GetType();
- FrameParticule(m_time, event.rTime);
+ FrameParticle(m_time, event.rTime);
MotorUpdate(m_time, event.rTime);
EffectUpdate(m_time, event.rTime);
WaterFrame(m_time, event.rTime);
- iPos = pos = m_object->RetPosition(0);
- iAngle = angle = m_object->RetAngle(0);
+ iPos = pos = m_object->GetPosition(0);
+ iAngle = angle = m_object->GetAngle(0);
// Accelerate is the descent, brake is the ascent.
- if ( m_bFreeze || m_object->RetDead() )
+ if ( m_bFreeze || m_object->GetDead() )
{
m_linMotion.terrainSpeed.x = 0.0f;
m_linMotion.terrainSpeed.z = 0.0f;
@@ -1501,7 +1492,7 @@ bool CPhysics::EventFrame(const Event &event)
else
{
tAngle = angle;
- h = m_terrain->RetBuildingFactor(pos);
+ h = m_terrain->GetBuildingFactor(pos);
if ( type == OBJECT_HUMAN ||
type == OBJECT_TECH )
{
@@ -1512,7 +1503,7 @@ bool CPhysics::EventFrame(const Event &event)
FloorAngle(pos, tAngle); // calculates the angle with the ground
}
#if 1
- if ( pos.y < m_water->RetLevel(m_object) ) // underwater?
+ if ( pos.y < m_water->GetLevel(m_object) ) // underwater?
{
h *= 0.5f;
}
@@ -1535,7 +1526,7 @@ bool CPhysics::EventFrame(const Event &event)
if ( type == OBJECT_BEE && !m_bLand )
{
h = m_floorLevel; // ground level
- w = m_water->RetLevel(m_object);
+ w = m_water->GetLevel(m_object);
if ( h < w ) h = w;
h = pos.y-h-10.0f; // maximum height (*)
if ( h < 0.0f ) h = 0.0f;
@@ -1554,12 +1545,12 @@ bool CPhysics::EventFrame(const Event &event)
newpos = Transform(matRotate, newpos);
newpos += pos;
- m_terrain->LimitPos(newpos);
+ m_terrain->AdjustToStandardBounds(newpos);
if ( m_type == TYPE_FLYING && !m_bLand )
{
- h = m_terrain->RetFlyingLimit(newpos, type==OBJECT_BEE);
- h += m_object->RetCharacter()->height;
+ h = m_terrain->GetFlyingLimit(newpos, type==OBJECT_BEE);
+ h += m_object->GetCharacter()->height;
if ( newpos.y > h ) newpos.y = h;
}
@@ -1604,7 +1595,7 @@ bool CPhysics::EventFrame(const Event &event)
m_object->SetPosition(0, newpos);
}
- MotorParticule(m_time, event.rTime);
+ MotorParticle(m_time, event.rTime);
SoundMotor(event.rTime);
m_bForceUpdate = false;
@@ -1621,33 +1612,33 @@ void CPhysics::SoundMotor(float rTime)
float energy;
m_lastSoundInsect -= rTime;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_MOTHER )
{
- if ( m_lastSoundInsect <= 0.0f && m_object->RetActif() )
+ if ( m_lastSoundInsect <= 0.0f && m_object->GetActif() )
{
- m_sound->Play(SOUND_INSECTm, m_object->RetPosition(0));
+ m_sound->Play(SOUND_INSECTm, m_object->GetPosition(0));
if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
}
else if ( type == OBJECT_ANT )
{
- if ( m_object->RetBurn() ||
- m_object->RetFixed() )
+ if ( m_object->GetBurn() ||
+ m_object->GetFixed() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTa, m_object->RetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
+ m_sound->Play(SOUND_INSECTa, m_object->GetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
m_lastSoundInsect = 0.4f+Math::Rand()*0.6f;
}
}
- else if ( m_object->RetActif() )
+ else if ( m_object->GetActif() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTa, m_object->RetPosition(0));
+ m_sound->Play(SOUND_INSECTa, m_object->GetPosition(0));
if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
@@ -1655,60 +1646,60 @@ void CPhysics::SoundMotor(float rTime)
}
else if ( type == OBJECT_BEE )
{
- if ( m_object->RetActif() )
+ if ( m_object->GetActif() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTb, m_object->RetPosition(0));
+ m_sound->Play(SOUND_INSECTb, m_object->GetPosition(0));
if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
}
- else if ( m_object->RetBurn() )
+ else if ( m_object->GetBurn() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTb, m_object->RetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
+ m_sound->Play(SOUND_INSECTb, m_object->GetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
m_lastSoundInsect = 0.3f+Math::Rand()*0.5f;
}
}
}
else if ( type == OBJECT_WORM )
{
- if ( m_object->RetActif() )
+ if ( m_object->GetActif() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTw, m_object->RetPosition(0));
+ m_sound->Play(SOUND_INSECTw, m_object->GetPosition(0));
if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
}
- else if ( m_object->RetBurn() )
+ else if ( m_object->GetBurn() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTw, m_object->RetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
+ m_sound->Play(SOUND_INSECTw, m_object->GetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
m_lastSoundInsect = 0.2f+Math::Rand()*0.2f;
}
}
}
else if ( type == OBJECT_SPIDER )
{
- if ( m_object->RetBurn() ||
- m_object->RetFixed() )
+ if ( m_object->GetBurn() ||
+ m_object->GetFixed() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTs, m_object->RetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
+ m_sound->Play(SOUND_INSECTs, m_object->GetPosition(0), 1.0f, 1.5f+Math::Rand()*0.5f);
m_lastSoundInsect = 0.4f+Math::Rand()*0.6f;
}
}
- else if ( m_object->RetActif() )
+ else if ( m_object->GetActif() )
{
if ( m_lastSoundInsect <= 0.0f )
{
- m_sound->Play(SOUND_INSECTs, m_object->RetPosition(0));
+ m_sound->Play(SOUND_INSECTs, m_object->GetPosition(0));
if ( m_bMotor ) m_lastSoundInsect = 0.4f+Math::Rand()*2.5f;
else m_lastSoundInsect = 1.5f+Math::Rand()*4.0f;
}
@@ -1718,20 +1709,20 @@ void CPhysics::SoundMotor(float rTime)
{
if ( m_type == TYPE_ROLLING )
{
- if ( m_bMotor && m_object->RetActif() )
+ if ( m_bMotor && m_object->GetActif() )
{
SoundMotorFull(rTime, type); // full diet
}
else
{
energy = 0.0f;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
- if ( m_object->RetSelect() &&
+ if ( m_object->GetSelect() &&
energy != 0.0f )
{
SoundMotorSlow(rTime, type); // in slow motion
@@ -1746,7 +1737,7 @@ void CPhysics::SoundMotor(float rTime)
if ( m_type == TYPE_FLYING )
{
if ( m_bMotor && !m_bSwim &&
- m_object->RetActif() && !m_object->RetDead() )
+ m_object->GetActif() && !m_object->GetDead() )
{
SoundReactorFull(rTime, type); // full diet
}
@@ -1767,20 +1758,20 @@ void CPhysics::WaterFrame(float aTime, float rTime)
Math::Point dim;
float level;
- level = m_water->RetLevel();
+ level = m_water->GetLevel();
if ( level == 0.0f ) return; // no water?
- if ( m_object->RetTruck() != 0 ) return; // object transported?
+ if ( m_object->GetTruck() != 0 ) return; // object transported?
// Management of flames into the lava.
- pos = m_object->RetPosition(0);
- if ( m_water->RetLava() &&
- pos.y-m_object->RetCharacter()->height <= level )
+ pos = m_object->GetPosition(0);
+ if ( m_water->GetLava() &&
+ pos.y-m_object->GetCharacter()->height <= level )
{
- if ( m_lastFlameParticule+m_engine->ParticuleAdapt(0.05f) <= aTime )
+ if ( m_lastFlameParticle+m_engine->ParticleAdapt(0.05f) <= aTime )
{
- m_lastFlameParticule = aTime;
+ m_lastFlameParticle = aTime;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*3.0f;
pos.z += (Math::Rand()-0.5f)*3.0f;
speed.x = 0.0f;
@@ -1788,9 +1779,9 @@ void CPhysics::WaterFrame(float aTime, float rTime)
speed.y = Math::Rand()*5.0f+3.0f;
dim.x = Math::Rand()*2.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFLAME, 2.0f, 0.0f, 0.2f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFLAME, 2.0f, 0.0f, 0.2f);
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y -= 2.0f;
pos.x += (Math::Rand()-0.5f)*5.0f;
pos.z += (Math::Rand()-0.5f)*5.0f;
@@ -1799,23 +1790,23 @@ void CPhysics::WaterFrame(float aTime, float rTime)
speed.y = 6.0f+Math::Rand()*6.0f+6.0f;
dim.x = Math::Rand()*1.5f+1.0f+3.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f);
}
}
- pos = m_object->RetPosition(0);
- if ( pos.y >= m_water->RetLevel(m_object) ) return; // out of water?
+ pos = m_object->GetPosition(0);
+ if ( pos.y >= m_water->GetLevel(m_object) ) return; // out of water?
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_TOTO ) return;
if ( type == OBJECT_NULL ) return;
- if ( !m_object->RetActif() ) return;
- if ( m_object->RetResetBusy() ) return; // reset in progress?
+ if ( !m_object->GetActif() ) return;
+ if ( m_object->GetResetBusy() ) return; // reset in progress?
- if ( m_water->RetLava() ||
+ if ( m_water->GetLava() ||
(type == OBJECT_HUMAN &&
- m_object->RetOption() != 0 ) || // human without a helmet?
+ m_object->GetOption() != 0 ) || // human without a helmet?
type == OBJECT_MOBILEfa ||
type == OBJECT_MOBILEta ||
type == OBJECT_MOBILEwa ||
@@ -1861,13 +1852,13 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type)
{
if ( m_soundChannel == -1 )
{
- m_soundChannel = m_sound->Play(SOUND_MOTORi, m_object->RetPosition(0), 0.0f, 1.0f, true);
+ m_soundChannel = m_sound->Play(SOUND_MOTORi, m_object->GetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, 0.2f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, 1.0f, SOPER_LOOP);
}
else
{
- m_sound->Position(m_soundChannel, m_object->RetPosition(0));
+ m_sound->Position(m_soundChannel, m_object->GetPosition(0));
}
freq = 1.0f+m_linMotion.terrainSpeed.x/50.0f;
@@ -1921,7 +1912,7 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type)
time = 0.3f;
}
- if ( m_object->RetToy() )
+ if ( m_object->GetToy() )
{
sound = SOUND_MOTORd;
amplitude = 1.0f;
@@ -1930,17 +1921,17 @@ void CPhysics::SoundMotorFull(float rTime, ObjectType type)
freq = 0.75f+(fabs(m_motorSpeed.x)+fabs(m_motorSpeed.z))*0.25f;
if ( freq > 1.0f ) freq = 1.0f;
- if ( m_object->RetToy() ) freq = 1.0f;
+ if ( m_object->GetToy() ) freq = 1.0f;
if ( m_soundChannel == -1 )
{
- m_soundChannel = m_sound->Play(sound, m_object->RetPosition(0), 0.0f, 0.5f, true);
+ m_soundChannel = m_sound->Play(sound, m_object->GetPosition(0), 0.0f, 0.5f, true);
m_sound->AddEnvelope(m_soundChannel, amplitude, freq, time, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, amplitude, freq, 1.0f, SOPER_LOOP);
}
else
{
- m_sound->Position(m_soundChannel, m_object->RetPosition(0));
+ m_sound->Position(m_soundChannel, m_object->GetPosition(0));
if ( m_bSoundSlow ) // in slow motion?
{
@@ -2020,7 +2011,7 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type)
amplitude = 0.3f;
}
- if ( m_object->RetToy() )
+ if ( m_object->GetToy() )
{
sound = SOUND_MOTORd;
amplitude = 0.0f;
@@ -2028,13 +2019,13 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type)
if ( m_soundChannel == -1 )
{
- m_soundChannel = m_sound->Play(sound, m_object->RetPosition(0), 0.0f, 0.25f, true);
+ m_soundChannel = m_sound->Play(sound, m_object->GetPosition(0), 0.0f, 0.25f, true);
m_sound->AddEnvelope(m_soundChannel, amplitude, 0.5f, 0.2f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, amplitude, 0.5f, 1.0f, SOPER_LOOP);
}
else
{
- m_sound->Position(m_soundChannel, m_object->RetPosition(0));
+ m_sound->Position(m_soundChannel, m_object->GetPosition(0));
if ( !m_bSoundSlow ) // full power?
{
@@ -2056,12 +2047,12 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type)
{
amplitude = 0.5f-m_soundTimePshhh*0.08f;
if ( amplitude > 1.0f ) amplitude = 1.0f;
-//? m_sound->Play(SOUND_PSHHH, m_object->RetPosition(0), amplitude);
- m_sound->Play(SOUND_PSHHH, m_object->RetPosition(0), 1.0f);
+//? m_sound->Play(SOUND_PSHHH, m_object->GetPosition(0), amplitude);
+ m_sound->Play(SOUND_PSHHH, m_object->GetPosition(0), 1.0f);
m_soundTimePshhh = 4.0f+4.0f*Math::Rand();
- max = (int)(10.0f*m_engine->RetParticuleDensity());
+ max = static_cast<int>(10.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<max ; i++ )
{
pos = Math::Vector(-5.0f, 2.0f, 0.0f);
@@ -2073,14 +2064,14 @@ void CPhysics::SoundMotorSlow(float rTime, ObjectType type)
speed.y -= Math::Rand()*3.0f;
speed.z += (Math::Rand()-0.5f)*6.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = Transform(*mat, speed)-pos;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIMOTOR, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIMOTOR, 2.0f);
}
}
}
@@ -2146,13 +2137,13 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type)
sound = SOUND_FLY;
}
- m_soundChannel = m_sound->Play(sound, m_object->RetPosition(0), 0.0f, 1.0f, true);
+ m_soundChannel = m_sound->Play(sound, m_object->GetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, 0.6f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, 1.0f, SOPER_LOOP);
}
else
{
- m_sound->Position(m_soundChannel, m_object->RetPosition(0));
+ m_sound->Position(m_soundChannel, m_object->GetPosition(0));
}
freq = 1.0f + m_linMotion.realSpeed.y/100.0f;
@@ -2171,13 +2162,13 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type)
if ( m_timeReactorFail <= m_time )
{
freq = 1.0f+Math::Rand()*0.5f;
- m_sound->Play(SOUND_FLYf, m_object->RetPosition(0), 1.0f, freq);
- m_camera->StartEffect(CE_PET, m_object->RetPosition(0), 1.0f);
+ m_sound->Play(SOUND_FLYf, m_object->GetPosition(0), 1.0f, freq);
+ m_camera->StartEffect(Gfx::CAM_EFFECT_PET, m_object->GetPosition(0), 1.0f);
for ( i=0 ; i<5 ; i++ )
{
- if ( m_object->RetType() == OBJECT_HUMAN ||
- m_object->RetType() == OBJECT_TECH )
+ if ( m_object->GetType() == OBJECT_HUMAN ||
+ m_object->GetType() == OBJECT_TECH )
{
pos = Math::Vector(-1.6f, -0.5f, 0.0f);
}
@@ -2187,22 +2178,22 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type)
}
pos.x += (Math::Rand()-0.5f)*2.0f;
pos.z += (Math::Rand()-0.5f)*2.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
speed.x = (Math::Rand()-0.5f)*5.0f;
speed.z = (Math::Rand()-0.5f)*5.0f;
speed.y = -(4.0f+Math::Rand()*4.0f);
dim.x = (2.0f+Math::Rand()*1.0f);
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 2.0f, 0.0f, 0.1f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE1, 2.0f, 0.0f, 0.1f);
}
m_timeReactorFail = m_time+0.10f+Math::Rand()*0.30f;
}
else
{
- if ( m_object->RetType() == OBJECT_HUMAN ||
- m_object->RetType() == OBJECT_TECH )
+ if ( m_object->GetType() == OBJECT_HUMAN ||
+ m_object->GetType() == OBJECT_TECH )
{
pos = Math::Vector(-1.6f, -0.5f, 0.0f);
}
@@ -2212,14 +2203,14 @@ void CPhysics::SoundReactorFull(float rTime, ObjectType type)
}
pos.x += (Math::Rand()-0.5f)*1.0f;
pos.z += (Math::Rand()-0.5f)*1.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
speed.x = (Math::Rand()-0.5f)*2.0f;
speed.z = (Math::Rand()-0.5f)*2.0f;
speed.y = -(4.0f+Math::Rand()*4.0f);
dim.x = (0.7f+Math::Rand()*0.4f);
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE1, 2.0f, 0.0f, 0.1f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE1, 2.0f, 0.0f, 0.1f);
}
}
@@ -2233,10 +2224,10 @@ void CPhysics::SoundReactorStop(float rTime, ObjectType type)
float energy;
energy = 0.0f;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
if ( m_soundChannel != -1 ) // engine is running?
@@ -2264,11 +2255,11 @@ void CPhysics::SoundReactorStop(float rTime, ObjectType type)
{
if ( m_soundChannelSlide == -1 )
{
- m_soundChannelSlide = m_sound->Play(SOUND_SLIDE, m_object->RetPosition(0), 0.0f, 1.0f, true);
+ m_soundChannelSlide = m_sound->Play(SOUND_SLIDE, m_object->GetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_soundChannelSlide, 0.5f, 1.0f, 0.3f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannelSlide, 0.5f, 1.0f, 1.0f, SOPER_LOOP);
}
- m_sound->Position(m_soundChannelSlide, m_object->RetPosition(0));
+ m_sound->Position(m_soundChannelSlide, m_object->GetPosition(0));
}
else
{
@@ -2293,21 +2284,20 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
Math::Vector norm;
Math::Matrix matRotate;
float level, h, f, a1, volume, freq, force;
- bool bOldSwim, bSlopingTerrain;
+ bool bSlopingTerrain;
- type = m_object->RetType();
- character = m_object->RetCharacter();
+ type = m_object->GetType();
+ character = m_object->GetCharacter();
- level = m_water->RetLevel(m_object);
- bOldSwim = m_bSwim;
+ level = m_water->GetLevel(m_object);
SetSwim( pos.y < level );
- m_floorLevel = m_terrain->RetFloorLevel(pos); // height above the ground
+ m_floorLevel = m_terrain->GetFloorLevel(pos); // height above the ground
h = pos.y-m_floorLevel;
h -= character->height;
m_floorHeight = h;
- WaterParticule(aTime, pos, type, m_floorLevel,
+ WaterParticle(aTime, pos, type, m_floorLevel,
fabs(m_linMotion.realSpeed.x),
fabs(m_cirMotion.realSpeed.y*15.0f));
@@ -2342,13 +2332,13 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
{
volume = fabs(m_linMotion.realSpeed.x*0.02f)+
fabs(m_linMotion.realSpeed.y*0.02f);
- freq = 0.5f+m_terrain->RetHardness(pos)*2.5f;
+ freq = 0.5f+m_terrain->GetHardness(pos)*2.5f;
m_sound->Play(SOUND_BOUM, pos, volume, freq);
m_soundTimeBoum = aTime;
}
-//? pos = m_object->RetPosition(0); // gives position before collision
+//? pos = m_object->GetPosition(0); // gives position before collision
}
}
}
@@ -2358,7 +2348,7 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
if ( !m_bLand ) // in flight?
{
volume = fabs(m_linMotion.realSpeed.y*0.02f);
- freq = 0.5f+m_terrain->RetHardness(pos)*2.5f;
+ freq = 0.5f+m_terrain->GetHardness(pos)*2.5f;
m_sound->Play(SOUND_BOUM, pos, volume, freq);
}
@@ -2370,7 +2360,7 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
if ( h < 0.0f )
{
f = fabs(m_linMotion.currentSpeed.y/m_linMotion.advanceSpeed.y);
- CrashParticule(f);
+ CrashParticle(f);
}
m_linMotion.currentSpeed.y = 0.0f;
m_inclinaisonFactor = 1.0f/LANDING_SPEED; // slips a little to the ground
@@ -2422,13 +2412,13 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
if ( m_floorHeight == 0.0f ) // ground plate?
{
- if ( m_object->RetTraceDown() )
+ if ( m_object->GetTraceDown() )
{
- WheelParticule(m_object->RetTraceColor(), m_object->RetTraceWidth()*g_unit);
+ WheelParticle(m_object->GetTraceColor(), m_object->GetTraceWidth()*g_unit);
}
else
{
- WheelParticule(-1, 0.0f);
+ WheelParticle(-1, 0.0f);
}
}
@@ -2463,29 +2453,29 @@ void CPhysics::FloorAngle(const Math::Vector &pos, Math::Vector &angle)
Math::Vector pw, norm;
float a1, a2;
- character = m_object->RetCharacter();
+ character = m_object->GetCharacter();
pw.x = pos.x+character->wheelFront*cosf(angle.y+Math::PI*0.0f);
pw.y = pos.y;
pw.z = pos.z-character->wheelFront*sinf(angle.y+Math::PI*0.0f);
- a1 = atanf(m_terrain->RetFloorHeight(pw)/character->wheelFront);
+ a1 = atanf(m_terrain->GetHeightToFloor(pw)/character->wheelFront);
pw.x = pos.x+character->wheelBack*cosf(angle.y+Math::PI*1.0f);
pw.y = pos.y;
pw.z = pos.z-character->wheelBack*sinf(angle.y+Math::PI*1.0f);
- a2 = atanf(m_terrain->RetFloorHeight(pw)/character->wheelBack);
+ a2 = atanf(m_terrain->GetHeightToFloor(pw)/character->wheelBack);
angle.z = (a2-a1)/2.0f;
pw.x = pos.x+character->wheelLeft*cosf(angle.y+Math::PI*0.5f)*cosf(angle.z);
pw.y = pos.y;
pw.z = pos.z-character->wheelLeft*sinf(angle.y+Math::PI*0.5f)*cosf(angle.z);
- a1 = atanf(m_terrain->RetFloorHeight(pw)/character->wheelLeft);
+ a1 = atanf(m_terrain->GetHeightToFloor(pw)/character->wheelLeft);
pw.x = pos.x+character->wheelRight*cosf(angle.y+Math::PI*1.5f)*cosf(angle.z);
pw.y = pos.y;
pw.z = pos.z-character->wheelRight*sinf(angle.y+Math::PI*1.5f)*cosf(angle.z);
- a2 = atanf(m_terrain->RetFloorHeight(pw)/character->wheelRight);
+ a2 = atanf(m_terrain->GetHeightToFloor(pw)/character->wheelRight);
angle.x = (a2-a1)/2.0f;
}
@@ -2498,37 +2488,37 @@ void CPhysics::FloorAngle(const Math::Vector &pos, Math::Vector &angle)
int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
{
- CObject* pObj;
- CPyro* pyro;
- CPhysics* ph;
+ CObject* pObj;
+ Gfx::CPyro* pyro;
+ CPhysics* ph;
Math::Matrix matRotate;
Math::Vector iPos, oPos, iiPos, oAngle, oSpeed;
- Sound sound;
- float iRad, oRad, distance, force, volume;
- int i, j, colType;
- ObjectType iType, oType;
+ Sound sound;
+ float iRad, oRad, distance, force, volume;
+ int i, j, colType;
+ ObjectType iType, oType;
- if ( m_object->RetRuin() ) return 0; // is burning or exploding?
- if ( !m_object->RetClip() ) return 0;
+ if ( m_object->GetRuin() ) return 0; // is burning or exploding?
+ if ( !m_object->GetClip() ) return 0;
// iiPos = sphere center is the old position.
// iPos = sphere center has the new position.
m_object->GetCrashSphere(0, iiPos, iRad);
- iPos = iiPos + (pos - m_object->RetPosition(0));
- iType = m_object->RetType();
+ iPos = iiPos + (pos - m_object->GetPosition(0));
+ iType = m_object->GetType();
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
- if ( !pObj->RetEnable() ) continue; // inactive?
- if ( pObj->RetRuin() ) continue; // is burning or exploding?
- if ( pObj->RetDead() ) continue; // dead man?
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetEnable() ) continue; // inactive?
+ if ( pObj->GetRuin() ) continue; // is burning or exploding?
+ if ( pObj->GetDead() ) continue; // dead man?
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType == OBJECT_NULL ) continue;
if ( oType == OBJECT_TOTO ) continue;
//? if ( iType == OBJECT_BEE && oType == OBJECT_BEE ) continue;
@@ -2571,34 +2561,34 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
#if _TEEN
if ( oType == OBJECT_WAYPOINT &&
- pObj->RetEnable() &&
- !m_object->RetResetBusy() ) // driving vehicle?
+ pObj->GetEnable() &&
+ !m_object->GetResetBusy() ) // driving vehicle?
#else
if ( oType == OBJECT_WAYPOINT &&
- pObj->RetEnable() &&
- !m_object->RetResetBusy() &&
- m_object->RetTrainer() ) // driving vehicle?
+ pObj->GetEnable() &&
+ !m_object->GetResetBusy() &&
+ m_object->GetTrainer() ) // driving vehicle?
#endif
{
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
distance = Math::DistanceProjected(oPos, iPos);
if ( distance < 4.0f )
{
- m_sound->Play(SOUND_WAYPOINT, m_object->RetPosition(0));
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_WPCHECK, pObj);
+ m_sound->Play(SOUND_WAYPOINT, m_object->GetPosition(0));
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_WPCHECK, pObj);
}
}
if ( oType == OBJECT_TARGET2 )
{
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
distance = Math::Distance(oPos, iPos);
if ( distance < 10.0f*1.5f )
{
- m_sound->Play(SOUND_WAYPOINT, m_object->RetPosition(0));
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_WPCHECK, pObj);
+ m_sound->Play(SOUND_WAYPOINT, m_object->GetPosition(0));
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_WPCHECK, pObj);
}
}
@@ -2620,11 +2610,11 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
m_bCollision = true;
m_bObstacle = true;
- sound = pObj->RetCrashSphereSound(j-1);
+ sound = pObj->GetCrashSphereSound(j-1);
if ( sound != SOUND_CLICK )
{
force = fabs(m_linMotion.realSpeed.x);
- force *= pObj->RetCrashSphereHardness(j-1)*2.0f;
+ force *= pObj->GetCrashSphereHardness(j-1)*2.0f;
if ( ExploOther(iType, pObj, oType, force) ) continue;
colType = ExploHimself(iType, oType, force);
if ( colType == 2 ) return 2; // destroyed?
@@ -2632,16 +2622,16 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
}
force = m_linMotion.realSpeed.Length();
- force *= pObj->RetCrashSphereHardness(j-1);
+ force *= pObj->GetCrashSphereHardness(j-1);
volume = fabs(force*0.05f);
if ( volume > 1.0f ) volume = 1.0f;
if ( sound != SOUND_CLICK )
{
- m_sound->Play(sound, m_object->RetPosition(0), volume);
+ m_sound->Play(sound, m_object->GetPosition(0), volume);
}
if ( iType == OBJECT_HUMAN && volume > 0.5f )
{
- m_sound->Play(SOUND_AIE, m_object->RetPosition(0), volume);
+ m_sound->Play(SOUND_AIE, m_object->GetPosition(0), volume);
}
if ( m_repeatCollision > 0 )
@@ -2663,14 +2653,14 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
m_linMotion.currentSpeed.y = 0.0f;
}
- ph = pObj->RetPhysics();
+ ph = pObj->GetPhysics();
if ( ph != 0 )
{
- oAngle = pObj->RetAngle(0);
+ oAngle = pObj->GetAngle(0);
oSpeed = Normalize(oPos-iPos)*force;
Math::LoadRotationXZYMatrix(matRotate, -oAngle);
oSpeed = Transform(matRotate, oSpeed);
- if ( ph->RetType() == TYPE_ROLLING )
+ if ( ph->GetType() == TYPE_ROLLING )
{
oSpeed.y = 0.0f;
}
@@ -2737,7 +2727,7 @@ bool CPhysics::JostleObject(CObject* pObj, float force)
if ( m_soundTimeJostle >= 0.20f )
{
m_soundTimeJostle = 0.0f;
- m_sound->Play(SOUND_JOSTLE, pObj->RetPosition(0), force);
+ m_sound->Play(SOUND_JOSTLE, pObj->GetPosition(0), force);
}
return pObj->JostleObject(force);
@@ -2749,9 +2739,9 @@ bool CPhysics::JostleObject(CObject* pObj, float force)
bool CPhysics::ExploOther(ObjectType iType,
CObject *pObj, ObjectType oType, float force)
{
- CPyro* pyro;
+ Gfx::CPyro* pyro;
- if ( !pObj->RetEnable() ) return true;
+ if ( !pObj->GetEnable() ) return true;
JostleObject(pObj, 1.0f); // shakes the object
@@ -2759,24 +2749,24 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_FRET ||
oType == OBJECT_METAL ) )
{
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_EXPLOT, pObj); // total destruction
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_EXPLOT, pObj); // total destruction
}
if ( force > 50.0f &&
(oType == OBJECT_POWER ||
oType == OBJECT_ATOMIC ) )
{
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FRAGT, pObj); // total destruction
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
if ( force > 25.0f &&
(oType == OBJECT_STONE ||
oType == OBJECT_URANIUM ) )
{
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FRAGT, pObj); // total destruction
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
if ( force > 25.0f &&
@@ -2836,15 +2826,15 @@ bool CPhysics::ExploOther(ObjectType iType,
(oType == OBJECT_MOBILEtg ||
oType == OBJECT_TNT ) )
{
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FRAGT, pObj); // total destruction
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
if ( force > 0.0f &&
oType == OBJECT_BOMB )
{
- pyro = new CPyro(m_iMan);
- pyro->Create(PT_FRAGT, pObj); // total destruction
+ pyro = new Gfx::CPyro(m_iMan);
+ pyro->Create(Gfx::PT_FRAGT, pObj); // total destruction
}
return false;
@@ -2857,16 +2847,16 @@ bool CPhysics::ExploOther(ObjectType iType,
int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force)
{
- PyroType type;
- CPyro* pyro;
+ Gfx::PyroType type;
+ Gfx::CPyro* pyro;
if ( force > 10.0f &&
(oType == OBJECT_TNT ||
oType == OBJECT_MOBILEtg ) )
{
- if ( iType == OBJECT_HUMAN ) type = PT_DEADG;
- else type = PT_EXPLOT;
- pyro = new CPyro(m_iMan);
+ if ( iType == OBJECT_HUMAN ) type = Gfx::PT_DEADG;
+ else type = Gfx::PT_EXPLOT;
+ pyro = new Gfx::CPyro(m_iMan);
pyro->Create(type, m_object); // total destruction
return 2;
}
@@ -2876,19 +2866,19 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force)
{
if ( iType == OBJECT_HUMAN )
{
- type = PT_DEADG;
+ type = Gfx::PT_DEADG;
}
else if ( iType == OBJECT_ANT ||
iType == OBJECT_SPIDER ||
iType == OBJECT_BEE )
{
- type = PT_EXPLOO;
+ type = Gfx::PT_EXPLOO;
}
else
{
- type = PT_EXPLOT;
+ type = Gfx::PT_EXPLOT;
}
- pyro = new CPyro(m_iMan);
+ pyro = new Gfx::CPyro(m_iMan);
pyro->Create(type, m_object); // total destruction
return 2;
}
@@ -2980,7 +2970,7 @@ int CPhysics::ExploHimself(ObjectType iType, ObjectType oType, float force)
// Makes the particles evolve.
-void CPhysics::FrameParticule(float aTime, float rTime)
+void CPhysics::FrameParticle(float aTime, float rTime)
{
Math::Vector pos;
CObject* power;
@@ -2988,61 +2978,61 @@ void CPhysics::FrameParticule(float aTime, float rTime)
int effectLight;
bool bFlash;
- m_restBreakParticule -= rTime;
- if ( aTime-m_lastPowerParticule < m_engine->ParticuleAdapt(0.05f) ) return;
- m_lastPowerParticule = aTime;
+ m_restBreakParticle -= rTime;
+ if ( aTime-m_lastPowerParticle < m_engine->ParticleAdapt(0.05f) ) return;
+ m_lastPowerParticle = aTime;
bFlash = false;
energy = 0.0f;
- power = m_object->RetPower();
+ power = m_object->GetPower();
if ( power != 0 )
{
- energy = power->RetEnergy();
+ energy = power->GetEnergy();
}
if ( energy != m_lastEnergy ) // change the energy level?
{
if ( energy > m_lastEnergy ) // recharge?
{
- PowerParticule(1.0f, false);
+ PowerParticle(1.0f, false);
bFlash = true;
}
if ( energy == 0.0f || m_lastEnergy == 0.0f )
{
- m_restBreakParticule = 2.5f; // particles for 2.5s
+ m_restBreakParticle = 2.5f; // particles for 2.5s
}
m_lastEnergy = energy;
}
- if ( m_restBreakParticule > 0.0f )
+ if ( m_restBreakParticle > 0.0f )
{
- PowerParticule(m_restBreakParticule/2.5f, (energy == 0));
+ PowerParticle(m_restBreakParticle/2.5f, (energy == 0));
bFlash = true;
}
- effectLight = m_object->RetEffectLight();
+ effectLight = m_object->GetEffectLight();
if ( effectLight != -1 )
{
if ( bFlash )
{
intensity = 0.0f;
if ( Math::Rand() < 0.5f ) intensity = 1.0f;
- m_light->SetLightIntensity(effectLight, intensity);
- m_light->SetLightIntensitySpeed(effectLight, 10000.0f);
+ m_lightMan->SetLightIntensity(effectLight, intensity);
+ m_lightMan->SetLightIntensitySpeed(effectLight, 10000.0f);
}
else
{
- m_light->SetLightIntensity(effectLight, 0.0f);
+ m_lightMan->SetLightIntensity(effectLight, 0.0f);
}
}
}
// Generates some particles after a recharge.
-void CPhysics::PowerParticule(float factor, bool bBreak)
+void CPhysics::PowerParticle(float factor, bool bBreak)
{
Character* character;
CObject* fret;
@@ -3052,15 +3042,15 @@ void CPhysics::PowerParticule(float factor, bool bBreak)
bool bCarryPower;
bCarryPower = false;
- fret = m_object->RetFret();
- if ( fret != 0 && fret->RetType() == OBJECT_POWER &&
- m_object->RetAngleZ(1) == ARM_STOCK_ANGLE1 )
+ fret = m_object->GetFret();
+ if ( fret != 0 && fret->GetType() == OBJECT_POWER &&
+ m_object->GetAngleZ(1) == ARM_STOCK_ANGLE1 )
{
bCarryPower = true; // carries a battery
}
- mat = m_object->RetWorldMatrix(0);
- character = m_object->RetCharacter();
+ mat = m_object->GetWorldMatrix(0);
+ character = m_object->GetCharacter();
pos = character->posPower;
pos.x -= 0.3f;
@@ -3078,7 +3068,7 @@ void CPhysics::PowerParticule(float factor, bool bBreak)
dim.x = 1.0f*factor;
dim.y = 1.0f*factor;
- m_particule->CreateParticule(ppos, speed, dim, PARTIBLITZ, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(ppos, speed, dim, Gfx::PARTIBLITZ, 0.5f, 0.0f, 0.0f);
if ( bCarryPower ) // carry a battery?
{
@@ -3096,27 +3086,27 @@ void CPhysics::PowerParticule(float factor, bool bBreak)
dim.x = 1.0f*factor;
dim.y = 1.0f*factor;
- m_particule->CreateParticule(ppos, speed, dim, PARTIBLITZ, 0.5f, 0.0f, 0.0f);
+ m_particle->CreateParticle(ppos, speed, dim, Gfx::PARTIBLITZ, 0.5f, 0.0f, 0.0f);
}
}
// Generates some particles after a fall.
// crash: 0=super soft, 1=big crash
-void CPhysics::CrashParticule(float crash)
+void CPhysics::CrashParticle(float crash)
{
Math::Vector pos, ppos, speed;
Math::Point dim;
- float len;
- int i, max;
+ float len;
+ int i, max;
if ( crash < 0.2f ) return;
- pos = m_object->RetPosition(0);
- m_camera->StartEffect(CE_CRASH, pos, crash);
+ pos = m_object->GetPosition(0);
+ m_camera->StartEffect(Gfx::CAM_EFFECT_CRASH, pos, crash);
//? max = (int)(crash*50.0f);
- max = (int)(crash*10.0f*m_engine->RetParticuleDensity());
+ max = static_cast<int>(crash*10.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<max ; i++ )
{
@@ -3130,13 +3120,13 @@ void CPhysics::CrashParticule(float crash)
speed.y = -2.0f;
dim.x = 2.0f+crash*5.0f*len;
dim.y = dim.x;
- m_particule->CreateParticule(ppos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(ppos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
}
// Generates some exhaust gas particle.
-void CPhysics::MotorParticule(float aTime, float rTime)
+void CPhysics::MotorParticle(float aTime, float rTime)
{
Math::Matrix* mat;
Math::Vector pos, speed;
@@ -3146,9 +3136,9 @@ void CPhysics::MotorParticule(float aTime, float rTime)
float h, a, delay, level;
int r, i, nb;
- if ( m_object->RetToy() ) return;
+ if ( m_object->GetToy() ) return;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_MOBILEia ||
type == OBJECT_MOBILEic ||
@@ -3166,14 +3156,14 @@ void CPhysics::MotorParticule(float aTime, float rTime)
else delay = 8.0f;
if ( m_bSwim && m_timeUnderWater < delay ) // bubbles when entering water?
{
- if ( aTime-m_lastUnderParticule >= m_engine->ParticuleAdapt(0.05f) )
+ if ( aTime-m_lastUnderParticle >= m_engine->ParticleAdapt(0.05f) )
{
- m_lastUnderParticule = aTime;
+ m_lastUnderParticle = aTime;
- nb = (int)(20.0f-(20.0f/delay)*m_timeUnderWater);
+ nb = static_cast<int>(20.0f-(20.0f/delay)*m_timeUnderWater);
for ( i=0 ; i<nb ; i++ )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.x += (Math::Rand()-0.5f)*4.0f;
pos.y += (Math::Rand()-0.5f)*4.0f;
pos.z += (Math::Rand()-0.5f)*4.0f;
@@ -3182,13 +3172,13 @@ void CPhysics::MotorParticule(float aTime, float rTime)
speed.z = (Math::Rand()-0.5f)*0.2f;
dim.x = 0.06f+Math::Rand()*0.10f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
}
}
}
- level = m_water->RetLevel();
- pos = m_object->RetPosition(0);
+ level = m_water->GetLevel();
+ pos = m_object->GetPosition(0);
if ( type == OBJECT_HUMAN ) pos.y -= 2.0f;
if ( pos.y < level ) // underwater?
{
@@ -3203,16 +3193,16 @@ void CPhysics::MotorParticule(float aTime, float rTime)
if ( pos.y >= level &&
m_absorbWater > 0.0f &&
- !m_water->RetLava() ) // drops on leaving the water?
+ !m_water->GetLava() ) // drops on leaving the water?
{
- if ( aTime-m_lastUnderParticule >= m_engine->ParticuleAdapt(0.05f) )
+ if ( aTime-m_lastUnderParticle >= m_engine->ParticleAdapt(0.05f) )
{
- m_lastUnderParticule = aTime;
+ m_lastUnderParticle = aTime;
- nb = (int)(8.0f*m_absorbWater);
+ nb = static_cast<int>(8.0f*m_absorbWater);
for ( i=0 ; i<nb ; i++ )
{
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
if ( type == OBJECT_HUMAN ) pos.y -= Math::Rand()*2.0f;
else pos.y += Math::Rand()*2.0f;
pos.x += (Math::Rand()-0.5f)*2.0f;
@@ -3222,7 +3212,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
speed.z = 0.0f;
dim.x = 0.2f;
dim.y = 0.2f;
- m_particule->CreateParticule(pos, speed, dim, PARTIWATER, 2.0f, 0.0f, 1.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIWATER, 2.0f, 0.0f, 1.0f);
}
}
}
@@ -3231,18 +3221,18 @@ void CPhysics::MotorParticule(float aTime, float rTime)
type == OBJECT_TECH )
{
if ( m_bLand &&
- aTime-m_lastSlideParticule >= m_engine->ParticuleAdapt(0.05f) )
+ aTime-m_lastSlideParticle >= m_engine->ParticleAdapt(0.05f) )
{
h = Math::Max(fabs(m_linMotion.terrainSpeed.x),
fabs(m_linMotion.terrainSpeed.z));
if ( h > m_linMotion.terrainSlide.x+0.5f &&
m_linMotion.motorSpeed.x == 0.0f ) // slides a stop?
{
- m_lastSlideParticule = aTime;
+ m_lastSlideParticle = aTime;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos.x = (Math::Rand()-0.5f)*1.0f;
- pos.y = -m_object->RetCharacter()->height;
+ pos.y = -m_object->GetCharacter()->height;
pos.z = Math::Rand()*0.4f+1.0f;
if ( rand()%2 == 0 ) pos.z = -pos.z;
pos = Transform(*mat, pos);
@@ -3250,7 +3240,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
dim.x = Math::Rand()*(h-5.0f)/2.0f+1.0f;
if ( dim.x > 2.5f ) dim.x = 2.5f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.2f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 0.2f);
}
}
}
@@ -3260,14 +3250,14 @@ void CPhysics::MotorParticule(float aTime, float rTime)
type == OBJECT_MOBILEti ||
type == OBJECT_MOBILEts ) // caterpillars?
{
- if ( aTime-m_lastSlideParticule >= m_engine->ParticuleAdapt(0.05f) )
+ if ( aTime-m_lastSlideParticle >= m_engine->ParticleAdapt(0.05f) )
{
h = fabs(m_linMotion.motorSpeed.x-m_linMotion.realSpeed.x);
if ( h > 5.0f )
{
- m_lastSlideParticule = aTime;
+ m_lastSlideParticle = aTime;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos.x = (Math::Rand()-0.5f)*8.0f;
pos.y = 0.0f;
pos.z = Math::Rand()*2.0f+3.0f;
@@ -3277,7 +3267,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
dim.x = Math::Rand()*(h-5.0f)/2.0f+1.0f;
if ( dim.x > 3.0f ) dim.x = 3.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.2f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 0.2f);
}
}
}
@@ -3287,14 +3277,14 @@ void CPhysics::MotorParticule(float aTime, float rTime)
type == OBJECT_MOBILErr ||
type == OBJECT_MOBILErs ) // large caterpillars?
{
- if ( aTime-m_lastSlideParticule >= m_engine->ParticuleAdapt(0.05f) )
+ if ( aTime-m_lastSlideParticle >= m_engine->ParticleAdapt(0.05f) )
{
h = fabs(m_linMotion.motorSpeed.x-m_linMotion.realSpeed.x);
if ( h > 5.0f )
{
- m_lastSlideParticule = aTime;
+ m_lastSlideParticle = aTime;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos.x = (Math::Rand()-0.5f)*9.0f;
pos.y = 0.0f;
pos.z = Math::Rand()*3.0f+3.0f;
@@ -3304,7 +3294,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
dim.x = Math::Rand()*(h-5.0f)/2.0f+1.0f;
if ( dim.x > 3.0f ) dim.x = 3.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.2f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 0.2f);
}
}
}
@@ -3323,11 +3313,11 @@ void CPhysics::MotorParticule(float aTime, float rTime)
}
if ( m_reactorTemperature == 0.0f ||
- aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.05f) ) return;
- m_lastMotorParticule = aTime;
+ aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.05f) ) return;
+ m_lastMotorParticle = aTime;
pos = Math::Vector(-1.6f, -0.5f, 0.0f);
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
speed.x = (Math::Rand()-0.5f)*0.6f;
@@ -3337,7 +3327,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
dim.x = (1.0f+Math::Rand()*0.5f)*(0.2f+m_reactorTemperature*0.8f);
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTISMOKE2, 3.0f, 0.0f, 0.1f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE2, 3.0f, 0.0f, 0.1f);
}
else // in flight?
{
@@ -3352,14 +3342,14 @@ void CPhysics::MotorParticule(float aTime, float rTime)
}
}
- if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.02f) ) return;
- m_lastMotorParticule = aTime;
+ if ( aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.02f) ) return;
+ m_lastMotorParticle = aTime;
pos = Math::Vector(-1.6f, -1.0f, 0.0f);
pos.x += (Math::Rand()-0.5f)*3.0f;
pos.y += (Math::Rand()-0.5f)*1.5f;
pos.z += (Math::Rand()-0.5f)*3.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
h = m_floorHeight;
@@ -3377,7 +3367,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
dim.x = 0.12f;
dim.y = 0.12f;
- m_particule->CreateParticule(pos, speed, dim, PARTISCRAPS, 2.0f, 10.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISCRAPS, 2.0f, 10.0f);
#if 1
pos = Math::Vector(-1.6f, -0.5f, 0.0f);
@@ -3396,7 +3386,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
{
speed.y += m_linMotion.realSpeed.y*1.2f;
}
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
p.x = speed.x;
p.y = speed.z;
p = Math::RotatePoint(-a, p);
@@ -3406,7 +3396,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
dim.x = 0.4f+Math::Rand()*0.2f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIEJECT, 0.3f, 10.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIEJECT, 0.3f, 10.0f);
#endif
}
}
@@ -3431,8 +3421,8 @@ void CPhysics::MotorParticule(float aTime, float rTime)
if ( h < 3.0f ) return;
- if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.2f) ) return;
- m_lastMotorParticule = aTime;
+ if ( aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.2f) ) return;
+ m_lastMotorParticle = aTime;
r = rand()%3;
if ( r == 0 ) pos = Math::Vector(-3.0f, 0.0f, -4.0f);
@@ -3441,20 +3431,20 @@ void CPhysics::MotorParticule(float aTime, float rTime)
pos.x += (Math::Rand()-0.5f)*2.0f;
pos.z += (Math::Rand()-0.5f)*2.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = Math::Rand()*h/5.0f+2.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f);
}
else // glide with small reactors in skates?
{
if ( m_linMotion.realSpeed.x == 0.0f &&
m_cirMotion.realSpeed.y == 0.0f ) return;
- if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.02f) ) return;
- m_lastMotorParticule = aTime;
+ if ( aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.02f) ) return;
+ m_lastMotorParticle = aTime;
r = rand()%3;
if ( r == 0 ) pos = Math::Vector(-3.0f, 0.0f, -4.0f);
@@ -3463,26 +3453,26 @@ void CPhysics::MotorParticule(float aTime, float rTime)
pos.x += (Math::Rand()-0.5f)*1.0f;
pos.z += (Math::Rand()-0.5f)*1.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = Math::Vector(0.0f, 0.0f, 0.0f);
dim.x = 1.0f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIEJECT);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIEJECT);
}
}
else // in flight?
{
if ( !m_bMotor || m_reactorRange == 0.0f ) return;
- if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.02f) ) return;
- m_lastMotorParticule = aTime;
+ if ( aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.02f) ) return;
+ m_lastMotorParticle = aTime;
pos = Math::Vector(0.0f, -1.0f, 0.0f);
pos.x += (Math::Rand()-0.5f)*6.0f;
pos.y += (Math::Rand()-0.5f)*3.0f;
pos.z += (Math::Rand()-0.5f)*6.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
h = m_floorHeight;
@@ -3500,7 +3490,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
dim.x = 0.2f;
dim.y = 0.2f;
- m_particule->CreateParticule(pos, speed, dim, PARTISCRAPS, 2.0f, 10.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISCRAPS, 2.0f, 10.0f);
#if 1
pos = Math::Vector(0.0f, 1.0f, 0.0f);
@@ -3519,7 +3509,7 @@ void CPhysics::MotorParticule(float aTime, float rTime)
{
speed.y += m_linMotion.realSpeed.y*1.2f;
}
- a = m_object->RetAngleY(0);
+ a = m_object->GetAngleY(0);
p.x = speed.x;
p.y = speed.z;
p = Math::RotatePoint(-a, p);
@@ -3529,23 +3519,23 @@ void CPhysics::MotorParticule(float aTime, float rTime)
dim.x = 0.7f+Math::Rand()*0.6f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIEJECT, 0.5f, 10.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIEJECT, 0.5f, 10.0f);
#endif
}
}
if ( (type == OBJECT_HUMAN || type == OBJECT_TECH) && m_bSwim )
{
- if ( !m_object->RetDead() )
+ if ( !m_object->GetDead() )
{
h = Math::Mod(aTime, 5.0f);
if ( h < 3.5f && ( h < 1.5f || h > 1.6f ) ) return;
}
- if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.06f) ) return;
- m_lastMotorParticule = aTime;
+ if ( aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.06f) ) return;
+ m_lastMotorParticle = aTime;
pos = Math::Vector(0.0f, 3.0f, 0.0f);
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
pos.x += (Math::Rand()-0.5f)*1.0f;
pos.z += (Math::Rand()-0.5f)*1.0f;
@@ -3554,12 +3544,12 @@ void CPhysics::MotorParticule(float aTime, float rTime)
speed.z = (Math::Rand()-0.5f)*0.2f;
dim.x = 0.2f;
dim.y = 0.2f;
- m_particule->CreateParticule(pos, speed, dim, PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
if ( aTime-m_lastSoundWater > 1.5f )
{
m_lastSoundWater = aTime;
- m_sound->Play(SOUND_BLUP, m_object->RetPosition(0), 0.5f+Math::Rand()*0.5f);
+ m_sound->Play(SOUND_BLUP, m_object->GetPosition(0), 0.5f+Math::Rand()*0.5f);
}
}
@@ -3567,11 +3557,11 @@ void CPhysics::MotorParticule(float aTime, float rTime)
{
h = Math::Mod(aTime, 3.0f);
if ( h < 1.5f && ( h < 0.5f || h > 0.9f ) ) return;
- if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.06f) ) return;
- m_lastMotorParticule = aTime;
+ if ( aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.06f) ) return;
+ m_lastMotorParticle = aTime;
pos = Math::Vector(0.0f, 3.0f, 0.0f);
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
pos.x += (Math::Rand()-0.5f)*1.0f;
pos.z += (Math::Rand()-0.5f)*1.0f;
@@ -3580,12 +3570,12 @@ void CPhysics::MotorParticule(float aTime, float rTime)
speed.z = (Math::Rand()-0.5f)*0.2f;
dim.x = 0.2f;
dim.y = 0.2f;
- m_particule->CreateParticule(pos, speed, dim, PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBUBBLE, 3.0f, 0.0f, 0.0f);
if ( aTime-m_lastSoundWater > 1.5f )
{
m_lastSoundWater = aTime;
- m_sound->Play(SOUND_BLUP, m_object->RetPosition(0), 0.5f+Math::Rand()*0.5f);
+ m_sound->Play(SOUND_BLUP, m_object->GetPosition(0), 0.5f+Math::Rand()*0.5f);
}
}
@@ -3600,13 +3590,13 @@ void CPhysics::MotorParticule(float aTime, float rTime)
{
if ( !m_bMotor ) return;
- if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.1f) ) return;
- m_lastMotorParticule = aTime;
+ if ( aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.1f) ) return;
+ m_lastMotorParticle = aTime;
pos = Math::Vector(-2.5f, 10.3f, -1.3f);
pos.x += (Math::Rand()-0.5f)*1.0f;
pos.z += (Math::Rand()-0.5f)*1.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
speed.x = (Math::Rand()-0.5f)*2.0f;
@@ -3616,14 +3606,14 @@ void CPhysics::MotorParticule(float aTime, float rTime)
dim.x = Math::Rand()*0.6f+0.4f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIMOTOR, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIMOTOR, 2.0f);
}
else
{
if ( !m_bMotor ) return;
- if ( aTime-m_lastMotorParticule < m_engine->ParticuleAdapt(0.05f) ) return;
- m_lastMotorParticule = aTime;
+ if ( aTime-m_lastMotorParticle < m_engine->ParticleAdapt(0.05f) ) return;
+ m_lastMotorParticle = aTime;
pos = Math::Vector(-3.4f, 1.8f, 0.5f);
@@ -3643,21 +3633,21 @@ void CPhysics::MotorParticule(float aTime, float rTime)
speed.y -= 0.5f+Math::Rand()*2.0f;
speed.z += (Math::Rand()-0.5f)*3.0f;
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, pos);
speed = Transform(*mat, speed)-pos;
dim.x = Math::Rand()*0.4f+0.3f;
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIMOTOR, 2.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIMOTOR, 2.0f);
}
}
}
// Generates some particles after falling into the water.
-void CPhysics::WaterParticule(float aTime, Math::Vector pos, ObjectType type,
+void CPhysics::WaterParticle(float aTime, Math::Vector pos, ObjectType type,
float floor, float advance, float turn)
{
Math::Vector ppos, speed;
@@ -3665,7 +3655,7 @@ void CPhysics::WaterParticule(float aTime, Math::Vector pos, ObjectType type,
float delay, level, min, max, force, volume, diam;
int i, nb;
- level = m_water->RetLevel();
+ level = m_water->GetLevel();
if ( floor >= level ) return;
if ( type == OBJECT_HUMAN ||
@@ -3684,9 +3674,9 @@ void CPhysics::WaterParticule(float aTime, Math::Vector pos, ObjectType type,
// Management of the particle "splash".
if ( m_linMotion.realSpeed.y < -10.0f &&
- aTime-m_lastPloufParticule >= 1.0f )
+ aTime-m_lastPloufParticle >= 1.0f )
{
- m_lastPloufParticule = aTime;
+ m_lastPloufParticle = aTime;
force = -m_linMotion.realSpeed.y/20.0f; // power according to speed drops
if ( type == OBJECT_HUMAN ||
@@ -3700,14 +3690,14 @@ void CPhysics::WaterParticule(float aTime, Math::Vector pos, ObjectType type,
force *= 1.3f; // a robot is heavier
}
- pos = m_object->RetPosition(0);
- pos.y = m_water->RetLevel()-1.0f;
+ pos = m_object->GetPosition(0);
+ pos.y = m_water->GetLevel()-1.0f;
dim.x = 2.0f*force; // height
dim.y = diam; // diameter
- m_particule->CreateParticule(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, PARTIPLOUF0, 1.4f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, Math::Vector(0.0f, 0.0f, 0.0f), dim, Gfx::PARTIPLOUF0, 1.4f, 0.0f, 0.0f);
force = (0.5f+force*0.5f);
- nb = (int)(force*50.0f*m_engine->RetParticuleDensity());
+ nb = static_cast<int>(force*50.0f*m_engine->GetParticleDensity());
for ( i=0 ; i<nb ; i++ )
{
ppos = pos;
@@ -3719,7 +3709,7 @@ void CPhysics::WaterParticule(float aTime, Math::Vector pos, ObjectType type,
speed.y = 6.0f+Math::Rand()*6.0f*force;
dim.x = 0.5f;
dim.y = dim.x;
- m_particule->CreateParticule(ppos, speed, dim, PARTIDROP, 2.0f, 20.0f, 0.2f);
+ m_particle->CreateParticle(ppos, speed, dim, Gfx::PARTIDROP, 2.0f, 20.0f, 0.2f);
}
volume = fabs(m_linMotion.realSpeed.y*0.02f);
@@ -3728,7 +3718,7 @@ void CPhysics::WaterParticule(float aTime, Math::Vector pos, ObjectType type,
}
// Management particles "cop".
- if ( m_water->RetLava() ) return;
+ if ( m_water->GetLava() ) return;
if ( advance == 0.0f && turn == 0.0f )
{
@@ -3743,15 +3733,15 @@ void CPhysics::WaterParticule(float aTime, Math::Vector pos, ObjectType type,
{
delay = 0.06f;
}
- m_engine->ParticuleAdapt(delay);
+ m_engine->ParticleAdapt(delay);
- if ( aTime-m_lastWaterParticule < delay ) return;
- m_lastWaterParticule = aTime;
+ if ( aTime-m_lastWaterParticle < delay ) return;
+ m_lastWaterParticle = aTime;
force = (advance+turn)*0.16f;
if ( force < 0.001f ) return;
- pos = m_object->RetPosition(0);
+ pos = m_object->GetPosition(0);
pos.y = level+0.1f;
if ( advance == 0 )
{
@@ -3768,29 +3758,27 @@ void CPhysics::WaterParticule(float aTime, Math::Vector pos, ObjectType type,
speed.z = 0.0f;
dim.x = Math::Min(Math::Rand()*force+force+1.0f, 10.0f);
dim.y = dim.x;
- m_particule->CreateParticule(pos, speed, dim, PARTIFLIC, 3.0f, 0.0f, 0.0f);
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFLIC, 3.0f, 0.0f, 0.0f);
}
// Creates the trace under the robot.
-void CPhysics::WheelParticule(int color, float width)
+void CPhysics::WheelParticle(int color, float width)
{
- Character* character;
Math::Matrix* mat;
Math::Vector goal1, goal2, wheel1, wheel2;
- ParticuleType parti;
- float dist1, dist2, step;
+ Gfx::ParticleType parti;
+ float dist1, dist2, step;
- character = m_object->RetCharacter();
- mat = m_object->RetWorldMatrix(0);
+ mat = m_object->GetWorldMatrix(0);
// Draw a trace on the ground.
if ( color >= 0 && color <= 17 )
{
- parti = (ParticuleType)(PARTITRACE0+color);
+ parti = static_cast<Gfx::ParticleType>(Gfx::PARTITRACE0+color);
step = 2.0f;
if ( color >= 16 ) step = 4.0f; // arrow?
- step /= m_engine->RetTracePrecision();
+ step /= m_engine->GetTracePrecision();
goal1.x = step/2.0f;
goal1.y = 0.0f;
@@ -3802,36 +3790,36 @@ void CPhysics::WheelParticule(int color, float width)
goal2.z = width/2.0f;
goal2 = Transform(*mat, goal2);
- if ( !m_bWheelParticuleBrake )
+ if ( !m_bWheelParticleBrake )
{
- m_wheelParticulePos[0] = goal1;
- m_wheelParticulePos[1] = goal2;
+ m_wheelParticlePos[0] = goal1;
+ m_wheelParticlePos[1] = goal2;
}
while ( true )
{
- dist1 = Math::Distance(m_wheelParticulePos[0], goal1);
+ dist1 = Math::Distance(m_wheelParticlePos[0], goal1);
if ( dist1 < step ) break;
- dist2 = Math::Distance(m_wheelParticulePos[1], goal2);
- wheel1 = Math::SegmentPoint(m_wheelParticulePos[0], goal1, step);
- wheel2 = Math::SegmentPoint(m_wheelParticulePos[1], goal2, step*dist2/dist1);
+ dist2 = Math::Distance(m_wheelParticlePos[1], goal2);
+ wheel1 = Math::SegmentPoint(m_wheelParticlePos[0], goal1, step);
+ wheel2 = Math::SegmentPoint(m_wheelParticlePos[1], goal2, step*dist2/dist1);
if ( m_linMotion.realSpeed.x >= 0.0f )
{
- m_particule->CreateWheelTrace(m_wheelParticulePos[0], m_wheelParticulePos[1], wheel1, wheel2, parti);
+ m_particle->CreateWheelTrace(m_wheelParticlePos[0], m_wheelParticlePos[1], wheel1, wheel2, parti);
}
else
{
- m_particule->CreateWheelTrace(m_wheelParticulePos[1], m_wheelParticulePos[0], wheel2, wheel1, parti);
+ m_particle->CreateWheelTrace(m_wheelParticlePos[1], m_wheelParticlePos[0], wheel2, wheel1, parti);
}
- m_wheelParticulePos[0] = wheel1;
- m_wheelParticulePos[1] = wheel2;
+ m_wheelParticlePos[0] = wheel1;
+ m_wheelParticlePos[1] = wheel2;
}
- m_bWheelParticuleBrake = true;
+ m_bWheelParticleBrake = true;
}
else
{
- m_bWheelParticuleBrake = false;
+ m_bWheelParticleBrake = false;
}
}
@@ -3849,12 +3837,12 @@ void CPhysics::CreateInterface(bool bSelect)
// Returns an error related to the general state.
-Error CPhysics::RetError()
+Error CPhysics::GetError()
{
ObjectType type;
CObject* power;
- type = m_object->RetType();
+ type = m_object->GetType();
if ( type == OBJECT_HUMAN ||
type == OBJECT_TECH ||
type == OBJECT_MOTHER ||
@@ -3865,19 +3853,19 @@ Error CPhysics::RetError()
type == OBJECT_APOLLO2 ||
type == OBJECT_MOBILEdr ) return ERR_OK;
- if ( m_brain != 0 && m_brain->RetActiveVirus() )
+ if ( m_brain != 0 && m_brain->GetActiveVirus() )
{
return ERR_VEH_VIRUS;
}
- power = m_object->RetPower(); // searches for the object battery used
+ power = m_object->GetPower(); // searches for the object battery used
if ( power == 0 )
{
return ERR_VEH_POWER;
}
else
{
- if ( power->RetEnergy() == 0.0f ) return ERR_VEH_ENERGY;
+ if ( power->GetEnergy() == 0.0f ) return ERR_VEH_ENERGY;
}
return ERR_OK;
diff --git a/src/physics/physics.h b/src/physics/physics.h
index 2e1f5eb..e8a1f84 100644
--- a/src/physics/physics.h
+++ b/src/physics/physics.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -14,28 +15,32 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// physics.h
-
#pragma once
+/**
+ * \file physics/physics.h
+ * \brief Responsible for physics "and more" in game
+ */
+
+
-#include "common/misc.h"
+#include "common/global.h"
#include "object/object.h"
#include "math/vector.h"
class CInstanceManager;
-class CCamera;
class CObject;
class CBrain;
class CMotion;
-class CSound;
+class CSoundInterface;
namespace Gfx
{
+class CCamera;
class CEngine;
class CLight;
-class CParticule;
+class CParticle;
class CTerrain;
class CWater;
};
@@ -170,7 +175,7 @@ protected:
void SoundMotorStop(float rTime, ObjectType type);
void SoundReactorFull(float rTime, ObjectType type);
void SoundReactorStop(float rTime, ObjectType type);
- void FrameParticule(float aTime, float rTime);
+ void FrameParticle(float aTime, float rTime);
void MotorUpdate(float aTime, float rTime);
void EffectUpdate(float aTime, float rTime);
void UpdateMotionStruct(float rTime, Motion &motion);
@@ -182,24 +187,24 @@ protected:
bool ExploOther(ObjectType iType, CObject *pObj, ObjectType oType, float force);
int ExploHimself(ObjectType iType, ObjectType oType, float force);
- void PowerParticule(float factor, bool bBreak);
- void CrashParticule(float crash);
- void MotorParticule(float aTime, float rTime);
- void WaterParticule(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn);
- void WheelParticule(int color, float width);
+ void PowerParticle(float factor, bool bBreak);
+ void CrashParticle(float crash);
+ void MotorParticle(float aTime, float rTime);
+ void WaterParticle(float aTime, Math::Vector pos, ObjectType type, float floor, float advance, float turn);
+ void WheelParticle(int color, float width);
protected:
- CInstanceManager* m_iMan;
+ CInstanceManager* m_iMan;
Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan;
Gfx::CParticle* m_particle;
Gfx::CTerrain* m_terrain;
Gfx::CWater* m_water;
Gfx::CCamera* m_camera;
- CObject* m_object;
- CBrain* m_brain;
- CMotion* m_motion;
- CSound* m_sound;
+ CObject* m_object;
+ CBrain* m_brain;
+ CMotion* m_motion;
+ CSoundInterface* m_sound;
PhysicsType m_type; // TYPE_*
float m_gravity; // force of gravity
@@ -217,15 +222,15 @@ protected:
float m_linVibrationFactor;
float m_cirVibrationFactor;
float m_inclinaisonFactor;
- float m_lastPowerParticule;
- float m_lastSlideParticule;
- float m_lastMotorParticule;
- float m_lastWaterParticule;
- float m_lastUnderParticule;
- float m_lastPloufParticule;
- float m_lastFlameParticule;
- bool m_bWheelParticuleBrake;
- Math::Vector m_wheelParticulePos[2];
+ float m_lastPowerParticle;
+ float m_lastSlideParticle;
+ float m_lastMotorParticle;
+ float m_lastWaterParticle;
+ float m_lastUnderParticle;
+ float m_lastPloufParticle;
+ float m_lastFlameParticle;
+ bool m_bWheelParticleBrake;
+ Math::Vector m_wheelParticlePos[2];
float m_absorbWater;
float m_reactorTemperature;
float m_reactorRange;
@@ -234,7 +239,7 @@ protected:
float m_lastEnergy;
float m_lastSoundWater;
float m_lastSoundInsect;
- float m_restBreakParticule;
+ float m_restBreakParticle;
float m_floorLevel; // ground level
float m_floorHeight; // height above the ground
int m_soundChannel;
diff --git a/src/plugins/plugininterface.h b/src/plugins/plugininterface.h
index b8adddc..87c355d 100644
--- a/src/plugins/plugininterface.h
+++ b/src/plugins/plugininterface.h
@@ -47,19 +47,19 @@ class CPluginInterface {
/** Function to get plugin name or description
* @return returns plugin name
*/
- virtual std::string PluginName() = 0;
+ inline std::string PluginName() { return "abc"; };
/** Function to get plugin version. 1 means version 0.01, 2 means 0.02 etc.
* @return number indicating plugin version
*/
- virtual int PluginVersion() = 0;
+ inline int PluginVersion() { return 0; };
/** Function to initialize plugin
*/
- virtual void InstallPlugin() = 0;
+ inline void InstallPlugin() {};
/** Function called before removing plugin
*/
- virtual bool UninstallPlugin(std::string &) = 0;
+ inline bool UninstallPlugin(std::string &) { return true; };
};
diff --git a/src/po/de.po b/src/po/de.po
index 88ab6f1..5af628c 100644
--- a/src/po/de.po
+++ b/src/po/de.po
@@ -1,29 +1,17 @@
-msgid "1.18 /e"
-msgstr "1.18 /d"
-
-msgid "CeeBot-A 1.18"
-msgstr "CeeBot-A 1.18"
-
-msgid "CeeBot-Teen EDU 1.18"
-msgstr "CeeBot-Teen EDU 1.18"
-
-msgid "CeeBot-A EDU 1.18"
-msgstr "CeeBot-A EDU 1.18"
-
-msgid "CeeBot-Teen PERSO 1.18"
-msgstr "CeeBot-Teen PERSO 1.18"
-
-msgid "CeeBot-A PERSO 1.18"
-msgstr "CeeBot-A PERSO 1.18"
-
-msgid "CeeBot-Teen DEMO 1.18"
-msgstr "CeeBot-Teen DEMO 1.18"
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Language: de_DE\n"
+"X-Source-Language: en_US\n"
-msgid "CeeBot-A DEMO 1.18"
-msgstr "CeeBot-A DEMO 1.18"
+msgid "Colobot rules!"
+msgstr "Colobot ist wunderbar!"
-msgid "Demo 1.18 /e"
-msgstr "Demo 1.18 /d"
+msgid "Colobot Gold"
+msgstr "Colobot Gold"
msgid "SatCom"
msgstr "SatCom"
@@ -55,9 +43,6 @@ msgstr "Neu ..."
msgid " or "
msgstr " oder "
-msgid "CeeBot"
-msgstr "CeeBot"
-
msgid "COLOBOT"
msgstr "COLOBOT"
@@ -154,12 +139,6 @@ msgstr "Farbe des Anzugs:"
msgid "Strip color:"
msgstr "Farbe der Streifen:"
-msgid "Do you want to quit CeeBot ?"
-msgstr "Wollen Sie CeeBot schließen ?"
-
-msgid "Quit\\Quit CeeBot"
-msgstr "Schließen\\CeeBot schließen"
-
msgid "Do you want to quit COLOBOT ?"
msgstr "Wollen Sie COLOBOT schließen ?"
@@ -223,8 +202,10 @@ msgstr "\\c; (keine)\\n;\n"
msgid "\\b;Error\n"
msgstr "\\b;Fehler\n"
-msgid "The list is only available if a \\l;radar station\\u object\\radar; is working.\n"
-msgstr "Die Liste ist ohne \\l;Radar\\u object\\radar; nicht verfügbar !\n"
+msgid ""
+"The list is only available if a \\l;radar station\\u object\\radar; is "
+"working.\n"
+msgstr "Die Liste ist ohne \\l;Radar\\u object\\radar; nicht verfügbar.\n"
msgid "Open"
msgstr "Öffnen"
@@ -266,7 +247,7 @@ msgid "Next"
msgstr "Nächster"
msgid "Previous"
-msgstr "Vorherg."
+msgstr "Vorherg"
msgid "Menu (\\key quit;)"
msgstr "Menü (\\key quit;)"
@@ -304,9 +285,6 @@ msgstr "Speichern\\Aktuelle Mission speichern"
msgid "Load\\Load a saved mission"
msgstr "Laden\\Eine gespeicherte Mission öffnen"
-msgid "\\Return to CeeBot"
-msgstr "\\Zurück zu CeeBot"
-
msgid "\\Return to COLOBOT"
msgstr "\\Zurück zu COLOBOT"
@@ -314,7 +292,7 @@ msgid "<< Back \\Back to the previous screen"
msgstr "<< Zurück \\Zurück zum Hauptmenü"
msgid "Play\\Start mission!"
-msgstr "Spielen ...\\Los geht's"
+msgstr "Spielen ...\\Los geht's!"
msgid "Device\\Driver and resolution settings"
msgstr "Bildschirm\\Driver und Bildschirmauflösung"
@@ -401,10 +379,11 @@ msgid "Exit film\\Film at the exit of exercises"
msgstr "Zurücksetzen \\Kleine Show beim Zurücksetzen in den Übungen"
msgid "Friendly fire\\Your shooting can damage your own objects "
-msgstr "Eigenbeschuss\\Ihre Einheiten werden von Ihren Waffen beschädigt."
+msgstr "Eigenbeschuss\\Ihre Einheiten werden von Ihren Waffen beschädigt"
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
-msgstr "Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht"
+msgstr ""
+"Kameradrehung mit der Maus\\Die Kamera dreht wenn die Maus den Rand erreicht"
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"
msgstr "Umkehr X\\Umkehr der Kameradrehung X-Achse"
@@ -425,7 +404,8 @@ msgid "Big indent\\Indent 2 or 4 spaces per level defined by braces"
msgstr "Einrücken mit 4 Leerstellen\\Einrücken mit 2 oder 4 Leerstellen"
msgid "Access to solutions\\Show program \"4: Solution\" in the exercises"
-msgstr "Lösung zugänglich\\Die Lösung ist im Programmslot \"4: Lösung\" zugänglich"
+msgstr ""
+"Lösung zugänglich\\Die Lösung ist im Programmslot \"4: Lösung\" zugänglich"
msgid "Standard controls\\Standard key functions"
msgstr "Alles zurücksetzen\\Standarddefinition aller Tasten"
@@ -454,8 +434,9 @@ msgstr "Andere Kamera\\Sichtpunkt einstellen"
msgid "Previous object\\Selects the previous object"
msgstr "Vorherg. Auswahl\\Das vorhergehende Objekt auswählen"
-msgid "Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
-msgstr "Standardhandlung\\Führt die Standardhandlung des Roboters aus."
+msgid ""
+"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
+msgstr "Standardhandlung\\Führt die Standardhandlung des Roboters aus"
msgid "Camera closer\\Moves the camera forward"
msgstr "Kamera näher\\Bewegung der Kamera vorwärts"
@@ -523,7 +504,8 @@ msgstr "Normal\\Normale Lautstärke"
msgid "Use a joystick\\Joystick or keyboard"
msgstr "Joystick\\Joystick oder Tastatur"
-msgid "Access to solution\\Shows the solution (detailed instructions for missions)"
+msgid ""
+"Access to solution\\Shows the solution (detailed instructions for missions)"
msgstr "Zeigt die Lösung\\Zeigt nach 3mal Scheitern die Lösung"
msgid "\\New player name"
@@ -1312,22 +1294,6 @@ msgstr "Fehler"
msgid "Unknown command"
msgstr "Befehl unbekannt"
-msgid "CeeBot not installed."
-msgstr "CeeBot wurde nicht installiert."
-
-msgid ""
-"Please insert the CeeBot CD\n"
-"and re-run the game."
-msgstr "Legen Sie die CeeBot-CD ein\nund starten Sie das Spiel neu."
-
-msgid "COLOBOT not installed."
-msgstr "COLOBOT wurde nicht installiert."
-
-msgid ""
-"Please insert the COLOBOT CD\n"
-"and re-run the game."
-msgstr "Legen Sie die COLOBOT-CD ein\nund starten Sie das Spiel neu."
-
msgid "Inappropriate bot"
msgstr "Roboter ungeeignet"
@@ -1490,8 +1456,11 @@ msgstr "Zu nahe an einer anderen Fahne"
msgid "No flag nearby"
msgstr "Keine Fahne in Reichweite"
-msgid "The mission is not accomplished yet (press \\key help; for more details)"
-msgstr "Mission noch nicht beendet (Drücken Sie auf \\key help; für weitere Informationen)"
+msgid ""
+"The mission is not accomplished yet (press \\key help; for more details)"
+msgstr ""
+"Mission noch nicht beendet (Drücken Sie auf \\key help; für weitere "
+"Informationen)"
msgid "Bot destroyed"
msgstr "Roboter zerstört"
@@ -1647,7 +1616,9 @@ msgid "Instruction \"break\" outside a loop"
msgstr "Anweisung \"break\" außerhalb einer Schleife"
msgid "A label must be followed by \"for\", \"while\", \"do\" or \"switch\""
-msgstr "Ein Label kann nur vor den Anweisungen \"for\", \"while\", \"do\" oder \"switch\" vorkommen"
+msgstr ""
+"Ein Label kann nur vor den Anweisungen \"for\", \"while\", \"do\" oder "
+"\"switch\" vorkommen"
msgid "This label does not exist"
msgstr "Dieses Label existiert nicht"
diff --git a/src/po/fr.po b/src/po/fr.po
index c70a77e..f893440 100644
--- a/src/po/fr.po
+++ b/src/po/fr.po
@@ -1,29 +1,17 @@
-msgid "1.18 /e"
-msgstr "1.18 /f"
-
-msgid "CeeBot-A 1.18"
-msgstr "CeeBot-A 1.18"
-
-msgid "CeeBot-Teen EDU 1.18"
-msgstr "CeeBot-Teen EDU 1.18"
-
-msgid "CeeBot-A EDU 1.18"
-msgstr "CeeBot-A EDU 1.18"
-
-msgid "CeeBot-Teen PERSO 1.18"
-msgstr "CeeBot-Teen PERSO 1.18"
-
-msgid "CeeBot-A PERSO 1.18"
-msgstr "CeeBot-A PERSO 1.18"
-
-msgid "CeeBot-Teen DEMO 1.18"
-msgstr "CeeBot-Teen DEMO 1.18"
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"X-Language: fr_FR\n"
+"X-Source-Language: en_US\n"
-msgid "CeeBot-A DEMO 1.18"
-msgstr "CeeBot-A DEMO 1.18"
+msgid "Colobot rules!"
+msgstr "Colobot est super!"
-msgid "Demo 1.18 /e"
-msgstr "Demo 1.18 /f"
+msgid "Colobot Gold"
+msgstr "Colobot Gold"
msgid "SatCom"
msgstr "SatCom"
@@ -55,9 +43,6 @@ msgstr "Nouveau ..."
msgid " or "
msgstr " ou "
-msgid "CeeBot"
-msgstr "CeeBot"
-
msgid "COLOBOT"
msgstr "COLOBOT"
@@ -154,12 +139,6 @@ msgstr "Couleur de la combinaison :"
msgid "Strip color:"
msgstr "Couleur des bandes :"
-msgid "Do you want to quit CeeBot ?"
-msgstr "Voulez-vous quitter CeeBot ?"
-
-msgid "Quit\\Quit CeeBot"
-msgstr "Quitter\\Quitter CeeBot"
-
msgid "Do you want to quit COLOBOT ?"
msgstr "Voulez-vous quitter COLOBOT ?"
@@ -223,8 +202,10 @@ msgstr "\\c; (aucun)\\n;\n"
msgid "\\b;Error\n"
msgstr "\\b;Erreur\n"
-msgid "The list is only available if a \\l;radar station\\u object\\radar; is working.\n"
-msgstr "Liste non disponible sans \\l;radar\\u object\\radar; !\n"
+msgid ""
+"The list is only available if a \\l;radar station\\u object\\radar; is "
+"working.\n"
+msgstr "Liste non disponible sans \\l;radar\\u object\\radar;.\n"
msgid "Open"
msgstr "Ouvrir"
@@ -304,9 +285,6 @@ msgstr "Enregistrer\\Enregistrer la mission en cours"
msgid "Load\\Load a saved mission"
msgstr "Charger\\Charger une mission enregistrée"
-msgid "\\Return to CeeBot"
-msgstr "\\Retourner dans CeeBot"
-
msgid "\\Return to COLOBOT"
msgstr "\\Retourner dans COLOBOT"
@@ -314,7 +292,7 @@ msgid "<< Back \\Back to the previous screen"
msgstr "<< Retour \\Retour au niveau précédent"
msgid "Play\\Start mission!"
-msgstr "Jouer ...\\Démarrer l'action"
+msgstr "Jouer ...\\Démarrer l'action!"
msgid "Device\\Driver and resolution settings"
msgstr "Affichage\\Pilote et résolution d'affichage"
@@ -404,13 +382,17 @@ msgid "Friendly fire\\Your shooting can damage your own objects "
msgstr "Dégâts ŕ soi-męme\\Vos tirs infligent des dommages ŕ vos unités"
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
-msgstr "Défilement dans les bords\\Défilement lorsque la souris touches les bords gauche ou droite"
+msgstr ""
+"Défilement dans les bords\\Défilement lorsque la souris touches les bords "
+"gauche ou droite"
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"
-msgstr "Inversion souris X\\Inversion de la rotation lorsque la souris touche un bord"
+msgstr ""
+"Inversion souris X\\Inversion de la rotation lorsque la souris touche un bord"
msgid "Mouse inversion Y\\Inversion of the scrolling direction on the Y axis"
-msgstr "Inversion souris Y\\Inversion de la rotation lorsque la souris touche un bord"
+msgstr ""
+"Inversion souris Y\\Inversion de la rotation lorsque la souris touche un bord"
msgid "Quake at explosions\\The screen shakes at explosions"
msgstr "Secousses lors d'explosions\\L'écran vibre lors d'une explosion"
@@ -454,7 +436,8 @@ msgstr "Changement de caméra\\Autre de point de vue"
msgid "Previous object\\Selects the previous object"
msgstr "Sélection précédente\\Sélectionne l'objet précédent"
-msgid "Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
+msgid ""
+"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
msgstr "Action standard\\Action du bouton avec le cadre rouge"
msgid "Camera closer\\Moves the camera forward"
@@ -523,7 +506,8 @@ msgstr "Normal\\Niveaux normaux"
msgid "Use a joystick\\Joystick or keyboard"
msgstr "Utilise un joystick\\Joystick ou clavier"
-msgid "Access to solution\\Shows the solution (detailed instructions for missions)"
+msgid ""
+"Access to solution\\Shows the solution (detailed instructions for missions)"
msgstr "AccÄs Å• la solution\\Donne la solution"
msgid "\\New player name"
@@ -1312,22 +1296,6 @@ msgstr "Erreur"
msgid "Unknown command"
msgstr "Commande inconnue"
-msgid "CeeBot not installed."
-msgstr "CeeBot n'est pas installé."
-
-msgid ""
-"Please insert the CeeBot CD\n"
-"and re-run the game."
-msgstr "Veuillez mettre le CD de CeeBot\net relancer le jeu."
-
-msgid "COLOBOT not installed."
-msgstr "COLOBOT n'est pas installé."
-
-msgid ""
-"Please insert the COLOBOT CD\n"
-"and re-run the game."
-msgstr "Veuillez mettre le CD de COLOBOT\net relancer le jeu."
-
msgid "Inappropriate bot"
msgstr "Robot inadapté"
@@ -1490,8 +1458,10 @@ msgstr "Trop proche d'un drapeau existant"
msgid "No flag nearby"
msgstr "Aucun drapeau ŕ proximité"
-msgid "The mission is not accomplished yet (press \\key help; for more details)"
-msgstr "La misssion n'est pas terminée (appuyez sur \\key help; pour plus de détails)"
+msgid ""
+"The mission is not accomplished yet (press \\key help; for more details)"
+msgstr ""
+"La misssion n'est pas terminée (appuyez sur \\key help; pour plus de détails)"
msgid "Bot destroyed"
msgstr "Robot détruit"
@@ -1521,7 +1491,8 @@ msgid "Plans for tracked robots available "
msgstr "Fabrication d'un robot Å• chenilles possible"
msgid "You can fly with the keys (\\key gup;) and (\\key gdown;)"
-msgstr "Il est possible de voler avec les touches (\\key gup;) et (\\key gdown;)"
+msgstr ""
+"Il est possible de voler avec les touches (\\key gup;) et (\\key gdown;)"
msgid "Plans for thumper available"
msgstr "Fabrication d'un robot secoueur possible"
@@ -1647,7 +1618,9 @@ msgid "Instruction \"break\" outside a loop"
msgstr "Instruction \"break\" en dehors d'une boucle"
msgid "A label must be followed by \"for\", \"while\", \"do\" or \"switch\""
-msgstr "Un label ne peut se placer que devant un \"for\", un \"while\", un \"do\" ou un \"switch\""
+msgstr ""
+"Un label ne peut se placer que devant un \"for\", un \"while\", un \"do\" ou "
+"un \"switch\""
msgid "This label does not exist"
msgstr "Cette étiquette n'existe pas"
diff --git a/src/po/pl.po b/src/po/pl.po
index 1f5db21..98fda0e 100644
--- a/src/po/pl.po
+++ b/src/po/pl.po
@@ -1,29 +1,17 @@
-msgid "1.18 /e"
-msgstr "Wersja 1.18 /pl"
-
-msgid "CeeBot-A 1.18"
-msgstr "CeeBot-A 1.18"
-
-msgid "CeeBot-Teen EDU 1.18"
-msgstr "CeeBot-Teen EDU 1.18"
-
-msgid "CeeBot-A EDU 1.18"
-msgstr "CeeBot-A EDU 1.18"
-
-msgid "CeeBot-Teen PERSO 1.18"
-msgstr "CeeBot-Teen PERSO 1.18"
-
-msgid "CeeBot-A PERSO 1.18"
-msgstr "CeeBot-A PERSO 1.18"
-
-msgid "CeeBot-Teen DEMO 1.18"
-msgstr "CeeBot-Teen DEMO 1.18"
+msgid ""
+msgstr ""
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
+"X-Language: pl_PL\n"
+"X-Source-Language: en_US\n"
-msgid "CeeBot-A DEMO 1.18"
-msgstr "CeeBot-A DEMO 1.18"
+msgid "Colobot rules!"
+msgstr "Colobot rzÄ…dzi!"
-msgid "Demo 1.18 /e"
-msgstr "Demo 1.18 /pl"
+msgid "Colobot Gold"
+msgstr "Colobot Gold"
msgid "SatCom"
msgstr "SatCom"
@@ -55,9 +43,6 @@ msgstr "Nowy ..."
msgid " or "
msgstr " lub "
-msgid "CeeBot"
-msgstr "CeeBot"
-
msgid "COLOBOT"
msgstr "COLOBOT"
@@ -154,12 +139,6 @@ msgstr "Kolor skafandra:"
msgid "Strip color:"
msgstr "Kolor pasków:"
-msgid "Do you want to quit CeeBot ?"
-msgstr "Czy na pewno chcesz opuścić grę CeeBot?"
-
-msgid "Quit\\Quit CeeBot"
-msgstr "Zakończ\\Kończy grę CeeBot"
-
msgid "Do you want to quit COLOBOT ?"
msgstr "Czy na pewno chcesz opuścić grę COLOBOT?"
@@ -223,8 +202,12 @@ msgstr "\\c; (brak)\\n;\n"
msgid "\\b;Error\n"
msgstr "\\b;BÅ‚Ä…d\n"
-msgid "The list is only available if a \\l;radar station\\u object\\radar; is working.\n"
-msgstr "Lista jest dostępna jedynie gdy działa \\l;stacja radarowa\\u object\\radar;.\n"
+msgid ""
+"The list is only available if a \\l;radar station\\u object\\radar; is "
+"working.\n"
+msgstr ""
+"Lista jest dostępna jedynie gdy działa \\l;stacja radarowa\\u "
+"object\\radar;.\n"
msgid "Open"
msgstr "Otwórz"
@@ -304,9 +287,6 @@ msgstr "Zapisz\\Zapisuje bieżącą misję"
msgid "Load\\Load a saved mission"
msgstr "Wczytaj\\Wczytuje zapisanÄ… misjÄ™"
-msgid "\\Return to CeeBot"
-msgstr "\\Powróć do gry CeeBot"
-
msgid "\\Return to COLOBOT"
msgstr "\\Powróć do gry COLOBOT"
@@ -404,7 +384,9 @@ msgid "Friendly fire\\Your shooting can damage your own objects "
msgstr "Przyjacielski ogień\\Własne strzały uszkadzają Twoje obiekty"
msgid "Scrolling\\Scrolling when the mouse touches right or left border"
-msgstr "Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego krawędzi"
+msgstr ""
+"Przewijanie\\Ekran jest przewijany gdy mysz dotknie prawej lub lewej jego "
+"krawędzi"
msgid "Mouse inversion X\\Inversion of the scrolling direction on the X axis"
msgstr "Odwrócenie myszy X\\Odwrócenie kierunków przewijania w poziomie"
@@ -422,7 +404,9 @@ msgid "Automatic indent\\When program editing"
msgstr "Automatyczne wcięcia\\Automatyczne wcięcia podczas edycji programu"
msgid "Big indent\\Indent 2 or 4 spaces per level defined by braces"
-msgstr "Duże wcięcie\\2 lub 4 spacje wcięcia na każdy poziom zdefiniowany przez klamry"
+msgstr ""
+"Duże wcięcie\\2 lub 4 spacje wcięcia na każdy poziom zdefiniowany przez "
+"klamry"
msgid "Access to solutions\\Show program \"4: Solution\" in the exercises"
msgstr "AccÄs aux solutions\\Programme \"4: Solution\" dans les exercices"
@@ -454,8 +438,11 @@ msgstr "Zmień kamerę\\Przełącza pomiędzy kamerą pokładową i śledzącą"
msgid "Previous object\\Selects the previous object"
msgstr "Poprzedni obiekt\\Zaznacz poprzedni obiekt"
-msgid "Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
-msgstr "Standardowa akcja\\Standardowa akcja robota (podnieś/upuść, strzelaj, szukaj, itp.)"
+msgid ""
+"Standard action\\Standard action of the bot (take/grab, shoot, sniff, etc)"
+msgstr ""
+"Standardowa akcja\\Standardowa akcja robota (podnieś/upuść, strzelaj, "
+"szukaj, itp.)"
msgid "Camera closer\\Moves the camera forward"
msgstr "Kamera bliżej\\Przybliża kamerę"
@@ -479,10 +466,12 @@ msgid "Programming help\\Gives more detailed help with programming"
msgstr "Podręcznik programowania\\Dostarcza szczegółową pomoc w programowaniu"
msgid "Key word help\\More detailed help about key words"
-msgstr "Pomoc dot. słów kluczowych\\Dokładniejsza pomoc na temat słów kluczowych"
+msgstr ""
+"Pomoc dot. słów kluczowych\\Dokładniejsza pomoc na temat słów kluczowych"
msgid "Origin of last message\\Shows where the last message was sent from"
-msgstr "Miejsce nadania wiadomości\\Pokazuje skąd została wysłana ostatnia wiadomość"
+msgstr ""
+"Miejsce nadania wiadomości\\Pokazuje skąd została wysłana ostatnia wiadomość"
msgid "Speed 1.0x\\Normal speed"
msgstr "Prędkość 1,0x\\Prędkość normalna"
@@ -506,13 +495,15 @@ msgid "3D sound\\3D positioning of the sound"
msgstr "Dźwięk 3D\\Przestrzenne pozycjonowanie dźwięków"
msgid "Lowest\\Minimum graphic quality (highest frame rate)"
-msgstr "Najniższa\\Minimalna jakość grafiki (najwyższa częstotliwość odświeżania)"
+msgstr ""
+"Najniższa\\Minimalna jakość grafiki (najwyższa częstotliwość odświeżania)"
msgid "Normal\\Normal graphic quality"
msgstr "Normalna\\Normalna jakość grafiki"
msgid "Highest\\Highest graphic quality (lowest frame rate)"
-msgstr "Najwyższa\\Maksymalna jakość grafiki (najniższa częstotliwość odświeżania)"
+msgstr ""
+"Najwyższa\\Maksymalna jakość grafiki (najniższa częstotliwość odświeżania)"
msgid "Mute\\No sound"
msgstr "Cisza\\Brak dźwięków"
@@ -523,8 +514,11 @@ msgstr "Normalne\\Normalna głośność dźwięków"
msgid "Use a joystick\\Joystick or keyboard"
msgstr "Używaj joysticka\\Joystick lub klawiatura"
-msgid "Access to solution\\Shows the solution (detailed instructions for missions)"
-msgstr "Dostęp do rozwiązania\\Pokazuje rozwiązanie (szczegółowe instrukcje dotyczące misji)"
+msgid ""
+"Access to solution\\Shows the solution (detailed instructions for missions)"
+msgstr ""
+"Dostęp do rozwiązania\\Pokazuje rozwiązanie (szczegółowe instrukcje "
+"dotyczÄ…ce misji)"
msgid "\\New player name"
msgstr "\\Nowe imiÄ™ gracza"
@@ -1312,22 +1306,6 @@ msgstr "BÅ‚Ä…d"
msgid "Unknown command"
msgstr "Nieznane polecenie"
-msgid "CeeBot not installed."
-msgstr "Gra CeeBot nie jest zainstalowana."
-
-msgid ""
-"Please insert the CeeBot CD\n"
-"and re-run the game."
-msgstr "Włóż dysk CD z grą CeeBot\ni uruchom grę jeszcze raz."
-
-msgid "COLOBOT not installed."
-msgstr "Gra COLOBOT nie jest zainstalowana."
-
-msgid ""
-"Please insert the COLOBOT CD\n"
-"and re-run the game."
-msgstr "Włóż dysk CD z grą COLOBOT\ni uruchom grę jeszcze raz."
-
msgid "Inappropriate bot"
msgstr "Nieodpowiedni robot"
@@ -1490,7 +1468,8 @@ msgstr "Za blisko istniejÄ…cej flagi"
msgid "No flag nearby"
msgstr "Nie ma flagi w pobliżu"
-msgid "The mission is not accomplished yet (press \\key help; for more details)"
+msgid ""
+"The mission is not accomplished yet (press \\key help; for more details)"
msgstr "Misja nie jest wypełniona (naciśnij \\key help; aby uzyskać szczegóły)"
msgid "Bot destroyed"
@@ -1590,7 +1569,8 @@ msgid "Spider fatally wounded"
msgstr "Pająk śmiertelnie raniony"
msgid "Press \\key help; to read instructions on your SatCom"
-msgstr "Naciśnij klawisz \\key help; aby wyświetlić rozkazy na przekaźniku SatCom"
+msgstr ""
+"Naciśnij klawisz \\key help; aby wyświetlić rozkazy na przekaźniku SatCom"
msgid "Opening bracket missing"
msgstr "Brak nawiasu otwierajÄ…cego"
@@ -1638,7 +1618,7 @@ msgid "Unknown function"
msgstr "Funkcja nieznana"
msgid "Sign \" : \" missing"
-msgstr "Brak znaku \" : "
+msgstr "Brak znaku \" :\""
msgid "Keyword \"while\" missing"
msgstr "Brak kluczowego słowa \"while"
diff --git a/src/script/cbottoken.cpp b/src/script/cbottoken.cpp
index 223da4d..0bb368c 100644
--- a/src/script/cbottoken.cpp
+++ b/src/script/cbottoken.cpp
@@ -15,25 +15,16 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/language.h"
-#include "common/global.h"
-#include "common/event.h"
-#include "object/object.h"
#include "script/cbottoken.h"
+#include "object/object.h"
+#include <string.h>
// Seeking the name of an object.
-char* RetObjectName(ObjectType type)
+const char* GetObjectName(ObjectType type)
{
if ( type == OBJECT_PORTICO ) return "Portico";
if ( type == OBJECT_BASE ) return "SpaceShip";
@@ -126,7 +117,7 @@ char* RetObjectName(ObjectType type)
// Seeking the name of a secondary object.
// (because Otto thinks that Germans do not like nuclear power)
-char* RetObjectAlias(ObjectType type)
+const char* GetObjectAlias(ObjectType type)
{
if ( type == OBJECT_NUCLEAR ) return "FuelCellPlant";
if ( type == OBJECT_URANIUM ) return "PlatinumOre";
@@ -139,7 +130,7 @@ char* RetObjectAlias(ObjectType type)
// Returns the help file to use for the object.
-char* RetHelpFilename(ObjectType type)
+const char* GetHelpFilename(ObjectType type)
{
if ( type == OBJECT_BASE ) return "help\\object\\base.txt";
if ( type == OBJECT_DERRICK ) return "help\\object\\derrick.txt";
@@ -224,7 +215,7 @@ char* RetHelpFilename(ObjectType type)
// Returns the help file to use for instruction.
-char* RetHelpFilename(const char *token)
+const char* GetHelpFilename(const char *token)
{
if ( strcmp(token, "if" ) == 0 ) return "help\\cbot\\if.txt";
if ( strcmp(token, "else" ) == 0 ) return "help\\cbot\\if.txt";
@@ -436,7 +427,7 @@ bool IsFunction(const char *token)
// Returns using a compact instruction.
-char* RetHelpText(const char *token)
+const char* GetHelpText(const char *token)
{
if ( strcmp(token, "if" ) == 0 ) return "if ( condition ) { bloc }";
if ( strcmp(token, "else" ) == 0 ) return "else { bloc }";
diff --git a/src/script/cbottoken.h b/src/script/cbottoken.h
index c1a6a65..1f2d6e7 100644
--- a/src/script/cbottoken.h
+++ b/src/script/cbottoken.h
@@ -25,12 +25,12 @@
// Procedures.
-extern char* RetObjectName(ObjectType type);
-extern char* RetObjectAlias(ObjectType type);
-extern char* RetHelpFilename(ObjectType type);
-extern char* RetHelpFilename(const char *token);
+extern const char* GetObjectName(ObjectType type);
+extern const char* GetObjectAlias(ObjectType type);
+extern const char* GetHelpFilename(ObjectType type);
+extern const char* GetHelpFilename(const char *token);
extern bool IsType(const char *token);
extern bool IsFunction(const char *token);
-extern char* RetHelpText(const char *token);
+extern const char* GetHelpText(const char *token);
diff --git a/src/script/cmdtoken.cpp b/src/script/cmdtoken.cpp
index 256b580..e44f82d 100644
--- a/src/script/cmdtoken.cpp
+++ b/src/script/cmdtoken.cpp
@@ -15,23 +15,12 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/language.h"
-#include "common/global.h"
-#include "common/event.h"
-#include "old/water.h"
-#include "old/pyro.h"
-#include "old/camera.h"
-#include "object/object.h"
#include "script/cmdtoken.h"
+#include "common/global.h"
+#include <string.h>
+#include <cstdio>
@@ -48,7 +37,7 @@ char* SkipSpace(char *line)
// Checks if a line contains a command.
-bool Cmd(char *line, char *token)
+bool Cmd(char *line, const char *token)
{
char* p;
@@ -59,7 +48,7 @@ bool Cmd(char *line, char *token)
// Seeking an operator.
-char* SearchOp(char *line, char *op)
+char* SearchOp(char *line, const char *op)
{
char opeq[50];
char* p;
@@ -418,7 +407,7 @@ ObjectType GetTypeObject(char *line, int rank, ObjectType def)
// Returns the name of an object type.
-char* GetTypeObject(ObjectType type)
+const char* GetTypeObject(ObjectType type)
{
if ( type == OBJECT_PORTICO ) return "Portico";
if ( type == OBJECT_BASE ) return "SpaceShip";
@@ -663,35 +652,35 @@ char* GetTypeObject(ObjectType type)
// Returns the type of water.
-WaterType GetTypeWater(char *line, int rank, WaterType def)
+Gfx::WaterType GetTypeWater(char *line, int rank, Gfx::WaterType def)
{
char* p;
p = SearchArg(line, rank);
if ( *p == 0 ) return def;
- if ( Cmd(p, "NULL" ) ) return WATER_NULL;
- if ( Cmd(p, "TT" ) ) return WATER_TT;
- if ( Cmd(p, "TO" ) ) return WATER_TO;
- if ( Cmd(p, "CT" ) ) return WATER_CT;
- if ( Cmd(p, "CO" ) ) return WATER_CO;
+ if ( Cmd(p, "NULL" ) ) return Gfx::WATER_NULL;
+ if ( Cmd(p, "TT" ) ) return Gfx::WATER_TT;
+ if ( Cmd(p, "TO" ) ) return Gfx::WATER_TO;
+ if ( Cmd(p, "CT" ) ) return Gfx::WATER_CT;
+ if ( Cmd(p, "CO" ) ) return Gfx::WATER_CO;
return def;
}
// Returns the type of terrain.
-D3DTypeObj GetTypeTerrain(char *line, int rank, D3DTypeObj def)
+Gfx::EngineObjectType GetTypeTerrain(char *line, int rank, Gfx::EngineObjectType def)
{
char* p;
p = SearchArg(line, rank);
if ( *p == 0 ) return def;
- if ( Cmd(p, "Terrain" ) ) return TYPETERRAIN;
- if ( Cmd(p, "Object" ) ) return TYPEFIX;
- if ( Cmd(p, "Quartz" ) ) return TYPEQUARTZ;
- if ( Cmd(p, "Metal" ) ) return TYPEMETAL;
+ if ( Cmd(p, "Terrain" ) ) return Gfx::ENG_OBJTYPE_TERRAIN;
+ if ( Cmd(p, "Object" ) ) return Gfx::ENG_OBJTYPE_FIX;
+ if ( Cmd(p, "Quartz" ) ) return Gfx::ENG_OBJTYPE_QUARTZ;
+ if ( Cmd(p, "Metal" ) ) return Gfx::ENG_OBJTYPE_METAL;
return def;
}
@@ -753,64 +742,64 @@ int GetResearch(char *line, int rank)
// Returns the type of pyrotechnic effect.
-PyroType GetPyro(char *line, int rank)
+Gfx::PyroType GetPyro(char *line, int rank)
{
char* p;
p = SearchArg(line, rank);
- if ( *p == 0 ) return PT_NULL;
-
- if ( Cmd(p, "FRAGt" ) ) return PT_FRAGT;
- if ( Cmd(p, "FRAGo" ) ) return PT_FRAGO;
- if ( Cmd(p, "FRAGw" ) ) return PT_FRAGW;
- if ( Cmd(p, "EXPLOt" ) ) return PT_EXPLOT;
- if ( Cmd(p, "EXPLOo" ) ) return PT_EXPLOO;
- if ( Cmd(p, "EXPLOw" ) ) return PT_EXPLOW;
- if ( Cmd(p, "SHOTt" ) ) return PT_SHOTT;
- if ( Cmd(p, "SHOTh" ) ) return PT_SHOTH;
- if ( Cmd(p, "SHOTm" ) ) return PT_SHOTM;
- if ( Cmd(p, "SHOTw" ) ) return PT_SHOTW;
- if ( Cmd(p, "EGG" ) ) return PT_EGG;
- if ( Cmd(p, "BURNt" ) ) return PT_BURNT;
- if ( Cmd(p, "BURNo" ) ) return PT_BURNO;
- if ( Cmd(p, "SPIDER" ) ) return PT_SPIDER;
- if ( Cmd(p, "FALL" ) ) return PT_FALL;
- if ( Cmd(p, "RESET" ) ) return PT_RESET;
- if ( Cmd(p, "WIN" ) ) return PT_WIN;
- if ( Cmd(p, "LOST" ) ) return PT_LOST;
-
- return PT_NULL;
+ if ( *p == 0 ) return Gfx::PT_NULL;
+
+ if ( Cmd(p, "FRAGt" ) ) return Gfx::PT_FRAGT;
+ if ( Cmd(p, "FRAGo" ) ) return Gfx::PT_FRAGO;
+ if ( Cmd(p, "FRAGw" ) ) return Gfx::PT_FRAGW;
+ if ( Cmd(p, "EXPLOt" ) ) return Gfx::PT_EXPLOT;
+ if ( Cmd(p, "EXPLOo" ) ) return Gfx::PT_EXPLOO;
+ if ( Cmd(p, "EXPLOw" ) ) return Gfx::PT_EXPLOW;
+ if ( Cmd(p, "SHOTt" ) ) return Gfx::PT_SHOTT;
+ if ( Cmd(p, "SHOTh" ) ) return Gfx::PT_SHOTH;
+ if ( Cmd(p, "SHOTm" ) ) return Gfx::PT_SHOTM;
+ if ( Cmd(p, "SHOTw" ) ) return Gfx::PT_SHOTW;
+ if ( Cmd(p, "EGG" ) ) return Gfx::PT_EGG;
+ if ( Cmd(p, "BURNt" ) ) return Gfx::PT_BURNT;
+ if ( Cmd(p, "BURNo" ) ) return Gfx::PT_BURNO;
+ if ( Cmd(p, "SPIDER" ) ) return Gfx::PT_SPIDER;
+ if ( Cmd(p, "FALL" ) ) return Gfx::PT_FALL;
+ if ( Cmd(p, "RESET" ) ) return Gfx::PT_RESET;
+ if ( Cmd(p, "WIN" ) ) return Gfx::PT_WIN;
+ if ( Cmd(p, "LOST" ) ) return Gfx::PT_LOST;
+
+ return Gfx::PT_NULL;
}
// Returns the type of camera.
-CameraType GetCamera(char *line, int rank)
+Gfx::CameraType GetCamera(char *line, int rank)
{
char* p;
p = SearchArg(line, rank);
- if ( *p == 0 ) return CAMERA_NULL;
+ if ( *p == 0 ) return Gfx::CAM_TYPE_NULL;
- if ( Cmd(p, "BACK" ) ) return CAMERA_BACK;
- if ( Cmd(p, "PLANE" ) ) return CAMERA_PLANE;
- if ( Cmd(p, "ONBOARD" ) ) return CAMERA_ONBOARD;
- if ( Cmd(p, "FIX" ) ) return CAMERA_FIX;
+ if ( Cmd(p, "BACK" ) ) return Gfx::CAM_TYPE_BACK;
+ if ( Cmd(p, "PLANE" ) ) return Gfx::CAM_TYPE_PLANE;
+ if ( Cmd(p, "ONBOARD" ) ) return Gfx::CAM_TYPE_ONBOARD;
+ if ( Cmd(p, "FIX" ) ) return Gfx::CAM_TYPE_FIX;
- return CAMERA_NULL;
+ return Gfx::CAM_TYPE_NULL;
}
// Returns the name of a camera.
-char* GetCamera(CameraType type)
+const char* GetCamera(Gfx::CameraType type)
{
- if ( type == CAMERA_ONBOARD ) return "ONBOARD";
- if ( type == CAMERA_FIX ) return "FIX";
+ if ( type == Gfx::CAM_TYPE_ONBOARD ) return "ONBOARD";
+ if ( type == Gfx::CAM_TYPE_FIX ) return "FIX";
return "BACK";
}
// Returns an integer.
-int OpInt(char *line, char *op, int def)
+int OpInt(char *line, const char *op, int def)
{
line = SearchOp(line, op);
if ( *line == 0 ) return def;
@@ -819,7 +808,7 @@ int OpInt(char *line, char *op, int def)
// Returns a float number.
-float OpFloat(char *line, char *op, float def)
+float OpFloat(char *line, const char *op, float def)
{
line = SearchOp(line, op);
if ( *line == 0 ) return def;
@@ -828,7 +817,7 @@ float OpFloat(char *line, char *op, float def)
// Returns a string.
-void OpString(char *line, char *op, char *buffer)
+void OpString(char *line, const char *op, char *buffer)
{
line = SearchOp(line, op);
if ( *line == 0 )
@@ -843,7 +832,7 @@ void OpString(char *line, char *op, char *buffer)
// Returns the type of an object.
-ObjectType OpTypeObject(char *line, char *op, ObjectType def)
+ObjectType OpTypeObject(char *line, const char *op, ObjectType def)
{
line = SearchOp(line, op);
if ( *line == 0 ) return def;
@@ -852,7 +841,7 @@ ObjectType OpTypeObject(char *line, char *op, ObjectType def)
// Returns the type of a water.
-WaterType OpTypeWater(char *line, char *op, WaterType def)
+Gfx::WaterType OpTypeWater(char *line, const char *op, Gfx::WaterType def)
{
line = SearchOp(line, op);
if ( *line == 0 ) return def;
@@ -861,7 +850,7 @@ WaterType OpTypeWater(char *line, char *op, WaterType def)
// Returns the type of a terrain.
-D3DTypeObj OpTypeTerrain(char *line, char *op, D3DTypeObj def)
+Gfx::EngineObjectType OpTypeTerrain(char *line, const char *op, Gfx::EngineObjectType def)
{
line = SearchOp(line, op);
if ( *line == 0 ) return def;
@@ -870,7 +859,7 @@ D3DTypeObj OpTypeTerrain(char *line, char *op, D3DTypeObj def)
// Returns the type of research.
-int OpResearch(char *line, char *op)
+int OpResearch(char *line, const char *op)
{
line = SearchOp(line, op);
if ( *line == 0 ) return 0;
@@ -879,25 +868,25 @@ int OpResearch(char *line, char *op)
// Returns the type of pyrotechnic effect.
-PyroType OpPyro(char *line, char *op)
+Gfx::PyroType OpPyro(char *line, const char *op)
{
line = SearchOp(line, op);
- if ( *line == 0 ) return PT_NULL;
+ if ( *line == 0 ) return Gfx::PT_NULL;
return GetPyro(line, 0);
}
// Returns the type of camera.
-CameraType OpCamera(char *line, char *op)
+Gfx::CameraType OpCamera(char *line, const char *op)
{
line = SearchOp(line, op);
- if ( *line == 0 ) return CAMERA_NULL;
+ if ( *line == 0 ) return Gfx::CAM_TYPE_NULL;
return GetCamera(line, 0);
}
// Returns the type of a building.
-int OpBuild(char *line, char *op)
+int OpBuild(char *line, const char *op)
{
line = SearchOp(line, op);
if ( *line == 0 ) return 0;
@@ -906,7 +895,7 @@ int OpBuild(char *line, char *op)
// Returns a position in the XZ plane (top view).
-Math::Vector OpPos(char *line, char *op)
+Math::Vector OpPos(char *line, const char *op)
{
Math::Vector pos;
@@ -924,7 +913,7 @@ Math::Vector OpPos(char *line, char *op)
// Returns a direction.
-Math::Vector OpDir(char *line, char *op)
+Math::Vector OpDir(char *line, const char *op)
{
Math::Vector dir;
@@ -940,28 +929,10 @@ Math::Vector OpDir(char *line, char *op)
return dir;
}
-// Reads a color (0 .. 255).
-
-D3DCOLOR OpColor(char *line, char *op, D3DCOLOR def)
-{
- D3DCOLOR color;
-
- line = SearchOp(line, op);
- if ( *line == 0 ) return def;
-
- color = 0;
- color |= (GetInt(line, 0, 0)&0xff)<<16; // r
- color |= (GetInt(line, 1, 0)&0xff)<<8; // g
- color |= (GetInt(line, 2, 0)&0xff)<<0; // b
- color |= (GetInt(line, 3, 0)&0xff)<<24; // a
- return color;
-}
-
// Reads a color (-1 .. 1).
-
-D3DCOLORVALUE OpColorValue(char *line, char *op, D3DCOLORVALUE def)
+Gfx::Color OpColor(char *line, const char *op, Gfx::Color def)
{
- D3DCOLORVALUE color;
+ Gfx::Color color;
line = SearchOp(line, op);
if ( *line == 0 ) return def;
diff --git a/src/script/cmdtoken.h b/src/script/cmdtoken.h
index 05ff758..812cec7 100644
--- a/src/script/cmdtoken.h
+++ b/src/script/cmdtoken.h
@@ -18,47 +18,41 @@
#pragma once
-
-#include "old/d3denum.h"
-#include "old/d3dengine.h"
-#include "object/object.h"
-#include "old/water.h"
-#include "old/pyro.h"
-#include "old/camera.h"
+#include "graphics/engine/water.h"
+#include "graphics/engine/engine.h"
+#include "graphics/engine/pyro.h"
// Procedures.
-extern bool Cmd(char *line, char *token);
-extern char* SearchOp(char *line, char *op);
+extern bool Cmd(char *line, const char *token);
+extern char* SearchOp(char *line, const char *op);
extern int GetInt(char *line, int rank, int def);
extern float GetFloat(char *line, int rank, float def);
extern void GetString(char *line, int rank, char *buffer);
extern ObjectType GetTypeObject(char *line, int rank, ObjectType def);
-extern char* GetTypeObject(ObjectType type);
-extern WaterType GetTypeWater(char *line, int rank, WaterType def);
-extern D3DTypeObj GetTypeTerrain(char *line, int rank, D3DTypeObj def);
+extern const char* GetTypeObject(ObjectType type);
+extern Gfx::WaterType GetTypeWater(char *line, int rank, Gfx::WaterType def);
+extern Gfx::EngineObjectType GetTypeTerrain(char *line, int rank, Gfx::EngineObjectType def);
extern int GetBuild(char *line, int rank);
extern int GetResearch(char *line, int rank);
-extern PyroType GetPyro(char *line, int rank);
-extern CameraType GetCamera(char *line, int rank);
-extern char* GetCamera(CameraType type);
-
-extern int OpInt(char *line, char *op, int def);
-extern float OpFloat(char *line, char *op, float def);
-extern void OpString(char *line, char *op, char *buffer);
-extern ObjectType OpTypeObject(char *line, char *op, ObjectType def);
-extern WaterType OpTypeWater(char *line, char *op, WaterType def);
-extern D3DTypeObj OpTypeTerrain(char *line, char *op, D3DTypeObj def);
-extern int OpResearch(char *line, char *op);
-extern PyroType OpPyro(char *line, char *op);
-extern CameraType OpCamera(char *line, char *op);
-extern int OpBuild(char *line, char *op);
-extern Math::Vector OpPos(char *line, char *op);
-extern Math::Vector OpDir(char *line, char *op);
-extern D3DCOLOR OpColor(char *line, char *op, D3DCOLOR def);
-extern D3DCOLORVALUE OpColorValue(char *line, char *op, D3DCOLORVALUE def);
-
+extern Gfx::PyroType GetPyro(char *line, int rank);
+extern Gfx::CameraType GetCamera(char *line, int rank);
+extern const char* GetCamera(Gfx::CameraType type);
+
+extern int OpInt(char *line, const char *op, int def);
+extern float OpFloat(char *line, const char *op, float def);
+extern void OpString(char *line, const char *op, char *buffer);
+extern ObjectType OpTypeObject(char *line, const char *op, ObjectType def);
+extern Gfx::WaterType OpTypeWater(char *line, const char *op, Gfx::WaterType def);
+extern Gfx::EngineObjectType OpTypeTerrain(char *line, const char *op, Gfx::EngineObjectType def);
+extern int OpResearch(char *line, const char *op);
+extern Gfx::PyroType OpPyro(char *line, const char *op);
+extern Gfx::CameraType OpCamera(char *line, const char *op);
+extern int OpBuild(char *line, const char *op);
+extern Math::Vector OpPos(char *line, const char *op);
+extern Math::Vector OpDir(char *line, const char *op);
+extern Gfx::Color OpColor(char *line, const char *op, Gfx::Color def);
diff --git a/src/script/script.cpp b/src/script/script.cpp
index d9d6444..b29c625 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -17,38 +17,28 @@
// script.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
+#include "script/script.h"
-#include "CBot/CBotDll.h"
-#include "common/struct.h"
-#include "math/geometry.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
#include "common/global.h"
-#include "common/event.h"
-#include "common/misc.h"
#include "common/iman.h"
#include "common/restext.h"
-#include "old/math3d.h"
-#include "object/robotmain.h"
-#include "old/terrain.h"
-#include "old/water.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/water.h"
+#include "graphics/engine/text.h"
+#include "math/geometry.h"
+#include "math/vector.h"
#include "object/object.h"
+#include "object/robotmain.h"
+#include "object/task/taskmanager.h"
#include "physics/physics.h"
+#include "script/cbottoken.h"
#include "ui/interface.h"
#include "ui/edit.h"
#include "ui/list.h"
-#include "old/text.h"
#include "ui/displaytext.h"
-#include "object/task/taskmanager.h"
-#include "object/task/task.h"
-#include "object/task/taskmanip.h"
-#include "object/task/taskgoto.h"
-#include "object/task/taskshield.h"
-#include "script/cbottoken.h"
-#include "script/script.h"
+
+
+#include <stdio.h>
@@ -62,7 +52,7 @@ const int ERM_STOP = 1; // if error -> stop
// Compiling a procedure without any parameters.
-CBotTypResult cNull(CBotVar* &var, void* user)
+CBotTypResult CScript::cNull(CBotVar* &var, void* user)
{
if ( var != 0 ) return CBotErrOverParam;
return CBotTypResult(CBotTypFloat);
@@ -70,26 +60,26 @@ CBotTypResult cNull(CBotVar* &var, void* user)
// Compiling a procedure with a single real number.
-CBotTypResult cOneFloat(CBotVar* &var, void* user)
+CBotTypResult CScript::cOneFloat(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
}
// Compiling a procedure with two real numbers.
-CBotTypResult cTwoFloat(CBotVar* &var, void* user)
+CBotTypResult CScript::cTwoFloat(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
@@ -97,26 +87,26 @@ CBotTypResult cTwoFloat(CBotVar* &var, void* user)
// Compiling a procedure with a "dot".
-CBotTypResult cPoint(CBotVar* &var, void* user)
+CBotTypResult CScript::cPoint(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() <= CBotTypDouble )
+ if ( var->GetType() <= CBotTypDouble )
{
- var = var->GivNext();
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
//? if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
-//? if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
-//? var = var->GivNext();
+//? if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+//? var = var->GetNext();
return CBotTypResult(0);
}
- if ( var->GivType() == CBotTypClass )
+ if ( var->GetType() == CBotTypClass )
{
if ( !var->IsElemOfClass("point") ) return CBotTypResult(CBotErrBadParam);
- var = var->GivNext();
+ var = var->GetNext();
return CBotTypResult(0);
}
@@ -125,12 +115,12 @@ CBotTypResult cPoint(CBotVar* &var, void* user)
// Compiling a procedure with a single "point".
-CBotTypResult cOnePoint(CBotVar* &var, void* user)
+CBotTypResult CScript::cOnePoint(CBotVar* &var, void* user)
{
CBotTypResult ret;
ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ if ( ret.GetType() != 0 ) return ret;
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
@@ -138,12 +128,12 @@ CBotTypResult cOnePoint(CBotVar* &var, void* user)
// Compiling a procedure with a single string.
-CBotTypResult cString(CBotVar* &var, void* user)
+CBotTypResult CScript::cString(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() != CBotTypString &&
- var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() != CBotTypString &&
+ var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
}
@@ -155,8 +145,8 @@ bool FindList(CBotVar* array, int type)
{
while ( array != 0 )
{
- if ( type == array->GivValInt() ) return true;
- array = array->GivNext();
+ if ( type == array->GetValInt() ) return true;
+ array = array->GetNext();
}
return false;
}
@@ -168,40 +158,40 @@ bool GetPoint(CBotVar* &var, int& exception, Math::Vector& pos)
{
CBotVar *pX, *pY, *pZ;
- if ( var->GivType() <= CBotTypDouble )
+ if ( var->GetType() <= CBotTypDouble )
{
- pos.x = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ pos.x = var->GetValFloat()*g_unit;
+ var = var->GetNext();
- pos.z = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ pos.z = var->GetValFloat()*g_unit;
+ var = var->GetNext();
pos.y = 0.0f;
}
else
{
- pX = var->GivItem("x");
+ pX = var->GetItem("x");
if ( pX == NULL )
{
exception = CBotErrUndefItem; return true;
}
- pos.x = pX->GivValFloat()*g_unit;
+ pos.x = pX->GetValFloat()*g_unit;
- pY = var->GivItem("y");
+ pY = var->GetItem("y");
if ( pY == NULL )
{
exception = CBotErrUndefItem; return true;
}
- pos.z = pY->GivValFloat()*g_unit; // attention y -> z !
+ pos.z = pY->GetValFloat()*g_unit; // attention y -> z !
- pZ = var->GivItem("z");
+ pZ = var->GetItem("z");
if ( pZ == NULL )
{
exception = CBotErrUndefItem; return true;
}
- pos.y = pZ->GivValFloat()*g_unit; // attention z -> y !
+ pos.y = pZ->GetValFloat()*g_unit; // attention z -> y !
- var = var->GivNext();
+ var = var->GetNext();
}
return true;
}
@@ -209,33 +199,33 @@ bool GetPoint(CBotVar* &var, int& exception, Math::Vector& pos)
// Instruction "sin(degrees)".
-bool rSin(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rSin(CBotVar* var, CBotVar* result, int& exception, void* user)
{
float value;
- value = var->GivValFloat();
+ value = var->GetValFloat();
result->SetValFloat(sinf(value*Math::PI/180.0f));
return true;
}
// Instruction "cos(degrees)".
-bool rCos(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rCos(CBotVar* var, CBotVar* result, int& exception, void* user)
{
float value;
- value = var->GivValFloat();
+ value = var->GetValFloat();
result->SetValFloat(cosf(value*Math::PI/180.0f));
return true;
}
// Instruction "tan(degrees)".
-bool rTan(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rTan(CBotVar* var, CBotVar* result, int& exception, void* user)
{
float value;
- value = var->GivValFloat();
+ value = var->GetValFloat();
result->SetValFloat(tanf(value*Math::PI/180.0f));
return true;
}
@@ -246,7 +236,7 @@ bool raSin(CBotVar* var, CBotVar* result, int& exception, void* user)
{
float value;
- value = var->GivValFloat();
+ value = var->GetValFloat();
result->SetValFloat(asinf(value)*180.0f/Math::PI);
return true;
}
@@ -257,7 +247,7 @@ bool raCos(CBotVar* var, CBotVar* result, int& exception, void* user)
{
float value;
- value = var->GivValFloat();
+ value = var->GetValFloat();
result->SetValFloat(acosf(value)*180.0f/Math::PI);
return true;
}
@@ -268,38 +258,38 @@ bool raTan(CBotVar* var, CBotVar* result, int& exception, void* user)
{
float value;
- value = var->GivValFloat();
+ value = var->GetValFloat();
result->SetValFloat(atanf(value)*180.0f/Math::PI);
return true;
}
// Instruction "sqrt(value)".
-bool rSqrt(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rSqrt(CBotVar* var, CBotVar* result, int& exception, void* user)
{
float value;
- value = var->GivValFloat();
+ value = var->GetValFloat();
result->SetValFloat(sqrtf(value));
return true;
}
// Instruction "pow(x, y)".
-bool rPow(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rPow(CBotVar* var, CBotVar* result, int& exception, void* user)
{
float x, y;
- x = var->GivValFloat();
- var = var->GivNext();
- y = var->GivValFloat();
+ x = var->GetValFloat();
+ var = var->GetNext();
+ y = var->GetValFloat();
result->SetValFloat(powf(x, y));
return true;
}
// Instruction "rand()".
-bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rRand(CBotVar* var, CBotVar* result, int& exception, void* user)
{
result->SetValFloat(Math::Rand());
return true;
@@ -307,11 +297,11 @@ bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "abs()".
-bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rAbs(CBotVar* var, CBotVar* result, int& exception, void* user)
{
float value;
- value = var->GivValFloat();
+ value = var->GetValFloat();
result->SetValFloat(fabs(value));
return true;
}
@@ -319,11 +309,11 @@ bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "retobject(rank)".
-CBotTypResult cRetObject(CBotVar* &var, void* user)
+CBotTypResult CScript::cGetObject(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypPointer, "object");
@@ -331,22 +321,22 @@ CBotTypResult cRetObject(CBotVar* &var, void* user)
// Instruction "retobject(rank)".
-bool rRetObject(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject*>(user))->GetRunScript();
CObject* pObj;
int rank;
- rank = var->GivValInt();
+ rank = var->GetValInt();
- pObj = (CObject*)script->m_iMan->SearchInstance(CLASS_OBJECT, rank);
+ pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, rank));
if ( pObj == 0 )
{
result->SetPointer(0);
}
else
{
- result->SetPointer(pObj->RetBotVar());
+ result->SetPointer(pObj->GetBotVar());
}
return true;
}
@@ -354,24 +344,24 @@ bool rRetObject(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "search(type, pos)".
-CBotTypResult cSearch(CBotVar* &var, void* user)
+CBotTypResult CScript::cSearch(CBotVar* &var, void* user)
{
CBotVar* array;
CBotTypResult ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() == CBotTypArrayPointer )
+ if ( var->GetType() == CBotTypArrayPointer )
{
- array = var->GivItemList();
+ array = var->GetItemList();
if ( array == 0 ) return CBotTypResult(CBotTypPointer);
- if ( array->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ if ( array->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
}
- else if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ else if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 )
{
ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ if ( ret.GetType() != 0 ) return ret;
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
}
@@ -380,9 +370,9 @@ CBotTypResult cSearch(CBotVar* &var, void* user)
// Instruction "search(type, pos)".
-bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
CObject *pObj, *pBest;
CBotVar* array;
Math::Vector pos, oPos;
@@ -391,17 +381,17 @@ bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
float min, dist;
int type, oType, i;
- if ( var->GivType() == CBotTypArrayPointer )
+ if ( var->GetType() == CBotTypArrayPointer )
{
- array = var->GivItemList();
+ array = var->GetItemList();
bArray = true;
}
else
{
- type = var->GivValInt();
+ type = var->GetValInt();
bArray = false;
}
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
if ( !GetPoint(var, exception, pos) ) return true;
@@ -412,13 +402,13 @@ bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)script->m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
- if ( !pObj->RetActif() ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType == OBJECT_TOTO ) continue;
if ( oType == OBJECT_RUINmobilew2 ||
@@ -455,7 +445,7 @@ bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( bNearest )
{
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(pos, oPos);
if ( dist < min )
{
@@ -476,7 +466,7 @@ bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
}
else
{
- result->SetPointer(pBest->RetBotVar());
+ result->SetPointer(pBest->GetBotVar());
}
return true;
}
@@ -484,47 +474,47 @@ bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of instruction "radar(type, angle, focus, min, max, sens)".
-CBotTypResult cRadar(CBotVar* &var, void* user)
+CBotTypResult CScript::cRadar(CBotVar* &var, void* user)
{
CBotVar* array;
if ( var == 0 ) return CBotTypResult(CBotTypPointer, "object");
- if ( var->GivType() == CBotTypArrayPointer )
+ if ( var->GetType() == CBotTypArrayPointer )
{
- array = var->GivItemList();
+ array = var->GetItemList();
if ( array == 0 ) return CBotTypResult(CBotTypPointer, "object");
- if ( array->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // type
+ if ( array->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // type
}
- else if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // type
- var = var->GivNext();
+ else if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // type
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypPointer, "object");
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // angle
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // angle
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypPointer, "object");
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // focus
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // focus
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypPointer, "object");
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // min
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // min
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypPointer, "object");
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // max
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // max
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypPointer, "object");
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // sense
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // sense
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypPointer, "object");
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // filter
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum); // filter
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypPointer, "object");
return CBotTypResult(CBotErrOverParam);
}
// Instruction "radar(type, angle, focus, min, max, sens, filter)".
-bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
CObject *pObj, *pBest;
CPhysics* physics;
CBotVar* array;
@@ -544,46 +534,46 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( var != 0 )
{
- if ( var->GivType() == CBotTypArrayPointer )
+ if ( var->GetType() == CBotTypArrayPointer )
{
- array = var->GivItemList();
+ array = var->GetItemList();
bArray = true;
}
else
{
- type = var->GivValInt();
+ type = var->GetValInt();
bArray = false;
}
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- angle = -var->GivValFloat()*Math::PI/180.0f;
+ angle = -var->GetValFloat()*Math::PI/180.0f;
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- focus = var->GivValFloat()*Math::PI/180.0f;
+ focus = var->GetValFloat()*Math::PI/180.0f;
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- minDist = var->GivValFloat()*g_unit;
+ minDist = var->GetValFloat()*g_unit;
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- maxDist = var->GivValFloat()*g_unit;
+ maxDist = var->GetValFloat()*g_unit;
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- sens = var->GivValFloat();
+ sens = var->GetValFloat();
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- filter = (RadarFilter)var->GivValInt();
+ filter = static_cast<RadarFilter>(var->GetValInt());
}
}
}
@@ -592,8 +582,8 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
}
}
- iPos = pThis->RetPosition(0);
- iAngle = pThis->RetAngleY(0)+angle;
+ iPos = pThis->GetPosition(0);
+ iAngle = pThis->GetAngleY(0)+angle;
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( sens >= 0.0f ) best = 100000.0f;
@@ -601,15 +591,15 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)script->m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == pThis ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
- if ( !pObj->RetActif() ) continue;
- if ( pObj->RetProxyActivate() ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue;
+ if ( pObj->GetProxyActivate() ) continue;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType == OBJECT_TOTO ) continue;
if ( oType == OBJECT_RUINmobilew2 ||
@@ -637,13 +627,13 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( filter == FILTER_ONLYLANDING )
{
- physics = pObj->RetPhysics();
- if ( physics != 0 && !physics->RetLand() ) continue;
+ physics = pObj->GetPhysics();
+ if ( physics != 0 && !physics->GetLand() ) continue;
}
if ( filter == FILTER_ONLYFLYING )
{
- physics = pObj->RetPhysics();
- if ( physics != 0 && physics->RetLand() ) continue;
+ physics = pObj->GetPhysics();
+ if ( physics != 0 && physics->GetLand() ) continue;
}
if ( bArray )
@@ -655,7 +645,7 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( type != oType && type != OBJECT_NULL ) continue;
}
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
d = Math::DistanceProjected(iPos, oPos);
if ( d < minDist || d > maxDist ) continue; // too close or too far?
@@ -671,6 +661,7 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
}
a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
+ //TODO uninitialized variable
if ( Math::TestAngle(a, iAngle-focus/2.0f, iAngle+focus/2.0f) )
{
if ( (sens >= 0.0f && d < best) ||
@@ -688,7 +679,7 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
}
else
{
- result->SetPointer(pBest->RetBotVar());
+ result->SetPointer(pBest->GetBotVar());
}
return true;
}
@@ -696,7 +687,7 @@ bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user)
// Monitoring a task.
-bool Process(CScript* script, CBotVar* result, int &exception)
+bool CScript::Process(CScript* script, CBotVar* result, int &exception)
{
Error err;
@@ -726,21 +717,21 @@ bool Process(CScript* script, CBotVar* result, int &exception)
// Compilation of the instruction "detect(type)".
-CBotTypResult cDetect(CBotVar* &var, void* user)
+CBotTypResult CScript::cDetect(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypBoolean);
}
// Instruction "detect(type)".
-bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
CObject *pObj, *pGoal, *pBest;
CPhysics* physics;
CBotVar* array;
@@ -765,20 +756,20 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( var != 0 )
{
- if ( var->GivType() == CBotTypArrayPointer )
+ if ( var->GetType() == CBotTypArrayPointer )
{
- array = var->GivItemList();
+ array = var->GetItemList();
bArray = true;
}
else
{
- type = var->GivValInt();
+ type = var->GetValInt();
bArray = false;
}
}
- iPos = pThis->RetPosition(0);
- iAngle = pThis->RetAngleY(0)+angle;
+ iPos = pThis->GetPosition(0);
+ iAngle = pThis->GetAngleY(0)+angle;
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
bGoal = 100000.0f;
@@ -788,15 +779,15 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)script->m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == pThis ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
- if ( !pObj->RetActif() ) continue;
- if ( pObj->RetProxyActivate() ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue;
+ if ( pObj->GetProxyActivate() ) continue;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType == OBJECT_TOTO ) continue;
if ( oType == OBJECT_RUINmobilew2 ||
@@ -824,13 +815,13 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( filter == FILTER_ONLYLANDING )
{
- physics = pObj->RetPhysics();
- if ( physics != 0 && !physics->RetLand() ) continue;
+ physics = pObj->GetPhysics();
+ if ( physics != 0 && !physics->GetLand() ) continue;
}
if ( filter == FILTER_ONLYFLYING )
{
- physics = pObj->RetPhysics();
- if ( physics != 0 && physics->RetLand() ) continue;
+ physics = pObj->GetPhysics();
+ if ( physics != 0 && physics->GetLand() ) continue;
}
if ( bArray )
@@ -842,7 +833,7 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( type != oType && type != OBJECT_NULL ) continue;
}
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
d = Math::DistanceProjected(iPos, oPos);
a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
@@ -911,13 +902,13 @@ bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "direction(pos)".
-CBotTypResult cDirection(CBotVar* &var, void* user)
+CBotTypResult CScript::cDirection(CBotVar* &var, void* user)
{
CBotTypResult ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ if ( ret.GetType() != 0 ) return ret;
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
@@ -925,18 +916,17 @@ CBotTypResult cDirection(CBotVar* &var, void* user)
// Instruction "direction(pos)".
-bool rDirection(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rDirection(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CObject* pThis = static_cast<CObject *>(user);
Math::Vector iPos, oPos;
- float a, g;
+ float a, g;
if ( !GetPoint(var, exception, oPos) ) return true;
- iPos = pThis->RetPosition(0);
+ iPos = pThis->GetPosition(0);
- a = pThis->RetAngleY(0);
+ a = pThis->GetAngleY(0);
g = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
result->SetValFloat(-Math::Direction(a, g)*180.0f/Math::PI);
@@ -946,25 +936,25 @@ bool rDirection(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "produce(pos, angle, type, scriptName)".
-CBotTypResult cProduce(CBotVar* &var, void* user)
+CBotTypResult CScript::cProduce(CBotVar* &var, void* user)
{
CBotTypResult ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ if ( ret.GetType() != 0 ) return ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
- var = var->GivNext();
+ if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
@@ -973,9 +963,9 @@ CBotTypResult cProduce(CBotVar* &var, void* user)
// Instruction "produce(pos, angle, type, scriptName)".
-bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rProduce(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
CObject* object;
CBotString cbs;
const char* name;
@@ -985,13 +975,13 @@ bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( !GetPoint(var, exception, pos) ) return true;
- angle = var->GivValFloat()*Math::PI/180.0f;
- var = var->GivNext();
+ angle = var->GetValFloat()*Math::PI/180.0f;
+ var = var->GetNext();
- type = (ObjectType)var->GivValInt();
- var = var->GivNext();
+ type = static_cast<ObjectType>(var->GetValInt());
+ var = var->GetNext();
- cbs = var->GivValString();
+ cbs = var->GetValString();
name = cbs;
if ( type == OBJECT_FRET ||
@@ -1054,7 +1044,7 @@ bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user)
return true;
}
object->SetActivity(false);
- object->ReadProgram(0, (char*)name);
+ object->ReadProgram(0, static_cast<const char*>(name));
object->RunProgram(0);
result->SetValInt(0); // no error
@@ -1064,17 +1054,17 @@ bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "distance(p1, p2)".
-CBotTypResult cDistance(CBotVar* &var, void* user)
+CBotTypResult CScript::cDistance(CBotVar* &var, void* user)
{
CBotTypResult ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ if ( ret.GetType() != 0 ) return ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ if ( ret.GetType() != 0 ) return ret;
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
@@ -1083,7 +1073,7 @@ CBotTypResult cDistance(CBotVar* &var, void* user)
// Instruction "distance(p1, p2)".
-bool rDistance(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rDistance(CBotVar* var, CBotVar* result, int& exception, void* user)
{
Math::Vector p1, p2;
float value;
@@ -1098,7 +1088,7 @@ bool rDistance(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "distance2d(p1, p2)".
-bool rDistance2d(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rDistance2d(CBotVar* var, CBotVar* result, int& exception, void* user)
{
Math::Vector p1, p2;
float value;
@@ -1114,25 +1104,25 @@ bool rDistance2d(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "space(center, rMin, rMax, dist)".
-CBotTypResult cSpace(CBotVar* &var, void* user)
+CBotTypResult CScript::cSpace(CBotVar* &var, void* user)
{
CBotTypResult ret;
if ( var == 0 ) return CBotTypResult(CBotTypIntrinsic, "point");
ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ if ( ret.GetType() != 0 ) return ret;
if ( var == 0 ) return CBotTypResult(CBotTypIntrinsic, "point");
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypIntrinsic, "point");
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypIntrinsic, "point");
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypIntrinsic, "point");
@@ -1140,10 +1130,10 @@ CBotTypResult cSpace(CBotVar* &var, void* user)
// Instruction "space(center, rMin, rMax, dist)".
-bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
CBotVar* pSub;
Math::Vector center;
float rMin, rMax, dist;
@@ -1154,7 +1144,7 @@ bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( var == 0 )
{
- center = pThis->RetPosition(0);
+ center = pThis->GetPosition(0);
}
else
{
@@ -1162,18 +1152,18 @@ bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( var != 0 )
{
- rMin = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ rMin = var->GetValFloat()*g_unit;
+ var = var->GetNext();
if ( var != 0 )
{
- rMax = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ rMax = var->GetValFloat()*g_unit;
+ var = var->GetNext();
if ( var != 0 )
{
- dist = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ dist = var->GetValFloat()*g_unit;
+ var = var->GetNext();
}
}
}
@@ -1182,13 +1172,13 @@ bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( result != 0 )
{
- pSub = result->GivItemList();
+ pSub = result->GetItemList();
if ( pSub != 0 )
{
pSub->SetValFloat(center.x/g_unit);
- pSub = pSub->GivNext(); // "y"
+ pSub = pSub->GetNext(); // "y"
pSub->SetValFloat(center.z/g_unit);
- pSub = pSub->GivNext(); // "z"
+ pSub = pSub->GetNext(); // "z"
pSub->SetValFloat(center.y/g_unit);
}
}
@@ -1198,17 +1188,17 @@ bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "flatground(center, rMax)".
-CBotTypResult cFlatGround(CBotVar* &var, void* user)
+CBotTypResult CScript::cFlatGround(CBotVar* &var, void* user)
{
CBotTypResult ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ if ( ret.GetType() != 0 ) return ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
@@ -1217,18 +1207,18 @@ CBotTypResult cFlatGround(CBotVar* &var, void* user)
// Instruction "flatground(center, rMax)".
-bool rFlatGround(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rFlatGround(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
Math::Vector center;
float rMax, dist;
if ( !GetPoint(var, exception, center) ) return true;
- rMax = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ rMax = var->GetValFloat()*g_unit;
+ var = var->GetNext();
- dist = script->m_main->RetFlatZoneRadius(center, rMax, pThis);
+ dist = script->m_main->GetFlatZoneRadius(center, rMax, pThis);
result->SetValFloat(dist/g_unit);
return true;
@@ -1237,9 +1227,9 @@ bool rFlatGround(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "wait(t)".
-bool rWait(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rWait(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
float value;
Error err;
@@ -1248,7 +1238,7 @@ bool rWait(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- value = var->GivValFloat();
+ value = var->GetValFloat();
err = script->m_primaryTask->StartTaskWait(value);
if ( err != ERR_OK )
{
@@ -1268,9 +1258,9 @@ bool rWait(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "move(dist)".
-bool rMove(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rMove(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
float value;
Error err;
@@ -1279,7 +1269,7 @@ bool rMove(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- value = var->GivValFloat();
+ value = var->GetValFloat();
err = script->m_primaryTask->StartTaskAdvance(value*g_unit);
if ( err != ERR_OK )
{
@@ -1299,9 +1289,9 @@ bool rMove(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "turn(angle)".
-bool rTurn(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rTurn(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
float value;
Error err;
@@ -1310,7 +1300,7 @@ bool rTurn(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- value = var->GivValFloat();
+ value = var->GetValFloat();
err = script->m_primaryTask->StartTaskTurn(-value*Math::PI/180.0f);
if ( err != ERR_OK )
{
@@ -1330,25 +1320,25 @@ bool rTurn(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "goto(pos, altitude, crash, goal)".
-CBotTypResult cGoto(CBotVar* &var, void* user)
+CBotTypResult CScript::cGoto(CBotVar* &var, void* user)
{
CBotTypResult ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ if ( ret.GetType() != 0 ) return ret;
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
return CBotTypResult(CBotErrOverParam);
@@ -1356,9 +1346,9 @@ CBotTypResult cGoto(CBotVar* &var, void* user)
// Instruction "goto(pos, altitude, mode)".
-bool rGoto(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rGoto(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
Math::Vector pos;
TaskGotoGoal goal;
TaskGotoCrash crash;
@@ -1378,17 +1368,17 @@ bool rGoto(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( var != 0 )
{
- altitude = var->GivValFloat()*g_unit;
+ altitude = var->GetValFloat()*g_unit;
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- goal = (TaskGotoGoal)var->GivValInt();
+ goal = static_cast<TaskGotoGoal>(var->GetValInt());
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- crash = (TaskGotoCrash)var->GivValInt();
+ crash = static_cast<TaskGotoCrash>(var->GetValInt());
}
}
}
@@ -1412,19 +1402,19 @@ bool rGoto(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "find(type)".
-bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
Math::Vector pos;
TaskGotoGoal goal;
TaskGotoCrash crash;
float altitude;
Error err;
- CObject* pThis = (CObject*)user;
+ CObject* pThis = static_cast<CObject *>(user);
CObject *pObj, *pBest;
CBotVar* array;
Math::Vector iPos, oPos;
- float best, minDist, maxDist, sens, iAngle, angle, focus, d, a;
+ float best, minDist, maxDist, iAngle, focus, d, a;
int type, oType, i;
bool bArray;
@@ -1433,20 +1423,18 @@ bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
type = OBJECT_NULL;
- angle = 0.0f;
focus = Math::PI*2.0f;
minDist = 0.0f*g_unit;
maxDist = 1000.0f*g_unit;
- sens = 1.0f;
- if ( var->GivType() == CBotTypArrayPointer )
+ if ( var->GetType() == CBotTypArrayPointer )
{
- array = var->GivItemList();
+ array = var->GetItemList();
bArray = true;
}
else
{
- type = var->GivValInt();
+ type = var->GetValInt();
bArray = false;
}
@@ -1454,15 +1442,15 @@ bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)script->m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == pThis ) continue;
- if ( pObj->RetTruck() != 0 ) continue; // object transported?
- if ( !pObj->RetActif() ) continue;
- if ( pObj->RetProxyActivate() ) continue;
+ if ( pObj->GetTruck() != 0 ) continue; // object transported?
+ if ( !pObj->GetActif() ) continue;
+ if ( pObj->GetProxyActivate() ) continue;
- oType = pObj->RetType();
+ oType = pObj->GetType();
if ( oType == OBJECT_TOTO ) continue;
if ( oType == OBJECT_RUINmobilew2 ||
@@ -1497,7 +1485,7 @@ bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( type != oType && type != OBJECT_NULL ) continue;
}
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
d = Math::DistanceProjected(iPos, oPos);
if ( d < minDist || d > maxDist ) continue; // too close or too far?
@@ -1528,7 +1516,7 @@ bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
return false;
}
- pos = pBest->RetPosition(0);
+ pos = pBest->GetPosition(0);
goal = TGG_DEFAULT;
crash = TGC_DEFAULT;
altitude = 0.0f*g_unit;
@@ -1553,21 +1541,21 @@ bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation "grab/drop(oper)".
-CBotTypResult cGrabDrop(CBotVar* &var, void* user)
+CBotTypResult CScript::cGrabDrop(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
}
// Instruction "grab(oper)".
-bool rGrab(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rGrab(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
ObjectType oType;
TaskManipArm type;
Error err;
@@ -1577,10 +1565,16 @@ bool rGrab(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- if ( var == 0 ) type = TMA_FFRONT;
- else type = (TaskManipArm)var->GivValInt();
+ if ( var == 0 )
+ {
+ type = TMA_FFRONT;
+ }
+ else
+ {
+ type = static_cast<TaskManipArm>(var->GetValInt());
+ }
- oType = pThis->RetType();
+ oType = pThis->GetType();
if ( oType == OBJECT_HUMAN ||
oType == OBJECT_TECH )
{
@@ -1609,10 +1603,10 @@ bool rGrab(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "drop(oper)".
-bool rDrop(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rDrop(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
ObjectType oType;
TaskManipArm type;
Error err;
@@ -1623,9 +1617,9 @@ bool rDrop(CBotVar* var, CBotVar* result, int& exception, void* user)
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
if ( var == 0 ) type = TMA_FFRONT;
- else type = (TaskManipArm)var->GivValInt();
+ else type = static_cast<TaskManipArm>(var->GetValInt());
- oType = pThis->RetType();
+ oType = pThis->GetType();
if ( oType == OBJECT_HUMAN ||
oType == OBJECT_TECH )
{
@@ -1654,9 +1648,9 @@ bool rDrop(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "sniff()".
-bool rSniff(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rSniff(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
Error err;
exception = 0;
@@ -1683,15 +1677,15 @@ bool rSniff(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "receive(nom, power)".
-CBotTypResult cReceive(CBotVar* &var, void* user)
+CBotTypResult CScript::cReceive(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
- var = var->GivNext();
+ if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
@@ -1699,10 +1693,10 @@ CBotTypResult cReceive(CBotVar* &var, void* user)
// Instruction "receive(nom, power)".
-bool rReceive(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rReceive(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
CBotString cbs;
Error err;
const char* p;
@@ -1714,18 +1708,18 @@ bool rReceive(CBotVar* var, CBotVar* result, int& exception, void* user)
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- cbs = var->GivValString();
+ cbs = var->GetValString();
p = cbs;
- var = var->GivNext();
+ var = var->GetNext();
power = 10.0f*g_unit;
if ( var != 0 )
{
- power = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ power = var->GetValFloat()*g_unit;
+ var = var->GetNext();
}
- err = script->m_primaryTask->StartTaskInfo((char*)p, 0.0f, power, false);
+ err = script->m_primaryTask->StartTaskInfo(static_cast<const char*>(p), 0.0f, power, false);
if ( err != ERR_OK )
{
delete script->m_primaryTask;
@@ -1736,7 +1730,7 @@ bool rReceive(CBotVar* var, CBotVar* result, int& exception, void* user)
}
if ( !Process(script, result, exception) ) return false; // not finished
- value = pThis->RetInfoReturn();
+ value = pThis->GetInfoReturn();
if ( value == NAN )
{
result->SetInit(IS_NAN);
@@ -1750,19 +1744,19 @@ bool rReceive(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "send(nom, value, power)".
-CBotTypResult cSend(CBotVar* &var, void* user)
+CBotTypResult CScript::cSend(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
- var = var->GivNext();
+ if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
@@ -1770,10 +1764,9 @@ CBotTypResult cSend(CBotVar* &var, void* user)
// Instruction "send(nom, value, power)".
-bool rSend(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rSend(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
CBotString cbs;
Error err;
const char* p;
@@ -1785,21 +1778,21 @@ bool rSend(CBotVar* var, CBotVar* result, int& exception, void* user)
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- cbs = var->GivValString();
+ cbs = var->GetValString();
p = cbs;
- var = var->GivNext();
+ var = var->GetNext();
- value = var->GivValFloat();
- var = var->GivNext();
+ value = var->GetValFloat();
+ var = var->GetNext();
power = 10.0f*g_unit;
if ( var != 0 )
{
- power = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ power = var->GetValFloat()*g_unit;
+ var = var->GetNext();
}
- err = script->m_primaryTask->StartTaskInfo((char*)p, value, power, true);
+ err = script->m_primaryTask->StartTaskInfo(static_cast<const char*>(p), value, power, true);
if ( err != ERR_OK )
{
delete script->m_primaryTask;
@@ -1818,7 +1811,7 @@ bool rSend(CBotVar* var, CBotVar* result, int& exception, void* user)
// Seeks the nearest information terminal.
-CObject* SearchInfo(CScript* script, CObject* object, float power)
+CObject* CScript::SearchInfo(CScript* script, CObject* object, float power)
{
CObject *pObj, *pBest;
Math::Vector iPos, oPos;
@@ -1826,21 +1819,21 @@ CObject* SearchInfo(CScript* script, CObject* object, float power)
float dist, min;
int i;
- iPos = object->RetPosition(0);
+ iPos = object->GetPosition(0);
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)script->m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(script->m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type != OBJECT_INFO ) continue;
- if ( !pObj->RetActif() ) continue;
+ if ( !pObj->GetActif() ) continue;
- oPos = pObj->RetPosition(0);
+ oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, iPos);
if ( dist > power ) continue; // too far?
if ( dist < min )
@@ -1855,15 +1848,15 @@ CObject* SearchInfo(CScript* script, CObject* object, float power)
// Compilation of the instruction "deleteinfo(nom, power)".
-CBotTypResult cDeleteInfo(CBotVar* &var, void* user)
+CBotTypResult CScript::cDeleteInfo(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
- var = var->GivNext();
+ if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
@@ -1871,10 +1864,10 @@ CBotTypResult cDeleteInfo(CBotVar* &var, void* user)
// Instruction "deleteinfo(nom, power)".
-bool rDeleteInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rDeleteInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
CObject* pInfo;
CBotString cbs;
Info info;
@@ -1884,15 +1877,15 @@ bool rDeleteInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
exception = 0;
- cbs = var->GivValString();
+ cbs = var->GetValString();
p = cbs;
- var = var->GivNext();
+ var = var->GetNext();
power = 10.0f*g_unit;
if ( var != 0 )
{
- power = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ power = var->GetValFloat()*g_unit;
+ var = var->GetNext();
}
pInfo = SearchInfo(script, pThis, power);
@@ -1902,10 +1895,10 @@ bool rDeleteInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
return true;
}
- total = pInfo->RetInfoTotal();
+ total = pInfo->GetInfoTotal();
for ( i=0 ; i<total ; i++ )
{
- info = pInfo->RetInfo(i);
+ info = pInfo->GetInfo(i);
if ( strcmp(info.name, p) == 0 )
{
pInfo->DeleteInfo(i);
@@ -1919,15 +1912,15 @@ bool rDeleteInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "testinfo(nom, power)".
-CBotTypResult cTestInfo(CBotVar* &var, void* user)
+CBotTypResult CScript::cTestInfo(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
- var = var->GivNext();
+ if ( var->GetType() != CBotTypString ) return CBotTypResult(CBotErrBadString);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypBoolean);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypBoolean);
@@ -1935,10 +1928,10 @@ CBotTypResult cTestInfo(CBotVar* &var, void* user)
// Instruction "testinfo(nom, power)".
-bool rTestInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rTestInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
CObject* pInfo;
CBotString cbs;
Info info;
@@ -1948,15 +1941,15 @@ bool rTestInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
exception = 0;
- cbs = var->GivValString();
+ cbs = var->GetValString();
p = cbs;
- var = var->GivNext();
+ var = var->GetNext();
power = 10.0f*g_unit;
if ( var != 0 )
{
- power = var->GivValFloat()*g_unit;
- var = var->GivNext();
+ power = var->GetValFloat()*g_unit;
+ var = var->GetNext();
}
pInfo = SearchInfo(script, pThis, power);
@@ -1966,10 +1959,10 @@ bool rTestInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
return true;
}
- total = pInfo->RetInfoTotal();
+ total = pInfo->GetInfoTotal();
for ( i=0 ; i<total ; i++ )
{
- info = pInfo->RetInfo(i);
+ info = pInfo->GetInfo(i);
if ( strcmp(info.name, p) == 0 )
{
result->SetValInt(true);
@@ -1982,9 +1975,9 @@ bool rTestInfo(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "thump()".
-bool rThump(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rThump(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
Error err;
exception = 0;
@@ -2011,9 +2004,9 @@ bool rThump(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "recycle()".
-bool rRecycle(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rRecycle(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
Error err;
exception = 0;
@@ -2040,15 +2033,15 @@ bool rRecycle(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation "shield(oper, radius)".
-CBotTypResult cShield(CBotVar* &var, void* user)
+CBotTypResult CScript::cShield(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
@@ -2057,17 +2050,17 @@ CBotTypResult cShield(CBotVar* &var, void* user)
// Instruction "shield(oper, radius)".
-bool rShield(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rShield(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
float oper, radius;
Error err;
- oper = var->GivValFloat(); // 0=down, 1=up
- var = var->GivNext();
+ oper = var->GetValFloat(); // 0=down, 1=up
+ var = var->GetNext();
- radius = var->GivValFloat();
+ radius = var->GetValFloat();
if ( radius < 10.0f ) radius = 10.0f;
if ( radius > 25.0f ) radius = 25.0f;
radius = (radius-10.0f)/15.0f;
@@ -2111,13 +2104,13 @@ bool rShield(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation "fire(delay)".
-CBotTypResult cFire(CBotVar* &var, void* user)
+CBotTypResult CScript::cFire(CBotVar* &var, void* user)
{
#if 0
- CObject* pThis = (CObject*)user;
+ CObject* pThis = static_cast<CObject *>(user);
ObjectType type;
- type = pThis->RetType();
+ type = pThis->GetType();
if ( type == OBJECT_ANT )
{
@@ -2130,8 +2123,8 @@ CBotTypResult cFire(CBotVar* &var, void* user)
else
{
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
return CBotTypResult(CBotTypFloat);
}
@@ -2142,10 +2135,10 @@ CBotTypResult cFire(CBotVar* &var, void* user)
// Instruction "fire(delay)".
-bool rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
float delay;
Math::Vector impact;
Error err;
@@ -2157,12 +2150,12 @@ bool rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- type = pThis->RetType();
+ type = pThis->GetType();
if ( type == OBJECT_ANT )
{
if ( !GetPoint(var, exception, impact) ) return true;
- impact.y += pThis->RetWaterLevel();
+ impact.y += pThis->GetWaterLevel();
err = script->m_primaryTask->StartTaskFireAnt(impact);
}
else if ( type == OBJECT_SPIDER )
@@ -2172,7 +2165,7 @@ bool rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
else
{
if ( var == 0 ) delay = 0.0f;
- else delay = var->GivValFloat();
+ else delay = var->GetValFloat();
err = script->m_primaryTask->StartTaskFire(delay);
}
@@ -2189,9 +2182,9 @@ bool rFire(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "aim(dir)".
-bool rAim(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rAim(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
float value;
Error err;
@@ -2200,7 +2193,7 @@ bool rAim(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( script->m_primaryTask == 0 ) // no task in progress?
{
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- value = var->GivValFloat();
+ value = var->GetValFloat();
err = script->m_primaryTask->StartTaskGunGoal(value*Math::PI/180.0f, 0.0f);
if ( err != ERR_OK )
{
@@ -2215,15 +2208,15 @@ bool rAim(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "motor(left, right)".
-CBotTypResult cMotor(CBotVar* &var, void* user)
+CBotTypResult CScript::cMotor(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var != 0 ) return CBotTypResult(CBotErrOverParam);
@@ -2232,15 +2225,15 @@ CBotTypResult cMotor(CBotVar* &var, void* user)
// Instruction "motor(left, right)".
-bool rMotor(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rMotor(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CObject* pThis = (CObject*)user;
- CPhysics* physics = ((CObject*)user)->RetPhysics();
+ CObject* pThis = static_cast<CObject *>(user);
+ CPhysics* physics = (static_cast<CObject *>(user))->GetPhysics();
float left, right, speed, turn;
- left = var->GivValFloat();
- var = var->GivNext();
- right = var->GivValFloat();
+ left = var->GetValFloat();
+ var = var->GetNext();
+ right = var->GetValFloat();
speed = (left+right)/2.0f;
if ( speed < -1.0f ) speed = -1.0f;
@@ -2250,7 +2243,7 @@ bool rMotor(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( turn < -1.0f ) turn = -1.0f;
if ( turn > 1.0f ) turn = 1.0f;
- if ( pThis->RetFixed() ) // ant on the back?
+ if ( pThis->GetFixed() ) // ant on the back?
{
speed = 0.0f;
turn = 0.0f;
@@ -2264,12 +2257,12 @@ bool rMotor(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "jet(power)".
-bool rJet(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rJet(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CPhysics* physics = ((CObject*)user)->RetPhysics();
+ CPhysics* physics = (static_cast<CObject *>(user))->GetPhysics();
float value;
- value = var->GivValFloat();
+ value = var->GetValFloat();
physics->SetMotorSpeedY(value);
return true;
@@ -2277,13 +2270,13 @@ bool rJet(CBotVar* var, CBotVar* result, int& exception, void* user)
// Compilation of the instruction "topo(pos)".
-CBotTypResult cTopo(CBotVar* &var, void* user)
+CBotTypResult CScript::cTopo(CBotVar* &var, void* user)
{
CBotTypResult ret;
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- ret = cPoint(var, user);
- if ( ret.GivType() != 0 ) return ret;
+ ret = CScript::cPoint(var, user);
+ if ( ret.GetType() != 0 ) return ret;
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
return CBotTypResult(CBotErrOverParam);
@@ -2291,9 +2284,9 @@ CBotTypResult cTopo(CBotVar* &var, void* user)
// Instruction "topo(pos)".
-bool rTopo(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rTopo(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
Math::Vector pos;
float level;
@@ -2301,24 +2294,24 @@ bool rTopo(CBotVar* var, CBotVar* result, int& exception, void* user)
if ( !GetPoint(var, exception, pos) ) return true;
- level = script->m_terrain->RetFloorLevel(pos);
- level -= script->m_water->RetLevel();
+ level = script->m_terrain->GetFloorLevel(pos);
+ level -= script->m_water->GetLevel();
result->SetValFloat(level/g_unit);
return true;
}
// Compilation of the instruction "message(string, type)".
-CBotTypResult cMessage(CBotVar* &var, void* user)
+CBotTypResult CScript::cMessage(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotErrLowParam);
- if ( var->GivType() != CBotTypString &&
- var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() != CBotTypString &&
+ var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
return CBotTypResult(CBotErrOverParam);
@@ -2326,40 +2319,39 @@ CBotTypResult cMessage(CBotVar* &var, void* user)
// Instruction "message(string, type)".
-bool rMessage(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rMessage(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
CBotString cbs;
const char* p;
- TextType type;
+ Ui::TextType type;
- cbs = var->GivValString();
+ cbs = var->GetValString();
p = cbs;
- type = TT_MESSAGE;
- var = var->GivNext();
+ type = Ui::TT_MESSAGE;
+ var = var->GetNext();
if ( var != 0 )
{
- type = (TextType)var->GivValInt();
+ type = static_cast<Ui::TextType>(var->GetValInt());
}
- script->m_displayText->DisplayText((char*)p, script->m_object, 10.0f, type);
- script->m_main->CheckEndMessage((char*)p);
+ script->m_displayText->DisplayText(p, script->m_object, 10.0f, type);
+ script->m_main->CheckEndMessage(p);
return true;
}
// Instruction "cmdline(rank)".
-bool rCmdline(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rCmdline(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CObject* pThis = static_cast<CObject *>(user);
float value;
int rank;
- rank = var->GivValInt();
- value = pThis->RetCmdLine(rank);
+ rank = var->GetValInt();
+ value = pThis->GetCmdLine(rank);
result->SetValFloat(value);
return true;
@@ -2367,12 +2359,12 @@ bool rCmdline(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "ismovie()".
-bool rIsMovie(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rIsMovie(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
float value;
- value = script->m_main->RetMovieLock()?1.0f:0.0f;
+ value = script->m_main->GetMovieLock()?1.0f:0.0f;
result->SetValFloat(value);
return true;
@@ -2380,12 +2372,12 @@ bool rIsMovie(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "errmode(mode)".
-bool rErrMode(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rErrMode(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
int value;
- value = var->GivValInt();
+ value = var->GetValInt();
if ( value < 0 ) value = 0;
if ( value > 1 ) value = 1;
script->m_errMode = value;
@@ -2395,12 +2387,12 @@ bool rErrMode(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "ipf(num)".
-bool rIPF(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rIPF(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
int value;
- value = var->GivValInt();
+ value = var->GetValInt();
if ( value < 1 ) value = 1;
if ( value > 10000 ) value = 10000;
script->m_ipf = value;
@@ -2410,12 +2402,12 @@ bool rIPF(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "abstime()".
-bool rAbsTime(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rAbsTime(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
float value;
- value = script->m_main->RetGameTime();
+ value = script->m_main->GetGameTime();
result->SetValFloat(value);
return true;
}
@@ -2450,33 +2442,32 @@ void PrepareFilename(CBotString &filename, char *dir)
// Instruction "deletefile(filename)".
-bool rDeleteFile(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rDeleteFile(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
CBotString cbs;
- const char* p;
+ const char* filename;
char* dir;
- cbs = var->GivValString();
- dir = script->m_main->RetFilesDir();
+ cbs = var->GetValString();
+ dir = script->m_main->GetFilesDir();
PrepareFilename(cbs, dir);
- p = cbs;
- DeleteFile(p);
-
- return true;
+ filename = cbs;
+ //std function that removes file.
+ return (!remove(filename));
}
// Compilation of the instruction "pendown(color, width)".
-CBotTypResult cPenDown(CBotVar* &var, void* user)
+CBotTypResult CScript::cPenDown(CBotVar* &var, void* user)
{
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
- if ( var->GivType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
- var = var->GivNext();
+ if ( var->GetType() > CBotTypDouble ) return CBotTypResult(CBotErrBadNum);
+ var = var->GetNext();
if ( var == 0 ) return CBotTypResult(CBotTypFloat);
return CBotTypResult(CBotErrOverParam);
@@ -2484,15 +2475,15 @@ CBotTypResult cPenDown(CBotVar* &var, void* user)
// Instruction "pendown(color, width)".
-bool rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
int color;
float width;
Error err;
- if ( pThis->RetType() == OBJECT_MOBILEdr )
+ if ( pThis->GetType() == OBJECT_MOBILEdr )
{
exception = 0;
@@ -2500,15 +2491,15 @@ bool rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user)
{
if ( var != 0 )
{
- color = var->GivValInt();
+ color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > 17 ) color = 17;
pThis->SetTraceColor(color);
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- width = var->GivValFloat();
+ width = var->GetValFloat();
if ( width < 0.1f ) width = 0.1f;
if ( width > 1.0f ) width = 1.0f;
pThis->SetTraceWidth(width);
@@ -2517,7 +2508,7 @@ bool rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user)
pThis->SetTraceDown(true);
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- err = script->m_primaryTask->StartTaskPen(pThis->RetTraceDown(), pThis->RetTraceColor());
+ err = script->m_primaryTask->StartTaskPen(pThis->GetTraceDown(), pThis->GetTraceColor());
if ( err != ERR_OK )
{
delete script->m_primaryTask;
@@ -2537,15 +2528,15 @@ bool rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user)
{
if ( var != 0 )
{
- color = var->GivValInt();
+ color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > 17 ) color = 17;
pThis->SetTraceColor(color);
- var = var->GivNext();
+ var = var->GetNext();
if ( var != 0 )
{
- width = var->GivValFloat();
+ width = var->GetValFloat();
if ( width < 0.1f ) width = 0.1f;
if ( width > 1.0f ) width = 1.0f;
pThis->SetTraceWidth(width);
@@ -2559,13 +2550,13 @@ bool rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "penup()".
-bool rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
Error err;
- if ( pThis->RetType() == OBJECT_MOBILEdr )
+ if ( pThis->GetType() == OBJECT_MOBILEdr )
{
exception = 0;
@@ -2574,7 +2565,7 @@ bool rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user)
pThis->SetTraceDown(false);
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- err = script->m_primaryTask->StartTaskPen(pThis->RetTraceDown(), pThis->RetTraceColor());
+ err = script->m_primaryTask->StartTaskPen(pThis->GetTraceDown(), pThis->GetTraceColor());
if ( err != ERR_OK )
{
delete script->m_primaryTask;
@@ -2599,27 +2590,26 @@ bool rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "pencolor()".
-bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CScript* script = ((CObject*)user)->RetRunScript();
- CPhysics* physics = ((CObject*)user)->RetPhysics();
- CObject* pThis = (CObject*)user;
+ CScript* script = (static_cast<CObject *>(user))->GetRunScript();
+ CObject* pThis = static_cast<CObject *>(user);
int color;
Error err;
- if ( pThis->RetType() == OBJECT_MOBILEdr )
+ if ( pThis->GetType() == OBJECT_MOBILEdr )
{
exception = 0;
if ( script->m_primaryTask == 0 ) // no task in progress?
{
- color = var->GivValInt();
+ color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > 17 ) color = 17;
pThis->SetTraceColor(color);
script->m_primaryTask = new CTaskManager(script->m_iMan, script->m_object);
- err = script->m_primaryTask->StartTaskPen(pThis->RetTraceDown(), pThis->RetTraceColor());
+ err = script->m_primaryTask->StartTaskPen(pThis->GetTraceDown(), pThis->GetTraceColor());
if ( err != ERR_OK )
{
delete script->m_primaryTask;
@@ -2637,7 +2627,7 @@ bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user)
}
else
{
- color = var->GivValInt();
+ color = var->GetValInt();
if ( color < 0 ) color = 0;
if ( color > 17 ) color = 17;
pThis->SetTraceColor(color);
@@ -2648,12 +2638,12 @@ bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user)
// Instruction "penwidth()".
-bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user)
+bool CScript::rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user)
{
- CObject* pThis = (CObject*)user;
+ CObject* pThis = static_cast<CObject *>(user);
float width;
- width = var->GivValFloat();
+ width = var->GetValFloat();
if ( width < 0.1f ) width = 0.1f;
if ( width > 1.0f ) width = 1.0f;
pThis->SetTraceWidth(width);
@@ -2669,15 +2659,13 @@ CScript::CScript(CInstanceManager* iMan, CObject* object, CTaskManager** seconda
m_iMan = iMan;
m_iMan->AddInstance(CLASS_SCRIPT, this, 100);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_displayText = (CDisplayText*)m_iMan->SearchInstance(CLASS_DISPLAYTEXT);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
- m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
- m_botProg = 0;
- m_object = object;
- m_primaryTask = 0;
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
+ m_botProg = 0;
+ m_object = object;
+ m_primaryTask = 0;
m_secondaryTask = secondaryTask;
m_ipf = CBOT_IPF;
@@ -2697,58 +2685,58 @@ CScript::CScript(CInstanceManager* iMan, CObject* object, CTaskManager** seconda
void CScript::InitFonctions()
{
- CBotProgram::AddFunction("sin", rSin, cOneFloat);
- CBotProgram::AddFunction("cos", rCos, cOneFloat);
- CBotProgram::AddFunction("tan", rTan, cOneFloat);
- CBotProgram::AddFunction("asin", raSin, cOneFloat);
- CBotProgram::AddFunction("acos", raCos, cOneFloat);
- CBotProgram::AddFunction("atan", raTan, cOneFloat);
- CBotProgram::AddFunction("sqrt", rSqrt, cOneFloat);
- CBotProgram::AddFunction("pow", rPow, cTwoFloat);
- CBotProgram::AddFunction("rand", rRand, cNull);
- CBotProgram::AddFunction("abs", rAbs, cOneFloat);
-
- CBotProgram::AddFunction("retobject", rRetObject, cRetObject);
- CBotProgram::AddFunction("search", rSearch, cSearch);
- CBotProgram::AddFunction("radar", rRadar, cRadar);
- CBotProgram::AddFunction("detect", rDetect, cDetect);
- CBotProgram::AddFunction("direction", rDirection, cDirection);
- CBotProgram::AddFunction("produce", rProduce, cProduce);
- CBotProgram::AddFunction("distance", rDistance, cDistance);
- CBotProgram::AddFunction("distance2d",rDistance2d,cDistance);
- CBotProgram::AddFunction("space", rSpace, cSpace);
- CBotProgram::AddFunction("flatground",rFlatGround,cFlatGround);
- CBotProgram::AddFunction("wait", rWait, cOneFloat);
- CBotProgram::AddFunction("move", rMove, cOneFloat);
- CBotProgram::AddFunction("turn", rTurn, cOneFloat);
- CBotProgram::AddFunction("goto", rGoto, cGoto);
- CBotProgram::AddFunction("find", rFind, cOneFloat);
- CBotProgram::AddFunction("grab", rGrab, cGrabDrop);
- CBotProgram::AddFunction("drop", rDrop, cGrabDrop);
- CBotProgram::AddFunction("sniff", rSniff, cNull);
- CBotProgram::AddFunction("receive", rReceive, cReceive);
- CBotProgram::AddFunction("send", rSend, cSend);
- CBotProgram::AddFunction("deleteinfo",rDeleteInfo,cDeleteInfo);
- CBotProgram::AddFunction("testinfo", rTestInfo, cTestInfo);
- CBotProgram::AddFunction("thump", rThump, cNull);
- CBotProgram::AddFunction("recycle", rRecycle, cNull);
- CBotProgram::AddFunction("shield", rShield, cShield);
- CBotProgram::AddFunction("fire", rFire, cFire);
- CBotProgram::AddFunction("aim", rAim, cOneFloat);
- CBotProgram::AddFunction("motor", rMotor, cMotor);
- CBotProgram::AddFunction("jet", rJet, cOneFloat);
- CBotProgram::AddFunction("topo", rTopo, cTopo);
- CBotProgram::AddFunction("message", rMessage, cMessage);
- CBotProgram::AddFunction("cmdline", rCmdline, cOneFloat);
- CBotProgram::AddFunction("ismovie", rIsMovie, cNull);
- CBotProgram::AddFunction("errmode", rErrMode, cOneFloat);
- CBotProgram::AddFunction("ipf", rIPF, cOneFloat);
- CBotProgram::AddFunction("abstime", rAbsTime, cNull);
- CBotProgram::AddFunction("deletefile",rDeleteFile,cString);
- CBotProgram::AddFunction("pendown", rPenDown, cPenDown);
- CBotProgram::AddFunction("penup", rPenUp, cNull);
- CBotProgram::AddFunction("pencolor", rPenColor, cOneFloat);
- CBotProgram::AddFunction("penwidth", rPenWidth, cOneFloat);
+ CBotProgram::AddFunction("sin", rSin, CScript::cOneFloat);
+ CBotProgram::AddFunction("cos", rCos, CScript::cOneFloat);
+ CBotProgram::AddFunction("tan", rTan, CScript::cOneFloat);
+ CBotProgram::AddFunction("asin", raSin, CScript::cOneFloat);
+ CBotProgram::AddFunction("acos", raCos, CScript::cOneFloat);
+ CBotProgram::AddFunction("atan", raTan, CScript::cOneFloat);
+ CBotProgram::AddFunction("sqrt", rSqrt, CScript::cOneFloat);
+ CBotProgram::AddFunction("pow", rPow, CScript::cTwoFloat);
+ CBotProgram::AddFunction("rand", rRand, CScript::cNull);
+ CBotProgram::AddFunction("abs", rAbs, CScript::cOneFloat);
+
+ CBotProgram::AddFunction("retobject", rGetObject, CScript::cGetObject);
+ CBotProgram::AddFunction("search", rSearch, CScript::cSearch);
+ CBotProgram::AddFunction("radar", rRadar, CScript::cRadar);
+ CBotProgram::AddFunction("detect", rDetect, CScript::cDetect);
+ CBotProgram::AddFunction("direction", rDirection, CScript::cDirection);
+ CBotProgram::AddFunction("produce", rProduce, CScript::cProduce);
+ CBotProgram::AddFunction("distance", rDistance, CScript::cDistance);
+ CBotProgram::AddFunction("distance2d",rDistance2d,CScript::cDistance);
+ CBotProgram::AddFunction("space", rSpace, CScript::cSpace);
+ CBotProgram::AddFunction("flatground",rFlatGround,CScript::cFlatGround);
+ CBotProgram::AddFunction("wait", rWait, CScript::cOneFloat);
+ CBotProgram::AddFunction("move", rMove, CScript::cOneFloat);
+ CBotProgram::AddFunction("turn", rTurn, CScript::cOneFloat);
+ CBotProgram::AddFunction("goto", rGoto, CScript::cGoto);
+ CBotProgram::AddFunction("find", rFind, CScript::cOneFloat);
+ CBotProgram::AddFunction("grab", rGrab, CScript::cGrabDrop);
+ CBotProgram::AddFunction("drop", rDrop, CScript::cGrabDrop);
+ CBotProgram::AddFunction("sniff", rSniff, CScript::cNull);
+ CBotProgram::AddFunction("receive", rReceive, CScript::cReceive);
+ CBotProgram::AddFunction("send", rSend, CScript::cSend);
+ CBotProgram::AddFunction("deleteinfo",rDeleteInfo,CScript::cDeleteInfo);
+ CBotProgram::AddFunction("testinfo", rTestInfo, CScript::cTestInfo);
+ CBotProgram::AddFunction("thump", rThump, CScript::cNull);
+ CBotProgram::AddFunction("recycle", rRecycle, CScript::cNull);
+ CBotProgram::AddFunction("shield", rShield, CScript::cShield);
+ CBotProgram::AddFunction("fire", rFire, CScript::cFire);
+ CBotProgram::AddFunction("aim", rAim, CScript::cOneFloat);
+ CBotProgram::AddFunction("motor", rMotor, CScript::cMotor);
+ CBotProgram::AddFunction("jet", rJet, CScript::cOneFloat);
+ CBotProgram::AddFunction("topo", rTopo, CScript::cTopo);
+ CBotProgram::AddFunction("message", rMessage, CScript::cMessage);
+ CBotProgram::AddFunction("cmdline", rCmdline, CScript::cOneFloat);
+ CBotProgram::AddFunction("ismovie", rIsMovie, CScript::cNull);
+ CBotProgram::AddFunction("errmode", rErrMode, CScript::cOneFloat);
+ CBotProgram::AddFunction("ipf", rIPF, CScript::cOneFloat);
+ CBotProgram::AddFunction("abstime", rAbsTime, CScript::cNull);
+ CBotProgram::AddFunction("deletefile",rDeleteFile,CScript::cString);
+ CBotProgram::AddFunction("pendown", rPenDown, CScript::cPenDown);
+ CBotProgram::AddFunction("penup", rPenUp, CScript::cNull);
+ CBotProgram::AddFunction("pencolor", rPenColor, CScript::cOneFloat);
+ CBotProgram::AddFunction("penwidth", rPenWidth, CScript::cOneFloat);
}
// Object's destructor.
@@ -2767,7 +2755,7 @@ CScript::~CScript()
// Gives the script editable block of text.
-void CScript::PutScript(CEdit* edit, char* name)
+void CScript::PutScript(Ui::CEdit* edit, const char* name)
{
if ( m_script == 0 )
{
@@ -2784,15 +2772,15 @@ void CScript::PutScript(CEdit* edit, char* name)
// The script takes a paved text.
-bool CScript::GetScript(CEdit* edit)
+bool CScript::GetScript(Ui::CEdit* edit)
{
int len;
delete m_script;
m_script = 0;
- len = edit->RetTextLength();
- m_script = (char*)malloc(sizeof(char)*(len+1));
+ len = edit->GetTextLength();
+ m_script = static_cast<char*>(malloc(sizeof(char)*(len+1)));
edit->GetText(m_script, len+1);
edit->GetCursor(m_cursor2, m_cursor1);
@@ -2819,7 +2807,7 @@ bool CScript::GetScript(CEdit* edit)
// Indicates whether a program is compiled correctly.
-bool CScript::RetCompile()
+bool CScript::GetCompile()
{
return m_bCompile;
}
@@ -2846,17 +2834,17 @@ bool CScript::CheckToken()
CBotToken* bt;
CBotString bs;
const char* token;
- int error, type, cursor1, cursor2, i;
+ int error, cursor1, cursor2, i;
char used[100];
- if ( !m_object->RetCheckToken() ) return true;
+ if ( !m_object->GetCheckToken() ) return true;
m_error = 0;
m_title[0] = 0;
m_token[0] = 0;
m_bCompile = false;
- for ( i=0 ; i<m_main->RetObligatoryToken() ; i++ )
+ for ( i=0 ; i<m_main->GetObligatoryToken() ; i++ )
{
used[i] = 0; // token not used
}
@@ -2864,20 +2852,19 @@ bool CScript::CheckToken()
bt = CBotToken::CompileTokens(m_script, error);
while ( bt != 0 )
{
- bs = bt->GivString();
+ bs = bt->GetString();
token = bs;
- type = bt->GivType();
- cursor1 = bt->GivStart();
- cursor2 = bt->GivEnd();
+ cursor1 = bt->GetStart();
+ cursor2 = bt->GetEnd();
- i = m_main->IsObligatoryToken((char*)token);
+ i = m_main->IsObligatoryToken(token);
if ( i != -1 )
{
used[i] = 1; // token used
}
- if ( !m_main->IsProhibitedToken((char*)token) )
+ if ( !m_main->IsProhibitedToken(token) )
{
m_error = ERR_PROHIBITEDTOKEN;
m_cursor1 = cursor1;
@@ -2887,15 +2874,15 @@ bool CScript::CheckToken()
return false;
}
- bt = bt->GivNext();
+ bt = bt->GetNext();
}
// At least once every obligatory instruction?
- for ( i=0 ; i<m_main->RetObligatoryToken() ; i++ )
+ for ( i=0 ; i<m_main->GetObligatoryToken() ; i++ )
{
if ( used[i] == 0 ) // token not used?
{
- strcpy(m_token, m_main->RetObligatoryToken(i));
+ strcpy(m_token, m_main->GetObligatoryToken(i));
m_error = ERR_OBLIGATORYTOKEN;
strcpy(m_title, "<erreur>");
CBotToken::Delete(bt);
@@ -2930,12 +2917,12 @@ bool CScript::Compile()
if ( m_botProg == 0 )
{
- m_botProg = new CBotProgram(m_object->RetBotVar());
+ m_botProg = new CBotProgram(m_object->GetBotVar());
}
if ( m_botProg->Compile(m_script, liste, this) )
{
- if ( liste.GivSize() == 0 )
+ if ( liste.GetSize() == 0 )
{
strcpy(m_title, "<sans nom>");
}
@@ -3014,7 +3001,7 @@ bool CScript::Run()
if ( m_bStepMode ) // step by step mode?
{
Event newEvent;
- ZeroMemory(&newEvent, sizeof(Event));
+ memset(&newEvent, 0, sizeof(Event));
Step(newEvent);
}
@@ -3054,7 +3041,7 @@ bool CScript::Continue(const Event &event)
{
char s[100];
GetError(s);
- m_displayText->DisplayText(s, m_object, 10.0f, TT_ERROR);
+ m_displayText->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
}
m_engine->SetPause(true); // gives pause
return true;
@@ -3087,7 +3074,7 @@ bool CScript::Continue(const Event &event)
{
char s[100];
GetError(s);
- m_displayText->DisplayText(s, m_object, 10.0f, TT_ERROR);
+ m_displayText->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
}
return true;
}
@@ -3105,7 +3092,7 @@ bool CScript::Step(const Event &event)
if ( !m_bStepMode ) return false;
m_engine->SetPause(false);
- m_engine->StepSimul(0.01f); // advance of 10ms
+ // TODO: m_app StepSimulation??? m_engine->StepSimulation(0.01f); // advance of 10ms
m_engine->SetPause(true);
m_event = event;
@@ -3129,7 +3116,7 @@ bool CScript::Step(const Event &event)
{
char s[100];
GetError(s);
- m_displayText->DisplayText(s, m_object, 10.0f, TT_ERROR);
+ m_displayText->DisplayText(s, m_object, 10.0f, Ui::TT_ERROR);
}
return true;
}
@@ -3201,7 +3188,7 @@ bool CScript::GetCursor(int &cursor1, int &cursor2)
// Put of the variables in a list.
-void PutList(char *baseName, bool bArray, CBotVar *var, CList *list, int &rankList)
+void PutList(const char *baseName, bool bArray, CBotVar *var, Ui::CList *list, int &rankList)
{
CBotString bs;
CBotVar *svar, *pStatic;
@@ -3221,13 +3208,13 @@ void PutList(char *baseName, bool bArray, CBotVar *var, CList *list, int &rankLi
while ( var != 0 )
{
var->Maj(NULL, false);
- pStatic = var->GivStaticVar(); // finds the static element
+ pStatic = var->GetStaticVar(); // finds the static element
- bs = pStatic->GivName(); // variable name
+ bs = pStatic->GetName(); // variable name
p = bs;
//? if ( strcmp(p, "this") == 0 )
//? {
-//? var = var->GivNext();
+//? var = var->GetNext();
//? continue;
//? }
@@ -3247,12 +3234,12 @@ void PutList(char *baseName, bool bArray, CBotVar *var, CList *list, int &rankLi
}
}
- type = pStatic->GivType();
+ type = pStatic->GetType();
if ( type < CBotTypBoolean )
{
CBotString value;
- value = pStatic->GivValString();
+ value = pStatic->GetValString();
p = value;
sprintf(buffer, "%s = %s;", varName, p);
list->SetName(rankList++, buffer);
@@ -3260,20 +3247,20 @@ void PutList(char *baseName, bool bArray, CBotVar *var, CList *list, int &rankLi
else if ( type == CBotTypString )
{
CBotString value;
- value = pStatic->GivValString();
+ value = pStatic->GetValString();
p = value;
sprintf(buffer, "%s = \"%s\";", varName, p);
list->SetName(rankList++, buffer);
}
else if ( type == CBotTypArrayPointer )
{
- svar = pStatic->GivItemList();
+ svar = pStatic->GetItemList();
PutList(varName, true, svar, list, rankList);
}
else if ( type == CBotTypClass ||
type == CBotTypPointer )
{
- svar = pStatic->GivItemList();
+ svar = pStatic->GetItemList();
PutList(varName, false, svar, list, rankList);
}
else
@@ -3283,13 +3270,13 @@ void PutList(char *baseName, bool bArray, CBotVar *var, CList *list, int &rankLi
}
index ++;
- var = var->GivNext();
+ var = var->GetNext();
}
}
// Fills a list with variables.
-void CScript::UpdateList(CList* list)
+void CScript::UpdateList(Ui::CList* list)
{
CBotVar *var;
const char *progName, *funcName;
@@ -3297,8 +3284,8 @@ void CScript::UpdateList(CList* list)
if( m_botProg == 0 ) return;
- total = list->RetTotal();
- select = list->RetSelect();
+ total = list->GetTotal();
+ select = list->GetSelect();
list->Flush(); // empty list
m_botProg->GetRunPos(progName, cursor1, cursor2);
@@ -3308,70 +3295,71 @@ void CScript::UpdateList(CList* list)
rank = 0;
while ( true )
{
- var = m_botProg->GivStackVars(funcName, level--);
+ var = m_botProg->GetStackVars(funcName, level--);
if ( funcName != progName ) break;
PutList("", false, var, list, rank);
}
- if ( total == list->RetTotal() ) // same total?
+ if ( total == list->GetTotal() ) // same total?
{
list->SetSelect(select);
}
list->SetTooltip("");
- list->SetState(STATE_ENABLE);
+ list->SetState(Ui::STATE_ENABLE);
}
// Colorize the text according to syntax.
-void CScript::ColorizeScript(CEdit* edit)
+void CScript::ColorizeScript(Ui::CEdit* edit)
{
CBotToken* bt;
CBotString bs;
const char* token;
- int error, type, cursor1, cursor2, color;
+ int error, type, cursor1, cursor2;
+ Gfx::FontHighlight color;
edit->ClearFormat();
- bt = CBotToken::CompileTokens(edit->RetText(), error);
+ bt = CBotToken::CompileTokens(edit->GetText(), error);
while ( bt != 0 )
{
- bs = bt->GivString();
+ bs = bt->GetString();
token = bs;
- type = bt->GivType();
+ type = bt->GetType();
- cursor1 = bt->GivStart();
- cursor2 = bt->GivEnd();
+ cursor1 = bt->GetStart();
+ cursor2 = bt->GetEnd();
- color = 0;
+ color = Gfx::FONT_HIGHLIGHT_NONE;
if ( type >= TokenKeyWord && type < TokenKeyWord+100 )
{
- color = COLOR_TOKEN;
+ color = Gfx::FONT_HIGHLIGHT_TOKEN;
}
if ( type >= TokenKeyDeclare && type < TokenKeyDeclare+100 )
{
- color = COLOR_TYPE;
+ color = Gfx::FONT_HIGHLIGHT_TYPE;
}
if ( type >= TokenKeyVal && type < TokenKeyVal+100 )
{
- color = COLOR_CONST;
+ color = Gfx::FONT_HIGHLIGHT_CONST;
}
if ( type == TokenTypVar )
{
if ( IsType(token) )
{
- color = COLOR_TYPE;
+ color = Gfx::FONT_HIGHLIGHT_TYPE;
}
else if ( IsFunction(token) )
{
- color = COLOR_TOKEN;
+ color = Gfx::FONT_HIGHLIGHT_TOKEN;
}
}
if ( type == TokenTypDef )
{
- color = COLOR_CONST;
+ color =Gfx::FONT_HIGHLIGHT_CONST;
}
if ( cursor1 < cursor2 && color != 0 )
@@ -3379,7 +3367,7 @@ void CScript::ColorizeScript(CEdit* edit)
edit->SetFormat(cursor1, cursor2, color);
}
- bt = bt->GivNext();
+ bt = bt->GetNext();
}
CBotToken::Delete(bt);
@@ -3389,7 +3377,8 @@ void CScript::ColorizeScript(CEdit* edit)
// Seeks a token at random in a script.
// Returns the index of the start of the token found, or -1.
-int SearchToken(char* script, char* token)
+
+int SearchToken(char* script, const char* token)
{
int lScript, lToken, i, iFound;
int found[100];
@@ -3425,7 +3414,7 @@ void DeleteToken(char* script, int pos, int len)
// Inserts a token in a script.
-void InsertToken(char* script, int pos, char* token)
+void InsertToken(char* script, int pos, const char* token)
{
int lScript, lToken, i;
@@ -3446,7 +3435,7 @@ bool CScript::IntroduceVirus()
int found[11*2];
char* newScript;
- char* names[11*2] =
+ const char* names[11*2] =
{
"==", "!=",
"!=", "==",
@@ -3477,7 +3466,7 @@ bool CScript::IntroduceVirus()
start = found[i+1];
i = found[i+0];
- newScript = (char*)malloc(sizeof(char)*(m_len+strlen(names[i+1])+1));
+ newScript = static_cast<char*>(malloc(sizeof(char)*(m_len+strlen(names[i+1])+1)));
strcpy(newScript, m_script);
delete m_script;
m_script = newScript;
@@ -3493,7 +3482,7 @@ bool CScript::IntroduceVirus()
// Returns the number of the error.
-int CScript::RetError()
+int CScript::GetError()
{
return m_error;
}
@@ -3528,7 +3517,7 @@ void CScript::GetError(char* buffer)
// New program.
-void CScript::New(CEdit* edit, char* name)
+void CScript::New(Ui::CEdit* edit, const char* name)
{
FILE *file = NULL;
char res[100];
@@ -3553,7 +3542,7 @@ void CScript::New(CEdit* edit, char* name)
}
else
{
- if ( edit->RetAutoIndent() )
+ if ( edit->GetAutoIndent() )
{
cursor1 = 20+strlen(text)+6;
cursor2 = cursor1; // cursor in { }
@@ -3569,7 +3558,7 @@ void CScript::New(CEdit* edit, char* name)
edit->ShowSelect();
edit->SetFocus(true);
- sf = m_main->RetScriptFile();
+ sf = m_main->GetScriptFile();
if ( sf[0] != 0 ) // Load an empty program specific?
{
strcpy(filename, "script\\");
@@ -3599,7 +3588,7 @@ void CScript::New(CEdit* edit, char* name)
continue;
}
- if ( buffer[i] == '\t' && edit->RetAutoIndent() )
+ if ( buffer[i] == '\t' && edit->GetAutoIndent() )
{
i ++;
continue;
@@ -3642,7 +3631,7 @@ void CScript::New(CEdit* edit, char* name)
bool CScript::SendScript(char* text)
{
m_len = strlen(text);
- m_script = (char*)malloc(sizeof(char)*(m_len+1));
+ m_script = static_cast<char*>(malloc(sizeof(char)*(m_len+1)));
strcpy(m_script, text);
if ( !CheckToken() ) return false;
if ( !Compile() ) return false;
@@ -3652,10 +3641,10 @@ bool CScript::SendScript(char* text)
// Reads a script as a text file.
-bool CScript::ReadScript(char* filename)
+bool CScript::ReadScript(const char* filename)
{
FILE* file;
- CEdit* edit;
+ Ui::CEdit* edit;
char name[100];
if ( strchr(filename, '\\') == 0 )
@@ -3677,8 +3666,8 @@ bool CScript::ReadScript(char* filename)
m_script = 0;
edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9);
- edit->SetMaxChar(EDITSTUDIOMAX);
- edit->SetAutoIndent(m_engine->RetEditIndentMode());
+ edit->SetMaxChar(Ui::EDITSTUDIOMAX);
+ edit->SetAutoIndent(m_engine->GetEditIndentMode());
edit->ReadText(name);
GetScript(edit);
m_interface->DeleteControl(EVENT_EDIT9);
@@ -3687,9 +3676,9 @@ bool CScript::ReadScript(char* filename)
// Writes a script as a text file.
-bool CScript::WriteScript(char* filename)
+bool CScript::WriteScript(const char* filename)
{
- CEdit* edit;
+ Ui::CEdit* edit;
char name[100];
if ( strchr(filename, '\\') == 0 )
@@ -3709,8 +3698,8 @@ bool CScript::WriteScript(char* filename)
}
edit = m_interface->CreateEdit(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 0, EVENT_EDIT9);
- edit->SetMaxChar(EDITSTUDIOMAX);
- edit->SetAutoIndent(m_engine->RetEditIndentMode());
+ edit->SetMaxChar(Ui::EDITSTUDIOMAX);
+ edit->SetAutoIndent(m_engine->GetEditIndentMode());
edit->SetText(m_script);
edit->WriteText(name);
m_interface->DeleteControl(EVENT_EDIT9);
@@ -3769,7 +3758,7 @@ void CScript::SetFilename(char *filename)
strcpy(m_filename, filename);
}
-char* CScript::RetFilename()
+char* CScript::GetFilename()
{
return m_filename;
}
diff --git a/src/script/script.h b/src/script/script.h
index 8b2ae0b..5c1118f 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -22,20 +22,26 @@
#include <stdio.h>
#include "common/event.h"
+#include "CBot/CBotDll.h"
class CInstanceManager;
-class CD3DEngine;
-class CInterface;
-class CDisplayText;
-class CEdit;
-class CList;
class CObject;
class CTaskManager;
-class CBotProgram;
class CRobotMain;
+
+namespace Ui{
+class CDisplayText;
+class CEdit;
+class CInterface;
+class CList;
+} /* Ui */
+
+namespace Gfx {
+class CEngine;
class CTerrain;
class CWater;
+} /* Gfx */
@@ -47,9 +53,9 @@ public:
static void InitFonctions();
- void PutScript(CEdit* edit, char* name);
- bool GetScript(CEdit* edit);
- bool RetCompile();
+ void PutScript(Ui::CEdit* edit, const char* name);
+ bool GetScript(Ui::CEdit* edit);
+ bool GetCompile();
void GetTitle(char* buffer);
@@ -61,58 +67,140 @@ public:
bool IsRunning();
bool IsContinue();
bool GetCursor(int &cursor1, int &cursor2);
- void UpdateList(CList* list);
- void ColorizeScript(CEdit* edit);
+ void UpdateList(Ui::CList* list);
+ void ColorizeScript(Ui::CEdit* edit);
bool IntroduceVirus();
- int RetError();
+ int GetError();
void GetError(char* buffer);
- void New(CEdit* edit, char* name);
+ void New(Ui::CEdit* edit, const char* name);
bool SendScript(char* text);
- bool ReadScript(char* filename);
- bool WriteScript(char* filename);
+ bool ReadScript(const char* filename);
+ bool WriteScript(const char* filename);
bool ReadStack(FILE *file);
bool WriteStack(FILE *file);
bool Compare(CScript* other);
void SetFilename(char *filename);
- char* RetFilename();
+ char* GetFilename();
protected:
bool IsEmpty();
bool CheckToken();
bool Compile();
-public:
- CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CInterface* m_interface;
- CDisplayText* m_displayText;
- CBotProgram* m_botProg;
- CRobotMain* m_main;
- CTerrain* m_terrain;
- CWater* m_water;
- CTaskManager* m_primaryTask;
- CTaskManager** m_secondaryTask;
- CObject* m_object;
-
- int m_ipf; // number of instructions/second
- int m_errMode; // what to do in case of error
- int m_len; // length of the script (without <0>)
- char* m_script; // script ends with <0>
- bool m_bRun; // program during execution?
- bool m_bStepMode; // step by step
- bool m_bContinue; // external function to continue
- bool m_bCompile; // compilation ok?
- char m_title[50]; // script title
- char m_filename[50]; // file name
- char m_token[50]; // missing instruction
- int m_error; // error (0=ok)
- int m_cursor1;
- int m_cursor2;
- Event m_event;
- float m_returnValue;
+private:
+
+ static CBotTypResult cNull(CBotVar* &var, void* user);
+ static CBotTypResult cOneFloat(CBotVar* &var, void* user);
+ static CBotTypResult cTwoFloat(CBotVar* &var, void* user);
+ static CBotTypResult cString(CBotVar* &var, void* user);
+ static CBotTypResult cGetObject(CBotVar* &var, void* user);
+ static CBotTypResult cSearch(CBotVar* &var, void* user);
+ static CBotTypResult cRadar(CBotVar* &var, void* user);
+ static CBotTypResult cDetect(CBotVar* &var, void* user);
+ static CBotTypResult cDirection(CBotVar* &var, void* user);
+ static CBotTypResult cProduce(CBotVar* &var, void* user);
+ static CBotTypResult cDistance(CBotVar* &var, void* user);
+ static CBotTypResult cSpace(CBotVar* &var, void* user);
+ static CBotTypResult cFlatGround(CBotVar* &var, void* user);
+ static CBotTypResult cGoto(CBotVar* &var, void* user);
+ static CBotTypResult cGrabDrop(CBotVar* &var, void* user);
+ static CBotTypResult cReceive(CBotVar* &var, void* user);
+ static CBotTypResult cSend(CBotVar* &var, void* user);
+ static CBotTypResult cDeleteInfo(CBotVar* &var, void* user);
+ static CBotTypResult cTestInfo(CBotVar* &var, void* user);
+ static CBotTypResult cShield(CBotVar* &var, void* user);
+ static CBotTypResult cFire(CBotVar* &var, void* user);
+ static CBotTypResult cMotor(CBotVar* &var, void* user);
+ static CBotTypResult cTopo(CBotVar* &var, void* user);
+ static CBotTypResult cMessage(CBotVar* &var, void* user);
+ static CBotTypResult cPenDown(CBotVar* &var, void* user);
+ static CBotTypResult cOnePoint(CBotVar* &var, void* user);
+ static CBotTypResult cPoint(CBotVar* &var, void* user);
+
+
+ static bool rSin(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rCos(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rTan(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rSqrt(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rPow(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rRand(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rAbs(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rGetObject(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rSearch(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rRadar(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rDetect(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rDirection(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rProduce(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rDistance(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rDistance2d(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rSpace(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rFlatGround(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rWait(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rMove(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rTurn(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rGoto(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rFind(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rGrab(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rDrop(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rSniff(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rReceive(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rSend(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rDeleteInfo(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rTestInfo(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rThump(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rRecycle(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rShield(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rFire(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rAim(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rMotor(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rJet(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rTopo(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rMessage(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rCmdline(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rIsMovie(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rErrMode(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rIPF(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rAbsTime(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rDeleteFile(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rPenDown(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rPenUp(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rPenColor(CBotVar* var, CBotVar* result, int& exception, void* user);
+ static bool rPenWidth(CBotVar* var, CBotVar* result, int& exception, void* user);
+
+ static bool Process(CScript* script, CBotVar* result, int &exception);
+ static CObject* SearchInfo(CScript* script, CObject* object, float power);
+
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ Ui::CInterface* m_interface;
+ Ui::CDisplayText* m_displayText;
+ CBotProgram* m_botProg;
+ CRobotMain* m_main;
+ Gfx::CTerrain* m_terrain;
+ Gfx::CWater* m_water;
+ CTaskManager* m_primaryTask;
+ CTaskManager** m_secondaryTask;
+ CObject* m_object;
+
+ int m_ipf; // number of instructions/second
+ int m_errMode; // what to do in case of error
+ int m_len; // length of the script (without <0>)
+ char* m_script; // script ends with <0>
+ bool m_bRun; // program during execution?
+ bool m_bStepMode; // step by step
+ bool m_bContinue; // external function to continue
+ bool m_bCompile; // compilation ok?
+ char m_title[50]; // script title
+ char m_filename[50]; // file name
+ char m_token[50]; // missing instruction
+ int m_error; // error (0=ok)
+ int m_cursor1;
+ int m_cursor2;
+ Event m_event;
+ float m_returnValue;
};
diff --git a/src/sound/sound.h b/src/sound/sound.h
index 45ec7e1..883c659 100644
--- a/src/sound/sound.h
+++ b/src/sound/sound.h
@@ -44,7 +44,7 @@
**/
enum Sound
{
- SOUND_CLICK = 0,
+ SOUND_CLICK = 0,
SOUND_BOUM = 1,
SOUND_EXPLO = 2,
SOUND_FLYh = 3, /*!< human */
@@ -151,21 +151,21 @@ enum SoundNext
class CSoundInterface : public CPluginInterface
{
public:
- CSoundInterface() {
+ inline CSoundInterface() {
//CInstanceManager::getInstance().AddInstance(CLASS_SOUND, this);
//m_iMan->AddInstance(CLASS_SOUND, this);
};
- virtual ~CSoundInterface() = 0;
+ inline ~CSoundInterface() {};
/** Function to initialize sound device
* @param bool b3D - enable support for 3D sound
*/
- virtual bool Create(bool b3D) = 0;
+ inline bool Create(bool b3D) { return true; };
/** Function called to cache all sound effect files.
* Function calls \link CSoundInterface::Cache() \endlink for each file
*/
- virtual void CacheAll() = 0;
+ inline void CacheAll() {};
/** Function called to cache sound effect file.
* This function is called by plugin interface for each file.
@@ -173,58 +173,58 @@ class CSoundInterface : public CPluginInterface
* @param std::string bFile - file to load
* @return return true on success
*/
- virtual bool Cache(Sound bSound, std::string bFile) = 0;
+ inline bool Cache(Sound bSound, std::string bFile) { return true; };
- /** Return if plugin is enabled
+ /** Geturn if plugin is enabled
* @return return true if plugin is enabled
*/
- virtual bool RetEnable() = 0;
+ inline bool GetEnable() {return true;};
/** Change sound mode to 2D/3D
* @param bool bMode - true to enable 3D sound
*/
- virtual void SetSound3D(bool bMode) = 0;
+ inline void SetSound3D(bool bMode) {};
- /** Return if we use 3D sound
+ /** Geturn if we use 3D sound
* @return true if we have 3D sound enabled
*/
- virtual bool RetSound3D() = 0;
+ inline bool GetSound3D() {return true;};
- /** Return if we have 3D sound capable card
+ /** Geturn if we have 3D sound capable card
* @return true for 3D sound support
*/
- virtual bool RetSound3DCap() = 0;
+ inline bool GetSound3DCap() {return true;};
/** Change global sound volume
* @param int volume - range from 0 to MAXVOLUME
*/
- virtual void SetAudioVolume(int volume) = 0;
+ inline void SetAudioVolume(int volume) {};
- /** Return global sound volume
+ /** Geturn global sound volume
* @return global volume as int in range from 0 to MAXVOLUME
*/
- virtual int RetAudioVolume() = 0;
+ inline int GetAudioVolume() {return 0;};
/** Set music volume
* @param int volume - range from 0 to MAXVOLUME
*/
- virtual void SetMusicVolume(int volume) = 0;
+ inline void SetMusicVolume(int volume) {};
- /** Return music volume
+ /** Geturn music volume
* @return music volume as int in range from 0 to MAXVOLUME
*/
- virtual int RetMusicVolume() = 0;
+ inline int GetMusicVolume() {return 0;};
/** Set listener position
* @param Math::Vector eye - position of listener
* @param Math::Vector lookat - direction listener is looking at
*/
- virtual void SetListener(Math::Vector eye, Math::Vector lookat) = 0;
+ inline void SetListener(Math::Vector eye, Math::Vector lookat) {};
/** Update data each frame
* @param float rTime - time since last update
*/
- virtual void FrameMove(float rTime) = 0;
+ inline void FrameMove(float rTime) {};
/** Play specific sound
* @param Sound sound - sound to play
@@ -233,7 +233,7 @@ class CSoundInterface : public CPluginInterface
* @param bool bLoop - loop sound
* @return identifier of channel that sound will be played on
*/
- virtual int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) = 0;
+ inline int Play(Sound sound, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) {return 0;};
/** Play specific sound
* @param Sound sound - sound to play
@@ -243,13 +243,13 @@ class CSoundInterface : public CPluginInterface
* @param bool bLoop - loop sound
* @return identifier of channel that sound will be played on
*/
- virtual int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) = 0;
+ inline int Play(Sound sound, Math::Vector pos, float amplitude=1.0f, float frequency=1.0f, bool bLoop = false) {return 0;};
/** Remove all operations that would be made on sound in channel.
* @param int channel - channel to work on
* @return return true on success
*/
- virtual bool FlushEnvelope(int channel) = 0;
+ inline bool FlushEnvelope(int channel) {return true;};
/** Add envelope to sound. Envelope is a operatino that will be performend on sound in future like changing frequency
* @param int channel - channel to work on
@@ -259,64 +259,64 @@ class CSoundInterface : public CPluginInterface
* @param SoundNext oper - operation to perform
* @return return true on success
*/
- virtual bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) = 0;
+ inline bool AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper) {return true;};
/** Set sound position in space
* @param int channel - channel to work on
* @param Math::Vector pos - new positino of a sound
* @return return true on success
*/
- virtual bool Position(int channel, Math::Vector pos) = 0;
+ inline bool Position(int channel, Math::Vector pos) {return true;};
/** Set sound frequency
* @param int channel - channel to work on
* @param float frequency - change sound frequency
* @return return true on success
*/
- virtual bool Frequency(int channel, float frequency) = 0;
+ inline bool Frequency(int channel, float frequency) {return true;};
/** Stop playing sound
* @param int channel - channel to work on
* @return return true on success
*/
- virtual bool Stop(int channel) = 0;
+ inline bool Stop(int channel) {return true;};
/** Stop playing all sounds
* @return return true on success
*/
- virtual bool StopAll() = 0;
+ inline bool StopAll() {return true;};
/** Mute/unmute all sounds
* @param bool bMute
* @return return true on success
*/
- virtual bool MuteAll(bool bMute) = 0;
+ inline bool MuteAll(bool bMute) {return true;};
/** Start playing music
* @param int rank - track number
* @param bool bRepeat - repeat playing
* @return return true on success
*/
- virtual bool PlayMusic(int rank, bool bRepeat) = 0;
+ inline bool PlayMusic(int rank, bool bRepeat) {return true;};
/** Restart music
* @return return true on success
*/
- virtual bool RestartMusic() = 0;
+ inline bool RestartMusic() {return true;};
/** Susspend paying music
* @return return true on success
*/
- virtual void SuspendMusic() = 0;
+ inline void SuspendMusic() {};
/** Stop playing music
* @return return true on success
*/
- virtual void StopMusic() = 0;
+ inline void StopMusic() {};
/** Check if music if playing
* @return return true if music is playing
*/
- virtual bool IsPlayingMusic() = 0;
+ inline bool IsPlayingMusic() {return true;};
};
diff --git a/src/ui/button.cpp b/src/ui/button.cpp
index 0147f63..d98e676 100644
--- a/src/ui/button.cpp
+++ b/src/ui/button.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,30 +16,27 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "common/language.h"
-#include "old/math3d.h"
+#include "ui/button.h"
+
#include "common/event.h"
#include "common/misc.h"
-#include "common/iman.h"
#include "common/restext.h"
-#include "ui/button.h"
+#include "graphics/engine/engine.h"
+
+#include <string.h>
+namespace Ui {
+
const float DELAY1 = 0.4f;
const float DELAY2 = 0.1f;
-
// Object's constructor.
-CButton::CButton(CInstanceManager* iMan) : CControl(iMan)
+CButton::CButton() : CControl()
{
m_bCapture = false;
m_bImmediat = false;
@@ -55,18 +53,18 @@ CButton::~CButton()
// Creates a new button.
-bool CButton::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CButton::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
- CControl::Create(pos, dim, icon, eventMsg);
+ CControl::Create(pos, dim, icon, eventType);
if ( icon == -1 )
{
char name[100];
char* p;
- GetResource(RES_EVENT, eventMsg, name);
+ GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\');
if ( p != 0 ) *p = 0;
SetName(name);
@@ -85,7 +83,7 @@ bool CButton::EventProcess(const Event &event)
CControl::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
if ( m_bRepeat && m_repeat != 0.0f )
{
@@ -95,18 +93,19 @@ bool CButton::EventProcess(const Event &event)
m_repeat = DELAY2;
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
}
}
- if ( event.event == EVENT_LBUTTONDOWN &&
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
m_bCapture = true;
m_repeat = DELAY1;
@@ -114,25 +113,27 @@ bool CButton::EventProcess(const Event &event)
if ( m_bImmediat || m_bRepeat )
{
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
return false;
}
}
- if ( event.event == EVENT_MOUSEMOVE && m_bCapture )
+ if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
}
- if ( event.event == EVENT_LBUTTONUP && m_bCapture )
+ if ( event.type == EVENT_MOUSE_BUTTON_UP && //left
+ event.mouseButton.button == 1 &&
+ m_bCapture )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
if ( !m_bImmediat && !m_bRepeat )
{
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
}
@@ -158,10 +159,10 @@ void CButton::Draw()
if ( m_state & STATE_WARNING ) // shading yellow-black?
{
- pos.x = m_pos.x-( 8.0f/640.0f);
- pos.y = m_pos.y-( 4.0f/480.0f);
- dim.x = m_dim.x+(16.0f/640.0f);
- dim.y = m_dim.y+( 8.0f/480.0f);
+ pos.x = m_pos.x - ( 8.0f / 640.0f);
+ pos.y = m_pos.y - ( 4.0f / 480.0f);
+ dim.x = m_dim.x + (16.0f / 640.0f);
+ dim.y = m_dim.y + ( 8.0f / 480.0f);
if ( m_state & STATE_SHADOW )
{
DrawShadow(pos, dim);
@@ -181,20 +182,20 @@ void CButton::Draw()
(m_state & STATE_CARD ) == 0 &&
(m_state & STATE_SIMPLY) == 0 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
- dp = 0.5f/256.0f;
+ dp = 0.5f / 256.0f;
- uv1.x = 128.0f/256.0f;
- uv1.y = 96.0f/256.0f;
- uv2.x = 136.0f/256.0f;
- uv2.y = 128.0f/256.0f;
+ uv1.x = 128.0f / 256.0f;
+ uv1.y = 96.0f / 256.0f;
+ uv2.x = 136.0f / 256.0f;
+ uv2.y = 128.0f / 256.0f;
if ( (m_state & STATE_ENABLE) == 0 )
{
- uv1.x += 16.0f/256.0f;
- uv2.x += 16.0f/256.0f;
+ uv1.x += 16.0f / 256.0f;
+ uv2.x += 16.0f / 256.0f;
}
uv1.x += dp;
@@ -202,15 +203,15 @@ void CButton::Draw()
uv2.x -= dp;
uv2.y -= dp;
- pos.y = m_pos.y+5.0f/480.0f;
- dim.y = m_dim.y-10.0f/480.0f;
- pos.x = m_pos.x+5.0f/640.0f;
- dim.x = 3.0f/640.0f;
+ pos.y = m_pos.y + 5.0f / 480.0f;
+ dim.y = m_dim.y - 10.0f / 480.0f;
+ pos.x = m_pos.x + 5.0f / 640.0f;
+ dim.x = 3.0f / 640.0f;
DrawIcon(pos, dim, uv1, uv2, 0.0f);
- uv1.x += 8.0f/256.0f;
- uv2.x += 8.0f/256.0f;
- pos.x = m_pos.x+m_dim.x-5.0f/640.0f-3.0f/640.0f;
+ uv1.x += 8.0f / 256.0f;
+ uv2.x += 8.0f / 256.0f;
+ pos.x = m_pos.x + m_dim.x - 5.0f / 640.0f - 3.0f / 640.0f;
DrawIcon(pos, dim, uv1, uv2, 0.0f);
}
#endif
@@ -225,7 +226,7 @@ void CButton::SetImmediat(bool bImmediat)
m_bImmediat = bImmediat;
}
-bool CButton::RetImmediat()
+bool CButton::GetImmediat()
{
return m_bImmediat;
}
@@ -239,8 +240,9 @@ void CButton::SetRepeat(bool bRepeat)
m_bRepeat = bRepeat;
}
-bool CButton::RetRepeat()
+bool CButton::GetRepeat()
{
return m_bRepeat;
}
+}
diff --git a/src/ui/button.h b/src/ui/button.h
index 0a05b11..33a48ee 100644
--- a/src/ui/button.h
+++ b/src/ui/button.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,39 +19,37 @@
#pragma once
-
#include "ui/control.h"
-class CD3DEngine;
-
-
+namespace Ui {
-class CButton : public CControl
-{
-public:
- CButton(CInstanceManager* iMan);
- virtual ~CButton();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ class CButton : public CControl
+ {
+ public:
+ CButton();
+ virtual ~CButton();
- bool EventProcess(const Event &event);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- void Draw();
+ bool EventProcess(const Event &event);
- void SetImmediat(bool bRepeat);
- bool RetImmediat();
+ void Draw();
- void SetRepeat(bool bRepeat);
- bool RetRepeat();
+ void SetImmediat(bool bRepeat);
+ bool GetImmediat();
-protected:
+ void SetRepeat(bool bRepeat);
+ bool GetRepeat();
-protected:
- bool m_bCapture;
- bool m_bImmediat;
- bool m_bRepeat;
- float m_repeat;
-};
+ protected:
+ protected:
+ bool m_bCapture;
+ bool m_bImmediat;
+ bool m_bRepeat;
+ float m_repeat;
+ };
+}
diff --git a/src/ui/check.cpp b/src/ui/check.cpp
index 18c7633..a64fb5f 100644
--- a/src/ui/check.cpp
+++ b/src/ui/check.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,26 +16,24 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
+#include "ui/check.h"
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
#include "common/event.h"
-#include "common/misc.h"
#include "common/iman.h"
+#include "common/misc.h"
#include "common/restext.h"
-#include "old/text.h"
-#include "ui/check.h"
+#include "graphics/engine/engine.h"
+#include "graphics/engine/text.h"
+#include <string.h>
+namespace Ui {
+
// Object's constructor.
-CCheck::CCheck(CInstanceManager* iMan) : CControl(iMan)
+CCheck::CCheck() : CControl()
{
}
@@ -47,16 +46,16 @@ CCheck::~CCheck()
// Creates a new button.
-bool CCheck::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CCheck::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
char name[100];
char* p;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
- CControl::Create(pos, dim, icon, eventMsg);
+ CControl::Create(pos, dim, icon, eventType);
- GetResource(RES_EVENT, eventMsg, name);
+ GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\');
if ( p != 0 ) *p = 0;
SetName(name);
@@ -73,14 +72,15 @@ bool CCheck::EventProcess(const Event &event)
CControl::EventProcess(event);
- if ( event.event == EVENT_LBUTTONDOWN &&
- (m_state & STATE_VISIBLE) &&
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1 &&
+ (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
@@ -101,15 +101,15 @@ void CCheck::Draw()
if ( (m_state & STATE_VISIBLE) == 0 ) return;
iDim = m_dim;
- m_dim.x = m_dim.y*0.75f; // square
+ m_dim.x = m_dim.y * 0.75f; // square
if ( m_state & STATE_SHADOW )
{
DrawShadow(m_pos, m_dim);
}
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
zoomExt = 1.00f;
zoomInt = 0.95f;
@@ -143,7 +143,7 @@ void CCheck::Draw()
if ( (m_state & STATE_DEAD) == 0 )
{
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
if ( m_state & STATE_CHECK )
{
@@ -157,10 +157,10 @@ void CCheck::Draw()
if ( m_state & STATE_DEAD ) return;
// Draw the name.
- pos.x = m_pos.x+m_dim.y/0.9f;
- pos.y = m_pos.y+m_dim.y*0.50f;
- pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f;
- m_engine->RetText()->DrawText(m_name, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0);
+ pos.x = m_pos.x + m_dim.y / 0.9f;
+ pos.y = m_pos.y + m_dim.y * 0.50f;
+ pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f;
+ m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
}
-
+}
diff --git a/src/ui/check.h b/src/ui/check.h
index 24c58f3..af26add 100644
--- a/src/ui/check.h
+++ b/src/ui/check.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,29 +19,30 @@
#pragma once
-
#include "ui/control.h"
-class CD3DEngine;
-
-
+namespace Gfx{
+ class CEngine;
+}
-class CCheck : public CControl
-{
-public:
- CCheck(CInstanceManager* iMan);
- virtual ~CCheck();
+namespace Ui {
+ class CCheck : public CControl
+ {
+ public:
+ CCheck();
+ virtual ~CCheck();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
-protected:
+ protected:
-protected:
-};
+ protected:
+ };
+}
diff --git a/src/ui/color.cpp b/src/ui/color.cpp
index 1038343..200ed0c 100644
--- a/src/ui/color.cpp
+++ b/src/ui/color.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -15,22 +16,20 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
+#include "ui/color.h"
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "common/language.h"
-#include "old/math3d.h"
#include "common/event.h"
-#include "common/misc.h"
#include "common/iman.h"
+#include "common/misc.h"
#include "common/restext.h"
-#include "ui/color.h"
+#include "graphics/core/device.h"
+#include "graphics/engine/engine.h"
+
+#include <string.h>
+namespace Ui {
const float DELAY1 = 0.4f;
const float DELAY2 = 0.1f;
@@ -38,7 +37,8 @@ const float DELAY2 = 0.1f;
// Object's constructor.
-CColor::CColor(CInstanceManager* iMan) : CControl(iMan)
+//CColor::CColor(CInstanceManager* iMan) : CControl(iMan)
+CColor::CColor() : CControl()
{
m_bRepeat = false;
m_repeat = 0.0f;
@@ -58,18 +58,18 @@ CColor::~CColor()
// Creates a new button.
-bool CColor::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CColor::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
- CControl::Create(pos, dim, icon, eventMsg);
+ CControl::Create(pos, dim, icon, eventType);
if ( icon == -1 )
{
char name[100];
char* p;
- GetResource(RES_EVENT, eventMsg, name);
+ GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\');
if ( p != 0 ) *p = 0;
SetName(name);
@@ -87,7 +87,7 @@ bool CColor::EventProcess(const Event &event)
CControl::EventProcess(event);
- if ( event.event == EVENT_FRAME && m_bRepeat )
+ if ( event.type == EVENT_FRAME && m_bRepeat )
{
if ( m_repeat != 0.0f )
{
@@ -97,29 +97,30 @@ bool CColor::EventProcess(const Event &event)
m_repeat = DELAY2;
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
}
}
- if ( event.event == EVENT_LBUTTONDOWN &&
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
m_repeat = DELAY1;
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
}
- if ( event.event == EVENT_LBUTTONUP )
+ if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1)
{
m_repeat = 0.0f;
}
@@ -132,9 +133,9 @@ bool CColor::EventProcess(const Event &event)
void CColor::Draw()
{
- LPDIRECT3DDEVICE7 device;
- D3DLVERTEX vertex[4]; // 2 triangles
- D3DCOLOR color;
+ Gfx::CDevice* device;
+ Gfx::VertexCol vertex[4]; // 2 triangles
+ Gfx::Color color;
Math::Point p1, p2;
if ( (m_state & STATE_VISIBLE) == 0 ) return;
@@ -144,57 +145,58 @@ void CColor::Draw()
DrawShadow(m_pos, m_dim);
}
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
CControl::Draw();
#if _TEEN
- color = ::RetColor(m_color);
-
- m_engine->SetTexture("xxx.tga"); // no texture
- m_engine->SetState(D3DSTATENORMAL);
-
- device = m_engine->RetD3DDevice();
-
- p1.x = m_pos.x+(4.0f/640.0f);
- p1.y = m_pos.y+(4.0f/480.0f);
- p2.x = m_pos.x+m_dim.x-(4.0f/640.0f);
- p2.y = m_pos.y+m_dim.y-(4.0f/480.0f);
- vertex[0] = D3DLVERTEX(D3DVECTOR(p1.x, p1.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f);
- vertex[1] = D3DLVERTEX(D3DVECTOR(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f);
- vertex[2] = D3DLVERTEX(D3DVECTOR(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f);
- vertex[3] = D3DLVERTEX(D3DVECTOR(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, 0.0f,0.0f);
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL);
-
- p1.x = m_pos.x+(5.0f/640.0f);
- p1.y = m_pos.y+(5.0f/480.0f);
- p2.x = m_pos.x+m_dim.x-(5.0f/640.0f);
- p2.y = m_pos.y+m_dim.y-(5.0f/480.0f);
- vertex[0] = D3DLVERTEX(D3DVECTOR(p1.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f);
- vertex[1] = D3DLVERTEX(D3DVECTOR(p1.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f);
- vertex[2] = D3DLVERTEX(D3DVECTOR(p2.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f);
- vertex[3] = D3DLVERTEX(D3DVECTOR(p2.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f);
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL);
+// color = GetColor(m_color);
+ color = GetColor();
+
+ m_engine->SetTexture("xxx.png"); // no texture
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+
+ device = m_engine->GetDevice();
+
+ p1.x = m_pos.x + (4.0f / 640.0f);
+ p1.y = m_pos.y + (4.0f / 480.0f);
+ p2.x = m_pos.x + m_dim.x - (4.0f / 640.0f);
+ p2.y = m_pos.y + m_dim.y - (4.0f / 480.0f);
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
+ vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
+ vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), 0x00000000,0x00000000, Math::Point( 0.0f, 0.0f));
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
+
+ p1.x = m_pos.x + (5.0f / 640.0f);
+ p1.y = m_pos.y + (5.0f / 480.0f);
+ p2.x = m_pos.x + m_dim.x - (5.0f / 640.0f);
+ p2.y = m_pos.y + m_dim.y - (5.0f / 480.0f);
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
+ vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
+ vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), color,0x00000000, Math::Point( 0.0f, 0.0f));
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(4);
#else
- p1.x = m_pos.x+(3.0f/640.0f);
- p1.y = m_pos.y+(3.0f/480.0f);
- p2.x = m_pos.x+m_dim.x-(3.0f/640.0f);
- p2.y = m_pos.y+m_dim.y-(3.0f/480.0f);
+ p1.x = m_pos.x + (3.0f / 640.0f);
+ p1.y = m_pos.y + (3.0f / 480.0f);
+ p2.x = m_pos.x + m_dim.x - (3.0f / 640.0f);
+ p2.y = m_pos.y + m_dim.y - (3.0f / 480.0f);
- color = ::RetColor(m_color);
+ color = GetColor();
- m_engine->SetTexture("xxx.tga"); // no texture
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("xxx.png"); // no texture
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
- vertex[0] = D3DLVERTEX(D3DVECTOR(p1.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f);
- vertex[1] = D3DLVERTEX(D3DVECTOR(p1.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f);
- vertex[2] = D3DLVERTEX(D3DVECTOR(p2.x, p1.y, 0.0f), color,0x00000000, 0.0f,0.0f);
- vertex[3] = D3DLVERTEX(D3DVECTOR(p2.x, p2.y, 0.0f), color,0x00000000, 0.0f,0.0f);
+ vertex[0] = Gfx::VertexCol(Math::Vector(p1.x, p1.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f));
+ vertex[1] = Gfx::VertexCol(Math::Vector(p1.x, p2.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f));
+ vertex[2] = Gfx::VertexCol(Math::Vector(p2.x, p1.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f));
+ vertex[3] = Gfx::VertexCol(Math::Vector(p2.x, p2.y, 0.0f), color, Gfx::Color(), Math::Point(0.0f, 0.0f));
- device = m_engine->RetD3DDevice();
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_LVERTEX, vertex, 4, NULL);
+ device = m_engine->GetDevice();
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2);
#endif
}
@@ -205,20 +207,21 @@ void CColor::SetRepeat(bool bRepeat)
m_bRepeat = bRepeat;
}
-bool CColor::RetRepeat()
+bool CColor::GetRepeat()
{
return m_bRepeat;
}
-void CColor::SetColor(D3DCOLORVALUE color)
+void CColor::SetColor(Gfx::Color color)
{
m_color = color;
}
-D3DCOLORVALUE CColor::RetColor()
+Gfx::Color CColor::GetColor()
{
return m_color;
}
+}
diff --git a/src/ui/color.h b/src/ui/color.h
index 41052a7..ad99ddd 100644
--- a/src/ui/color.h
+++ b/src/ui/color.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,39 +19,41 @@
#pragma once
-
#include "ui/control.h"
-#include "old/d3dengine.h"
-
-
-class CD3DEngine;
+namespace Gfx{
+ class CEngine;
+ struct Color;
+}
-class CColor : public CControl
-{
-public:
- CColor(CInstanceManager* iMan);
- virtual ~CColor();
+namespace Ui {
+ class CColor : public CControl
+ {
+ public:
+ // CColor(CInstanceManager* iMan);
+ CColor();
+ virtual ~CColor();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
- void SetRepeat(bool bRepeat);
- bool RetRepeat();
+ void SetRepeat(bool bRepeat);
+ bool GetRepeat();
- void SetColor(D3DCOLORVALUE color);
- D3DCOLORVALUE RetColor();
+ void SetColor(Gfx::Color color);
+ Gfx::Color GetColor();
-protected:
+ protected:
-protected:
- bool m_bRepeat;
- float m_repeat;
- D3DCOLORVALUE m_color;
-};
+ protected:
+ bool m_bRepeat;
+ float m_repeat;
+ Gfx::Color m_color;
+ };
+}
diff --git a/src/ui/compass.cpp b/src/ui/compass.cpp
index 7ea6e9d..c7d0068 100644
--- a/src/ui/compass.cpp
+++ b/src/ui/compass.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -14,26 +15,22 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
+#include "ui/compass.h"
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "math/geometry.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
#include "common/event.h"
-#include "common/misc.h"
#include "common/iman.h"
-#include "ui/compass.h"
-
+#include "common/misc.h"
+#include "graphics/core/device.h"
+#include "graphics/engine/engine.h"
+#include "math/geometry.h"
+namespace Ui {
// Object's constructor.
-CCompass::CCompass(CInstanceManager* iMan) : CControl(iMan)
+//CCompass::CCompass(CInstanceManager* iMan) : CControl(iMan)
+CCompass::CCompass() : CControl()
{
m_dir = 0.0f;
}
@@ -47,11 +44,11 @@ CCompass::~CCompass()
// Creates a new button.
-bool CCompass::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CCompass::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
- CControl::Create(pos, dim, icon, eventMsg);
+ CControl::Create(pos, dim, icon, eventType);
return true;
}
@@ -62,12 +59,13 @@ bool CCompass::EventProcess(const Event &event)
{
CControl::EventProcess(event);
- if ( event.event == EVENT_LBUTTONDOWN )
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1)
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
@@ -81,33 +79,33 @@ bool CCompass::EventProcess(const Event &event)
void CCompass::Draw()
{
- LPDIRECT3DDEVICE7 device;
- D3DVERTEX2 vertex[4]; // 2 triangles
- Math::Point p1, p2, p3, c, uv1, uv2;
- Math::Vector n;
- float dp;
+ Gfx::CDevice* device;
+ Gfx::Vertex vertex[4]; // 2 triangles
+ Math::Point p1, p2, p3, c, uv1, uv2;
+ Math::Vector n;
+ float dp;
if ( (m_state & STATE_VISIBLE) == 0 ) return;
- device = m_engine->RetD3DDevice();
+ device = m_engine->GetDevice();
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
p1.x = m_pos.x;
p1.y = m_pos.y;
p2.x = m_pos.x + m_dim.x;
p2.y = m_pos.y + m_dim.y;
- c.x = (p1.x+p2.x)/2.0f;
- c.y = (p1.y+p2.y)/2.0f; // center
+ c.x = (p1.x + p2.x) / 2.0f;
+ c.y = (p1.y + p2.y) / 2.0f; // center
- uv1.x = 64.0f/256.0f;
- uv1.y = 32.0f/256.0f;
- uv2.x = 96.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ uv1.x = 64.0f / 256.0f;
+ uv1.y = 32.0f / 256.0f;
+ uv2.x = 96.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
- dp = 0.5f/256.0f;
+ dp = 0.5f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -115,46 +113,46 @@ void CCompass::Draw()
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y);
- vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y);
- vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y);
- vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y);
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y));
+ vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y));
+ vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y));
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2);
if ( m_state & STATE_ENABLE )
{
p1.x = c.x;
- p1.y = c.y+m_dim.x*0.40f;
+ p1.y = c.y + m_dim.x * 0.40f;
p1 = Math::RotatePoint(c, m_dir, p1);
- p1.x = c.x+(p1.x-c.x)*(m_dim.x/m_dim.y);
+ p1.x = c.x + (p1.x - c.x) * (m_dim.x / m_dim.y);
- p2.x = c.x+m_dim.x*0.20f;
- p2.y = c.y-m_dim.x*0.40f;
+ p2.x = c.x + m_dim.x * 0.20f;
+ p2.y = c.y - m_dim.x * 0.40f;
p2 = Math::RotatePoint(c, m_dir, p2);
- p2.x = c.x+(p2.x-c.x)*(m_dim.x/m_dim.y);
+ p2.x = c.x + (p2.x - c.x) * (m_dim.x / m_dim.y);
- p3.x = c.x-m_dim.x*0.20f;
- p3.y = c.y-m_dim.x*0.40f;
+ p3.x = c.x - m_dim.x * 0.20f;
+ p3.y = c.y - m_dim.x * 0.40f;
p3 = Math::RotatePoint(c, m_dir, p3);
- p3.x = c.x+(p3.x-c.x)*(m_dim.x/m_dim.y);
+ p3.x = c.x + (p3.x - c.x) * (m_dim.x / m_dim.y);
- uv1.x = 96.0f/256.0f;
- uv1.y = 32.0f/256.0f;
- uv2.x = 104.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ uv1.x = 96.0f / 256.0f;
+ uv1.y = 32.0f / 256.0f;
+ uv2.x = 104.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y);
- vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y);
- vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y);
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv1.y));
+ vertex[1] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv2.y));
+ vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y));
- device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL);
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3);
m_engine->AddStatisticTriangle(1);
}
}
@@ -167,9 +165,10 @@ void CCompass::SetDirection(float dir)
m_dir = dir;
}
-float CCompass::RetDirection()
+float CCompass::GetDirection()
{
return m_dir;
}
+}
diff --git a/src/ui/compass.h b/src/ui/compass.h
index 0014f3d..09eec9d 100644
--- a/src/ui/compass.h
+++ b/src/ui/compass.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,33 +19,36 @@
#pragma once
-
#include "ui/control.h"
-class CD3DEngine;
-
+namespace Gfx {
+ class CEngine;
+}
+namespace Ui {
-class CCompass : public CControl
-{
-public:
- CCompass(CInstanceManager* iMan);
- virtual ~CCompass();
+ class CCompass : public CControl
+ {
+ public:
+ // CCompass(CInstanceManager* iMan);
+ CCompass();
+ virtual ~CCompass();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
- void SetDirection(float dir);
- float RetDirection();
+ void SetDirection(float dir);
+ float GetDirection();
-protected:
+ protected:
-protected:
- float m_dir;
-};
+ protected:
+ float m_dir;
+ };
+}
diff --git a/src/ui/control.cpp b/src/ui/control.cpp
index 6ff7c2f..6ac82bc 100644
--- a/src/ui/control.cpp
+++ b/src/ui/control.cpp
@@ -1,6 +1,7 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
-// *
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
+//
// * 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
@@ -15,47 +16,28 @@
// * along with this program. If not, see http://www.gnu.org/licenses/.
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "common/language.h"
-#include "common/restext.h"
-#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "object/robotmain.h"
-#include "old/particule.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "old/text.h"
-#include "old/sound.h"
#include "ui/control.h"
-
-
+namespace Ui {
// Object's constructor.
-CControl::CControl(CInstanceManager* iMan)
+CControl::CControl()
{
- m_iMan = iMan;
+ m_iMan = CInstanceManager::GetInstancePointer();
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
- m_eventMsg = EVENT_NULL;
+ m_engine = static_cast< Gfx::CEngine* > ( m_iMan->SearchInstance(CLASS_ENGINE) );
+ m_event = static_cast< CEventQueue* > ( m_iMan->SearchInstance(CLASS_EVENT) );
+ m_main = static_cast< CRobotMain* > ( m_iMan->SearchInstance(CLASS_MAIN) );
+ m_particle = static_cast< Gfx::CParticle* > (m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_sound = static_cast< CSoundInterface* > (m_iMan->SearchInstance(CLASS_SOUND));
+ m_eventType = EVENT_NULL;
m_state = STATE_ENABLE|STATE_VISIBLE|STATE_GLINT;
- m_fontSize = SMALLFONT;
- m_fontStretch = NORMSTRETCH;
- m_fontType = FONT_COLOBOT;
- m_justif = 0;
- m_name[0] = 0;
- m_tooltip[0] = 0;
+ m_fontSize = Gfx::FONT_SIZE_SMALL;
+// m_fontStretch = Gfx::FONT_NORM_STRETCH; //there is font stretching no more master
+ m_fontType = Gfx::FONT_COLOBOT;
+ m_textAlign = Gfx::TEXT_ALIGN_CENTER; //instead m_justify
+// m_justif = 0;
m_bFocus = false;
m_bCapture = false;
@@ -76,34 +58,31 @@ CControl::~CControl()
// Creates a new button.
// pos: [0..1]
-bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CControl::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- char text[100];
- char* p;
+ char text[100];
+ std::string str_text;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL )
+ eventType = GetUniqueEventType();
m_pos = pos;
m_dim = dim;
m_icon = icon;
- m_eventMsg = eventMsg;
+ m_eventType = eventType;
pos.x = m_pos.x;
- pos.y = m_pos.y+m_dim.y;
+ pos.y = m_pos.y + m_dim.y;
GlintCreate(pos);
- GetResource(RES_EVENT, m_eventMsg, text);
- p = strchr(text, '\\');
- if ( p == 0 )
- {
+ GetResource(RES_EVENT, m_eventType, text);
+ str_text = std::string(text);
+ auto p = str_text.find("\\");
+ if ( p == std::string::npos ) {
if ( icon != -1 )
- {
- strcpy(m_tooltip, text);
- }
- }
- else
- {
- strcpy(m_tooltip, p+1); // text after "\\"
+ m_tooltip = str_text;
+ } else {
+ m_tooltip = str_text.substr(p + 1);
}
return true;
@@ -115,11 +94,11 @@ void CControl::SetPos(Math::Point pos)
m_pos = pos;
pos.x = m_pos.x;
- pos.y = m_pos.y+m_dim.y;
+ pos.y = m_pos.y + m_dim.y;
GlintCreate(pos);
}
-Math::Point CControl::RetPos()
+Math::Point CControl::GetPos()
{
return m_pos;
}
@@ -131,11 +110,11 @@ void CControl::SetDim(Math::Point dim)
m_dim = dim;
pos.x = m_pos.x;
- pos.y = m_pos.y+m_dim.y;
+ pos.y = m_pos.y + m_dim.y;
GlintCreate(pos);
}
-Math::Point CControl::RetDim()
+Math::Point CControl::GetDim()
{
return m_dim;
}
@@ -175,7 +154,7 @@ bool CControl::TestState(int state)
// Returns all attributes of state.
-int CControl::RetState()
+int CControl::GetState()
{
return m_state;
}
@@ -188,7 +167,7 @@ void CControl::SetIcon(int icon)
m_icon = icon;
}
-int CControl::RetIcon()
+int CControl::GetIcon()
{
return m_icon;
}
@@ -196,41 +175,21 @@ int CControl::RetIcon()
// Management of the button name.
-void CControl::SetName(char* name, bool bTooltip)
+void CControl::SetName(std::string name, bool bTooltip)
{
- char* p;
-
- if ( bTooltip )
- {
- p = strchr(name, '\\');
- if ( p == 0 )
- {
- strncpy(m_name, name, 100);
- m_name[100-1] = 0;
+ if ( bTooltip ) {
+ auto p = name.find("\\");
+ if ( p == std::string::npos )
+ m_name = name;
+ else {
+ m_tooltip = name.substr(p + 1);
+ m_name = name.substr(0, p);
}
- else
- {
- char buffer[100];
-
- strncpy(m_tooltip, p+1, 100); // text after "\\"
- m_tooltip[100-1] = 0;
-
- strncpy(buffer, name, 100);
- buffer[100-1] = 0;
- p = strchr(buffer, '\\');
- if ( p != 0 ) *p = 0;
- strncpy(m_name, buffer, 100);
- m_name[100-1] = 0;
- }
- }
- else
- {
- strncpy(m_name, name, 100);
- m_name[100-1] = 0;
- }
+ } else
+ m_name = name;
}
-char* CControl::RetName()
+std::string CControl::GetName()
{
return m_name;
}
@@ -238,14 +197,16 @@ char* CControl::RetName()
// Management of the mode of justification (-1,0,1).
-void CControl::SetJustif(int mode)
+void CControl::SetTextAlign(Gfx::TextAlign mode)
{
- m_justif = mode;
+ m_textAlign = mode;
+// m_justif = mode;
}
-int CControl::RetJustif()
+int CControl::GetTextAlign()
{
- return m_justif;
+ return m_textAlign;
+// return m_justif;
}
@@ -256,7 +217,7 @@ void CControl::SetFontSize(float size)
m_fontSize = size;
}
-float CControl::RetFontSize()
+float CControl::GetFontSize()
{
return m_fontSize;
}
@@ -269,7 +230,7 @@ void CControl::SetFontStretch(float stretch)
m_fontStretch = stretch;
}
-float CControl::RetFontStretch()
+float CControl::GetFontStretch()
{
return m_fontStretch;
}
@@ -277,12 +238,12 @@ float CControl::RetFontStretch()
// Choice of the font.
-void CControl::SetFontType(FontType font)
+void CControl::SetFontType(Gfx::FontType font)
{
m_fontType = font;
}
-FontType CControl::RetFontType()
+Gfx::FontType CControl::GetFontType()
{
return m_fontType;
}
@@ -290,21 +251,21 @@ FontType CControl::RetFontType()
// Specifies the tooltip.
-bool CControl::SetTooltip(char* name)
+bool CControl::SetTooltip(std::string name)
{
- strcpy(m_tooltip, name);
+ m_tooltip = name;
return true;
}
-bool CControl::GetTooltip(Math::Point pos, char* name)
+bool CControl::GetTooltip(Math::Point pos, std::string &name)
{
- if ( m_tooltip[0] == 0 ) return false;
- if ( (m_state & STATE_VISIBLE) == 0 ) return false;
+ if ( m_tooltip.length() == 0 ) return false;
+ if ( (m_state & STATE_VISIBLE) == 0 ) return false;
if ( (m_state & STATE_ENABLE) == 0 ) return false;
if ( m_state & STATE_DEAD ) return false;
if ( !Detect(pos) ) return false;
- strcpy(name, m_tooltip);
+ name = m_tooltip;
return true;
}
@@ -316,7 +277,7 @@ void CControl::SetFocus(bool bFocus)
m_bFocus = bFocus;
}
-bool CControl::RetFocus()
+bool CControl::GetFocus()
{
return m_bFocus;
}
@@ -324,9 +285,9 @@ bool CControl::RetFocus()
// Returns the event associated with the control.
-EventMsg CControl::RetEventMsg()
+EventType CControl::GetEventType()
{
- return m_eventMsg;
+ return m_eventType;
}
@@ -336,21 +297,21 @@ bool CControl::EventProcess(const Event &event)
{
if ( m_state & STATE_DEAD ) return true;
- if ( event.event == EVENT_FRAME && m_bGlint )
+ if ( event.type == EVENT_FRAME && m_bGlint )
{
GlintFrame(event);
}
- if ( event.event == EVENT_MOUSEMOVE )
+ if ( event.type == EVENT_MOUSE_MOVE )
{
- m_glintMouse = event.pos;
+ m_glintMouse = event.mouseMove.pos;
- if ( Detect(event.pos) )
+ if ( Detect(event.mouseMove.pos) )
{
if ( (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE ) )
{
- m_engine->SetMouseType(D3DMOUSEHAND);
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
}
SetState(STATE_HILIGHT);
}
@@ -360,18 +321,18 @@ bool CControl::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_LBUTTONDOWN )
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1)
{
- if ( Detect(event.pos) )
+ if ( Detect(event.mouseButton.pos) )
{
m_bCapture = true;
SetState(STATE_PRESS);
}
}
- if ( event.event == EVENT_MOUSEMOVE && m_bCapture )
+ if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
- if ( Detect(event.pos) )
+ if ( Detect(event.mouseMove.pos) )
{
SetState(STATE_PRESS);
}
@@ -381,7 +342,7 @@ bool CControl::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_LBUTTONUP && m_bCapture )
+ if ( event.type == EVENT_MOUSE_BUTTON_UP && m_bCapture && event.mouseButton.button == 1)
{
m_bCapture = false;
ClearState(STATE_PRESS);
@@ -404,8 +365,8 @@ void CControl::GlintCreate(Math::Point ref, bool bLeft, bool bUp)
{
float offset;
- offset = 8.0f/640.0f;
- if ( offset > m_dim.x/4.0f) offset = m_dim.x/4.0f;
+ offset = 8.0f / 640.0f;
+ if ( offset > m_dim.x / 4.0f) offset = m_dim.x / 4.0f;
if ( bLeft )
{
@@ -419,17 +380,17 @@ void CControl::GlintCreate(Math::Point ref, bool bLeft, bool bUp)
}
offset = 8.0f/480.0f;
- if ( offset > m_dim.y/4.0f) offset = m_dim.y/4.0f;
+ if ( offset > m_dim.y / 4.0f) offset = m_dim.y / 4.0f;
if ( bUp )
{
- m_glintCorner1.y = ref.y-offset;
+ m_glintCorner1.y = ref.y - offset;
m_glintCorner2.y = ref.y;
}
else
{
m_glintCorner1.y = ref.y;
- m_glintCorner2.y = ref.y+offset;
+ m_glintCorner2.y = ref.y + offset;
}
m_bGlint = true;
@@ -446,20 +407,20 @@ void CControl::GlintFrame(const Event &event)
(m_state & STATE_ENABLE ) == 0 ||
(m_state & STATE_VISIBLE) == 0 ) return;
- if ( !m_main->RetGlint() ) return;
+ if ( !m_main->GetGlint() ) return;
m_glintProgress += event.rTime;
if ( m_glintProgress >= 2.0f && Detect(m_glintMouse) )
{
- pos.x = m_glintCorner1.x + (m_glintCorner2.x-m_glintCorner1.x)*Math::Rand();
- pos.y = m_glintCorner1.y + (m_glintCorner2.y-m_glintCorner1.y)*Math::Rand();
+ pos.x = m_glintCorner1.x + (m_glintCorner2.x - m_glintCorner1.x) * Math::Rand();
+ pos.y = m_glintCorner1.y + (m_glintCorner2.y - m_glintCorner1.y) * Math::Rand();
pos.z = 0.0f;
speed = Math::Vector(0.0f, 0.0f, 0.0f);
- dim.x = ((15.0f+Math::Rand()*15.0f)/640.0f);
- dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, PARTICONTROL,
- 1.0f, 0.0f, 0.0f, SH_INTERFACE);
+ dim.x = ((15.0f + Math::Rand() * 15.0f) / 640.0f);
+ dim.y = dim.x / 0.75f;
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICONTROL,
+ 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE );
m_glintProgress = 0.0f;
}
@@ -476,8 +437,8 @@ void CControl::Draw()
if ( (m_state & STATE_VISIBLE) == 0 ) return;
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
zoomExt = 1.00f;
zoomInt = 0.95f;
@@ -530,14 +491,14 @@ void CControl::Draw()
if ( m_state & STATE_OKAY )
{
- m_engine->SetTexture("button3.tga");
+ m_engine->SetTexture("button3.png");
icon = 3; // yellow with green point pressed
}
if ( m_name[0] == 0 ) // button without name?
{
//? DrawPart(icon, zoomExt, 0.0f);
- DrawPart(icon, zoomExt, 8.0f/256.0f);
+ DrawPart(icon, zoomExt, 8.0f / 256.0f);
if ( m_state & STATE_DEAD ) return;
@@ -546,27 +507,27 @@ void CControl::Draw()
{
icon -= 192;
#if _POLISH
- m_engine->SetTexture("textp.tga");
+ m_engine->SetTexture("textp.png");
#else
- m_engine->SetTexture("text.tga");
+ m_engine->SetTexture("text.png");
#endif
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
}
else if ( icon >= 128 )
{
icon -= 128;
- m_engine->SetTexture("button3.tga");
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetTexture("button3.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
}
else if ( icon >= 64 )
{
icon -= 64;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
}
else
{
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
}
if ( icon != -1 )
{
@@ -579,26 +540,28 @@ void CControl::Draw()
if ( m_state & STATE_DEAD ) return;
- if ( m_justif < 0 )
+// if ( m_justif < 0 )
+ if ( m_textAlign == Gfx::TEXT_ALIGN_LEFT )
{
- pos.x = m_pos.x+m_dim.x-m_dim.y*0.5f;
- pos.y = m_pos.y+m_dim.y*0.5f;
- pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2;
- m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0);
+ pos.x = m_pos.x + m_dim.x - m_dim.y * 0.5f;
+ pos.y = m_pos.y + m_dim.y * 0.5f;
+ pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f;
+ m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
}
- else if ( m_justif > 0 )
+ else if ( m_textAlign == Gfx::TEXT_ALIGN_RIGHT )
+// else if ( m_justif > 0 )
{
- pos.x = m_pos.x+m_dim.y*0.5f;
- pos.y = m_pos.y+m_dim.y*0.5f;
- pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f;
- m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0);
+ pos.x = m_pos.x + m_dim.y * 0.5f;
+ pos.y = m_pos.y + m_dim.y * 0.5f;
+ pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f;
+ m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
}
else
{
- pos.x = m_pos.x+m_dim.x*0.5f;
- pos.y = m_pos.y+m_dim.y*0.5f;
- pos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f;
- m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0);
+ pos.x = m_pos.x + m_dim.x * 0.5f;
+ pos.y = m_pos.y + m_dim.y * 0.5f;
+ pos.y -= m_engine->GetText()->GetHeight( m_fontType, m_fontSize)/2.0f;
+ m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
}
}
}
@@ -618,26 +581,26 @@ void CControl::DrawPart(int icon, float zoom, float ex)
if ( (m_state & STATE_CARD ) &&
(m_state & STATE_CHECK) )
{
- p2.y += (2.0f/480.0f); // a bit above
+ p2.y += (2.0f / 480.0f); // a bit above
}
- c.x = (p1.x+p2.x)/2.0f;
- c.y = (p1.y+p2.y)/2.0f; // center
+ c.x = (p1.x + p2.x)/2.0f;
+ c.y = (p1.y + p2.y)/2.0f; // center
- p1.x = (p1.x-c.x)*zoom + c.x;
- p1.y = (p1.y-c.y)*zoom + c.y;
- p2.x = (p2.x-c.x)*zoom + c.x;
- p2.y = (p2.y-c.y)*zoom + c.y;
+ p1.x = (p1.x - c.x) * zoom + c.x;
+ p1.y = (p1.y - c.y) * zoom + c.y;
+ p2.x = (p2.x - c.x) * zoom + c.x;
+ p2.y = (p2.y - c.y) * zoom + c.y;
p2.x -= p1.x;
p2.y -= p1.y;
- uv1.x = (32.0f/256.0f)*(icon%8);
- uv1.y = (32.0f/256.0f)*(icon/8); // uv texture
- uv2.x = (32.0f/256.0f)+uv1.x;
- uv2.y = (32.0f/256.0f)+uv1.y;
+ uv1.x = (32.0f / 256.0f) * (icon%8);
+ uv1.y = (32.0f / 256.0f) * (icon/8); // uv texture
+ uv2.x = (32.0f / 256.0f) + uv1.x;
+ uv2.y = (32.0f / 256.0f) + uv1.y;
- dp = 0.5f/256.0f;
+ dp = 0.5f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -652,12 +615,12 @@ void CControl::DrawPart(int icon, float zoom, float ex)
void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2,
float ex)
{
- LPDIRECT3DDEVICE7 device;
- D3DVERTEX2 vertex[8]; // 6 triangles
+ Gfx::CDevice* device;
+ Gfx::Vertex vertex[8]; // 6 triangles
Math::Point p1, p2, p3, p4;
Math::Vector n;
- device = m_engine->RetD3DDevice();
+ device = m_engine->GetDevice();
p1.x = pos.x;
p1.y = pos.y;
@@ -668,48 +631,48 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
if ( ex == 0.0f ) // one piece?
{
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y);
- vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y);
- vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y);
- vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y);
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
+ vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
+ vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x,uv1.y));
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2);
}
else // 3 pieces?
{
if ( dim.x >= dim.y )
{
- p3.x = p1.x + ex*dim.y/(uv2.y-uv1.y);
- p4.x = p2.x - ex*dim.y/(uv2.y-uv1.y);
-
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x, uv2.y);
- vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x, uv1.y);
- vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p1.y, 0.0f), n, uv1.x+ex,uv2.y);
- vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p2.y, 0.0f), n, uv1.x+ex,uv1.y);
- vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p1.y, 0.0f), n, uv2.x-ex,uv2.y);
- vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p2.y, 0.0f), n, uv2.x-ex,uv1.y);
- vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x, uv2.y);
- vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x, uv1.y);
-
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL);
+ p3.x = p1.x + ex*dim.y / (uv2.y - uv1.y);
+ p4.x = p2.x - ex*dim.y / (uv2.y - uv1.y);
+
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y));
+ vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p1.y, 0.0f), n, Math::Point(uv1.x+ex,uv2.y));
+ vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p2.y, 0.0f), n, Math::Point(uv1.x+ex,uv1.y));
+ vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p1.y, 0.0f), n, Math::Point(uv2.x-ex,uv2.y));
+ vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p2.y, 0.0f), n, Math::Point(uv2.x-ex,uv1.y));
+ vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y));
+ vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y));
+
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6);
}
else
{
- p3.y = p1.y + ex*dim.x/(uv2.x-uv1.x);
- p4.y = p2.y - ex*dim.x/(uv2.x-uv1.x);
-
- vertex[0] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y );
- vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y );
- vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p3.y, 0.0f), n, uv2.x,uv2.y-ex);
- vertex[3] = D3DVERTEX2(Math::Vector(p1.x, p3.y, 0.0f), n, uv1.x,uv2.y-ex);
- vertex[4] = D3DVERTEX2(Math::Vector(p2.x, p4.y, 0.0f), n, uv2.x,uv1.y+ex);
- vertex[5] = D3DVERTEX2(Math::Vector(p1.x, p4.y, 0.0f), n, uv1.x,uv1.y+ex);
- vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y );
- vertex[7] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y );
-
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL);
+ p3.y = p1.y + ex*dim.x / (uv2.x - uv1.x);
+ p4.y = p2.y - ex*dim.x / (uv2.x - uv1.x);
+
+ vertex[0] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y ));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y ));
+ vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y - ex));
+ vertex[3] = Gfx::Vertex(Math::Vector(p1.x, p3.y, 0.0f), n, Math::Point(uv1.x, uv2.y - ex));
+ vertex[4] = Gfx::Vertex(Math::Vector(p2.x, p4.y, 0.0f), n, Math::Point(uv2.x, uv1.y + ex));
+ vertex[5] = Gfx::Vertex(Math::Vector(p1.x, p4.y, 0.0f), n, Math::Point(uv1.x, uv1.y + ex));
+ vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y ));
+ vertex[7] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y ));
+
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6);
}
}
@@ -720,12 +683,12 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2,
Math::Point corner, float ex)
{
- LPDIRECT3DDEVICE7 device;
- D3DVERTEX2 vertex[8]; // 6 triangles
+ Gfx::CDevice* device;
+ Gfx::Vertex vertex[8]; // 6 triangles
Math::Point p1, p2, p3, p4;
Math::Vector n;
- device = m_engine->RetD3DDevice();
+ device = m_engine->GetDevice();
p1.x = pos.x;
p1.y = pos.y;
@@ -734,8 +697,8 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
- if ( corner.x > dim.x/2.0f ) corner.x = dim.x/2.0f;
- if ( corner.y > dim.y/2.0f ) corner.y = dim.y/2.0f;
+ if ( corner.x > dim.x / 2.0f ) corner.x = dim.x / 2.0f;
+ if ( corner.y > dim.y / 2.0f ) corner.y = dim.y / 2.0f;
p1.x = pos.x;
p1.y = pos.y;
@@ -747,39 +710,39 @@ void CControl::DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math:
p4.y = p2.y - corner.y;
// Bottom horizontal band.
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x, uv2.y );
- vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p3.y, 0.0f), n, uv1.x, uv2.y-ex);
- vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p1.y, 0.0f), n, uv1.x+ex,uv2.y );
- vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x+ex,uv2.y-ex);
- vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p1.y, 0.0f), n, uv2.x-ex,uv2.y );
- vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p3.y, 0.0f), n, uv2.x-ex,uv2.y-ex);
- vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x, uv2.y );
- vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p3.y, 0.0f), n, uv2.x, uv2.y-ex);
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL);
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x, uv2.y ));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p3.y, 0.0f), n, Math::Point(uv1.x, uv2.y - ex));
+ vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p1.y, 0.0f), n, Math::Point(uv1.x + ex, uv2.y ));
+ vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x + ex, uv2.y - ex));
+ vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p1.y, 0.0f), n, Math::Point(uv2.x - ex, uv2.y ));
+ vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p3.y, 0.0f), n, Math::Point(uv2.x - ex, uv2.y - ex));
+ vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x, uv2.y ));
+ vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y - ex));
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6);
// Central horizontal band.
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p3.y, 0.0f), n, uv1.x, uv2.y-ex);
- vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p4.y, 0.0f), n, uv1.x, uv1.y+ex);
- vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x+ex,uv2.y-ex);
- vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p4.y, 0.0f), n, uv1.x+ex,uv1.y+ex);
- vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p3.y, 0.0f), n, uv2.x-ex,uv2.y-ex);
- vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x-ex,uv1.y+ex);
- vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p3.y, 0.0f), n, uv2.x, uv2.y-ex);
- vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p4.y, 0.0f), n, uv2.x, uv1.y+ex);
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL);
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p3.y, 0.0f), n, Math::Point(uv1.x, uv2.y - ex));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p4.y, 0.0f), n, Math::Point(uv1.x, uv1.y + ex));
+ vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x + ex, uv2.y - ex));
+ vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p4.y, 0.0f), n, Math::Point(uv1.x + ex, uv1.y + ex));
+ vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p3.y, 0.0f), n, Math::Point(uv2.x - ex, uv2.y - ex));
+ vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x - ex, uv1.y + ex));
+ vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p3.y, 0.0f), n, Math::Point(uv2.x, uv2.y - ex));
+ vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p4.y, 0.0f), n, Math::Point(uv2.x, uv1.y + ex));
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6);
// Top horizontal band.
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p4.y, 0.0f), n, uv1.x, uv1.y+ex);
- vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x, uv1.y );
- vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p4.y, 0.0f), n, uv1.x+ex,uv1.y+ex);
- vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p2.y, 0.0f), n, uv1.x+ex,uv1.y );
- vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x-ex,uv1.y+ex);
- vertex[5] = D3DVERTEX2(Math::Vector(p4.x, p2.y, 0.0f), n, uv2.x-ex,uv1.y );
- vertex[6] = D3DVERTEX2(Math::Vector(p2.x, p4.y, 0.0f), n, uv2.x, uv1.y+ex);
- vertex[7] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x, uv1.y );
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 8, NULL);
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p4.y, 0.0f), n, Math::Point(uv1.x, uv1.y + ex));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x, uv1.y ));
+ vertex[2] = Gfx::Vertex(Math::Vector(p3.x, p4.y, 0.0f), n, Math::Point(uv1.x + ex, uv1.y + ex));
+ vertex[3] = Gfx::Vertex(Math::Vector(p3.x, p2.y, 0.0f), n, Math::Point(uv1.x + ex, uv1.y ));
+ vertex[4] = Gfx::Vertex(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x - ex, uv1.y + ex));
+ vertex[5] = Gfx::Vertex(Math::Vector(p4.x, p2.y, 0.0f), n, Math::Point(uv2.x - ex, uv1.y ));
+ vertex[6] = Gfx::Vertex(Math::Vector(p2.x, p4.y, 0.0f), n, Math::Point(uv2.x, uv1.y + ex));
+ vertex[7] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x, uv1.y ));
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 8);
m_engine->AddStatisticTriangle(6);
}
@@ -790,15 +753,15 @@ void CControl::DrawWarning(Math::Point pos, Math::Point dim)
Math::Point uv1, uv2;
float dp;
- dp = 0.5f/256.0f;
+ dp = 0.5f / 256.0f;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
- uv1.x = 64.0f/256.0f;
- uv1.y = 208.0f/256.0f;
- uv2.x = 160.0f/256.0f;
- uv2.y = 224.0f/256.0f;
+ uv1.x = 64.0f / 256.0f;
+ uv1.y = 208.0f / 256.0f;
+ uv2.x = 160.0f / 256.0f;
+ uv2.y = 224.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
@@ -836,28 +799,28 @@ void CControl::DrawShadow(Math::Point pos, Math::Point dim, float deep)
dp = 0.5f/256.0f;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState( Gfx::ENG_RSTATE_TTEXTURE_WHITE);
- pos.x += deep*0.010f*0.75f;
- pos.y -= deep*0.015f;
- dim.x += deep*0.005f*0.75f;
- dim.y += deep*0.005f;
+ pos.x += deep * 0.010f * 0.75f;
+ pos.y -= deep * 0.015f;
+ dim.x += deep * 0.005f * 0.75f;
+ dim.y += deep * 0.005f;
- uv1.x = 192.0f/256.0f;
- uv1.y = 32.0f/256.0f;
- uv2.x = 224.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ uv1.x = 192.0f / 256.0f;
+ uv1.y = 32.0f / 256.0f;
+ uv2.x = 224.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 10.0f/640.0f;
- corner.y = 10.0f/480.0f;
+ corner.x = 10.0f / 640.0f;
+ corner.y = 10.0f / 480.0f;
- DrawIcon(pos, dim, uv1, uv2, corner, 6.0f/256.0f);
+ DrawIcon(pos, dim, uv1, uv2, corner, 6.0f / 256.0f);
}
@@ -865,10 +828,10 @@ void CControl::DrawShadow(Math::Point pos, Math::Point dim, float deep)
bool CControl::Detect(Math::Point pos)
{
- return ( pos.x >= m_pos.x &&
- pos.x <= m_pos.x+m_dim.x &&
- pos.y >= m_pos.y &&
- pos.y <= m_pos.y+m_dim.y );
+ return ( pos.x >= m_pos.x &&
+ pos.x <= m_pos.x + m_dim.x &&
+ pos.y >= m_pos.y &&
+ pos.y <= m_pos.y + m_dim.y );
}
-
+}
diff --git a/src/ui/control.h b/src/ui/control.h
index 0a12ff1..e08c34d 100644
--- a/src/ui/control.h
+++ b/src/ui/control.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,121 +19,129 @@
#pragma once
+#include <string>
-#include "old/text.h"
-#include "common/struct.h"
#include "common/event.h"
-
-
-class CInstanceManager;
-class CEvent;
-class CD3DEngine;
-class CRobotMain;
-class CParticule;
-class CSound;
-
-
-enum ControlState
-{
- STATE_ENABLE = (1<<0), // active
- STATE_CHECK = (1<<1), // pressed
- STATE_HILIGHT = (1<<2), // overflown by mouse
- STATE_PRESS = (1<<3), // pressed by mouse
- STATE_VISIBLE = (1<<4), // visible
- STATE_DEAD = (1<<5), // inaccessible (x)
- STATE_DEFAULT = (1<<6), // actuated by RETURN
- STATE_OKAY = (1<<7), // green point at the bottom right
- STATE_SHADOW = (1<<8), // shadow
- STATE_GLINT = (1<<9), // dynamic reflection
- STATE_CARD = (1<<10), // tab
- STATE_EXTEND = (1<<11), // extended mode
- STATE_SIMPLY = (1<<12), // undecorated
- STATE_FRAME = (1<<13), // framework highlighting
- STATE_WARNING = (1<<14), // framework hatched yellow / black
- STATE_VALUE = (1<<15), // displays the value
- STATE_RUN = (1<<16) // running program
-};
-
-
-
-class CControl
-{
-public:
- CControl(CInstanceManager* iMan);
- virtual ~CControl();
-
- virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
-
- virtual bool EventProcess(const Event &event);
-
- virtual void SetPos(Math::Point pos);
- virtual Math::Point RetPos();
- virtual void SetDim(Math::Point dim);
- virtual Math::Point RetDim();
- virtual bool SetState(int state, bool bState);
- virtual bool SetState(int state);
- virtual bool ClearState(int state);
- virtual bool TestState(int state);
- virtual int RetState();
- virtual void SetIcon(int icon);
- virtual int RetIcon();
- virtual void SetName(char* name, bool bTooltip=true);
- virtual char* RetName();
- virtual void SetJustif(int mode);
- virtual int RetJustif();
- virtual void SetFontSize(float size);
- virtual float RetFontSize();
- virtual void SetFontStretch(float stretch);
- virtual float RetFontStretch();
- virtual void SetFontType(FontType font);
- virtual FontType RetFontType();
- virtual bool SetTooltip(char* name);
- virtual bool GetTooltip(Math::Point pos, char* name);
- virtual void SetFocus(bool bFocus);
- virtual bool RetFocus();
-
- virtual EventMsg RetEventMsg();
-
- virtual void Draw();
-
-protected:
- void GlintDelete();
- void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true);
- void GlintFrame(const Event &event);
- void DrawPart(int icon, float zoom, float ex);
- void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f);
- void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex);
- void DrawWarning(Math::Point pos, Math::Point dim);
- void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
- virtual bool Detect(Math::Point pos);
-
-protected:
- CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CEvent* m_event;
- CRobotMain* m_main;
- CParticule* m_particule;
- CSound* m_sound;
-
- Math::Point m_pos; // corner upper / left
- Math::Point m_dim; // dimensions
- int m_icon;
- EventMsg m_eventMsg; // message to send when clicking
- int m_state; // states (STATE_ *)
- float m_fontSize; // size of the button name
- float m_fontStretch; // stretch of the font
- FontType m_fontType; // type of font
- int m_justif; // type of justification (-1,0,1)
- char m_name[100]; // name of the button
- char m_tooltip[100]; // name of tooltip
- bool m_bFocus;
- bool m_bCapture;
-
- bool m_bGlint;
- Math::Point m_glintCorner1;
- Math::Point m_glintCorner2;
- float m_glintProgress;
- Math::Point m_glintMouse;
-};
-
-
+#include "common/iman.h"
+#include "common/misc.h"
+#include "common/restext.h"
+
+#include "graphics/core/device.h"
+#include "graphics/engine/engine.h"
+#include "graphics/engine/particle.h"
+#include "graphics/engine/text.h"
+
+#include "object/robotmain.h"
+
+#include "sound/sound.h"
+
+
+
+namespace Ui {
+
+ enum ControlState
+ {
+ STATE_ENABLE = (1<<0), // active
+ STATE_CHECK = (1<<1), // pressed
+ STATE_HILIGHT = (1<<2), // overflown by mouse
+ STATE_PRESS = (1<<3), // pressed by mouse
+ STATE_VISIBLE = (1<<4), // visible
+ STATE_DEAD = (1<<5), // inaccessible (x)
+ STATE_DEFAULT = (1<<6), // actuated by RETURN
+ STATE_OKAY = (1<<7), // green point at the bottom right
+ STATE_SHADOW = (1<<8), // shadow
+ STATE_GLINT = (1<<9), // dynamic reflection
+ STATE_CARD = (1<<10), // tab
+ STATE_EXTEND = (1<<11), // extended mode
+ STATE_SIMPLY = (1<<12), // undecorated
+ STATE_FRAME = (1<<13), // framework highlighting
+ STATE_WARNING = (1<<14), // framework hatched yellow / black
+ STATE_VALUE = (1<<15), // displays the value
+ STATE_RUN = (1<<16) // running program
+ };
+
+
+
+ class CControl
+ {
+ public:
+ // CControl(CInstanceManager* iMan);
+ CControl ();
+ virtual ~CControl();
+
+ virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
+
+ virtual bool EventProcess(const Event &event);
+
+ virtual void SetPos(Math::Point pos);
+ virtual Math::Point GetPos();
+ virtual void SetDim(Math::Point dim);
+ virtual Math::Point GetDim();
+ virtual bool SetState(int state, bool bState);
+ virtual bool SetState(int state);
+ virtual bool ClearState(int state);
+ virtual bool TestState(int state);
+ virtual int GetState();
+ virtual void SetIcon(int icon);
+ virtual int GetIcon();
+ virtual void SetName(std::string name, bool bTooltip=true);
+ virtual std::string GetName();
+ virtual void SetTextAlign(Gfx::TextAlign mode);
+ virtual int GetTextAlign();
+ virtual void SetFontSize(float size);
+ virtual float GetFontSize();
+ virtual void SetFontStretch(float stretch);
+ virtual float GetFontStretch();
+ virtual void SetFontType(Gfx::FontType font);
+ virtual Gfx::FontType GetFontType();
+ virtual bool SetTooltip(std::string name);
+ virtual bool GetTooltip(Math::Point pos, std::string &name);
+ virtual void SetFocus(bool bFocus);
+ virtual bool GetFocus();
+
+ virtual EventType GetEventType();
+
+ virtual void Draw();
+
+ protected:
+ void GlintDelete();
+ void GlintCreate(Math::Point ref, bool bLeft=true, bool bUp=true);
+ void GlintFrame(const Event &event);
+ void DrawPart(int icon, float zoom, float ex);
+ void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, float ex=0.0f);
+ void DrawIcon(Math::Point pos, Math::Point dim, Math::Point uv1, Math::Point uv2, Math::Point corner, float ex);
+ void DrawWarning(Math::Point pos, Math::Point dim);
+ void DrawShadow(Math::Point pos, Math::Point dim, float deep=1.0f);
+ virtual bool Detect(Math::Point pos);
+
+ protected:
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ Gfx::CParticle* m_particle;
+ CSoundInterface* m_sound;
+
+ Math::Point m_pos; // corner upper / left
+ Math::Point m_dim; // dimensions
+ int m_icon;
+ EventType m_eventType; // message to send when clicking
+ int m_state; // states (STATE_ *)
+ float m_fontSize; // size of the button name
+ float m_fontStretch; // stretch of the font
+ Gfx::FontType m_fontType; // type of font
+ Gfx::TextAlign m_textAlign; //type of alignment //comes in the place of m_justif
+ // int m_justif; // type of justification (-1,0,1)
+ std::string m_name; // name of the button
+ std::string m_tooltip; // name of tooltip
+ bool m_bFocus;
+ bool m_bCapture;
+
+ bool m_bGlint;
+ Math::Point m_glintCorner1;
+ Math::Point m_glintCorner2;
+ float m_glintProgress;
+ Math::Point m_glintMouse;
+ };
+
+}
diff --git a/src/ui/displayinfo.cpp b/src/ui/displayinfo.cpp
index 39a4a14..173c100 100644
--- a/src/ui/displayinfo.cpp
+++ b/src/ui/displayinfo.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,53 +18,50 @@
// displayinfo.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
+#include "ui/displayinfo.h"
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/language.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "common/restext.h"
-#include "old/math3d.h"
-#include "object/robotmain.h"
-#include "old/camera.h"
-#include "object/object.h"
-#include "object/motion/motion.h"
-#include "object/motion/motiontoto.h"
#include "ui/interface.h"
#include "ui/button.h"
#include "ui/slider.h"
#include "ui/edit.h"
#include "ui/group.h"
#include "ui/window.h"
-#include "old/particule.h"
-#include "old/light.h"
-#include "old/text.h"
-#include "script/cbottoken.h"
-#include "ui/displayinfo.h"
+#include "common/iman.h"
+#include "common/misc.h"
+#include "common/restext.h"
+
+#include "graphics/core/light.h"
+#include "graphics/engine/engine.h"
+#include "graphics/engine/lightman.h"
+#include "graphics/engine/particle.h"
+
+#include "object/object.h"
+#include "object/robotmain.h"
+#include "object/motion/motion.h"
+#include "object/motion/motiontoto.h"
+#include "script/cbottoken.h"
+#include <string.h>
+
+namespace Ui {
// Object's constructor.
-CDisplayInfo::CDisplayInfo(CInstanceManager* iMan)
+//CDisplayInfo::CDisplayInfo(CInstanceManager* iMan)
+CDisplayInfo::CDisplayInfo()
{
- m_iMan = iMan;
+ m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_STUDIO, this);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
- m_light = (CLight*)m_iMan->SearchInstance(CLASS_LIGHT);
+ m_engine = static_cast <Gfx::CEngine*> (m_iMan->SearchInstance(CLASS_ENGINE));
+ m_event = static_cast <CEventQueue*> (m_iMan->SearchInstance(CLASS_EVENT));
+ m_interface = static_cast <CInterface*> (m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_main = static_cast <CRobotMain*> (m_iMan->SearchInstance(CLASS_MAIN));
+ m_camera = static_cast <Gfx::CCamera*> (m_iMan->SearchInstance(CLASS_CAMERA));
+ m_particle = static_cast <Gfx::CParticle*> (m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_light = static_cast <Gfx::CLightManager*> (m_iMan->SearchInstance(CLASS_LIGHT));
m_bInfoMaximized = true;
m_bInfoMinimized = false;
@@ -87,44 +85,44 @@ CDisplayInfo::~CDisplayInfo()
bool CDisplayInfo::EventProcess(const Event &event)
{
- CWindow* pw;
- CEdit* edit;
- CSlider* slider;
+ Ui::CWindow* pw;
+ Ui::CEdit* edit;
+ Ui::CSlider* slider;
CMotionToto* toto;
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
EventFrame(event);
HyperUpdate();
}
- if ( event.event == EVENT_MOUSEMOVE )
+ if ( event.type == EVENT_MOUSE_MOVE )
{
if ( m_toto != 0 )
{
- toto = (CMotionToto*)m_toto->RetMotion();
+ toto = static_cast<CMotionToto*>(m_toto->GetMotion());
if ( toto != 0 )
{
- toto->SetMousePos(event.pos);
+ toto->SetMousePos(event.mouseMove.pos);
}
}
}
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 )
{
- if ( event.event == pw->RetEventMsgClose() )
+ if ( event.type == pw->GetEventTypeClose() )
{
Event newEvent = event;
- newEvent.event = EVENT_OBJECT_INFOOK;
+ newEvent.type = EVENT_OBJECT_INFOOK;
m_event->AddEvent(newEvent);
}
- if ( event.event == EVENT_SATCOM_HUSTON )
+ if ( event.type == EVENT_SATCOM_HUSTON )
{
ChangeIndexButton(SATCOM_HUSTON);
}
- if ( event.event == EVENT_SATCOM_SAT )
+ if ( event.type == EVENT_SATCOM_SAT )
{
ChangeIndexButton(SATCOM_SAT);
}
@@ -132,90 +130,90 @@ bool CDisplayInfo::EventProcess(const Event &event)
//? {
//? ChangeIndexButton(SATCOM_OBJECT);
//? }
- if ( event.event == EVENT_SATCOM_LOADING )
+ if ( event.type == EVENT_SATCOM_LOADING )
{
ChangeIndexButton(SATCOM_LOADING);
}
- if ( event.event == EVENT_SATCOM_PROG )
+ if ( event.type == EVENT_SATCOM_PROG )
{
ChangeIndexButton(SATCOM_PROG);
}
- if ( event.event == EVENT_SATCOM_SOLUCE )
+ if ( event.type == EVENT_SATCOM_SOLUCE )
{
ChangeIndexButton(SATCOM_SOLUCE);
}
- if ( event.event == EVENT_HYPER_HOME ||
- event.event == EVENT_HYPER_PREV ||
- event.event == EVENT_HYPER_NEXT )
+ if ( event.type == EVENT_HYPER_HOME ||
+ event.type == EVENT_HYPER_PREV ||
+ event.type == EVENT_HYPER_NEXT )
{
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 )
{
- edit->HyperGo(event.event);
+ edit->HyperGo(event.type);
HyperUpdate();
}
}
- if ( event.event == EVENT_HYPER_SIZE1 ) // size 1?
+ if ( event.type == EVENT_HYPER_SIZE1 ) // size 1?
{
m_main->SetFontSize(9.0f);
- slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
- if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
+ slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
+ if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
ViewDisplayInfo();
}
- if ( event.event == EVENT_HYPER_SIZE2 ) // size 2?
+ if ( event.type == EVENT_HYPER_SIZE2 ) // size 2?
{
m_main->SetFontSize(10.0f);
- slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
- if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
+ slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
+ if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
ViewDisplayInfo();
}
- if ( event.event == EVENT_HYPER_SIZE3 ) // size 3?
+ if ( event.type == EVENT_HYPER_SIZE3 ) // size 3?
{
m_main->SetFontSize(12.0f);
- slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
- if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
+ slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
+ if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
ViewDisplayInfo();
}
- if ( event.event == EVENT_HYPER_SIZE4 ) // size 4?
+ if ( event.type == EVENT_HYPER_SIZE4 ) // size 4?
{
m_main->SetFontSize(15.0f);
- slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
- if ( slider != 0 ) slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
+ slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
+ if ( slider != 0 ) slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
ViewDisplayInfo();
}
- if ( event.event == EVENT_STUDIO_SIZE ) // size?
+ if ( event.type == EVENT_STUDIO_SIZE ) // size?
{
- slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
+ slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
if ( slider == 0 ) return false;
- m_main->SetFontSize(9.0f+slider->RetVisibleValue()*6.0f);
+ m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f);
ViewDisplayInfo();
}
- if ( event.event == EVENT_HYPER_COPY ) // copy ?
+ if ( event.type == EVENT_HYPER_COPY ) // copy ?
{
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 )
{
edit->Copy();
}
}
- if ( event.event == EVENT_LBUTTONDOWN ||
- event.event == EVENT_LBUTTONUP )
+ if ( ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 )||
+ ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1 ))
{
UpdateCopyButton();
}
- if ( event.event == EVENT_WINDOW4 ) // window moved?
+ if ( event.type == EVENT_WINDOW4 ) // window moved?
{
- m_infoNormalPos = m_infoActualPos = m_infoFinalPos = pw->RetPos();
- m_infoNormalDim = m_infoActualDim = m_infoFinalDim = pw->RetDim();
+ m_infoNormalPos = m_infoActualPos = m_infoFinalPos = pw->GetPos();
+ m_infoNormalDim = m_infoActualDim = m_infoFinalDim = pw->GetDim();
AdjustDisplayInfo(m_infoActualPos, m_infoActualDim);
}
- if ( event.event == pw->RetEventMsgReduce() )
+ if ( event.type == pw->GetEventTypeReduce() )
{
if ( m_bInfoMinimized )
{
@@ -234,14 +232,14 @@ bool CDisplayInfo::EventProcess(const Event &event)
m_bInfoMaximized = false;
}
//? m_main->SetEditFull(m_bInfoMaximized);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 )
{
pw->SetMaximized(m_bInfoMaximized);
pw->SetMinimized(m_bInfoMinimized);
}
}
- if ( event.event == pw->RetEventMsgFull() )
+ if ( event.type == pw->GetEventTypeFull() )
{
if ( m_bInfoMaximized )
{
@@ -260,7 +258,7 @@ bool CDisplayInfo::EventProcess(const Event &event)
m_bInfoMaximized = true;
}
//? m_main->SetEditFull(m_bInfoMaximized);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 )
{
pw->SetMaximized(m_bInfoMaximized);
@@ -299,31 +297,31 @@ bool CDisplayInfo::EventFrame(const Event &event)
void CDisplayInfo::HyperUpdate()
{
- CWindow* pw;
- CEdit* edit;
- CButton* button;
- bool bEnable;
+ Ui::CWindow* pw;
+ Ui::CEdit* edit;
+ Ui::CButton* button;
+ bool bEnable;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return;
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_HOME);
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_HOME));
if ( button != 0 )
{
bEnable = edit->HyperTest(EVENT_HYPER_HOME);
button->SetState(STATE_ENABLE, bEnable);
}
- button = (CButton*)pw->SearchControl(EVENT_HYPER_PREV);
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_PREV));
if ( button != 0 )
{
bEnable = edit->HyperTest(EVENT_HYPER_PREV);
button->SetState(STATE_ENABLE, bEnable);
}
- button = (CButton*)pw->SearchControl(EVENT_HYPER_NEXT);
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_NEXT));
if ( button != 0 )
{
bEnable = edit->HyperTest(EVENT_HYPER_NEXT);
@@ -334,14 +332,14 @@ void CDisplayInfo::HyperUpdate()
// Beginning of the display of information.
-void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
+void CDisplayInfo::StartDisplayInfo(std::string filename, int index, bool bSoluce)
{
- D3DLIGHT7 light;
+ Gfx::Light light;
Math::Point pos, dim;
- CWindow* pw;
- CEdit* edit;
- CButton* button;
- CSlider* slider;
+ Ui::CWindow* pw;
+ Ui::CEdit* edit;
+ Ui::CButton* button;
+ Ui::CSlider* slider;
CMotionToto* toto;
m_index = index;
@@ -349,10 +347,10 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
//? CreateObjectsFile();
- m_bEditLock = m_main->RetEditLock();
+ m_bEditLock = m_main->GetEditLock();
if ( m_bEditLock ) // edition running program?
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW3));
if ( pw != 0 )
{
pw->ClearState(STATE_ENABLE); // CStudio inactive
@@ -361,10 +359,10 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
m_main->SetEditLock(true, false);
m_main->SetEditFull(false);
- m_bInitPause = m_engine->RetPause();
+ m_bInitPause = m_engine->GetPause();
m_engine->SetPause(true);
- m_infoCamera = m_camera->RetType();
- m_camera->SetType(CAMERA_INFO);
+ m_infoCamera = m_camera->GetType();
+ m_camera->SetType(Gfx::CAM_TYPE_INFO);
pos = m_infoActualPos = m_infoFinalPos;
dim = m_infoActualDim = m_infoFinalDim;
@@ -383,10 +381,10 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
edit->SetState(STATE_SHADOW);
edit->SetMultiFont(true);
edit->SetMaxChar(10000);
- edit->SetFontType(FONT_COLOBOT);
+ edit->SetFontType(Gfx::FONT_COLOBOT);
edit->SetSoluceMode(bSoluce);
- edit->ReadText(filename);
- edit->HyperHome(filename);
+ edit->ReadText(filename.c_str());
+ edit->HyperHome(filename.c_str());
edit->SetEditCap(false); // just to see!
edit->SetHiliteCap(false);
edit->SetFocus(true);
@@ -431,7 +429,7 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
button->SetState(STATE_SHADOW);
slider = pw->CreateSlider(pos, dim, 0, EVENT_STUDIO_SIZE);
slider->SetState(STATE_SHADOW);
- slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
+ slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
button = pw->CreateButton(pos, dim, 61, EVENT_HYPER_COPY);
button->SetState(STATE_SHADOW);
HyperUpdate();
@@ -447,29 +445,27 @@ void CDisplayInfo::StartDisplayInfo(char *filename, int index, bool bSoluce)
m_engine->SetDrawWorld(false); // doesn't draw anything in the interface
m_engine->SetDrawFront(true); // toto draws on the interface
- m_particule->SetFrameUpdate(SH_WORLD, false); // particles break into world
+ m_particle->SetFrameUpdate(Gfx::SH_WORLD, false); // particles break into world
m_toto = SearchToto();
if ( m_toto != 0 )
{
m_toto->SetDrawFront(true);
- toto = (CMotionToto*)m_toto->RetMotion();
+ toto = static_cast<CMotionToto*>(m_toto->GetMotion());
if ( toto != 0 )
{
toto->StartDisplayInfo();
}
}
- ZeroMemory(&light, sizeof(light));
- light.dltType = D3DLIGHT_DIRECTIONAL;
- light.dcvDiffuse.r = 1.0f;
- light.dcvDiffuse.g = 1.0f;
- light.dcvDiffuse.b = 1.0f;
- light.dvDirection = D3DVECTOR(1.0f, 0.0f, 1.0f);
+ light.type = Gfx::LIGHT_DIRECTIONAL;
+ light.diffuse = Gfx::Color(1.0f, 0.1f, 0.1f);
+ light.direction = Math::Vector(1.0f, 0.0f, 1.0f);
+
m_lightSuppl = m_light->CreateLight();
m_light->SetLight(m_lightSuppl, light);
- m_light->SetLightExcluType(m_lightSuppl, TYPETERRAIN);
+ m_light->SetLightExcludeType(m_lightSuppl, Gfx::ENG_OBJTYPE_TERRAIN);
}
// Repositions all controls editing.
@@ -483,31 +479,31 @@ void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim)
CGroup* group;
Math::Point pos, dim;
- wpos.x = 50.0f/640.0f;
- wpos.y = 30.0f/480.0f;
- wdim.x = 540.0f/640.0f;
- wdim.y = 420.0f/480.0f;
+ wpos.x = 50.0f / 640.0f;
+ wpos.y = 30.0f / 480.0f;
+ wdim.x = 540.0f / 640.0f;
+ wdim.y = 420.0f / 480.0f;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 )
{
pw->SetPos(wpos);
pw->SetDim(wdim);
- wdim = pw->RetDim();
+ wdim = pw->GetDim();
}
- pos.x = (50.0f+10.0f)/640.0f;
- pos.y = (30.0f+10.0f+24.0f+10.0f+324.0f-48.0f)/480.0f;
- dim.x = 48.0f/640.0f;
- dim.y = 48.0f/480.0f;
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_HUSTON);
+ pos.x = (50.0f + 10.0f) / 640.0f;
+ pos.y = (30.0f + 10.0f + 24.0f + 10.0f + 324.0f - 48.0f) / 480.0f;
+ dim.x = 48.0f / 640.0f;
+ dim.y = 48.0f / 480.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_HUSTON));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.y -= (48.0f+4.0f)/480.0f;
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_SAT);
+ pos.y -= (48.0f + 4.0f) / 480.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SAT));
if ( button != 0 )
{
button->SetPos(pos);
@@ -520,136 +516,136 @@ void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim)
//? button->SetPos(pos);
//? button->SetDim(dim);
//? }
- pos.y -= (48.0f+4.0f)/480.0f;
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_LOADING);
+ pos.y -= (48.0f + 4.0f) / 480.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_LOADING));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.y -= (48.0f+4.0f)/480.0f;
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_PROG);
+ pos.y -= (48.0f + 4.0f) / 480.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_PROG));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.y -= (48.0f+4.0f)/480.0f;
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_SOLUCE);
+ pos.y -= (48.0f + 4.0f) / 480.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SOLUCE));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x = (50.0f+10.0f+5.0f)/640.0f;
- pos.y = (30.0f+10.0f+4.0f)/480.0f;
- dim.x = (48.0f-10.0f)/640.0f;
- dim.y = 24.0f/480.0f;
- button = (CButton*)pw->SearchControl(EVENT_OBJECT_INFOOK);
+ pos.x = (50.0f + 10.0f + 5.0f) / 640.0f;
+ pos.y = (30.0f + 10.0f + 4.0f) / 480.0f;
+ dim.x = (48.0f - 10.0f) / 640.0f;
+ dim.y = 24.0f / 480.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_OBJECT_INFOOK));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x = (50.0f+10.0f+48.0f+10.0f)/640.0f;
- pos.y = (30.0f+10.0f)/480.0f;
- dim.x = 462.0f/640.0f;
- dim.y = 358.0f/480.0f;
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ pos.x = (50.0f + 10.0f + 48.0f + 10.0f) / 640.0f;
+ pos.y = (30.0f + 10.0f) / 480.0f;
+ dim.x = 462.0f / 640.0f;
+ dim.y = 358.0f / 480.0f;
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 )
{
edit->SetPos(pos);
edit->SetDim(dim);
}
- pos.x = (50.0f+10.0f+48.0f+10.0f)/640.0f;
- pos.y = (30.0f+10.0f+358.0f+10.0f)/480.0f;
- dim.x = 32.0f/640.0f;
- dim.y = 32.0f/480.0f;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_PREV);
+ pos.x = (50.0f + 10.0f + 48.0f + 10.0f) / 640.0f;
+ pos.y = (30.0f + 10.0f + 358.0f + 10.0f) / 480.0f;
+ dim.x = 32.0f / 640.0f;
+ dim.y = 32.0f / 480.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_PREV));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x += 35.0f/640.0f;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_NEXT);
+ pos.x += 35.0f / 640.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_NEXT));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x += 35.0f/640.0f;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_HOME);
+ pos.x += 35.0f / 640.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_HOME));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x += 50.0f/640.0f;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE1);
+ pos.x += 50.0f / 640.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE1));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x += 35.0f/640.0f;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE2);
+ pos.x += 35.0f / 640.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE2));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x += 35.0f/640.0f;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE3);
+ pos.x += 35.0f / 640.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE3));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x += 35.0f/640.0f;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_SIZE4);
+ pos.x += 35.0f / 640.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_SIZE4));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x += 35.0f/640.0f;
- dim.x = 18.0f/640.0f;
- slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
+ pos.x += 35.0f / 640.0f;
+ dim.x = 18.0f / 640.0f;
+ slider = static_cast<Ui::CSlider*>(pw->SearchControl(EVENT_STUDIO_SIZE));
if ( slider != 0 )
{
slider->SetPos(pos);
slider->SetDim(dim);
}
- pos.x += 50.0f/640.0f;
- dim.x = 32.0f/640.0f;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_COPY);
+ pos.x += 50.0f / 640.0f;
+ dim.x = 32.0f / 640.0f;
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_COPY));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
- pos.x = (50.0f+10.0f)/640.0f;
- pos.y = (30.0f+10.0f+24.0f+10.0f+324.0f+6.0f)/480.0f;
- dim.x = 48.0f/640.0f;
- dim.y = 40.0f/480.0f;
- group = (CGroup*)pw->SearchControl(EVENT_LABEL2); // symbol SatCom
+ pos.x = (50.0f + 10.0f) / 640.0f;
+ pos.y = (30.0f + 10.0f + 24.0f + 10.0f + 324.0f + 6.0f) / 480.0f;
+ dim.x = 48.0f / 640.0f;
+ dim.y = 40.0f / 480.0f;
+ group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL2)); // symbol SatCom
if ( group != 0 )
{
group->SetPos(pos);
group->SetDim(dim);
}
- pos.x = (50.0f+10.0f+14.0f)/640.0f;
- pos.y = (30.0f+10.0f+6.0f)/480.0f;
- dim.x = 20.0f/640.0f;
- dim.y = 20.0f/480.0f;
- group = (CGroup*)pw->SearchControl(EVENT_LABEL3); // symbol stand-by
+ pos.x = (50.0f + 10.0f + 14.0f) / 640.0f;
+ pos.y = (30.0f + 10.0f + 6.0f) / 480.0f;
+ dim.x = 20.0f / 640.0f;
+ dim.y = 20.0f / 480.0f;
+ group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL3)); // symbol stand-by
if ( group != 0 )
{
group->SetPos(pos);
@@ -661,26 +657,26 @@ void CDisplayInfo::AdjustDisplayInfo(Math::Point wpos, Math::Point wdim)
void CDisplayInfo::ChangeIndexButton(int index)
{
- CWindow* pw;
- CEdit* edit;
+ Ui::CWindow* pw;
+ Ui::CEdit* edit;
char* filename;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return;
if ( m_index != -1 )
{
- m_main->SetDisplayInfoPosition(m_index, RetPosition());
+ m_main->SetDisplayInfoPosition(m_index, GetPosition());
}
m_index = index;
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 )
{
- filename = m_main->RetDisplayInfoName(m_index);
+ filename = m_main->GetDisplayInfoName(m_index);
edit->ReadText(filename);
edit->HyperHome(filename);
- SetPosition(m_main->RetDisplayInfoPosition(m_index));
+ SetPosition(m_main->GetDisplayInfoPosition(m_index));
}
UpdateIndexButton();
@@ -690,10 +686,10 @@ void CDisplayInfo::ChangeIndexButton(int index)
void CDisplayInfo::UpdateIndexButton()
{
- CWindow* pw;
- CButton* button;
- CGroup* group;
- CEdit* edit;
+ Ui::CWindow* pw;
+ Ui::CButton* button;
+ Ui::CGroup* group;
+ Ui::CEdit* edit;
Math::Point pos, dim;
char* filename;
char* loading;
@@ -708,22 +704,22 @@ void CDisplayInfo::UpdateIndexButton()
4, // SATCOM_SOLUCE
};
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return;
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_HUSTON);
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_HUSTON));
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_HUSTON);
- filename = m_main->RetDisplayInfoName(SATCOM_HUSTON);
+ filename = m_main->GetDisplayInfoName(SATCOM_HUSTON);
button->SetState(STATE_VISIBLE, filename[0]!=0);
}
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_SAT);
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SAT));
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_SAT);
- filename = m_main->RetDisplayInfoName(SATCOM_SAT);
+ filename = m_main->GetDisplayInfoName(SATCOM_SAT);
button->SetState(STATE_VISIBLE, filename[0]!=0);
}
@@ -731,36 +727,36 @@ void CDisplayInfo::UpdateIndexButton()
//? if ( button != 0 )
//? {
//? button->SetState(STATE_CHECK, m_index==SATCOM_OBJECT);
-//? filename = m_main->RetDisplayInfoName(SATCOM_OBJECT);
+//? filename = m_main->GetDisplayInfoName(SATCOM_OBJECT);
//? button->SetState(STATE_VISIBLE, filename[0]!=0);
//? }
loading = 0;
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_LOADING);
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_LOADING));
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_LOADING);
- loading = m_main->RetDisplayInfoName(SATCOM_LOADING);
+ loading = m_main->GetDisplayInfoName(SATCOM_LOADING);
button->SetState(STATE_VISIBLE, loading[0]!=0);
}
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_PROG);
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_PROG));
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_PROG);
- filename = m_main->RetDisplayInfoName(SATCOM_PROG);
+ filename = m_main->GetDisplayInfoName(SATCOM_PROG);
button->SetState(STATE_VISIBLE, filename[0]!=0 && (m_index==SATCOM_LOADING||m_index==SATCOM_PROG||(loading!=0&&loading[0]==0)));
}
- button = (CButton*)pw->SearchControl(EVENT_SATCOM_SOLUCE);
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_SATCOM_SOLUCE));
if ( button != 0 )
{
button->SetState(STATE_CHECK, m_index==SATCOM_SOLUCE);
- filename = m_main->RetDisplayInfoName(SATCOM_SOLUCE);
+ filename = m_main->GetDisplayInfoName(SATCOM_SOLUCE);
button->SetState(STATE_VISIBLE, filename[0]!=0 && m_bSoluce);
}
- group = (CGroup*)pw->SearchControl(EVENT_LABEL1);
+ group = static_cast<Ui::CGroup*>(pw->SearchControl(EVENT_LABEL1));
if ( group != 0 )
{
if ( m_index == -1 )
@@ -789,7 +785,7 @@ void CDisplayInfo::UpdateIndexButton()
}
#endif
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit != 0 )
{
//? edit->SetHiliteCap(m_index==SATCOM_LOADING);
@@ -803,20 +799,20 @@ void CDisplayInfo::UpdateIndexButton()
void CDisplayInfo::UpdateCopyButton()
{
- CWindow* pw;
- CButton* button;
- CEdit* edit;
+ Ui::CWindow* pw;
+ Ui::CButton* button;
+ Ui::CEdit* edit;
int c1, c2;
//? if ( m_index != SATCOM_LOADING ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return;
- button = (CButton*)pw->SearchControl(EVENT_HYPER_COPY);
+ button = static_cast<Ui::CButton*>(pw->SearchControl(EVENT_HYPER_COPY));
if ( button == 0 ) return;
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return;
edit->GetCursor(c1, c2);
@@ -828,17 +824,17 @@ void CDisplayInfo::UpdateCopyButton()
void CDisplayInfo::StopDisplayInfo()
{
- CWindow* pw;
+ Ui::CWindow* pw;
CMotionToto* toto;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return;
m_interface->DeleteControl(EVENT_WINDOW4);
if ( m_bEditLock ) // editing running program?
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
+ pw = dynamic_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3));
if ( pw != 0 )
{
pw->SetState(STATE_ENABLE); // CStudio operating
@@ -853,13 +849,13 @@ void CDisplayInfo::StopDisplayInfo()
m_engine->SetDrawWorld(true); // draws all on the interface
m_engine->SetDrawFront(false); // draws nothing on the interface
- m_particule->SetFrameUpdate(SH_WORLD, true);
- m_particule->FlushParticule(SH_FRONT);
- m_particule->FlushParticule(SH_INTERFACE);
+ m_particle->SetFrameUpdate(Gfx::SH_WORLD, true);
+ m_particle->FlushParticle(Gfx::SH_FRONT);
+ m_particle->FlushParticle(Gfx::SH_INTERFACE);
if ( m_toto != 0 )
{
- toto = (CMotionToto*)m_toto->RetMotion();
+ toto = static_cast<CMotionToto*>(m_toto->GetMotion());
if ( toto != 0 )
{
toto->StopDisplayInfo();
@@ -875,13 +871,13 @@ void CDisplayInfo::StopDisplayInfo()
void CDisplayInfo::SetPosition(int pos)
{
- CWindow* pw;
- CEdit* edit;
+ Ui::CWindow* pw;
+ Ui::CEdit* edit;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return;
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return;
edit->SetFirstLine(pos);
@@ -889,18 +885,18 @@ void CDisplayInfo::SetPosition(int pos)
// Returns the position.
-int CDisplayInfo::RetPosition()
+int CDisplayInfo::GetPosition()
{
- CWindow* pw;
- CEdit* edit;
+ Ui::CWindow* pw;
+ Ui::CEdit* edit;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return 0;
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return 0;
- return edit->RetFirstLine();
+ return edit->GetFirstLine();
}
@@ -909,18 +905,18 @@ int CDisplayInfo::RetPosition()
void CDisplayInfo::ViewDisplayInfo()
{
- CWindow* pw;
- CEdit* edit;
- POINT dim;
+ Ui::CWindow* pw;
+ Ui::CEdit* edit;
+ Math::IntPoint dim;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw == 0 ) return;
- edit = (CEdit*)pw->SearchControl(EVENT_EDIT1);
+ edit = static_cast<Ui::CEdit*>(pw->SearchControl(EVENT_EDIT1));
if ( edit == 0 ) return;
- dim = m_engine->RetDim();
- edit->SetFontSize(m_main->RetFontSize()/(dim.x/640.0f));
+ dim = m_engine->GetWindowSize();
+ edit->SetFontSize(m_main->GetFontSize()/(dim.x / 640.0f));
}
// Returns the object human.
@@ -933,10 +929,10 @@ CObject* CDisplayInfo::SearchToto()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_TOTO )
{
return pObj;
@@ -995,7 +991,7 @@ void ObjectWrite(FILE* file, ObjectList list[], int i)
strcat(line, res);
strcat(line, "\\u ");
- p = RetHelpFilename(list[i].type);
+ p = const_cast<char*>(GetHelpFilename(list[i].type));
if ( p[0] == 0 ) return;
strcat(line, p+5); // skip "help\"
p = strstr(line, ".txt");
@@ -1023,14 +1019,14 @@ void CDisplayInfo::CreateObjectsFile()
bRadar = false;
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetActif() ) continue;
- if ( !pObj->RetSelectable() ) continue;
- if ( pObj->RetProxyActivate() ) continue;
+ if ( !pObj->GetActif() ) continue;
+ if ( !pObj->GetSelectable() ) continue;
+ if ( pObj->GetProxyActivate() ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_NULL ) continue;
if ( type == OBJECT_FIX ) continue;
@@ -1217,3 +1213,4 @@ void CDisplayInfo::CreateObjectsFile()
}
+}
diff --git a/src/ui/displayinfo.h b/src/ui/displayinfo.h
index 29677d4..2eabbf2 100644
--- a/src/ui/displayinfo.h
+++ b/src/ui/displayinfo.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,73 +19,81 @@
#pragma once
+#include <string>
-#include "common/struct.h"
-#include "old/camera.h"
+#include "common/event.h"
+#include "graphics/engine/camera.h"
class CInstanceManager;
-class CD3DEngine;
-class CEvent;
class CRobotMain;
-class CCamera;
-class CInterface;
class CObject;
-class CParticule;
-class CLight;
-
-
-class CDisplayInfo
-{
-public:
- CDisplayInfo(CInstanceManager* iMan);
- ~CDisplayInfo();
-
- bool EventProcess(const Event &event);
-
- void StartDisplayInfo(char *filename, int index, bool bSoluce);
- void StopDisplayInfo();
-
- void SetPosition(int pos);
- int RetPosition();
-
-protected:
- bool EventFrame(const Event &event);
- void HyperUpdate();
- void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim);
- void ChangeIndexButton(int index);
- void UpdateIndexButton();
- void UpdateCopyButton();
- void ViewDisplayInfo();
- CObject* SearchToto();
- void CreateObjectsFile();
-
-protected:
- CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CEvent* m_event;
- CRobotMain* m_main;
- CCamera* m_camera;
- CInterface* m_interface;
- CParticule* m_particule;
- CLight* m_light;
-
- bool m_bInfoMaximized;
- bool m_bInfoMinimized;
-
- int m_index;
- CameraType m_infoCamera;
- Math::Point m_infoNormalPos;
- Math::Point m_infoNormalDim;
- Math::Point m_infoActualPos;
- Math::Point m_infoActualDim;
- Math::Point m_infoFinalPos;
- Math::Point m_infoFinalDim;
- int m_lightSuppl;
- bool m_bEditLock;
- bool m_bInitPause;
- bool m_bSoluce;
- CObject* m_toto;
-};
-
-
+class CEventQueue;
+
+struct Event;
+
+namespace Gfx {
+ class CEngine;
+ class CParticle;
+ class CLightManager;
+}
+
+namespace Ui {
+ class CInterface;
+
+ class CDisplayInfo
+ {
+ public:
+ // CDisplayInfo(CInstanceManager* iMan);
+ CDisplayInfo();
+ ~CDisplayInfo();
+
+ bool EventProcess(const Event &event);
+
+ void StartDisplayInfo(std::string filename, int index, bool bSoluce);
+ void StopDisplayInfo();
+
+ void SetPosition(int pos);
+ int GetPosition();
+
+ protected:
+ bool EventFrame(const Event &event);
+ void HyperUpdate();
+ void AdjustDisplayInfo(Math::Point wpos, Math::Point wdim);
+ void ChangeIndexButton(int index);
+ void UpdateIndexButton();
+ void UpdateCopyButton();
+ void ViewDisplayInfo();
+ CObject* SearchToto();
+ void CreateObjectsFile();
+
+ protected:
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ Gfx::CCamera* m_camera;
+ CInterface* m_interface;
+ Gfx::CParticle* m_particle;
+ Gfx::CLightManager* m_light;
+
+ bool m_bInfoMaximized;
+ bool m_bInfoMinimized;
+
+ int m_index;
+ Gfx::CameraType m_infoCamera;
+ Math::Point m_infoNormalPos;
+ Math::Point m_infoNormalDim;
+ Math::Point m_infoActualPos;
+ Math::Point m_infoActualDim;
+ Math::Point m_infoFinalPos;
+ Math::Point m_infoFinalDim;
+ int m_lightSuppl;
+ bool m_bEditLock;
+ bool m_bInitPause;
+ bool m_bSoluce;
+ CObject* m_toto;
+ };
+
+
+}
diff --git a/src/ui/displaytext.cpp b/src/ui/displaytext.cpp
index 9be81f4..7c60f8b 100644
--- a/src/ui/displaytext.cpp
+++ b/src/ui/displaytext.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,46 +18,46 @@
// displaytext.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
+#include "ui/displaytext.h"
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/restext.h"
-#include "common/iman.h"
-#include "object/object.h"
-#include "object/motion/motion.h"
-#include "object/motion/motiontoto.h"
#include "ui/interface.h"
#include "ui/button.h"
#include "ui/label.h"
#include "ui/window.h"
#include "ui/group.h"
-#include "old/text.h"
-#include "old/sound.h"
-#include "ui/displaytext.h"
+#include "common/event.h"
+#include "common/iman.h"
+#include "common/restext.h"
+
+#include "graphics/engine/engine.h"
+#include "object/object.h"
+#include "object/motion/motion.h"
+#include "object/motion/motiontoto.h"
+
+
+
+namespace Ui {
const float FONTSIZE = 12.0f;
// Object's constructor.
-CDisplayText::CDisplayText(CInstanceManager* iMan)
+//CDisplayText::CDisplayText(CInstanceManager* iMan)
+CDisplayText::CDisplayText()
{
int i;
- m_iMan = iMan;
+// m_iMan = iMan;
+ m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_DISPLAYTEXT, this);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
for ( i=0 ; i<MAXDTLINE ; i++ )
{
@@ -94,9 +95,9 @@ bool CDisplayText::EventProcess(const Event &event)
{
int i;
- if ( m_engine->RetPause() ) return true;
+ if ( m_engine->GetPause() ) return true;
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
for ( i=0 ; i<MAXDTLINE ; i++ )
{
@@ -124,9 +125,9 @@ void CDisplayText::DisplayError(Error err, CObject* pObj, float time)
if ( pObj == 0 ) return;
- pos = pObj->RetPosition(0);
- h = RetIdealHeight(pObj);
- d = RetIdealDist(pObj);
+ pos = pObj->GetPosition(0);
+ h = GetIdealHeight(pObj);
+ d = GetIdealDist(pObj);
DisplayError(err, pos, h, d, time);
}
@@ -178,7 +179,7 @@ void CDisplayText::DisplayError(Error err, Math::Vector goal, float height,
// Displays text.
-void CDisplayText::DisplayText(char *text, CObject* pObj,
+void CDisplayText::DisplayText(const char *text, CObject* pObj,
float time, TextType type)
{
Math::Vector pos;
@@ -186,23 +187,23 @@ void CDisplayText::DisplayText(char *text, CObject* pObj,
if ( pObj == 0 ) return;
- pos = pObj->RetPosition(0);
- h = RetIdealHeight(pObj);
- d = RetIdealDist(pObj);
+ pos = pObj->GetPosition(0);
+ h = GetIdealHeight(pObj);
+ d = GetIdealDist(pObj);
DisplayText(text, pos, h, d, time, type);
}
// Displays text.
-void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
+void CDisplayText::DisplayText(const char *text, Math::Vector goal, float height,
float dist, float time, TextType type)
{
CObject* toto;
CMotion* motion;
- CWindow* pw;
- CButton* button;
- CGroup* group;
- CLabel* label;
+ Ui::CWindow* pw;
+ Ui::CButton* button;
+ Ui::CGroup* group;
+ Ui::CLabel* label;
Math::Point pos, ppos, dim;
Sound sound;
float hLine, hBox;
@@ -210,7 +211,7 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
if ( !m_bEnable ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 )
{
pos.x = 0.0f;
@@ -221,12 +222,12 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
}
hBox = 0.045f;
- hLine = m_engine->RetText()->RetHeight(FONTSIZE, FONT_COLOBOT);
+ hLine = m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, FONTSIZE);
nLine = 0;
for ( i=0 ; i<MAXDTLINE ; i++ )
{
- group = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i));
+ group = static_cast<CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i)));
if ( group == 0 ) break;
nLine ++;
}
@@ -247,13 +248,13 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
if ( type == TT_WARNING ) icon = 10; // blue
if ( type == TT_INFO ) icon = 8; // green
if ( type == TT_MESSAGE ) icon = 11; // yellow
- pw->CreateGroup(pos, dim, icon, EventMsg(EVENT_DT_GROUP0+nLine));
+ pw->CreateGroup(pos, dim, icon, EventType(EVENT_DT_GROUP0+nLine));
pw->SetTrashEvent(false);
ppos = pos;
ppos.y -= hLine/2.0f;
- label = pw->CreateLabel(ppos, dim, -1, EventMsg(EVENT_DT_LABEL0+nLine), text);
+ label = pw->CreateLabel(ppos, dim, -1, EventType(EVENT_DT_LABEL0+nLine), text);
if ( label != 0 )
{
label->SetFontSize(FONTSIZE);
@@ -261,7 +262,7 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
dim.x = dim.y*0.75f;
pos.x -= dim.x;
- button = pw->CreateButton(pos, dim, 14, EventMsg(EVENT_DT_VISIT0+nLine));
+ button = pw->CreateButton(pos, dim, 14, EventType(EVENT_DT_VISIT0+nLine));
if ( goal.x == 0.0f &&
goal.y == 0.0f &&
@@ -279,7 +280,7 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
toto = SearchToto();
if ( toto != 0 )
{
- motion = toto->RetMotion();
+ motion = toto->GetMotion();
if ( motion != 0 )
{
if ( type == TT_ERROR )
@@ -324,18 +325,18 @@ void CDisplayText::DisplayText(char *text, Math::Vector goal, float height,
void CDisplayText::ClearText()
{
- CWindow* pw;
+ Ui::CWindow* pw;
int i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
for ( i=0 ; i<MAXDTLINE ; i++ )
{
if ( pw != 0 )
{
- pw->DeleteControl(EventMsg(EVENT_DT_GROUP0+i));
- pw->DeleteControl(EventMsg(EVENT_DT_LABEL0+i));
- pw->DeleteControl(EventMsg(EVENT_DT_VISIT0+i));
+ pw->DeleteControl(EventType(EVENT_DT_GROUP0+i));
+ pw->DeleteControl(EventType(EVENT_DT_LABEL0+i));
+ pw->DeleteControl(EventType(EVENT_DT_VISIT0+i));
}
m_bExist[i] = false;
m_visitGoal[i] = Math::Vector(0.0f, 0.0f, 0.0f);
@@ -349,32 +350,32 @@ void CDisplayText::ClearText()
void CDisplayText::HideText(bool bHide)
{
- CWindow* pw;
- CGroup* pg;
- CLabel* pl;
- CButton* pb;
+ Ui::CWindow* pw;
+ Ui::CGroup* pg;
+ Ui::CLabel* pl;
+ Ui::CButton* pb;
int i;
m_bHide = bHide;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
+ pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return;
for ( i=0 ; i<MAXDTLINE ; i++ )
{
- pg = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i));
+ pg = static_cast<Ui::CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i)));
if ( pg != 0 )
{
pg->SetState(STATE_VISIBLE, !bHide);
}
- pl = (CLabel* )pw->SearchControl(EventMsg(EVENT_DT_LABEL0+i));
+ pl = static_cast<Ui::CLabel*>(pw->SearchControl(EventType(EVENT_DT_LABEL0+i)));
if ( pl != 0 )
{
pl->SetState(STATE_VISIBLE, !bHide);
}
- pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i));
+ pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i)));
if ( pb != 0 )
{
pb->SetState(STATE_VISIBLE, !bHide);
@@ -386,20 +387,20 @@ void CDisplayText::HideText(bool bHide)
bool CDisplayText::ClearLastText()
{
- CWindow *pw;
- CButton *pb1, *pb2;
- CGroup *pg1, *pg2;
- CLabel *pl1, *pl2;
+ Ui::CWindow *pw;
+ Ui::CButton *pb1, *pb2;
+ Ui::CGroup *pg1, *pg2;
+ Ui::CLabel *pl1, *pl2;
int i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return false;
- pb2 = (CButton*)pw->SearchControl(EVENT_DT_VISIT0);
+ pb2 = static_cast<CButton*>(pw->SearchControl(EVENT_DT_VISIT0));
if ( pb2 == 0 ) return false; // same not of first-line
- pg2 = (CGroup*)pw->SearchControl(EVENT_DT_GROUP0);
+ pg2 = static_cast<CGroup*>(pw->SearchControl(EVENT_DT_GROUP0));
if ( pg2 == 0 ) return false;
- pl2 = (CLabel*)pw->SearchControl(EVENT_DT_LABEL0);
+ pl2 = static_cast<CLabel*>(pw->SearchControl(EVENT_DT_LABEL0));
if ( pl2 == 0 ) return false;
for ( i=0 ; i<MAXDTLINE-1 ; i++ )
@@ -408,18 +409,18 @@ bool CDisplayText::ClearLastText()
pg1 = pg2;
pl1 = pl2;
- pb2 = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i+1));
+ pb2 = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i+1)));
if ( pb2 == 0 ) break;
- pg2 = (CGroup*)pw->SearchControl(EventMsg(EVENT_DT_GROUP0+i+1));
+ pg2 = static_cast<CGroup*>(pw->SearchControl(EventType(EVENT_DT_GROUP0+i+1)));
if ( pg2 == 0 ) break;
- pl2 = (CLabel*)pw->SearchControl(EventMsg(EVENT_DT_LABEL0+i+1));
+ pl2 = static_cast<CLabel*>(pw->SearchControl(EventType(EVENT_DT_LABEL0+i+1)));
if ( pl2 == 0 ) break;
pb1->SetState(STATE_ENABLE, pb2->TestState(STATE_ENABLE));
- pg1->SetIcon(pg2->RetIcon());
- pl1->SetName(pl2->RetName());
+ pg1->SetIcon(pg2->GetIcon());
+ pl1->SetName(pl2->GetName());
m_time[i] = m_time[i+1];
m_visitGoal[i] = m_visitGoal[i+1];
@@ -427,9 +428,9 @@ bool CDisplayText::ClearLastText()
m_visitHeight[i] = m_visitHeight[i+1]; // shift
}
- pw->DeleteControl(EventMsg(EVENT_DT_VISIT0+i));
- pw->DeleteControl(EventMsg(EVENT_DT_GROUP0+i));
- pw->DeleteControl(EventMsg(EVENT_DT_LABEL0+i));
+ pw->DeleteControl(EventType(EVENT_DT_VISIT0+i));
+ pw->DeleteControl(EventType(EVENT_DT_GROUP0+i));
+ pw->DeleteControl(EventType(EVENT_DT_LABEL0+i));
m_bExist[i] = false;
return true;
}
@@ -453,7 +454,7 @@ void CDisplayText::SetEnable(bool bEnable)
// Returns the goal during a visit.
-Math::Vector CDisplayText::RetVisitGoal(EventMsg event)
+Math::Vector CDisplayText::GetVisitGoal(EventType event)
{
int i;
@@ -464,7 +465,7 @@ Math::Vector CDisplayText::RetVisitGoal(EventMsg event)
// Returns the distance during a visit.
-float CDisplayText::RetVisitDist(EventMsg event)
+float CDisplayText::GetVisitDist(EventType event)
{
int i;
@@ -475,7 +476,7 @@ float CDisplayText::RetVisitDist(EventMsg event)
// Returns the height on a visit.
-float CDisplayText::RetVisitHeight(EventMsg event)
+float CDisplayText::GetVisitHeight(EventType event)
{
int i;
@@ -487,13 +488,13 @@ float CDisplayText::RetVisitHeight(EventMsg event)
// Ranges from ideal visit for a given object.
-float CDisplayText::RetIdealDist(CObject* pObj)
+float CDisplayText::GetIdealDist(CObject* pObj)
{
ObjectType type;
if ( pObj == 0 ) return 40.0f;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_PORTICO ) return 200.0f;
if ( type == OBJECT_BASE ) return 200.0f;
if ( type == OBJECT_NUCLEAR ) return 100.0f;
@@ -506,13 +507,13 @@ float CDisplayText::RetIdealDist(CObject* pObj)
// Returns the height of ideal visit for a given object.
-float CDisplayText::RetIdealHeight(CObject* pObj)
+float CDisplayText::GetIdealHeight(CObject* pObj)
{
ObjectType type;
if ( pObj == 0 ) return 5.0f;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_DERRICK ) return 35.0f;
if ( type == OBJECT_FACTORY ) return 22.0f;
if ( type == OBJECT_REPAIR ) return 30.0f;
@@ -537,16 +538,16 @@ float CDisplayText::RetIdealHeight(CObject* pObj)
void CDisplayText::ClearVisit()
{
- CWindow* pw;
- CButton* pb;
+ Ui::CWindow* pw;
+ Ui::CButton* pb;
int i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return;
for ( i=0 ; i<MAXDTLINE ; i++ )
{
- pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i));
+ pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i)));
if ( pb == 0 ) break;
pb->SetIcon(14); // eyes
}
@@ -554,38 +555,38 @@ void CDisplayText::ClearVisit()
// Puts a button in "visit".
-void CDisplayText::SetVisit(EventMsg event)
+void CDisplayText::SetVisit(EventType event)
{
- CWindow* pw;
- CButton* pb;
+ Ui::CWindow* pw;
+ Ui::CButton* pb;
int i;
i = event-EVENT_DT_VISIT0;
if ( i < 0 || i >= MAXDTLINE ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return;
- pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i));
+ pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i)));
if ( pb == 0 ) return;
pb->SetIcon(48); // >
}
// Indicates whether a button is set to "visit".
-bool CDisplayText::IsVisit(EventMsg event)
+bool CDisplayText::IsVisit(EventType event)
{
- CWindow* pw;
- CButton* pb;
+ Ui::CWindow* pw;
+ Ui::CButton* pb;
int i;
i = event-EVENT_DT_VISIT0;
if ( i < 0 || i >= MAXDTLINE ) return false;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw == 0 ) return false;
- pb = (CButton*)pw->SearchControl(EventMsg(EVENT_DT_VISIT0+i));
+ pb = static_cast<CButton*>(pw->SearchControl(EventType(EVENT_DT_VISIT0+i)));
if ( pb == 0 ) return false;
- return (pb->RetIcon() == 48); // > ?
+ return (pb->GetIcon() == 48); // > ?
}
@@ -599,10 +600,10 @@ CObject* CDisplayText::SearchToto()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_TOTO )
{
return pObj;
@@ -611,3 +612,4 @@ CObject* CDisplayText::SearchToto()
return 0;
}
+}
diff --git a/src/ui/displaytext.h b/src/ui/displaytext.h
index c2eea98..5714cc5 100644
--- a/src/ui/displaytext.h
+++ b/src/ui/displaytext.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -20,16 +21,24 @@
#include "common/event.h"
-#include "common/misc.h"
-#include "old/d3dengine.h"
+#include "common/global.h"
+
+#include "sound/sound.h"
+
class CInstanceManager;
-class CD3DEngine;
-class CInterface;
+//class CD3DEngine
class CObject;
class CSound;
+namespace Gfx {
+ class CEngine;
+}
+
+namespace Ui {;
+
+class CInterface;
enum TextType
{
@@ -45,7 +54,8 @@ const int MAXDTLINE = 4;
class CDisplayText
{
public:
- CDisplayText(CInstanceManager* iMan);
+// CDisplayText(CInstanceManager* iMan);
+ CDisplayText();
~CDisplayText();
void DeleteObject();
@@ -54,33 +64,33 @@ public:
void DisplayError(Error err, CObject* pObj, float time=10.0f);
void DisplayError(Error err, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f);
- void DisplayText(char *text, CObject* pObj, float time=10.0f, TextType type=TT_INFO);
- void DisplayText(char *text, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f, TextType type=TT_INFO);
+ void DisplayText(const char *text, CObject* pObj, float time=10.0f, TextType type=TT_INFO);
+ void DisplayText(const char *text, Math::Vector goal, float height=15.0f, float dist=60.0f, float time=10.0f, TextType type=TT_INFO);
void HideText(bool bHide);
void ClearText();
bool ClearLastText();
void SetDelay(float factor);
void SetEnable(bool bEnable);
- Math::Vector RetVisitGoal(EventMsg event);
- float RetVisitDist(EventMsg event);
- float RetVisitHeight(EventMsg event);
+ Math::Vector GetVisitGoal(EventType event);
+ float GetVisitDist(EventType event);
+ float GetVisitHeight(EventType event);
- float RetIdealDist(CObject* pObj);
- float RetIdealHeight(CObject* pObj);
+ float GetIdealDist(CObject* pObj);
+ float GetIdealHeight(CObject* pObj);
void ClearVisit();
- void SetVisit(EventMsg event);
- bool IsVisit(EventMsg event);
+ void SetVisit(EventType event);
+ bool IsVisit(EventType event);
protected:
CObject* SearchToto();
protected:
CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CInterface* m_interface;
- CSound* m_sound;
+ Gfx::CEngine* m_engine;
+ Ui::CInterface* m_interface;
+ CSoundInterface* m_sound;
bool m_bExist[MAXDTLINE];
float m_time[MAXDTLINE];
@@ -94,3 +104,4 @@ protected:
};
+}
diff --git a/src/ui/edit.cpp b/src/ui/edit.cpp
index 58a8b7d..e2baae9 100644
--- a/src/ui/edit.cpp
+++ b/src/ui/edit.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -16,38 +17,28 @@
// edit.cpp
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <windows.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "common/language.h"
-#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "common/restext.h"
-#include "ui/scroll.h"
-#include "old/text.h"
+#include "app/app.h"
#include "ui/edit.h"
+#include <string.h>
+
+namespace Ui {
const float MARGX = (5.0f/640.0f);
const float MARGY = (5.0f/480.0f);
const float MARGYS = (4.0f/480.0f);
const float MARGY1 = (1.0f/480.0f);
-const float DELAY_DBCLICK = 0.3f; // time limit for double-click
-const float DELAY_SCROLL = 0.1f; // time limit for scroll
-const float BIG_FONT = 1.6f; // expansion for \b;
+//! time limit for double-click
+const float DELAY_DBCLICK = 0.3f;
+//! time limit for scroll
+const float DELAY_SCROLL = 0.1f;
+//! expansion for \b;
+const float BIG_FONT = 1.6f;
-// Indicates whether a character is a space.
+//! Indicates whether a character is a space.
bool IsSpace(int character)
{
@@ -56,20 +47,20 @@ bool IsSpace(int character)
character == '\n' );
}
-// Indicates whether a character is part of a word.
+//! Indicates whether a character is part of a word.
bool IsWord(int character)
{
char c;
- c = tolower(RetNoAccent(character));
+ c = tolower(GetNoAccent(character));
return ( (c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') ||
c == '_' );
}
-// Indicates whether a character is a word separator.
+//! Indicates whether a character is a word separator.
bool IsSep(int character)
{
@@ -79,19 +70,22 @@ bool IsSep(int character)
-// Object's constructor.
+//! Object's constructor.
-CEdit::CEdit(CInstanceManager* iMan) : CControl(iMan)
+//CEdit::CEdit(CInstanceManager* iMan) : CControl(iMan)
+CEdit::CEdit () : CControl ()
{
Math::Point pos;
int i;
m_maxChar = 100;
- m_text = (char*)malloc(sizeof(char)*(m_maxChar+1));
- m_format = 0;
+ m_text = new char[m_maxChar+1];
+ memset(m_text, 0, m_maxChar+1);
m_len = 0;
- m_fontType = FONT_COURIER;
+ memset(m_lineOffset, 0, sizeof(int) * EDITLINEMAX);
+
+ m_fontType = Gfx::FONT_COURIER;
m_scroll = 0;
m_bEdit = true;
m_bHilite = true;
@@ -110,7 +104,7 @@ CEdit::CEdit(CInstanceManager* iMan) : CControl(iMan)
for ( i=0 ; i<EDITUNDOMAX ; i++ )
{
- m_undo[i].text = 0;
+ m_undo[i].text = nullptr;
}
m_bUndoForce = true;
m_undoOper = OPERUNDO_SPEC;
@@ -127,23 +121,29 @@ CEdit::~CEdit()
for ( i=0 ; i<EDITUNDOMAX ; i++ )
{
delete m_undo[i].text;
+ m_undo[i].text = nullptr;
+ }
+
+ if (m_text != nullptr)
+ {
+ delete[] m_text;
+ m_text = nullptr;
}
- delete m_text;
- delete m_format;
delete m_scroll;
+ m_scroll = nullptr;
}
// Creates a new editable line.
-bool CEdit::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CEdit::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
CScroll* pc;
Math::Point start, end;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
- CControl::Create(pos, dim, icon, eventMsg);
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
+ CControl::Create(pos, dim, icon, eventType);
m_len = 0;
m_lineFirst = 0;
@@ -162,8 +162,8 @@ bool CEdit::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg
{
m_bMulti = true;
MoveAdjust(); // readjusts multi-line mode
- m_scroll = new CScroll(m_iMan);
- pc = (CScroll*)m_scroll;
+ m_scroll = new Ui::CScroll();
+ pc = static_cast<CScroll*>(m_scroll);
pc->Create(pos, dim, -1, EVENT_NULL);
MoveAdjust();
}
@@ -189,25 +189,25 @@ void CEdit::MoveAdjust()
Math::Point pos, dim;
float height;
- m_lineDescent = m_engine->RetText()->RetDescent(m_fontSize, m_fontType);
- m_lineAscent = m_engine->RetText()->RetAscent(m_fontSize, m_fontType);
- m_lineHeight = m_engine->RetText()->RetHeight(m_fontSize, m_fontType);
+ m_lineDescent = m_engine->GetText()->GetDescent(m_fontType, m_fontSize);
+ m_lineAscent = m_engine->GetText()->GetAscent(m_fontType, m_fontSize);
+ m_lineHeight = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
height = m_dim.y-(m_bMulti?MARGY*2.0f:MARGY1);
- m_lineVisible = (int)(height/m_lineHeight);
+ m_lineVisible = static_cast<int>((height/m_lineHeight));
if ( m_scroll != 0 )
{
if ( m_bInsideScroll )
{
- pos.x = m_pos.x+m_dim.x-MARGX-SCROLL_WIDTH;
- pos.y = m_pos.y+MARGYS;
+ pos.x = m_pos.x + m_dim.x - MARGX-SCROLL_WIDTH;
+ pos.y = m_pos.y + MARGYS;
dim.x = SCROLL_WIDTH;
- dim.y = m_dim.y-MARGYS*2.0f;
+ dim.y = m_dim.y - MARGYS*2.0f;
}
else
{
- pos.x = m_pos.x+m_dim.x-SCROLL_WIDTH;
+ pos.x = m_pos.x + m_dim.x - SCROLL_WIDTH;
pos.y = m_pos.y;
dim.x = SCROLL_WIDTH;
dim.y = m_dim.y;
@@ -238,16 +238,16 @@ bool CEdit::EventProcess(const Event &event)
if ( (m_state & STATE_VISIBLE) == 0 ) return true;
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELUP &&
+ if (event.type == EVENT_MOUSE_WHEEL &&
+ event.mouseWheel.dir == WHEEL_UP &&
Detect(event.pos) )
{
Scroll(m_lineFirst-3, true);
return true;
}
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELDOWN &&
- Detect(event.pos) )
+ if (event.type == EVENT_KEY_DOWN &&
+ event.mouseWheel.dir == WHEEL_DOWN &&
+ Detect(event.mouseWheel.pos) )
{
Scroll(m_lineFirst+3, true);
return true;
@@ -255,30 +255,30 @@ bool CEdit::EventProcess(const Event &event)
CControl::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
m_time += event.rTime;
m_timeBlink += event.rTime;
}
- if ( event.event == EVENT_MOUSEMOVE )
+ if ( event.type == EVENT_MOUSE_MOVE )
{
- if ( Detect(event.pos) &&
- event.pos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )
+ if ( Detect(event.mouseMove.pos) &&
+ event.mouseMove.pos.x < m_pos.x+m_dim.x-(m_bMulti?MARGX+SCROLL_WIDTH:0.0f) )
{
if ( m_bEdit )
{
- m_engine->SetMouseType(D3DMOUSEEDIT);
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_EDIT);
}
else
{
- if ( IsLinkPos(event.pos) )
+ if ( IsLinkPos(event.mouseMove.pos) )
{
- m_engine->SetMouseType(D3DMOUSEHAND);
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
}
else
{
- m_engine->SetMouseType(D3DMOUSENORM);
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
}
}
}
@@ -288,109 +288,109 @@ bool CEdit::EventProcess(const Event &event)
{
m_scroll->EventProcess(event);
- if ( event.event == m_scroll->RetEventMsg() )
+ if ( event.type == m_scroll->GetEventType() )
{
Scroll();
return true;
}
}
- if ( event.event == EVENT_KEYDOWN && m_bFocus )
+ if ( event.type == EVENT_KEY_DOWN && m_bFocus )
{
- bShift = (event.keyState&KS_SHIFT);
- bControl = (event.keyState&KS_CONTROL);
+ bShift = ( (event.trackedKeys & TRKEY_SHIFT) != 0 );
+ bControl = ( (event.trackedKeys & TRKEY_CONTROL) != 0);
- if ( (event.param == 'X' && !bShift && bControl) ||
- (event.param == VK_DELETE && bShift && !bControl) )
+ if ( (event.key.unicode == 'X' && !bShift && bControl) ||
+ (event.key.key == KEY(DELETE) && bShift && !bControl) )
{
Cut();
return true;
}
- if ( (event.param == 'C' && !bShift && bControl) ||
- (event.param == VK_INSERT && !bShift && bControl) )
+ if ( (event.key.unicode == 'C' && !bShift && bControl) ||
+ (event.key.key == KEY(INSERT) && !bShift && bControl) )
{
Copy();
return true;
}
- if ( (event.param == 'V' && !bShift && bControl) ||
- (event.param == VK_INSERT && bShift && !bControl) )
+ if ( (event.key.unicode == 'V' && !bShift && bControl) ||
+ (event.param == KEY(INSERT) && bShift && !bControl) )
{
Paste();
return true;
}
- if ( event.param == 'A' && !bShift && bControl )
+ if ( event.key.unicode == 'A' && !bShift && bControl )
{
SetCursor(999999, 0);
return true;
}
- if ( event.param == 'O' && !bShift && bControl )
+ if ( event.key.unicode == 'O' && !bShift && bControl )
{
- Event newEvent;
- m_event->MakeEvent(newEvent, EVENT_STUDIO_OPEN);
+ Event newEvent(EVENT_STUDIO_OPEN);
+// m_event->NewEvent(newEvent, EVENT_STUDIO_OPEN);
m_event->AddEvent(newEvent);
}
- if ( event.param == 'S' && !bShift && bControl )
+ if ( event.key.unicode == 'S' && !bShift && bControl )
{
- Event newEvent;
- m_event->MakeEvent(newEvent, EVENT_STUDIO_SAVE);
+ Event newEvent( EVENT_STUDIO_SAVE );
+// m_event->MakeEvent(newEvent, EVENT_STUDIO_SAVE);
m_event->AddEvent(newEvent);
}
- if ( event.param == 'Z' && !bShift && bControl )
+ if ( event.key.unicode == 'Z' && !bShift && bControl )
{
Undo();
return true;
}
- if ( event.param == 'U' && !bShift && bControl )
+ if ( event.key.unicode == 'U' && !bShift && bControl )
{
if ( MinMaj(false) ) return true;
}
- if ( event.param == 'U' && bShift && bControl )
+ if ( event.key.unicode == 'U' && bShift && bControl )
{
if ( MinMaj(true) ) return true;
}
- if ( event.param == VK_TAB && !bShift && !bControl && !m_bAutoIndent )
+ if ( event.key.key == KEY(TAB) && !bShift && !bControl && !m_bAutoIndent )
{
if ( Shift(false) ) return true;
}
- if ( event.param == VK_TAB && bShift && !bControl && !m_bAutoIndent )
+ if ( event.key.key == KEY(TAB) && bShift && !bControl && !m_bAutoIndent )
{
if ( Shift(true) ) return true;
}
if ( m_bEdit )
{
- if ( event.param == VK_LEFT )
+ if ( event.key.key == KEY(LEFT) )
{
MoveChar(-1, bControl, bShift);
return true;
}
- if ( event.param == VK_RIGHT )
+ if ( event.key.key == KEY(RIGHT) )
{
MoveChar(1, bControl, bShift);
return true;
}
- if ( event.param == VK_UP )
+ if ( event.key.key == KEY(UP) )
{
MoveLine(-1, bControl, bShift);
return true;
}
- if ( event.param == VK_DOWN )
+ if ( event.key.key == KEY(DOWN) )
{
MoveLine(1, bControl, bShift);
return true;
}
- if ( event.param == VK_PRIOR ) // PageUp ?
+ if ( event.key.key == KEY(PAGEUP) ) // PageUp ?
{
MoveLine(-(m_lineVisible-1), bControl, bShift);
return true;
}
- if ( event.param == VK_NEXT ) // PageDown ?
+ if ( event.key.key == KEY(PAGEDOWN) ) // PageDown ?
{
MoveLine(m_lineVisible-1, bControl, bShift);
return true;
@@ -398,62 +398,62 @@ bool CEdit::EventProcess(const Event &event)
}
else
{
- if ( event.param == VK_LEFT ||
- event.param == VK_UP )
+ if ( event.key.key == KEY(LEFT) ||
+ event.key.key == KEY(UP) )
{
Scroll(m_lineFirst-1, true);
return true;
}
- if ( event.param == VK_RIGHT ||
- event.param == VK_DOWN )
+ if ( event.key.key == KEY(RIGHT) ||
+ event.key.key == KEY(DOWN) )
{
Scroll(m_lineFirst+1, true);
return true;
}
- if ( event.param == VK_PRIOR ) // PageUp ?
+ if ( event.key.key == KEY(PAGEUP) ) // PageUp ?
{
Scroll(m_lineFirst-(m_lineVisible-1), true);
return true;
}
- if ( event.param == VK_NEXT ) // PageDown ?
+ if ( event.key.key == KEY(PAGEDOWN) ) // PageDown ?
{
Scroll(m_lineFirst+(m_lineVisible-1), true);
return true;
}
}
- if ( event.param == VK_HOME )
+ if ( event.key.key == KEY(HOME) )
{
MoveHome(bControl, bShift);
return true;
}
- if ( event.param == VK_END )
+ if ( event.key.key == KEY(END) )
{
MoveEnd(bControl, bShift);
return true;
}
- if ( event.param == VK_BACK ) // backspace ( <- ) ?
+ if ( event.key.key == KEY(BACKSPACE) ) // backspace ( <- ) ?
{
Delete(-1);
SendModifEvent();
return true;
}
- if ( event.param == VK_DELETE )
+ if ( event.key.key == KEY(DELETE) )
{
Delete(1);
SendModifEvent();
return true;
}
- if ( event.param == VK_RETURN )
+ if ( event.key.key == KEY(RETURN) )
{
Insert('\n');
SendModifEvent();
return true;
}
- if ( event.param == VK_TAB )
+ if ( event.key.key == KEY(TAB) )
{
Insert('\t');
SendModifEvent();
@@ -461,19 +461,19 @@ bool CEdit::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_CHAR && m_bFocus )
+ if ( event.type == EVENT_ACTIVE && m_bFocus )
{
- if ( event.param >= ' ' && event.param <= 255 )
+ if ( event.key.key >= ' ' && event.key.key <= 255 )
{
- Insert((char)event.param);
+ Insert(static_cast<char>(event.key.key));
SendModifEvent();
return true;
}
}
- if ( event.event == EVENT_FOCUS )
+ if ( event.type == EVENT_ACTIVE )
{
- if ( event.param == m_eventMsg )
+ if ( event.param == m_eventType )
{
m_bFocus = true;
}
@@ -483,7 +483,8 @@ bool CEdit::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_LBUTTONDOWN )
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1)
{
m_mouseFirstPos = event.pos;
m_mouseLastPos = event.pos;
@@ -502,18 +503,19 @@ bool CEdit::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_MOUSEMOVE && m_bCapture )
+ if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
m_mouseLastPos = event.pos;
MouseMove(event.pos);
}
- if ( event.event == EVENT_FRAME && m_bCapture )
+ if ( event.type == EVENT_FRAME && m_bCapture )
{
MouseMove(m_mouseLastPos);
}
- if ( event.event == EVENT_LBUTTONUP )
+ if ( event.type == EVENT_MOUSE_BUTTON_UP &&
+ event.mouseButton.button == 1)
{
if ( Detect(event.pos) )
{
@@ -541,9 +543,9 @@ bool CEdit::EventProcess(const Event &event)
void CEdit::SendModifEvent()
{
- Event newEvent;
+ Event newEvent (m_eventType);
- m_event->MakeEvent(newEvent, m_eventMsg);
+// m_event->MakeEvent(newEvent, m_eventType);
m_event->AddEvent(newEvent);
}
@@ -554,13 +556,13 @@ bool CEdit::IsLinkPos(Math::Point pos)
{
int i;
- if ( m_format == 0 ) return false;
+ if ( m_format.size() == 0 ) return false;
i = MouseDetect(pos);
if ( i == -1 ) return false;
if ( i >= m_len ) return false;
- if ( (m_format[i]&COLOR_MASK) == COLOR_LINK ) return true;
+ if ( (m_format[i]& Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) return true; // TODO
return false;
}
@@ -578,7 +580,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse)
while ( i > 0 )
{
- character = (unsigned char)m_text[i-1];
+ character = static_cast<unsigned char>(m_text[i-1]);
if ( !IsWord(character) ) break;
i --;
}
@@ -586,7 +588,7 @@ void CEdit::MouseDoubleClick(Math::Point mouse)
while ( i < m_len )
{
- character = (unsigned char)m_text[i];
+ character = static_cast<unsigned char>(m_text[i]);
if ( !IsWord(character) ) break;
i ++;
}
@@ -634,14 +636,14 @@ void CEdit::MouseRelease(Math::Point mouse)
if ( !m_bEdit )
{
- if ( m_format != 0 && i < m_len && m_cursor1 == m_cursor2 &&
- (m_format[i]&COLOR_MASK) == COLOR_LINK )
+ if ( m_format.size() > 0 && i < m_len && m_cursor1 == m_cursor2 &&
+ (m_format[i]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) //TODO
{
rank = -1;
for ( j=0 ; j<=i ; j++ )
{
- if ( (j == 0 || (m_format[j-1]&COLOR_MASK) != COLOR_LINK) &&
- (m_format[j+0]&COLOR_MASK) == COLOR_LINK )
+ if ( (j == 0 || (m_format[j-1]&Gfx::FONT_MASK_HIGHLIGHT) != Gfx::FONT_HIGHLIGHT_LINK) && // TODO check if good
+ (m_format[j+0]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_LINK) // TODO
{
rank ++;
}
@@ -694,14 +696,14 @@ int CEdit::MouseDetect(Math::Point mouse)
if ( m_bAutoIndent )
{
- indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType)
- * m_engine->RetEditIndentValue();
+ indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f)
+ * m_engine->GetEditIndentValue();
}
pos.y = m_pos.y+m_dim.y-m_lineHeight-(m_bMulti?MARGY:MARGY1);
for ( i=m_lineFirst ; i<m_lineTotal ; i++ )
{
- bTitle = ( m_format != 0 && (m_format[m_lineOffset[i]]&TITLE_MASK) == TITLE_BIG );
+ bTitle = ( m_format.size() > 0 && (m_format[m_lineOffset[i]]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG );
if ( i >= m_lineFirst+m_lineVisible ) break;
@@ -718,21 +720,26 @@ int CEdit::MouseDetect(Math::Point mouse)
{
len = m_lineOffset[i+1] - m_lineOffset[i];
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- c = m_engine->RetText()->Detect(m_text+m_lineOffset[i],
- len, offset, m_fontSize,
- m_fontStretch, m_fontType);
+// c = m_engine->GetText()->Detect(m_text+m_lineOffset[i],
+// len, offset, m_fontSize,
+// m_fontStretch, m_fontType);
+ c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]), m_fontType, m_fontSize, offset); // TODO check if good
}
else
{
size = m_fontSize;
- if ( bTitle ) size *= BIG_FONT;
+ if ( bTitle ) size *= Gfx::FONT_SIZE_BIG;
- c = m_engine->RetText()->Detect(m_text+m_lineOffset[i],
- m_format+m_lineOffset[i],
- len, offset, size,
- m_fontStretch);
+// c = m_engine->GetText()->Detect(m_text+m_lineOffset[i],
+// m_format+m_lineOffset[i],
+// len, offset, size,
+// m_fontStretch);
+ c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[i]),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[i], m_format.end()),
+ size,
+ offset); // TODO check if good
}
return m_lineOffset[i]+c;
}
@@ -754,7 +761,7 @@ void CEdit::HyperFlush()
// Indicates which is the home page.
-void CEdit::HyperHome(char *filename)
+void CEdit::HyperHome(const char *filename)
{
HyperFlush();
HyperAdd(filename, 0);
@@ -762,7 +769,7 @@ void CEdit::HyperHome(char *filename)
// Performs a hyper jump through a link.
-void CEdit::HyperJump(char *name, char *marker)
+void CEdit::HyperJump(const char *name, const char *marker)
{
char filename[100];
char sMarker[100];
@@ -813,7 +820,7 @@ void CEdit::HyperJump(char *name, char *marker)
// Adds text to the history of visited.
-bool CEdit::HyperAdd(char *filename, int firstLine)
+bool CEdit::HyperAdd(const char *filename, int firstLine)
{
if ( m_historyCurrent >= EDITHISTORYMAX-1 ) return false;
@@ -827,7 +834,7 @@ bool CEdit::HyperAdd(char *filename, int firstLine)
// Indicates whether a button EVENT_HYPER_ * is active or not.
-bool CEdit::HyperTest(EventMsg event)
+bool CEdit::HyperTest(EventType event)
{
if ( event == EVENT_HYPER_HOME )
{
@@ -849,7 +856,7 @@ bool CEdit::HyperTest(EventMsg event)
// Performs the action corresponding to a button EVENT_HYPER_ *.
-bool CEdit::HyperGo(EventMsg event)
+bool CEdit::HyperGo(EventType event)
{
if ( !HyperTest(event) ) return false;
@@ -911,8 +918,8 @@ void CEdit::Draw()
if ( m_bAutoIndent )
{
- indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType)
- * m_engine->RetEditIndentValue();
+ indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f)
+ * m_engine->GetEditIndentValue();
}
pos.y = m_pos.y+m_dim.y-m_lineHeight-(m_bMulti?MARGY:MARGY1);
@@ -933,7 +940,7 @@ void CEdit::Draw()
for ( j=0 ; j<m_lineIndent[i] ; j++ )
{
char s = '\t'; // line | dotted
- m_engine->RetText()->DrawText(&s, 1, pos, 1.0f, 1, m_fontSize, m_fontStretch, m_fontType, 0);
+ m_engine->GetText()->DrawText(&s, m_fontType, m_fontSize, pos, 1.0f, Gfx::TEXT_ALIGN_LEFT, 0);
pos.x += indentLength;
}
}
@@ -945,8 +952,8 @@ void CEdit::Draw()
size = m_fontSize;
// Headline \b;?
- if ( beg+len < m_len && m_format != 0 &&
- (m_format[beg]&TITLE_MASK) == TITLE_BIG )
+ if ( beg+len < m_len && m_format.size() > 0 &&
+ (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG )
{
start.x = ppos.x-MARGX;
end.x = dim.x-MARGX*2.0f;
@@ -959,8 +966,8 @@ void CEdit::Draw()
}
// As \t;?
- if ( beg+len < m_len && m_format != 0 &&
- (m_format[beg]&TITLE_MASK) == TITLE_NORM )
+ if ( beg+len < m_len && m_format.size() > 0 &&
+ (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_NORM )
{
start.x = ppos.x-MARGX;
end.x = dim.x-MARGX*2.0f;
@@ -970,8 +977,8 @@ void CEdit::Draw()
}
// Subtitle \s;?
- if ( beg+len < m_len && m_format != 0 &&
- (m_format[beg]&TITLE_MASK) == TITLE_LITTLE )
+ if ( beg+len < m_len && m_format.size() > 0 &&
+ (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_LITTLE )
{
start.x = ppos.x-MARGX;
end.x = dim.x-MARGX*2.0f;
@@ -981,8 +988,8 @@ void CEdit::Draw()
}
// Table \tab;?
- if ( beg+len < m_len && m_format != 0 &&
- (m_format[beg]&COLOR_MASK) == COLOR_TABLE )
+ if ( beg+len < m_len && m_format.size() > 0 &&
+ (m_format[beg]&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_TABLE )
{
start.x = ppos.x-MARGX;
end.x = dim.x-MARGX*2.0f;
@@ -992,22 +999,22 @@ void CEdit::Draw()
}
// Image \image; ?
- if ( beg+len < m_len && m_format != 0 &&
- (m_format[beg]&IMAGE_MASK) != 0 )
+ if ( beg+len < m_len && m_format.size() > 0 &&
+ (m_format[beg]&Gfx::FONT_MASK_IMAGE) != 0 )
{
line = 1;
while ( true ) // includes the image slices
{
if ( i+line >= m_lineTotal ||
i+line >= m_lineFirst+m_lineVisible ||
- (m_format[beg+line]&IMAGE_MASK) == 0 ) break;
+ (m_format[beg+line]&Gfx::FONT_MASK_IMAGE) == 0 ) break;
line ++;
}
iIndex = m_text[beg]; // character = index in m_image
pos.y -= m_lineHeight*(line-1);
DrawImage(pos, m_image[iIndex].name,
- m_image[iIndex].width*(m_fontSize/SMALLFONT),
+ m_image[iIndex].width*(m_fontSize/Gfx::FONT_SIZE_SMALL),
m_image[iIndex].offset, m_image[iIndex].height*line, line);
pos.y -= m_lineHeight;
i += line-1;
@@ -1021,20 +1028,24 @@ void CEdit::Draw()
o1 = c1; if ( o1 < beg ) o1 = beg;
o2 = c2; if ( o2 > beg+len ) o2 = beg+len;
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- start.x = ppos.x+m_engine->RetText()->RetStringWidth(m_text+beg, o1-beg, size, m_fontStretch, m_fontType);
- end.x = m_engine->RetText()->RetStringWidth(m_text+o1, o2-o1, size, m_fontStretch, m_fontType);
+ start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg), m_fontType, size);
+ end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1), m_fontType, size);
}
else
{
- start.x = ppos.x+m_engine->RetText()->RetStringWidth(m_text+beg, m_format+beg, o1-beg, size, m_fontStretch);
- end.x = m_engine->RetText()->RetStringWidth(m_text+o1, m_format+o1, o2-o1, size, m_fontStretch);
+ start.x = ppos.x+m_engine->GetText()->GetStringWidth(std::string(m_text+beg),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+beg, m_format.end()),
+ size);
+ end.x = m_engine->GetText()->GetStringWidth(std::string(m_text+o1),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+o1, m_format.end()),
+ size);
}
start.y = ppos.y-(m_bMulti?0.0f:MARGY1);
end.y = m_lineHeight;
- if ( m_format != 0 && (m_format[beg]&TITLE_MASK) == TITLE_BIG ) end.y *= BIG_FONT;
+ if ( m_format.size() > 0 && (m_format[beg]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG) end.y *= BIG_FONT;
DrawPart(start, end, 1); // plain yellow background
}
@@ -1049,13 +1060,19 @@ void CEdit::Draw()
eol = 2; // square (eot)
}
if ( !m_bMulti || !m_bDisplaySpec ) eol = 0;
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- m_engine->RetText()->DrawText(m_text+beg, len, ppos, m_dim.x, 1, size, m_fontStretch, m_fontType, eol);
+ m_engine->GetText()->DrawText(std::string(m_text+beg), m_fontType, size, ppos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, eol);
}
else
{
- m_engine->RetText()->DrawText(m_text+beg, m_format+beg, len, ppos, m_dim.x, 1, size, m_fontStretch, eol);
+ m_engine->GetText()->DrawText(std::string(m_text+beg),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+beg, m_format.end()),
+ size,
+ ppos,
+ m_dim.x,
+ Gfx::TEXT_ALIGN_LEFT,
+ eol);
}
pos.y -= m_lineHeight;
@@ -1083,19 +1100,17 @@ void CEdit::Draw()
len = m_cursor1 - m_lineOffset[i];
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- m_engine->RetText()->DimText(m_text+m_lineOffset[i], len,
- pos, 1, size,
- m_fontStretch, m_fontType,
+ m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]), m_fontType,
+ size, pos, Gfx::TEXT_ALIGN_LEFT,
start, end);
}
else
{
- m_engine->RetText()->DimText(m_text+m_lineOffset[i],
- m_format+m_lineOffset[i],
- len, pos, 1, size,
- m_fontStretch,
+ m_engine->GetText()->SizeText(std::string(m_text+m_lineOffset[i]),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[i], m_format.end()),
+ size, pos, Gfx::TEXT_ALIGN_LEFT,
start, end);
}
@@ -1104,8 +1119,8 @@ void CEdit::Draw()
}
pos.y -= m_lineHeight;
}
- pos.x -= 1.0f/640.0f;
- dim.x = 2.0f/640.0f;
+ pos.x -= 1.0f / 640.0f;
+ dim.x = 2.0f / 640.0f;
dim.y = m_lineHeight;
DrawPart(pos, dim, 0); // red
}
@@ -1118,19 +1133,19 @@ void CEdit::Draw()
// Draw an image part.
-void CEdit::DrawImage(Math::Point pos, char *name, float width,
+void CEdit::DrawImage(Math::Point pos, const char *name, float width,
float offset, float height, int nbLine)
{
Math::Point uv1, uv2, dim;
float dp;
char filename[100];
-//? sprintf(filename, "diagram\\%s.bmp", name);
+//? sprintf(filename, "diagram\\%s.png", name);
UserDir(filename, name, "diagram");
- strcat(filename, ".bmp");
+ strcat(filename, ".png");
m_engine->SetTexture(filename);
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f;
uv2.x = 1.0f;
@@ -1157,8 +1172,8 @@ void CEdit::DrawBack(Math::Point pos, Math::Point dim)
if ( m_bGeneric ) return;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
if ( m_bMulti )
{
@@ -1208,11 +1223,11 @@ void CEdit::DrawPart(Math::Point pos, Math::Point dim, int icon)
float dp;
#if _POLISH
- m_engine->SetTexture("textp.tga");
+ m_engine->SetTexture("textp.png");
#else
- m_engine->SetTexture("text.tga");
+ m_engine->SetTexture("text.png");
#endif
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = (16.0f/256.0f)*(icon%16);
uv1.y = (240.0f/256.0f);
@@ -1231,7 +1246,7 @@ void CEdit::DrawPart(Math::Point pos, Math::Point dim, int icon)
// Give the text to edit.
-void CEdit::SetText(char *text, bool bNew)
+void CEdit::SetText(const char *text, bool bNew)
{
int i, j, font;
bool bBOL;
@@ -1241,7 +1256,7 @@ void CEdit::SetText(char *text, bool bNew)
m_len = strlen(text);
if ( m_len > m_maxChar ) m_len = m_maxChar;
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
if ( m_bAutoIndent )
{
@@ -1291,32 +1306,32 @@ void CEdit::SetText(char *text, bool bNew)
{
if ( text[i+1] == 'n' ) // normal ?
{
- font &= ~FONT_MASK;
- font |= FONT_COLOBOT;
+ font &= ~Gfx::FONT_MASK_FONT;
+ font |= Gfx::FONT_COLOBOT;
i += 2;
}
else if ( text[i+1] == 'c' ) // cbot ?
{
- font &= ~FONT_MASK;
- font |= FONT_COURIER;
+ font &= ~Gfx::FONT_MASK_FONT;
+ font |= Gfx::FONT_COURIER;
i += 2;
}
else if ( text[i+1] == 'b' ) // big title ?
{
- font &= ~TITLE_MASK;
- font |= TITLE_BIG;
+ font &= ~Gfx::FONT_MASK_TITLE;
+ font |= Gfx::FONT_TITLE_BIG;
i += 2;
}
else if ( text[i+1] == 't' ) // title ?
{
- font &= ~TITLE_MASK;
- font |= TITLE_NORM;
+ font &= ~Gfx::FONT_MASK_TITLE;
+ font |= Gfx::FONT_TITLE_NORM;
i += 2;
}
else if ( text[i+1] == 's' ) // subtitle ?
{
- font &= ~TITLE_MASK;
- font |= TITLE_LITTLE;
+ font &= ~Gfx::FONT_MASK_TITLE;
+ font |= Gfx::FONT_TITLE_LITTLE;
i += 2;
}
}
@@ -1326,7 +1341,7 @@ void CEdit::SetText(char *text, bool bNew)
m_format[j] = font;
j ++;
- font &= ~TITLE_MASK; // reset title
+ font &= ~Gfx::FONT_MASK_TITLE; // reset title
}
}
m_len = j;
@@ -1342,7 +1357,7 @@ void CEdit::SetText(char *text, bool bNew)
// Returns a pointer to the edited text.
-char* CEdit::RetText()
+char* CEdit::GetText()
{
m_text[m_len] = 0;
return m_text;
@@ -1361,7 +1376,7 @@ void CEdit::GetText(char *buffer, int max)
// Returns the length of the text.
-int CEdit::RetTextLength()
+int CEdit::GetTextLength()
{
return m_len;
}
@@ -1371,7 +1386,7 @@ int CEdit::RetTextLength()
// Returns a name in a command.
// \x nom1 nom2 nom3;
-void GetNameParam(char *cmd, int rank, char *buffer)
+void GetNameParam(const char *cmd, int rank, char *buffer)
{
int i;
@@ -1394,7 +1409,7 @@ void GetNameParam(char *cmd, int rank, char *buffer)
// Returns a number of a command.
// \x nom n1 n2;
-int RetValueParam(char *cmd, int rank)
+int GetValueParam(const char *cmd, int rank)
{
int n, i;
@@ -1420,28 +1435,28 @@ void CEdit::FreeImage()
for ( i=0 ; i<m_imageTotal ; i++ )
{
-//? sprintf(filename, "diagram\\%s.bmp", m_image[i].name);
+//? sprintf(filename, "diagram\\%s.png", m_image[i].name);
UserDir(filename, m_image[i].name, "diagram");
- strcat(filename, ".bmp");
- m_engine->FreeTexture(filename);
+ strcat(filename, ".png");
+ m_engine->DeleteTexture(filename);
}
}
// Reads the texture of an image.
-void CEdit::LoadImage(char *name)
+void CEdit::LoadImage(const char *name)
{
char filename[100];
-//? sprintf(filename, "diagram\\%s.bmp", name);
+//? sprintf(filename, "diagram\\%s.png", name);
UserDir(filename, name, "diagram");
- strcat(filename, ".bmp");
+ strcat(filename, ".png");
m_engine->LoadTexture(filename);
}
// Read from a text file.
-bool CEdit::ReadText(char *filename, int addSize)
+bool CEdit::ReadText(const char *filename, int addSize)
{
FILE *file = NULL;
char *buffer;
@@ -1449,7 +1464,7 @@ bool CEdit::ReadText(char *filename, int addSize)
char iName[50];
char text[50];
float iWidth;
- KeyRank key;
+ InputSlot slot;
bool bInSoluce, bBOL;
if ( filename[0] == 0 ) return false;
@@ -1466,15 +1481,21 @@ bool CEdit::ReadText(char *filename, int addSize)
m_cursor2 = 0;
FreeImage();
- delete m_text;
- m_text = (char*)malloc(sizeof(char)*(m_maxChar+1));
- buffer = (char*)malloc(sizeof(char)*(m_maxChar+1));
+
+ if (m_text != nullptr)
+ delete m_text;
+
+ m_text = new char[m_maxChar+1];
+ memset(m_text, 0, m_maxChar+1);
+
+ buffer = new char[m_maxChar+1];
+ memset(buffer, 0, m_maxChar+1);
+
fread(buffer, 1, len, file);
- if ( m_format != 0 )
+ if ( m_format.size() > 0 )
{
- delete m_format;
- m_format = (char*)malloc(sizeof(char)*m_maxChar);
+ m_format.clear();
}
fclose(file);
@@ -1496,7 +1517,7 @@ bool CEdit::ReadText(char *filename, int addSize)
if ( !bBOL )
{
m_text[j] = buffer[i];
- if ( m_format != 0 ) m_format[j] = font;
+ if ( m_format.size() > 0 ) m_format[j] = font;
j ++;
}
i ++;
@@ -1509,14 +1530,14 @@ bool CEdit::ReadText(char *filename, int addSize)
{
i ++;
}
- else if ( m_format != 0 && buffer[i] == '\\' && buffer[i+2] == ';' )
+ else if ( m_format.size() > 0 && buffer[i] == '\\' && buffer[i+2] == ';' )
{
if ( buffer[i+1] == 'n' ) // normal ?
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~FONT_MASK;
- font |= FONT_COLOBOT;
+ font &= ~Gfx::FONT_MASK_FONT;
+ font |= Gfx::FONT_COLOBOT;
}
i += 3;
}
@@ -1524,8 +1545,8 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~FONT_MASK;
- font |= FONT_COURIER;
+ font &= ~Gfx::FONT_MASK_FONT;
+ font |= Gfx::FONT_COURIER;
}
i += 3;
}
@@ -1533,8 +1554,8 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~TITLE_MASK;
- font |= TITLE_BIG;
+ font &= ~Gfx::FONT_MASK_TITLE;
+ font |= Gfx::FONT_TITLE_BIG;
}
i += 3;
}
@@ -1542,8 +1563,8 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~TITLE_MASK;
- font |= TITLE_NORM;
+ font &= ~Gfx::FONT_MASK_TITLE;
+ font |= Gfx::FONT_TITLE_NORM;
}
i += 3;
}
@@ -1551,8 +1572,8 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~TITLE_MASK;
- font |= TITLE_LITTLE;
+ font &= ~Gfx::FONT_MASK_TITLE;
+ font |= Gfx::FONT_TITLE_LITTLE;
}
i += 3;
}
@@ -1560,8 +1581,8 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~COLOR_MASK;
- font |= COLOR_LINK;
+ font &= ~Gfx::FONT_MASK_HIGHLIGHT;
+ font |= Gfx::FONT_HIGHLIGHT_LINK;
}
i += 3;
}
@@ -1570,7 +1591,7 @@ bool CEdit::ReadText(char *filename, int addSize)
i += 3;
}
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \u marker name; ?
buffer[i+1] == 'u' &&
buffer[i+2] == ' ' )
@@ -1583,11 +1604,11 @@ bool CEdit::ReadText(char *filename, int addSize)
GetNameParam(buffer+i+3, 1, m_link[iLink].marker);
iLink ++;
}
- font &= ~COLOR_MASK;
+ font &= ~Gfx::FONT_MASK_HIGHLIGHT;
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \m marker; ?
buffer[i+1] == 'm' &&
buffer[i+2] == ' ' )
@@ -1603,7 +1624,7 @@ bool CEdit::ReadText(char *filename, int addSize)
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \image name lx ly; ?
buffer[i+1] == 'i' &&
buffer[i+2] == 'm' &&
@@ -1620,27 +1641,27 @@ bool CEdit::ReadText(char *filename, int addSize)
GetNameParam(buffer+i+7, 0, iName);
#endif
//? iWidth = m_lineHeight*RetValueParam(buffer+i+7, 1);
- iWidth = (float)RetValueParam(buffer+i+7, 1);
- iWidth *= m_engine->RetText()->RetHeight(SMALLFONT, FONT_COLOBOT);
- iLines = RetValueParam(buffer+i+7, 2);
+ iWidth = static_cast<float>(GetValueParam(buffer+i+7, 1));
+ iWidth *= m_engine->GetText()->GetHeight(Gfx::FONT_COLOBOT, Gfx::FONT_SIZE_SMALL);
+ iLines = GetValueParam(buffer+i+7, 2);
LoadImage(iName);
// A part of image per line of text.
for ( iCount=0 ; iCount<iLines ; iCount++ )
{
strcpy(m_image[iIndex].name, iName);
- m_image[iIndex].offset = (float)iCount/iLines;
+ m_image[iIndex].offset = static_cast<float>(iCount/iLines);
m_image[iIndex].height = 1.0f/iLines;
m_image[iIndex].width = iWidth*0.75f;
- m_text[j] = (char)(iIndex++); // as an index into m_image
- m_format[j] = (unsigned char)IMAGE_MASK;
+ m_text[j] = static_cast<char>(iIndex++); // as an index into m_image
+ m_format[j] = static_cast<unsigned char>(Gfx::FONT_MASK_IMAGE);
j ++;
}
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \button; ?
buffer[i+1] == 'b' &&
buffer[i+2] == 'u' &&
@@ -1652,13 +1673,13 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- m_text[j] = RetValueParam(buffer+i+8, 0);
- m_format[j] = font|FONT_BUTTON;
+ m_text[j] = GetValueParam(buffer+i+8, 0);
+ m_format[j] = font|Gfx::FONT_BUTTON;
j ++;
}
i += strchr(buffer+i, ';')-(buffer+i)+1;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \token; ?
buffer[i+1] == 't' &&
buffer[i+2] == 'o' &&
@@ -1669,12 +1690,12 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~COLOR_MASK;
- font |= COLOR_TOKEN;
+ font &= ~Gfx::FONT_MASK_HIGHLIGHT;
+ font |= Gfx::FONT_HIGHLIGHT_TOKEN;
}
i += 7;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \type; ?
buffer[i+1] == 't' &&
buffer[i+2] == 'y' &&
@@ -1684,12 +1705,12 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~COLOR_MASK;
- font |= COLOR_TYPE;
+ font &= ~Gfx::FONT_MASK_HIGHLIGHT;
+ font |= Gfx::FONT_HIGHLIGHT_TYPE;
}
i += 6;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \const; ?
buffer[i+1] == 'c' &&
buffer[i+2] == 'o' &&
@@ -1700,12 +1721,12 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~COLOR_MASK;
- font |= COLOR_CONST;
+ font &= ~Gfx::FONT_MASK_HIGHLIGHT;
+ font |= Gfx::FONT_HIGHLIGHT_CONST;
}
i += 7;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \key; ?
buffer[i+1] == 'k' &&
buffer[i+2] == 'e' &&
@@ -1714,12 +1735,12 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~COLOR_MASK;
- font |= COLOR_KEY;
+ font &= ~Gfx::FONT_MASK_HIGHLIGHT;
+ font |= Gfx::FONT_HIGHLIGHT_KEY;
}
i += 5;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \tab; ?
buffer[i+1] == 't' &&
buffer[i+2] == 'a' &&
@@ -1728,11 +1749,11 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font |= COLOR_TABLE;
+ font |= Gfx::FONT_HIGHLIGHT_TABLE;
}
i += 5;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \norm; ?
buffer[i+1] == 'n' &&
buffer[i+2] == 'o' &&
@@ -1742,11 +1763,11 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- font &= ~COLOR_MASK;
+ font &= ~Gfx::FONT_MASK_HIGHLIGHT;
}
i += 6;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \begin soluce; ?
buffer[i+1] == 'b' &&
buffer[i+2] == 's' &&
@@ -1755,7 +1776,7 @@ bool CEdit::ReadText(char *filename, int addSize)
bInSoluce = true;
i += 4;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \end soluce; ?
buffer[i+1] == 'e' &&
buffer[i+2] == 's' &&
@@ -1764,7 +1785,7 @@ bool CEdit::ReadText(char *filename, int addSize)
bInSoluce = false;
i += 4;
}
- else if ( m_format != 0 &&
+ else if ( m_format.size() > 0 &&
buffer[i+0] == '\\' && // \key name; ?
buffer[i+1] == 'k' &&
buffer[i+2] == 'e' &&
@@ -1773,9 +1794,10 @@ bool CEdit::ReadText(char *filename, int addSize)
{
if ( m_bSoluce || !bInSoluce )
{
- if ( SearchKey(buffer+i+5, key) )
+ if ( SearchKey(buffer+i+5, slot) )
{
- res = m_engine->RetKey(key, 0);
+ CRobotMain* main = CRobotMain::GetInstancePointer();
+ res = main->GetInputBinding(slot).key;
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )
@@ -1794,7 +1816,7 @@ bool CEdit::ReadText(char *filename, int addSize)
m_format[j] = font;
j ++;
- res = m_engine->RetKey(key, 1);
+ res = main->GetInputBinding(slot).joy;
if ( res != 0 )
{
if ( GetResource(RES_KEY, res, iName) )
@@ -1804,7 +1826,7 @@ bool CEdit::ReadText(char *filename, int addSize)
while ( text[n] != 0 )
{
m_text[j] = text[n++];
- m_format[j] = font&~COLOR_MASK;
+ m_format[j] = font&~Gfx::FONT_MASK_HIGHLIGHT;
j ++;
}
n = 0;
@@ -1835,16 +1857,16 @@ bool CEdit::ReadText(char *filename, int addSize)
if ( m_bSoluce || !bInSoluce )
{
m_text[j] = buffer[i];
- if ( m_format != 0 ) m_format[j] = font;
+ if ( m_format.size() > 0 ) m_format[j] = font;
j ++;
}
i ++;
- font &= ~TITLE_MASK; // reset title
+ font &= ~Gfx::FONT_MASK_TITLE; // reset title
- if ( (font&COLOR_MASK) == COLOR_TABLE )
+ if ( (font&Gfx::FONT_MASK_HIGHLIGHT) == Gfx::FONT_HIGHLIGHT_TABLE )
{
- font &= ~COLOR_TABLE;
+ font &= ~Gfx::FONT_HIGHLIGHT_TABLE;
}
}
}
@@ -1860,7 +1882,7 @@ bool CEdit::ReadText(char *filename, int addSize)
// Writes all the text in a file.
-bool CEdit::WriteText(char *filename)
+bool CEdit::WriteText(const char *filename)
{
FILE* file;
char buffer[1000+20];
@@ -1927,16 +1949,18 @@ bool CEdit::WriteText(char *filename)
void CEdit::SetMaxChar(int max)
{
- m_maxChar = max;
FreeImage();
- delete m_text;
- m_text = (char*)malloc(sizeof(char)*(m_maxChar+1));
- if ( m_format != 0 )
- {
- delete m_format;
- m_format = (char*)malloc(sizeof(char)*m_maxChar);
- }
+ if (m_text != nullptr)
+ delete[] m_text;
+
+ m_maxChar = max;
+
+ m_text = new char[m_maxChar+1];
+ memset(m_text, 0, m_maxChar+1);
+
+ if (m_format.size() > 0)
+ m_format.clear();
m_len = 0;
m_cursor1 = 0;
@@ -1945,7 +1969,7 @@ void CEdit::SetMaxChar(int max)
UndoFlush();
}
-int CEdit::RetMaxChar()
+int CEdit::GetMaxChar()
{
return m_maxChar;
}
@@ -1958,7 +1982,7 @@ void CEdit::SetEditCap(bool bMode)
m_bEdit = bMode;
}
-bool CEdit::RetEditCap()
+bool CEdit::GetEditCap()
{
return m_bEdit;
}
@@ -1970,7 +1994,7 @@ void CEdit::SetHiliteCap(bool bEnable)
m_bHilite = bEnable;
}
-bool CEdit::RetHiliteCap()
+bool CEdit::GetHiliteCap()
{
return m_bHilite;
}
@@ -1982,7 +2006,7 @@ void CEdit::SetInsideScroll(bool bInside)
m_bInsideScroll = bInside;
}
-bool CEdit::RetInsideScroll()
+bool CEdit::GetInsideScroll()
{
return m_bInsideScroll;
}
@@ -1994,7 +2018,7 @@ void CEdit::SetSoluceMode(bool bSoluce)
m_bSoluce = bSoluce;
}
-bool CEdit::RetSoluceMode()
+bool CEdit::GetSoluceMode()
{
return m_bSoluce;
}
@@ -2006,7 +2030,7 @@ void CEdit::SetGenericMode(bool bGeneric)
m_bGeneric = bGeneric;
}
-bool CEdit::RetGenericMode()
+bool CEdit::GetGenericMode()
{
return m_bGeneric;
}
@@ -2019,7 +2043,7 @@ void CEdit::SetAutoIndent(bool bMode)
m_bAutoIndent = bMode;
}
-bool CEdit::RetAutoIndent()
+bool CEdit::GetAutoIndent()
{
return m_bAutoIndent;
}
@@ -2057,7 +2081,7 @@ void CEdit::SetFirstLine(int rank)
// Returns the first displayed line.
-int CEdit::RetFirstLine()
+int CEdit::GetFirstLine()
{
if ( m_historyTotal > 0 )
{
@@ -2091,7 +2115,7 @@ void CEdit::ShowSelect()
cursor2 = m_cursor1;
}
- line = RetCursorLine(cursor2);
+ line = GetCursorLine(cursor2);
if ( line >= m_lineFirst+m_lineVisible )
{
line -= m_lineVisible-1;
@@ -2099,7 +2123,7 @@ void CEdit::ShowSelect()
Scroll(line, false);
}
- line = RetCursorLine(cursor1);
+ line = GetCursorLine(cursor1);
if ( line < m_lineFirst )
{
Scroll(line, false);
@@ -2114,7 +2138,7 @@ void CEdit::SetDisplaySpec(bool bDisplay)
m_bDisplaySpec = bDisplay;
}
-bool CEdit::RetDisplaySpec()
+bool CEdit::GetDisplaySpec()
{
return m_bDisplaySpec;
}
@@ -2124,22 +2148,12 @@ bool CEdit::RetDisplaySpec()
void CEdit::SetMultiFont(bool bMulti)
{
- if ( bMulti )
- {
- delete m_format;
- m_format = (char*)malloc(sizeof(char)*m_maxChar);
- memset(m_format, 0, m_maxChar);
- }
- else
- {
- delete m_format;
- m_format = 0;
- }
+ m_format.clear();
}
-bool CEdit::RetMultiFont()
+bool CEdit::GetMultiFont()
{
- return ( m_format != 0 );
+ return ( m_format.size() > 0 );
}
@@ -2161,9 +2175,9 @@ void CEdit::Scroll()
if ( m_scroll != 0 )
{
- value = m_scroll->RetVisibleValue();
+ value = m_scroll->GetVisibleValue();
value *= m_lineTotal-m_lineVisible;
- Scroll((int)(value+0.5f), true);
+ Scroll(static_cast<int>(value+0.5f), true);
}
}
@@ -2181,7 +2195,7 @@ void CEdit::Scroll(int pos, bool bAdjustCursor)
if ( max < 0 ) max = 0;
if ( m_lineFirst > max ) m_lineFirst = max;
- line = RetCursorLine(m_cursor1);
+ line = GetCursorLine(m_cursor1);
if ( bAdjustCursor && m_bEdit )
{
@@ -2277,19 +2291,19 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( !IsSpace(character) ) break;
m_cursor1 --;
}
if ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( IsSpace(character) )
{
while ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( !IsSpace(character) ) break;
m_cursor1 --;
}
@@ -2298,7 +2312,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( !IsWord(character) ) break;
m_cursor1 --;
}
@@ -2307,7 +2321,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 > 0 )
{
- character = (unsigned char)m_text[m_cursor1-1];
+ character = static_cast<unsigned char>(m_text[m_cursor1-1]);
if ( !IsSep(character) ) break;
m_cursor1 --;
}
@@ -2327,12 +2341,12 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
if ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( IsSpace(character) )
{
while ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( !IsSpace(character) ) break;
m_cursor1 ++;
}
@@ -2341,7 +2355,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( !IsWord(character) ) break;
m_cursor1 ++;
}
@@ -2350,7 +2364,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
{
while ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( !IsSep(character) ) break;
m_cursor1 ++;
}
@@ -2359,7 +2373,7 @@ void CEdit::MoveChar(int move, bool bWord, bool bSelect)
while ( m_cursor1 < m_len )
{
- character = (unsigned char)m_text[m_cursor1];
+ character = static_cast<unsigned char>(m_text[m_cursor1]);
if ( !IsSpace(character) ) break;
m_cursor1 ++;
}
@@ -2418,29 +2432,28 @@ void CEdit::MoveLine(int move, bool bWord, bool bSelect)
}
}
- line = RetCursorLine(m_cursor1);
+ line = GetCursorLine(m_cursor1);
column = m_column;
if ( m_bAutoIndent )
{
- indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType)
- * m_engine->RetEditIndentValue();
+ indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f)
+ * m_engine->GetEditIndentValue();
column -= indentLength*m_lineIndent[line];
}
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- c = m_engine->RetText()->Detect(m_text+m_lineOffset[line],
- m_lineOffset[line+1]-m_lineOffset[line],
- column, m_fontSize,
- m_fontStretch, m_fontType);
+ c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]),
+ m_fontType, m_fontSize,
+ m_lineOffset[line+1]-m_lineOffset[line]);
}
else
{
- c = m_engine->RetText()->Detect(m_text+m_lineOffset[line],
- m_format+m_lineOffset[line],
- m_lineOffset[line+1]-m_lineOffset[line],
- column, m_fontSize, m_fontStretch);
+ c = m_engine->GetText()->Detect(std::string(m_text+m_lineOffset[line]),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[line], m_format.end()),
+ m_fontSize,
+ m_lineOffset[line+1]-m_lineOffset[line]);
}
m_cursor1 = m_lineOffset[line]+c;
@@ -2457,32 +2470,27 @@ void CEdit::ColumnFix()
float indentLength;
int line;
- line = RetCursorLine(m_cursor1);
+ line = GetCursorLine(m_cursor1);
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- m_column = m_engine->RetText()->RetStringWidth
- (
- m_text+m_lineOffset[line],
- m_cursor1-m_lineOffset[line],
- m_fontSize, m_fontStretch, m_fontType
- );
+ m_column = m_engine->GetText()->GetStringWidth(
+ std::string(m_text+m_lineOffset[line]),
+ m_fontType, m_fontSize);
}
else
{
- m_column = m_engine->RetText()->RetStringWidth
- (
- m_text+m_lineOffset[line],
- m_format+m_lineOffset[line],
- m_cursor1-m_lineOffset[line],
- m_fontSize, m_fontStretch
+ m_column = m_engine->GetText()->GetStringWidth(
+ std::string(m_text+m_lineOffset[line]),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+m_lineOffset[line], m_format.end()),
+ m_fontSize
);
}
if ( m_bAutoIndent )
{
- indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType)
- * m_engine->RetEditIndentValue();
+ indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f)
+ * m_engine->GetEditIndentValue();
m_column += indentLength*m_lineIndent[line];
}
}
@@ -2490,9 +2498,9 @@ void CEdit::ColumnFix()
// Cut the selected characters or entire line.
-bool CEdit::Cut()
+bool CEdit::Cut() // TODO MS Windows allocations
{
- HGLOBAL hg;
+ /* HGLOBAL hg;
char* text;
char c;
int c1, c2, start, len, i, j;
@@ -2565,15 +2573,15 @@ bool CEdit::Cut()
DeleteOne(0); // deletes the selected characters
Justif();
ColumnFix();
- SendModifEvent();
+ SendModifEvent();*/
return true;
}
// Copy the selected characters or entire line.
-bool CEdit::Copy()
+bool CEdit::Copy() // TODO
{
- HGLOBAL hg;
+ /* HGLOBAL hg;
char* text;
char c;
int c1, c2, start, len, i, j;
@@ -2637,15 +2645,15 @@ bool CEdit::Copy()
return false;
}
CloseClipboard();
-
+*/
return true;
}
// Paste the contents of the notebook.
-bool CEdit::Paste()
+bool CEdit::Paste() // TODO
{
- HANDLE h;
+ /*HANDLE h;
char c;
char* p;
@@ -2683,7 +2691,7 @@ bool CEdit::Paste()
Justif();
ColumnFix();
- SendModifEvent();
+ SendModifEvent();*/
return true;
}
@@ -2777,7 +2785,7 @@ void CEdit::Insert(char character)
#endif
else if ( character == '\t' )
{
- for ( i=0 ; i<m_engine->RetEditIndentValue() ; i++ )
+ for ( i=0 ; i<m_engine->GetEditIndentValue() ; i++ )
{
InsertOne(' ');
}
@@ -2816,7 +2824,7 @@ void CEdit::InsertOne(char character)
{
m_text[i] = m_text[i-1]; // shoot
- if ( m_format != 0 )
+ if ( m_format.size() > 0 )
{
m_format[i] = m_format[i-1]; // shoot
}
@@ -2826,7 +2834,7 @@ void CEdit::InsertOne(char character)
m_text[m_cursor1] = character;
- if ( m_format != 0 )
+ if ( m_format.size() > 0 )
{
m_format[m_cursor1] = 0;
}
@@ -2877,7 +2885,7 @@ void CEdit::DeleteOne(int dir)
{
m_text[i] = m_text[i+hole];
- if ( m_format != 0 )
+ if ( m_format.size() > 0 )
{
m_format[i] = m_format[i+hole];
}
@@ -3024,9 +3032,9 @@ bool CEdit::MinMaj(bool bMaj)
for ( i=c1 ; i<c2 ; i++ )
{
- character = (unsigned char)m_text[i];
- if ( bMaj ) character = RetToUpper(character);
- else character = RetToLower(character);
+ character = static_cast<unsigned char>(m_text[i]);
+ if ( bMaj ) character = GetToUpper(character);
+ else character = GetToLower(character);
m_text[i] = character;
}
@@ -3053,8 +3061,8 @@ void CEdit::Justif()
if ( m_bAutoIndent )
{
- indentLength = m_engine->RetText()->RetCharWidth(' ', 0.0f, m_fontSize, m_fontStretch, m_fontType)
- * m_engine->RetEditIndentValue();
+ indentLength = m_engine->GetText()->GetCharWidth(static_cast<Gfx::UTF8Char>(' '), m_fontType, m_fontSize, 0.0f)
+ * m_engine->GetEditIndentValue();
}
bString = bRem = false;
@@ -3069,31 +3077,34 @@ void CEdit::Justif()
width -= indentLength*m_lineIndent[m_lineTotal-1];
}
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
- i += m_engine->RetText()->Justif(m_text+i, m_len-i, width,
- m_fontSize, m_fontStretch,
- m_fontType);
+ // TODO check if good
+
+ i += m_engine->GetText()->Justify(m_text+i, m_fontType,
+ m_fontSize, width);
}
else
{
size = m_fontSize;
- if ( (m_format[i]&TITLE_MASK) == TITLE_BIG ) // headline?
+ if ( (m_format[i]&Gfx::FONT_MASK_TITLE) == Gfx::FONT_TITLE_BIG ) // headline?
{
size *= BIG_FONT;
bDual = true;
}
- if ( (m_format[i]&IMAGE_MASK) != 0 ) // image part?
+ if ( (m_format[i]&Gfx::FONT_MASK_IMAGE) != 0 ) // image part?
{
i ++; // jumps just a character (index in m_image)
}
else
{
- i += m_engine->RetText()->Justif(m_text+i, m_format+i,
- m_len-i, width,
- size, m_fontStretch);
+ // TODO check if good
+ i += m_engine->GetText()->Justify(std::string(m_text+i),
+ std::vector<Gfx::FontMetaChar>(m_format.begin()+i, m_format.end()),
+ size,
+ width);
}
}
@@ -3149,7 +3160,7 @@ void CEdit::Justif()
{
if ( m_bEdit )
{
- line = RetCursorLine(m_cursor1);
+ line = GetCursorLine(m_cursor1);
if ( line < m_lineFirst )
{
m_lineFirst = line;
@@ -3175,13 +3186,13 @@ void CEdit::Justif()
}
else
{
- value = (float)m_lineVisible/m_lineTotal;
+ value = static_cast<float>(m_lineVisible/m_lineTotal);
m_scroll->SetVisibleRatio(value);
- value = (float)m_lineFirst/(m_lineTotal-m_lineVisible);
+ value = static_cast<float>(m_lineFirst/(m_lineTotal-m_lineVisible));
m_scroll->SetVisibleValue(value);
- value = (float)1.0f/(m_lineTotal-m_lineVisible);
+ value = static_cast<float>(1.0f/(m_lineTotal-m_lineVisible));
m_scroll->SetArrowStep(value);
}
}
@@ -3191,7 +3202,7 @@ void CEdit::Justif()
// Returns the rank of the line where the cursor is located.
-int CEdit::RetCursorLine(int cursor)
+int CEdit::GetCursorLine(int cursor)
{
int line, i;
@@ -3216,7 +3227,7 @@ void CEdit::UndoFlush()
for ( i=0 ; i<EDITUNDOMAX ; i++ )
{
delete m_undo[i].text;
- m_undo[i].text = 0;
+ m_undo[i].text = nullptr;
}
m_bUndoForce = true;
@@ -3238,6 +3249,7 @@ void CEdit::UndoMemorize(OperUndo oper)
m_undoOper = oper;
delete m_undo[EDITUNDOMAX-1].text;
+ m_undo[EDITUNDOMAX-1].text = nullptr;
for ( i=EDITUNDOMAX-1 ; i>=1 ; i-- )
{
@@ -3246,7 +3258,7 @@ void CEdit::UndoMemorize(OperUndo oper)
len = m_len;
if ( len == 0 ) len ++;
- m_undo[0].text = (char*)malloc(sizeof(char)*(len+1));
+ m_undo[0].text = new char[len+1];
memcpy(m_undo[0].text, m_text, m_len);
m_undo[0].len = m_len;
@@ -3261,7 +3273,7 @@ bool CEdit::UndoRecall()
{
int i;
- if ( m_undo[0].text == 0 ) return false;
+ if ( m_undo[0].text == nullptr ) return false;
m_len = m_undo[0].len;
memcpy(m_text, m_undo[0].text, m_len);
@@ -3274,7 +3286,7 @@ bool CEdit::UndoRecall()
{
m_undo[i] = m_undo[i+1];
}
- m_undo[EDITUNDOMAX-1].text = 0;
+ m_undo[EDITUNDOMAX-1].text = nullptr;
m_bUndoForce = true;
Justif();
@@ -3288,11 +3300,11 @@ bool CEdit::UndoRecall()
bool CEdit::ClearFormat()
{
- if ( m_format == 0 )
+ if ( m_format.size() == 0 )
{
SetMultiFont(true);
}
- memset(m_format, m_fontType, m_len);
+ m_format.clear();
return true;
}
@@ -3303,7 +3315,7 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format)
{
int i;
- if ( m_format == 0 ) return false;
+ if ( m_format.size() == 0 ) return false;
for ( i=cursor1 ; i<cursor2 ; i++ )
{
@@ -3314,3 +3326,4 @@ bool CEdit::SetFormat(int cursor1, int cursor2, int format)
}
+}
diff --git a/src/ui/edit.h b/src/ui/edit.h
index dbd94d1..c5c6cf6 100644
--- a/src/ui/edit.h
+++ b/src/ui/edit.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -14,69 +15,107 @@
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see http://www.gnu.org/licenses/.
-// edit.h
+
+/**
+ * \file ui/edit.h
+ * \brief CEdit class
+ */
#pragma once
-#include "common/struct.h"
#include "ui/control.h"
+#include "ui/scroll.h"
+
+#include "graphics/engine/engine.h"
+#include "graphics/engine/text.h"
+
+#include "common/event.h"
+#include "common/misc.h"
+#include "common/iman.h"
+#include "common/restext.h"
+
+#include <vector>
+
-class CD3DEngine;
-class CScroll;
+namespace Ui {
-const int EDITSTUDIOMAX = 20000; // maximum number of characters in CBOT edit
-const int EDITLINEMAX = 1000; // maximum total number of lines
-const int EDITIMAGEMAX = 50; // maximum total number of lines with images
-const int EDITLINKMAX = 100; // maximum number of links
-const int EDITHISTORYMAX = 50; // max number of levels preserves
+//! maximum number of characters in CBOT edit
+const int EDITSTUDIOMAX = 20000;
+//! maximum total number of lines
+const int EDITLINEMAX = 1000;
+//! maximum total number of lines with images
+const int EDITIMAGEMAX = 50;
+//! maximum number of links
+const int EDITLINKMAX = 100;
+//! max number of levels preserves
+const int EDITHISTORYMAX = 50;
-const int EDITUNDOMAX = 20; // max number of successive undo
+//! max number of successive undo
+const int EDITUNDOMAX = 20;
struct EditUndo
{
- char* text; // original text
- int len; // length of the text
- int cursor1; // offset cursor
- int cursor2; // offset cursor
- int lineFirst; // the first line displayed.
+ //! original text
+ char* text;
+ //! length of the text
+ int len;
+ //! offset cursor
+ int cursor1;
+ //! offset cursor
+ int cursor2;
+ //! the first line displayed.
+ int lineFirst;
};
enum OperUndo
{
- OPERUNDO_SPEC = 0, // special operation
- OPERUNDO_INSERT = 1, // inserting characters
- OPERUNDO_DELETE = 2, // deleting characters
+ //! special operation
+ OPERUNDO_SPEC = 0,
+ //! inserting characters
+ OPERUNDO_INSERT = 1,
+ //! deleting characters
+ OPERUNDO_DELETE = 2,
};
struct ImageLine
{
- char name[40]; // name of the image (without diagram \)
- float offset; // vertical offset (v texture)
- float height; // height of the part (dv texture)
- float width; // width
+ //! name of the image (without diagram \)
+ char name[40];
+ //! vertical offset (v texture)
+ float offset;
+ //! height of the part (dv texture)
+ float height;
+ //! width
+ float width;
};
struct HyperLink
{
- char name[40]; // text file name (without help \)
- char marker[20]; // name of the marker
+ //! text file name (without help \)
+ char name[40];
+ //! name of the marker
+ char marker[20];
};
struct HyperMarker
{
- char name[20]; // name of the marker
- int pos; // position in the text
+ //! name of the marker
+ char name[20];
+ //! position in the text
+ int pos;
};
struct HyperHistory
{
- char filename[50]; // full file name text
- int firstLine; // rank of the first displayed line
+ //! full file name text
+ char filename[50];
+ //! rank of the first displayed line
+ int firstLine;
};
@@ -85,10 +124,11 @@ struct HyperHistory
class CEdit : public CControl
{
public:
- CEdit(CInstanceManager* iMan);
+// CEdit(CInstanceManager* iMan);
+ CEdit ();
virtual ~CEdit();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
void SetPos(Math::Point pos);
void SetDim(Math::Point dim);
@@ -96,47 +136,47 @@ public:
bool EventProcess(const Event &event);
void Draw();
- void SetText(char *text, bool bNew=true);
+ void SetText(const char *text, bool bNew=true);
void GetText(char *buffer, int max);
- char* RetText();
- int RetTextLength();
+ char* GetText();
+ int GetTextLength();
- bool ReadText(char *filename, int addSize=0);
- bool WriteText(char *filename);
+ bool ReadText(const char *filename, int addSize=0);
+ bool WriteText(const char *filename);
void SetMaxChar(int max);
- int RetMaxChar();
+ int GetMaxChar();
void SetEditCap(bool bMode);
- bool RetEditCap();
+ bool GetEditCap();
void SetHiliteCap(bool bEnable);
- bool RetHiliteCap();
+ bool GetHiliteCap();
void SetInsideScroll(bool bInside);
- bool RetInsideScroll();
+ bool GetInsideScroll();
void SetSoluceMode(bool bSoluce);
- bool RetSoluceMode();
+ bool GetSoluceMode();
void SetGenericMode(bool bGeneric);
- bool RetGenericMode();
+ bool GetGenericMode();
void SetAutoIndent(bool bMode);
- bool RetAutoIndent();
+ bool GetAutoIndent();
void SetCursor(int cursor1, int cursor2);
void GetCursor(int &cursor1, int &cursor2);
void SetFirstLine(int rank);
- int RetFirstLine();
+ int GetFirstLine();
void ShowSelect();
void SetDisplaySpec(bool bDisplay);
- bool RetDisplaySpec();
+ bool GetDisplaySpec();
void SetMultiFont(bool bMulti);
- bool RetMultiFont();
+ bool GetMultiFont();
bool Cut();
bool Copy();
@@ -144,9 +184,9 @@ public:
bool Undo();
void HyperFlush();
- void HyperHome(char *filename);
- bool HyperTest(EventMsg event);
- bool HyperGo(EventMsg event);
+ void HyperHome(const char *filename);
+ bool HyperTest(EventType event);
+ bool HyperGo(EventType event);
void SetFontSize(float size);
@@ -163,15 +203,15 @@ protected:
int MouseDetect(Math::Point mouse);
void MoveAdjust();
- void HyperJump(char *name, char *marker);
- bool HyperAdd(char *filename, int firstLine);
+ void HyperJump(const char *name, const char *marker);
+ bool HyperAdd(const char *filename, int firstLine);
- void DrawImage(Math::Point pos, char *name, float width, float offset, float height, int nbLine);
+ void DrawImage(Math::Point pos, const char *name, float width, float offset, float height, int nbLine);
void DrawBack(Math::Point pos, Math::Point dim);
void DrawPart(Math::Point pos, Math::Point dim, int icon);
void FreeImage();
- void LoadImage(char *name);
+ void LoadImage(const char *name);
void Scroll(int pos, bool bAdjustCursor);
void Scroll();
void MoveChar(int move, bool bWord, bool bSelect);
@@ -189,7 +229,7 @@ protected:
bool Shift(bool bLeft);
bool MinMaj(bool bMaj);
void Justif();
- int RetCursorLine(int cursor);
+ int GetCursorLine(int cursor);
void UndoFlush();
void UndoMemorize(OperUndo oper);
@@ -200,7 +240,7 @@ protected:
int m_maxChar; // max length of the buffer m_text
char* m_text; // text (without zero terminator)
- char* m_format; // format characters
+ std::vector<Gfx::FontMetaChar> m_format; // format characters
int m_len; // length used in m_text
int m_cursor1; // offset cursor
int m_cursor2; // offset cursor
@@ -246,3 +286,4 @@ protected:
};
+}
diff --git a/src/ui/editvalue.cpp b/src/ui/editvalue.cpp
index 71e06f2..3b819b3 100644
--- a/src/ui/editvalue.cpp
+++ b/src/ui/editvalue.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,13 +18,6 @@
// editvalue.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
@@ -33,10 +27,11 @@
-
+namespace Ui {
// Object's constructor.
-CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan)
+//CEditValue::CEditValue(CInstanceManager* iMan) : CControl(iMan)
+CEditValue::CEditValue() : CControl ()
{
m_edit = 0;
m_buttonUp = 0;
@@ -60,28 +55,28 @@ CEditValue::~CEditValue()
// Creates a new button.
-bool CEditValue::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CEditValue::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- CEdit* pe;
- CButton* pc;
+ Ui::CEdit* pe;
+ Ui::CButton* pc;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
- CControl::Create(pos, dim, icon, eventMsg);
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
+ CControl::Create(pos, dim, icon, eventType);
GlintDelete();
- m_edit = new CEdit(m_iMan);
- pe = (CEdit*)m_edit;
+ m_edit = new Ui::CEdit();
+ pe = static_cast<Ui::CEdit*>(m_edit);
pe->Create(pos, dim, 0, EVENT_NULL);
pe->SetMaxChar(4);
- m_buttonUp = new CButton(m_iMan);
- pc = (CButton*)m_buttonUp;
+ m_buttonUp = new Ui::CButton();
+ pc = static_cast<Ui::CButton*>(m_buttonUp);
pc->Create(pos, dim, 49, EVENT_NULL); // ^
pc->SetRepeat(true);
- m_buttonDown = new CButton(m_iMan);
- pc = (CButton*)m_buttonDown;
+ m_buttonDown = new Ui::CButton();
+ pc = static_cast<Ui::CButton*>(m_buttonDown);
pc->Create(pos, dim, 50, EVENT_NULL); // v
pc->SetRepeat(true);
@@ -151,11 +146,11 @@ bool CEditValue::EventProcess(const Event &event)
if ( m_edit != 0 )
{
- if ( m_edit->RetFocus() &&
- event.event == EVENT_KEYDOWN &&
- event.param == VK_RETURN )
+ if ( m_edit->GetFocus() &&
+ event.type == EVENT_KEY_DOWN &&
+ event.key.key == KEY(RETURN) )
{
- value = RetValue();
+ value = GetValue();
if ( value > m_maxValue ) value = m_maxValue;
if ( value < m_minValue ) value = m_minValue;
SetValue(value, true);
@@ -163,19 +158,18 @@ bool CEditValue::EventProcess(const Event &event)
}
if ( !m_edit->EventProcess(event) ) return false;
- if ( event.event == m_edit->RetEventMsg() )
+ if ( event.type == m_edit->GetEventType() )
{
- Event newEvent;
- m_event->MakeEvent(newEvent, m_eventMsg);
+ Event newEvent(m_eventType);
m_event->AddEvent(newEvent);
}
}
if ( m_buttonUp != 0 )
{
- if ( event.event == m_buttonUp->RetEventMsg() )
+ if ( event.type == m_buttonUp->GetEventType() )
{
- value = RetValue()+m_stepValue;
+ value = GetValue()+m_stepValue;
if ( value > m_maxValue ) value = m_maxValue;
SetValue(value, true);
HiliteValue(event);
@@ -185,9 +179,9 @@ bool CEditValue::EventProcess(const Event &event)
if ( m_buttonDown != 0 )
{
- if ( event.event == m_buttonDown->RetEventMsg() )
+ if ( event.type == m_buttonDown->GetEventType() )
{
- value = RetValue()-m_stepValue;
+ value = GetValue()-m_stepValue;
if ( value < m_minValue ) value = m_minValue;
SetValue(value, true);
HiliteValue(event);
@@ -195,20 +189,20 @@ bool CEditValue::EventProcess(const Event &event)
if ( !m_buttonDown->EventProcess(event) ) return false;
}
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELUP &&
- Detect(event.pos) )
+ if (event.type == EVENT_MOUSE_WHEEL &&
+ event.mouseWheel.dir == WHEEL_UP &&
+ Detect(event.mouseWheel.pos))
{
- value = RetValue()+m_stepValue;
+ value = GetValue()+m_stepValue;
if ( value > m_maxValue ) value = m_maxValue;
SetValue(value, true);
HiliteValue(event);
}
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELDOWN &&
- Detect(event.pos) )
+ if ( event.type == EVENT_KEY_DOWN &&
+ event.mouseWheel.dir == WHEEL_DOWN &&
+ Detect(event.mouseWheel.pos))
{
- value = RetValue()-m_stepValue;
+ value = GetValue()-m_stepValue;
if ( value < m_minValue ) value = m_minValue;
SetValue(value, true);
HiliteValue(event);
@@ -226,7 +220,7 @@ void CEditValue::HiliteValue(const Event &event)
if ( m_edit == 0 ) return;
- pos = m_edit->RetTextLength();
+ pos = m_edit->GetTextLength();
if ( m_type == EVT_100 && pos > 0 )
{
pos --; // not only selects the "%"
@@ -236,8 +230,9 @@ void CEditValue::HiliteValue(const Event &event)
m_edit->SetFocus(true);
Event newEvent = event;
- newEvent.event = EVENT_FOCUS;
- newEvent.param = m_edit->RetEventMsg();
+ newEvent.type = EVENT_ACTIVE;
+ newEvent.active.gain = true; // TODO not much pretty sure about it
+ newEvent.param = m_edit->GetEventType();
m_event->AddEvent(newEvent); // defocus the other objects
}
@@ -275,7 +270,7 @@ void CEditValue::SetType(EditValueType type)
m_type = type;
}
-EditValueType CEditValue::RetType()
+EditValueType CEditValue::GetType()
{
return m_type;
}
@@ -293,7 +288,7 @@ void CEditValue::SetValue(float value, bool bSendMessage)
if ( m_type == EVT_INT )
{
- sprintf(text, "%d", (int)value);
+ sprintf(text, "%d", static_cast<int>(value));
}
if ( m_type == EVT_FLOAT )
@@ -303,37 +298,36 @@ void CEditValue::SetValue(float value, bool bSendMessage)
if ( m_type == EVT_100 )
{
- sprintf(text, "%d%%", (int)(value*100.0f));
+ sprintf(text, "%d%%", static_cast<int>(value*100.0f));
}
m_edit->SetText(text);
if ( bSendMessage )
{
- Event newEvent;
- m_event->MakeEvent(newEvent, m_eventMsg);
+ Event newEvent(m_eventType);
m_event->AddEvent(newEvent);
}
}
// Return the edited value.
-float CEditValue::RetValue()
+float CEditValue::GetValue()
{
char text[100];
- float value;
+ float value = 0.0f;
- if ( m_edit == 0 ) 0.0f;
-
- m_edit->GetText(text, 100);
- sscanf(text, "%f", &value);
-
- if ( m_type == EVT_100 )
+ if ( m_edit != 0 )
{
- value = (value+0.5f)/100.0f;
- if ( value < 0.01f ) value = 0.0f; // less than 1%?
- }
+ m_edit->GetText(text, 100);
+ sscanf(text, "%f", &value);
+ if ( m_type == EVT_100 )
+ {
+ value = (value+0.5f)/100.0f;
+ if ( value < 0.01f ) value = 0.0f; // less than 1%?
+ }
+ }
return value;
}
@@ -345,7 +339,7 @@ void CEditValue::SetStepValue(float value)
m_stepValue = value;
}
-float CEditValue::RetStepValue()
+float CEditValue::GetStepValue()
{
return m_stepValue;
}
@@ -358,7 +352,7 @@ void CEditValue::SetMinValue(float value)
m_minValue = value;
}
-float CEditValue::RetMinValue()
+float CEditValue::GetMinValue()
{
return m_minValue;
}
@@ -371,8 +365,9 @@ void CEditValue::SetMaxValue(float value)
m_maxValue = value;
}
-float CEditValue::RetMaxValue()
+float CEditValue::GetMaxValue()
{
return m_maxValue;
}
+}
diff --git a/src/ui/editvalue.h b/src/ui/editvalue.h
index dbb7812..1469b69 100644
--- a/src/ui/editvalue.h
+++ b/src/ui/editvalue.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -22,6 +23,12 @@
#include "ui/control.h"
+namespace Gfx{
+class CEngine;
+}
+
+namespace Ui {
+
enum EditValueType
{
EVT_INT = 1, // integer
@@ -29,8 +36,6 @@ enum EditValueType
EVT_100 = 3, // percent (0 .. 1)
};
-
-class CD3DEngine;
class CEdit;
class CButton;
@@ -39,10 +44,11 @@ class CButton;
class CEditValue : public CControl
{
public:
- CEditValue(CInstanceManager* iMan);
+// CEditValue(CInstanceManager* iMan);
+ CEditValue();
virtual ~CEditValue();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
void SetPos(Math::Point pos);
void SetDim(Math::Point dim);
@@ -51,33 +57,32 @@ public:
void Draw();
void SetType(EditValueType type);
- EditValueType RetType();
+ EditValueType GetType();
void SetValue(float value, bool bSendMessage=false);
- float RetValue();
+ float GetValue();
void SetStepValue(float value);
- float RetStepValue();
+ float GetStepValue();
void SetMinValue(float value);
- float RetMinValue();
+ float GetMinValue();
void SetMaxValue(float value);
- float RetMaxValue();
+ float GetMaxValue();
protected:
void MoveAdjust();
void HiliteValue(const Event &event);
-protected:
- CEdit* m_edit;
- CButton* m_buttonUp;
- CButton* m_buttonDown;
-
- EditValueType m_type;
- float m_stepValue;
- float m_minValue;
- float m_maxValue;
+ Ui::CEdit* m_edit;
+ Ui::CButton* m_buttonUp;
+ Ui::CButton* m_buttonDown;
+ EditValueType m_type;
+ float m_stepValue;
+ float m_minValue;
+ float m_maxValue;
};
+}
diff --git a/src/ui/gauge.cpp b/src/ui/gauge.cpp
index 13cd4f7..b1ce31d 100644
--- a/src/ui/gauge.cpp
+++ b/src/ui/gauge.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,24 +18,14 @@
// gauge.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
#include "ui/gauge.h"
-
-
+namespace Ui {
// Object's constructor.
-CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan)
+//CGauge::CGauge(CInstanceManager* iMan) : CControl(iMan)
+CGauge::CGauge() : CControl()
{
m_level = 0.0f;
}
@@ -48,11 +39,11 @@ CGauge::~CGauge()
// Creates a new button.
-bool CGauge::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CGauge::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
- CControl::Create(pos, dim, icon, eventMsg);
+ CControl::Create(pos, dim, icon, eventType);
return true;
}
@@ -63,12 +54,12 @@ bool CGauge::EventProcess(const Event &event)
{
CControl::EventProcess(event);
- if ( event.event == EVENT_LBUTTONDOWN )
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
@@ -87,48 +78,48 @@ void CGauge::Draw()
if ( (m_state & STATE_VISIBLE) == 0 ) return;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
dp = 0.5f/256.0f;
pos = m_pos;
dim = m_dim;
- uv1.x = 32.0f/256.0f;
- uv1.y = 32.0f/256.0f;
- uv2.x = 64.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ uv1.x = 32.0f / 256.0f;
+ uv1.y = 32.0f / 256.0f;
+ uv2.x = 64.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 10.0f/640.0f;
- corner.y = 10.0f/480.0f;
+ corner.x = 10.0f / 640.0f;
+ corner.y = 10.0f / 480.0f;
DrawIcon(pos, dim, uv1, uv2, corner, 8.0f/256.0f);
- pos.x += 3.0f/640.0f;
- pos.y += 3.0f/480.0f;
- dim.x -= 6.0f/640.0f;
- dim.y -= 6.0f/480.0f;
+ pos.x += 3.0f / 640.0f;
+ pos.y += 3.0f / 480.0f;
+ dim.x -= 6.0f / 640.0f;
+ dim.y -= 6.0f / 480.0f;
if ( m_dim.x < m_dim.y ) // vertical gauge?
{
- uv1.x = (0.0f+m_icon*16.0f)/256.0f;
- uv2.x = uv1.x+16.0f/256.0f;
- uv1.y = 128.0f/256.0f+m_level*(64.0f/256.0f);
- uv2.y = uv1.y+64.0f/256.0f;
+ uv1.x = (0.0f + m_icon * 16.0f) / 256.0f;
+ uv2.x = uv1.x + 16.0f / 256.0f;
+ uv1.y = 128.0f/256.0f + m_level * (64.0f/256.0f);
+ uv2.y = uv1.y + 64.0f/256.0f;
}
else // horizontal gauge?
{
- uv1.x = 64.0f/256.0f+(1.0f-m_level)*(64.0f/256.0f);
- uv2.x = uv1.x+64.0f/256.0f;
- uv1.y = (128.0f+m_icon*16.0f)/256.0f;
- uv2.y = uv1.y+16.0f/256.0f;
+ uv1.x = 64.0f/256.0f + (1.0f - m_level) * (64.0f/256.0f);
+ uv2.x = uv1.x + 64.0f/256.0f;
+ uv1.y = (128.0f + m_icon*16.0f) / 256.0f;
+ uv2.y = uv1.y + 16.0f/256.0f;
}
uv1.x += dp;
@@ -149,9 +140,10 @@ void CGauge::SetLevel(float level)
m_level = level;
}
-float CGauge::RetLevel()
+float CGauge::GetLevel()
{
return m_level;
}
+}
diff --git a/src/ui/gauge.h b/src/ui/gauge.h
index bdc85ff..f4a008f 100644
--- a/src/ui/gauge.h
+++ b/src/ui/gauge.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,33 +19,37 @@
#pragma once
+#include "graphics/engine/engine.h"
-#include "ui/control.h"
-
+#include "common/event.h"
+#include "common/misc.h"
-class CD3DEngine;
+#include "ui/control.h"
+namespace Ui {
class CGauge : public CControl
{
-public:
- CGauge(CInstanceManager* iMan);
- virtual ~CGauge();
+ public:
+ // CGauge(CInstanceManager* iMan);
+ CGauge();
+ virtual ~CGauge();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
- void SetLevel(float level);
- float RetLevel();
+ void SetLevel(float level);
+ float GetLevel();
-protected:
+ protected:
-protected:
- float m_level;
+ protected:
+ float m_level;
};
+}
diff --git a/src/ui/group.cpp b/src/ui/group.cpp
index 06290e4..67369d9 100644
--- a/src/ui/group.cpp
+++ b/src/ui/group.cpp
@@ -16,26 +16,24 @@
// group.cpp
+#include "ui/group.h"
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "common/restext.h"
-#include "ui/group.h"
+#include "graphics/engine/engine.h"
+#include <stdio.h>
+#include <string.h>
+namespace Ui {
// Object's constructor.
-CGroup::CGroup(CInstanceManager* iMan) : CControl(iMan)
+//CGroup::CGroup(CInstanceManager* iMan) : CControl(iMan)
+CGroup::CGroup() : CControl()
{
}
@@ -48,18 +46,18 @@ CGroup::~CGroup()
// Creates a new button.
-bool CGroup::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CGroup::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
- CControl::Create(pos, dim, icon, eventMsg);
+ CControl::Create(pos, dim, icon, eventType);
if ( icon == -1 )
{
char name[100];
char* p;
- GetResource(RES_EVENT, eventMsg, name);
+ GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\');
if ( p != 0 ) *p = 0;
SetName(name);
@@ -92,16 +90,16 @@ void CGroup::Draw()
DrawShadow(m_pos, m_dim);
}
- dp = 0.5f/256.0f;
+ dp = 0.5f / 256.0f;
if ( m_icon == 0 ) // hollow frame?
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 160.0f/256.0f;
- uv1.y = 192.0f/256.0f; // u-v texture
- uv2.x = 192.0f/256.0f;
- uv2.y = 224.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 160.0f / 256.0f;
+ uv1.y = 192.0f / 256.0f; // u-v texture
+ uv2.x = 192.0f / 256.0f;
+ uv2.y = 224.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -112,12 +110,12 @@ void CGroup::Draw()
}
if ( m_icon == 1 ) // orange solid opaque?
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 104.0f/256.0f;
- uv1.y = 48.0f/256.0f;
- uv2.x = 112.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 104.0f / 256.0f;
+ uv1.y = 48.0f / 256.0f;
+ uv2.x = 112.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -126,12 +124,12 @@ void CGroup::Draw()
}
if ( m_icon == 2 ) // orange degrade -> transparent?
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 112.0f/256.0f;
- uv1.y = 48.0f/256.0f;
- uv2.x = 120.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
+ uv1.x = 112.0f / 256.0f;
+ uv1.y = 48.0f / 256.0f;
+ uv2.x = 120.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -140,12 +138,12 @@ void CGroup::Draw()
}
if ( m_icon == 3 ) // transparent gradient -> gray?
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 120.0f/256.0f;
- uv1.y = 48.0f/256.0f;
- uv2.x = 128.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
+ uv1.x = 120.0f / 256.0f;
+ uv1.y = 48.0f / 256.0f;
+ uv2.x = 128.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -154,12 +152,12 @@ void CGroup::Draw()
}
if ( m_icon == 4 ) // degrade blue corner?
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 192.0f/256.0f;
- uv1.y = 128.0f/256.0f;
- uv2.x = 224.0f/256.0f;
- uv2.y = 160.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
+ uv1.x = 192.0f / 256.0f;
+ uv1.y = 128.0f / 256.0f;
+ uv2.x = 224.0f / 256.0f;
+ uv2.y = 160.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -168,12 +166,12 @@ void CGroup::Draw()
}
if ( m_icon == 5 ) // degrade orange corner?
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 224.0f/256.0f;
- uv1.y = 128.0f/256.0f;
- uv2.x = 256.0f/256.0f;
- uv2.y = 160.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
+ uv1.x = 224.0f / 256.0f;
+ uv1.y = 128.0f / 256.0f;
+ uv2.x = 256.0f / 256.0f;
+ uv2.y = 160.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -182,28 +180,28 @@ void CGroup::Draw()
}
if ( m_icon == 6 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
- uv1.x = 0.0f/256.0f; // brown transparent
- uv1.y = 75.0f/256.0f;
- uv2.x = 64.0f/256.0f;
- uv2.y = 128.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
+ uv1.x = 0.0f / 256.0f; // brown transparent
+ uv1.y = 75.0f / 256.0f;
+ uv2.x = 64.0f / 256.0f;
+ uv2.y = 128.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 4.0f/640.0f;
- corner.y = 4.0f/480.0f;
+ corner.x = 4.0f / 640.0f;
+ corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 8.0f/256.0f);
}
if ( m_icon == 7 )
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 64.0f/256.0f;
- uv1.y = 0.0f/256.0f;
- uv2.x = 96.0f/256.0f;
- uv2.y = 32.0f/256.0f;
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 64.0f / 256.0f;
+ uv1.y = 0.0f / 256.0f;
+ uv2.x = 96.0f / 256.0f;
+ uv2.y = 32.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -212,12 +210,12 @@ void CGroup::Draw()
}
if ( m_icon == 8 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
- uv1.x = 64.0f/256.0f; // green transparent
- uv1.y = 160.0f/256.0f;
- uv2.x = 160.0f/256.0f;
- uv2.y = 176.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
+ uv1.x = 64.0f / 256.0f; // green transparent
+ uv1.y = 160.0f / 256.0f;
+ uv2.x = 160.0f / 256.0f;
+ uv2.y = 176.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -226,9 +224,9 @@ void CGroup::Draw()
}
if ( m_icon == 9 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
- uv1.x = 64.0f/256.0f; // red transparent
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
+ uv1.x = 64.0f / 256.0f; // red transparent
uv1.y = 176.0f/256.0f;
uv2.x = 160.0f/256.0f;
uv2.y = 192.0f/256.0f;
@@ -240,12 +238,12 @@ void CGroup::Draw()
}
if ( m_icon == 10 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
- uv1.x = 64.0f/256.0f; // blue transparent
- uv1.y = 192.0f/256.0f;
- uv2.x = 160.0f/256.0f;
- uv2.y = 208.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
+ uv1.x = 64.0f / 256.0f; // blue transparent
+ uv1.y = 192.0f / 256.0f;
+ uv2.x = 160.0f / 256.0f;
+ uv2.y = 208.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -254,12 +252,12 @@ void CGroup::Draw()
}
if ( m_icon == 11 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
- uv1.x = 64.0f/256.0f; // yellow transparent
- uv1.y = 224.0f/256.0f;
- uv2.x = 160.0f/256.0f;
- uv2.y = 240.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
+ uv1.x = 64.0f / 256.0f; // yellow transparent
+ uv1.y = 224.0f / 256.0f;
+ uv2.x = 160.0f / 256.0f;
+ uv2.y = 240.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -268,17 +266,17 @@ void CGroup::Draw()
}
if ( m_icon == 12 ) // viewfinder cross?
{
- dim.x = m_dim.x/2.0f;
- dim.y = m_dim.y/2.0f;
+ dim.x = m_dim.x / 2.0f;
+ dim.y = m_dim.y / 2.0f;
- m_engine->SetTexture("mouse.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("mouse.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/300.0f;
pos.y = m_pos.y+m_dim.y/300.0f+dim.y;
- uv1.x = 0.5f/256.0f;
- uv1.y = 192.5f/256.0f;
- uv2.x = 63.5f/256.0f;
- uv2.y = 255.5f/256.0f;
+ uv1.x = 0.5f / 256.0f;
+ uv1.y = 192.5f / 256.0f;
+ uv2.x = 63.5f / 256.0f;
+ uv2.y = 255.5f / 256.0f;
DrawIcon(pos, dim, uv1, uv2); // ul
pos.x += dim.x;
Math::Swap(uv1.x, uv2.x);
@@ -290,13 +288,13 @@ void CGroup::Draw()
Math::Swap(uv1.x, uv2.x);
DrawIcon(pos, dim, uv1, uv2); // dl
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/300.0f;
pos.y = m_pos.y-m_dim.y/300.0f+dim.y;
- uv1.x = 64.5f/256.0f;
- uv1.y = 192.5f/256.0f;
- uv2.x = 127.5f/256.0f;
- uv2.y = 255.5f/256.0f;
+ uv1.x = 64.5f / 256.0f;
+ uv1.y = 192.5f / 256.0f;
+ uv2.x = 127.5f / 256.0f;
+ uv2.y = 255.5f / 256.0f;
DrawIcon(pos, dim, uv1, uv2); // ul
pos.x += dim.x;
Math::Swap(uv1.x, uv2.x);
@@ -310,112 +308,112 @@ void CGroup::Draw()
}
if ( m_icon == 13 ) // corner upper / left?
{
- m_engine->SetTexture("mouse.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("mouse.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f;
- uv1.x = 128.5f/256.0f;
- uv1.y = 192.5f/256.0f;
- uv2.x = 191.5f/256.0f;
- uv2.y = 255.5f/256.0f;
+ uv1.x = 128.5f / 256.0f;
+ uv1.y = 192.5f / 256.0f;
+ uv2.x = 191.5f / 256.0f;
+ uv2.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2);
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/150.0f;
pos.y = m_pos.y-m_dim.y/150.0f;
- uv1.x = 192.5f/256.0f;
- uv1.y = 192.5f/256.0f;
- uv2.x = 255.5f/256.0f;
- uv2.y = 255.5f/256.0f;
+ uv1.x = 192.5f / 256.0f;
+ uv1.y = 192.5f / 256.0f;
+ uv2.x = 255.5f / 256.0f;
+ uv2.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2);
}
if ( m_icon == 14 ) // corner upper / right?
{
- m_engine->SetTexture("mouse.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("mouse.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f;
- uv2.x = 128.5f/256.0f;
- uv1.y = 192.5f/256.0f;
- uv1.x = 191.5f/256.0f;
- uv2.y = 255.5f/256.0f;
+ uv2.x = 128.5f / 256.0f;
+ uv1.y = 192.5f / 256.0f;
+ uv1.x = 191.5f / 256.0f;
+ uv2.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2);
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/150.0f;
pos.y = m_pos.y-m_dim.y/150.0f;
- uv2.x = 192.5f/256.0f;
- uv1.y = 192.5f/256.0f;
- uv1.x = 255.5f/256.0f;
- uv2.y = 255.5f/256.0f;
+ uv2.x = 192.5f / 256.0f;
+ uv1.y = 192.5f / 256.0f;
+ uv1.x = 255.5f / 256.0f;
+ uv2.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2);
}
if ( m_icon == 15 ) // corner lower / left?
{
- m_engine->SetTexture("mouse.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("mouse.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f;
- uv1.x = 128.5f/256.0f;
- uv2.y = 192.5f/256.0f;
- uv2.x = 191.5f/256.0f;
- uv1.y = 255.5f/256.0f;
+ uv1.x = 128.5f / 256.0f;
+ uv2.y = 192.5f / 256.0f;
+ uv2.x = 191.5f / 256.0f;
+ uv1.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2);
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/150.0f;
pos.y = m_pos.y-m_dim.y/150.0f;
- uv1.x = 192.5f/256.0f;
- uv2.y = 192.5f/256.0f;
- uv2.x = 255.5f/256.0f;
- uv1.y = 255.5f/256.0f;
+ uv1.x = 192.5f / 256.0f;
+ uv2.y = 192.5f / 256.0f;
+ uv2.x = 255.5f / 256.0f;
+ uv1.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2);
}
if ( m_icon == 16 ) // corner lower / left?
{
- m_engine->SetTexture("mouse.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("mouse.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
pos.x = m_pos.x-m_dim.x/150.0f;
pos.y = m_pos.y+m_dim.y/150.0f;
- uv2.x = 128.5f/256.0f;
- uv2.y = 192.5f/256.0f;
- uv1.x = 191.5f/256.0f;
- uv1.y = 255.5f/256.0f;
+ uv2.x = 128.5f / 256.0f;
+ uv2.y = 192.5f / 256.0f;
+ uv1.x = 191.5f / 256.0f;
+ uv1.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2);
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
pos.x = m_pos.x+m_dim.x/150.0f;
pos.y = m_pos.y-m_dim.y/150.0f;
- uv2.x = 192.5f/256.0f;
- uv2.y = 192.5f/256.0f;
- uv1.x = 255.5f/256.0f;
- uv1.y = 255.5f/256.0f;
+ uv2.x = 192.5f / 256.0f;
+ uv2.y = 192.5f / 256.0f;
+ uv1.x = 255.5f / 256.0f;
+ uv1.y = 255.5f / 256.0f;
DrawIcon(pos, m_dim, uv1, uv2);
}
if ( m_icon == 17 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 0.0f/256.0f; // blue frame
- uv1.y = 75.0f/256.0f;
- uv2.x = 64.0f/256.0f;
- uv2.y = 128.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 0.0f / 256.0f; // blue frame
+ uv1.y = 75.0f / 256.0f;
+ uv2.x = 64.0f / 256.0f;
+ uv2.y = 128.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 6.0f/640.0f;
- corner.y = 6.0f/480.0f;
+ corner.x = 6.0f / 640.0f;
+ corner.y = 6.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
}
if ( m_icon == 18 ) // arrow> for SatCom?
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 0.0f/256.0f; // >
- uv1.y = 192.0f/256.0f;
- uv2.x = 32.0f/256.0f;
- uv2.y = 224.0f/256.0f;
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
+ uv1.x = 0.0f / 256.0f; // >
+ uv1.y = 192.0f / 256.0f;
+ uv2.x = 32.0f / 256.0f;
+ uv2.y = 224.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -424,12 +422,12 @@ void CGroup::Draw()
}
if ( m_icon == 19 ) // SatCom symbol?
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 224.0f/256.0f; // SatCom symbol
- uv1.y = 224.0f/256.0f;
- uv2.x = 256.0f/256.0f;
- uv2.y = 256.0f/256.0f;
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
+ uv1.x = 224.0f / 256.0f; // SatCom symbol
+ uv1.y = 224.0f / 256.0f;
+ uv2.x = 256.0f / 256.0f;
+ uv2.y = 256.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -438,12 +436,12 @@ void CGroup::Draw()
}
if ( m_icon == 20 ) // solid blue background?
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 224.0f/256.0f;
- uv1.y = 32.0f/256.0f;
- uv2.x = 256.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
+ uv1.x = 224.0f / 256.0f;
+ uv1.y = 32.0f / 256.0f;
+ uv2.x = 256.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -452,12 +450,12 @@ void CGroup::Draw()
}
if ( m_icon == 21 ) // stand-by symbol?
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 160.0f/256.0f;
- uv1.y = 32.0f/256.0f;
- uv2.x = 192.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
+ uv1.x = 160.0f / 256.0f;
+ uv1.y = 32.0f / 256.0f;
+ uv2.x = 192.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -466,93 +464,93 @@ void CGroup::Draw()
}
if ( m_icon == 22 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 64.0f/256.0f; // opaque yellow
- uv1.y = 224.0f/256.0f;
- uv2.x = 160.0f/256.0f;
- uv2.y = 240.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 64.0f / 256.0f; // opaque yellow
+ uv1.y = 224.0f / 256.0f;
+ uv2.x = 160.0f / 256.0f;
+ uv2.y = 240.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 5.0f/640.0f;
- corner.y = 5.0f/480.0f;
+ corner.x = 5.0f / 640.0f;
+ corner.y = 5.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 3.0f/256.0f);
}
if ( m_icon == 23 )
{
- m_engine->SetTexture("button3.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 64.0f/256.0f; // yellow
- uv1.y = 192.0f/256.0f;
- uv2.x = 80.0f/256.0f;
- uv2.y = 208.0f/256.0f;
+ m_engine->SetTexture("button3.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 64.0f / 256.0f; // yellow
+ uv1.y = 192.0f / 256.0f;
+ uv2.x = 80.0f / 256.0f;
+ uv2.y = 208.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 4.0f/640.0f;
- corner.y = 4.0f/480.0f;
+ corner.x = 4.0f / 640.0f;
+ corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
}
if ( m_icon == 24 )
{
- m_engine->SetTexture("button3.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 80.0f/256.0f; // orange
- uv1.y = 192.0f/256.0f;
- uv2.x = 96.0f/256.0f;
- uv2.y = 208.0f/256.0f;
+ m_engine->SetTexture("button3.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 80.0f / 256.0f; // orange
+ uv1.y = 192.0f / 256.0f;
+ uv2.x = 96.0f / 256.0f;
+ uv2.y = 208.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 4.0f/640.0f;
- corner.y = 4.0f/480.0f;
+ corner.x = 4.0f / 640.0f;
+ corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
}
if ( m_icon == 25 )
{
- m_engine->SetTexture("button3.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 64.0f/256.0f; // orange
- uv1.y = 208.0f/256.0f;
- uv2.x = 80.0f/256.0f;
- uv2.y = 224.0f/256.0f;
+ m_engine->SetTexture("button3.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 64.0f / 256.0f; // orange
+ uv1.y = 208.0f / 256.0f;
+ uv2.x = 80.0f / 256.0f;
+ uv2.y = 224.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 4.0f/640.0f;
- corner.y = 4.0f/480.0f;
+ corner.x = 4.0f / 640.0f;
+ corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
}
if ( m_icon == 26 )
{
- m_engine->SetTexture("button3.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 80.0f/256.0f; // red
- uv1.y = 208.0f/256.0f;
- uv2.x = 96.0f/256.0f;
- uv2.y = 224.0f/256.0f;
+ m_engine->SetTexture("button3.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 80.0f / 256.0f; // red
+ uv1.y = 208.0f / 256.0f;
+ uv2.x = 96.0f / 256.0f;
+ uv2.y = 224.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 4.0f/640.0f;
- corner.y = 4.0f/480.0f;
+ corner.x = 4.0f / 640.0f;
+ corner.y = 4.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 2.0f/256.0f);
}
if ( m_icon == 27 )
{
- m_engine->SetTexture("button3.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 32.0f/256.0f;
- uv1.y = 0.0f/256.0f;
- uv2.x = 64.0f/256.0f;
- uv2.y = 32.0f/256.0f;
+ m_engine->SetTexture("button3.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 32.0f / 256.0f;
+ uv1.y = 0.0f / 256.0f;
+ uv2.x = 64.0f / 256.0f;
+ uv2.y = 32.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
@@ -565,10 +563,10 @@ void CGroup::Draw()
pos = m_pos;
dim = m_dim;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 32.0f/256.0f;
- uv1.y = 32.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 32.0f / 256.0f;
+ uv1.y = 32.0f / 256.0f;
uv2.x = uv1.x+32.0f/256.0f;
uv2.y = uv1.y+32.0f/256.0f;
uv1.x += dp;
@@ -577,14 +575,14 @@ void CGroup::Draw()
uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2);
- m_engine->SetTexture("button3.tga");
- m_engine->SetState(D3DSTATENORMAL);
- pos.x += 8.0f/640.0f;
- pos.y += 8.0f/480.0f;
- dim.x -= 16.0f/640.0f;
- dim.y -= 16.0f/480.0f;
- uv1.x = 32.0f/256.0f;
- uv1.y = 0.0f/256.0f;
+ m_engine->SetTexture("button3.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ pos.x += 8.0f / 640.0f;
+ pos.y += 8.0f / 480.0f;
+ dim.x -= 16.0f / 640.0f;
+ dim.y -= 16.0f / 480.0f;
+ uv1.x = 32.0f / 256.0f;
+ uv1.y = 0.0f / 256.0f;
uv2.x = uv1.x+32.0f/256.0f;
uv2.y = uv1.y+32.0f/256.0f;
uv1.x += dp;
@@ -593,13 +591,13 @@ void CGroup::Draw()
uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2);
- m_engine->SetState(D3DSTATENORMAL);
- pos.x += 2.0f/640.0f;
- pos.y += 2.0f/480.0f;
- dim.x -= 4.0f/640.0f;
- dim.y -= 4.0f/480.0f;
- uv1.x = 0.0f/256.0f;
- uv1.y = 0.0f/256.0f;
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ pos.x += 2.0f / 640.0f;
+ pos.y += 2.0f / 480.0f;
+ dim.x -= 4.0f / 640.0f;
+ dim.y -= 4.0f / 480.0f;
+ uv1.x = 0.0f / 256.0f;
+ uv1.y = 0.0f / 256.0f;
uv2.x = uv1.x+32.0f/256.0f;
uv2.y = uv1.y+32.0f/256.0f;
uv1.x += dp;
@@ -608,11 +606,11 @@ void CGroup::Draw()
uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2);
- m_engine->SetState(D3DSTATETTb);
- pos.x += 8.0f/640.0f;
- pos.y += 8.0f/480.0f;
- dim.x -= 16.0f/640.0f;
- dim.y -= 16.0f/480.0f;
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
+ pos.x += 8.0f / 640.0f;
+ pos.y += 8.0f / 480.0f;
+ dim.x -= 16.0f / 640.0f;
+ dim.y -= 16.0f / 480.0f;
if ( m_icon == 100 ) icon = 43; // base ?
if ( m_icon == 101 ) icon = 32; // factory ?
if ( m_icon == 102 ) icon = 35; // research ?
@@ -642,3 +640,4 @@ void CGroup::Draw()
}
+}
diff --git a/src/ui/group.h b/src/ui/group.h
index baf609f..bfeef74 100644
--- a/src/ui/group.h
+++ b/src/ui/group.h
@@ -21,18 +21,20 @@
#include "ui/control.h"
+namespace Gfx{
+class CEngine;
+};
-class CD3DEngine;
-
-
+namespace Ui {
class CGroup : public CControl
{
public:
- CGroup(CInstanceManager* iMan);
+// CGroup(CInstanceManager* iMan);
+ CGroup();
virtual ~CGroup();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
bool EventProcess(const Event &event);
@@ -44,3 +46,4 @@ protected:
};
+}
diff --git a/src/ui/image.cpp b/src/ui/image.cpp
index 8bf46fb..ad838fa 100644
--- a/src/ui/image.cpp
+++ b/src/ui/image.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,25 +18,23 @@
// image.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
+#include "graphics/engine/engine.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
#include "common/restext.h"
#include "ui/image.h"
+#include <string.h>
+#include <stdio.h>
-
+namespace Ui {
// Object's constructor.
-CImage::CImage(CInstanceManager* iMan) : CControl(iMan)
+//CImage::CImage(CInstanceManager* iMan) : CControl(iMan)
+CImage::CImage() : CControl()
{
m_filename[0] = 0;
}
@@ -46,25 +45,25 @@ CImage::~CImage()
{
if ( m_filename[0] != 0 )
{
- m_engine->FreeTexture(m_filename);
+ m_engine->DeleteTexture(m_filename);
}
}
// Creates a new button.
-bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
- CControl::Create(pos, dim, icon, eventMsg);
+ CControl::Create(pos, dim, icon, eventType);
if ( icon == -1 )
{
char name[100];
char* p;
- GetResource(RES_EVENT, eventMsg, name);
+ GetResource(RES_EVENT, eventType, name);
p = strchr(name, '\\');
if ( p != 0 ) *p = 0;
SetName(name);
@@ -76,17 +75,17 @@ bool CImage::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMs
// Specifies the name of the image display.
-void CImage::SetFilenameImage(char *name)
+void CImage::SetFilenameImage(const char *name)
{
if ( m_filename[0] != 0 )
{
- m_engine->FreeTexture(m_filename);
+ m_engine->DeleteTexture(m_filename);
}
strcpy(m_filename, name);
}
-char* CImage::RetFilenameImage()
+char* CImage::GetFilenameImage()
{
return m_filename;
}
@@ -118,18 +117,18 @@ void CImage::Draw()
if ( m_icon == 0 ) // hollow frame?
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 160.0f/256.0f;
- uv1.y = 192.0f/256.0f; // u-v texture
- uv2.x = 192.0f/256.0f;
- uv2.y = 224.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 160.0f / 256.0f;
+ uv1.y = 192.0f / 256.0f; // u-v texture
+ uv2.x = 192.0f / 256.0f;
+ uv2.y = 224.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 10.0f/640.0f;
- corner.y = 10.0f/480.0f;
+ corner.x = 10.0f / 640.0f;
+ corner.y = 10.0f / 480.0f;
DrawIcon(m_pos, m_dim, uv1, uv2, corner, 8.0f/256.0f);
}
@@ -137,13 +136,13 @@ void CImage::Draw()
{
m_engine->LoadTexture(m_filename);
m_engine->SetTexture(m_filename);
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
pos = m_pos;
dim = m_dim;
- pos.x += 5.0f/640.0f;
- pos.y += 5.0f/480.0f;
- dim.x -= 10.0f/640.0f;
- dim.y -= 10.0f/480.0f;
+ pos.x += 5.0f / 640.0f;
+ pos.y += 5.0f / 480.0f;
+ dim.x -= 10.0f / 640.0f;
+ dim.y -= 10.0f / 480.0f;
uv1.x = 0.0f;
uv1.y = 0.0f;
uv2.x = 1.0f;
@@ -153,3 +152,4 @@ void CImage::Draw()
}
+}
diff --git a/src/ui/image.h b/src/ui/image.h
index 85c5962..b73a5ae 100644
--- a/src/ui/image.h
+++ b/src/ui/image.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -21,25 +22,28 @@
#include "ui/control.h"
-
-class CD3DEngine;
+namespace Gfx{
+class CEngine;
+};
+namespace Ui {
class CImage : public CControl
{
public:
- CImage(CInstanceManager* iMan);
+// CImage(CInstanceManager* iMan);
+ CImage ();
virtual ~CImage();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
bool EventProcess(const Event &event);
void Draw();
- void SetFilenameImage(char *name);
- char* RetFilenameImage();
+ void SetFilenameImage(const char *name);
+ char* GetFilenameImage();
protected:
@@ -48,3 +52,4 @@ protected:
};
+}
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index 50d2352..0745c9b 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,55 +18,22 @@
// interface.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "ui/control.h"
-#include "ui/button.h"
-#include "ui/color.h"
-#include "ui/check.h"
-#include "ui/key.h"
-#include "ui/group.h"
-#include "ui/image.h"
-#include "ui/label.h"
-#include "ui/edit.h"
-#include "ui/editvalue.h"
-#include "ui/scroll.h"
-#include "ui/slider.h"
-#include "ui/list.h"
-#include "ui/shortcut.h"
-#include "ui/compass.h"
-#include "ui/target.h"
-#include "ui/map.h"
-#include "ui/window.h"
-#include "old/camera.h"
#include "ui/interface.h"
+namespace Ui {
-
-// Object's constructor.
-
-CInterface::CInterface(CInstanceManager* iMan)
+CInterface::CInterface()
{
- int i;
-
- m_iMan = iMan;
+ m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_INTERFACE, this);
+ m_event = static_cast<CEventQueue *>( m_iMan->SearchInstance(CLASS_EVENT) );
+ m_engine = static_cast<Gfx::CEngine *>( m_iMan->SearchInstance(CLASS_ENGINE) );
+ m_camera = nullptr;
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_camera = 0;
-
- for ( i=0 ; i<MAXCONTROL ; i++ )
+ for (int i = 0; i < MAXCONTROL; i++ )
{
- m_table[i] = 0;
+ m_table[i] = nullptr;
}
}
@@ -74,6 +42,7 @@ CInterface::CInterface(CInstanceManager* iMan)
CInterface::~CInterface()
{
Flush();
+ m_iMan->DeleteInstance(CLASS_INTERFACE, this);
}
@@ -81,424 +50,210 @@ CInterface::~CInterface()
void CInterface::Flush()
{
- int i;
-
- for ( i=0 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] != 0 )
- {
+ for (int i = 0; i < MAXCONTROL; i++ ) {
+ if ( m_table[i] != nullptr ) {
delete m_table[i];
- m_table[i] = 0;
+ m_table[i] = nullptr;
}
}
}
-// Creates a new button.
-
-CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+int CInterface::GetNextFreeControl()
{
- CWindow* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- if ( eventMsg == EVENT_WINDOW0 ) {i=0; goto create;}
- if ( eventMsg == EVENT_WINDOW1 ) {i=1; goto create;}
- if ( eventMsg == EVENT_WINDOW2 ) {i=2; goto create;}
- if ( eventMsg == EVENT_WINDOW3 ) {i=3; goto create;}
- if ( eventMsg == EVENT_WINDOW4 ) {i=4; goto create;}
- if ( eventMsg == EVENT_WINDOW5 ) {i=5; goto create;}
- if ( eventMsg == EVENT_WINDOW6 ) {i=6; goto create;}
- if ( eventMsg == EVENT_WINDOW7 ) {i=7; goto create;}
- if ( eventMsg == EVENT_WINDOW8 ) {i=8; goto create;}
- if ( eventMsg == EVENT_WINDOW9 ) {i=9; goto create;}
-
- if ( eventMsg == EVENT_TOOLTIP ) {i=MAXCONTROL-1; goto create;}
-
- for ( i=10 ; i<MAXCONTROL-1 ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- create:
- m_table[i] = new CWindow(m_iMan);
- pc = (CWindow*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
+ for (int i = 10; i < MAXCONTROL-1; i++) {
+ if (m_table[i] == nullptr)
+ return i;
}
- return 0;
+ return -1;
}
-// Creates a new button.
-CButton* CInterface::CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+template <typename T> inline T* CInterface::CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CButton* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CButton(m_iMan);
- pc = (CButton*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ T* pc;
+ int index;
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
+
+ if ((index = GetNextFreeControl()) < 0)
+ return nullptr;
+
+ m_table[index] = new T();
+ pc = static_cast<T *>(m_table[index]);
+ pc->Create(pos, dim, icon, eventMsg);
+ return pc;
}
+
// Creates a new button.
-CColor* CInterface::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CWindow* CInterface::CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CColor* pc;
- int i;
+ CWindow* pc;
+ int index;
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
+
+ switch (eventMsg) {
+ case EVENT_WINDOW0: index = 0; break;
+ case EVENT_WINDOW1: index = 1; break;
+ case EVENT_WINDOW2: index = 2; break;
+ case EVENT_WINDOW3: index = 3; break;
+ case EVENT_WINDOW4: index = 4; break;
+ case EVENT_WINDOW5: index = 5; break;
+ case EVENT_WINDOW6: index = 6; break;
+ case EVENT_WINDOW7: index = 7; break;
+ case EVENT_WINDOW8: index = 8; break;
+ case EVENT_WINDOW9: index = 9; break;
+ case EVENT_TOOLTIP: index = MAXCONTROL-1; break;
+ default: index = GetNextFreeControl(); break;
+ }
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if (index < 0)
+ return nullptr;
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CColor(m_iMan);
- pc = (CColor*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ m_table[index] = new CWindow();
+ pc = static_cast<CWindow *>(m_table[index]);
+ pc->Create(pos, dim, icon, eventMsg);
+ return pc;
}
// Creates a new button.
-CCheck* CInterface::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CButton* CInterface::CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CCheck* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CCheck(m_iMan);
- pc = (CCheck*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ return CreateControl<CButton>(pos, dim, icon, eventMsg);
}
// Creates a new button.
-CKey* CInterface::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CColor* CInterface::CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CKey* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CKey(m_iMan);
- pc = (CKey*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ return CreateControl<CColor>(pos, dim, icon, eventMsg);
}
// Creates a new button.
-CGroup* CInterface::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CCheck* CInterface::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CGroup* pc;
- int i;
+ return CreateControl<CCheck>(pos, dim, icon, eventMsg);
+}
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+// Creates a new button.
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CGroup(m_iMan);
- pc = (CGroup*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+CKey* CInterface::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
+{
+ return CreateControl<CKey>(pos, dim, icon, eventMsg);
}
// Creates a new button.
-CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CGroup* CInterface::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CImage* pc;
- int i;
+ return CreateControl<CGroup>(pos, dim, icon, eventMsg);
+}
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+// Creates a new button.
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CImage(m_iMan);
- pc = (CImage*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+CImage* CInterface::CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
+{
+ return CreateControl<CImage>(pos, dim, icon, eventMsg);
}
// Creates a new label.
-CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
- char *name)
+CLabel* CInterface::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name)
{
- CLabel* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CLabel(m_iMan);
- pc = (CLabel*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- pc->SetName(name);
- return pc;
- }
- }
- return 0;
+ CLabel* pc = CreateControl<CLabel>(pos, dim, icon, eventMsg);
+ if (pc != nullptr)
+ pc->SetName(name);
+ return pc;
}
// Creates a new pave editable.
-CEdit* CInterface::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CEdit* CInterface::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CEdit* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CEdit(m_iMan);
- pc = (CEdit*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ return CreateControl<CEdit>(pos, dim, icon, eventMsg);
}
// Creates a new pave editable.
-CEditValue* CInterface::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CEditValue* CInterface::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CEditValue* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CEditValue(m_iMan);
- pc = (CEditValue*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ return CreateControl<CEditValue>(pos, dim, icon, eventMsg);
}
// Creates a new lift.
-CScroll* CInterface::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CScroll* CInterface::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CScroll* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CScroll(m_iMan);
- pc = (CScroll*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ return CreateControl<CScroll>(pos, dim, icon, eventMsg);
}
// Creates a new cursor.
-CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CSlider* CInterface::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CSlider* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CSlider(m_iMan);
- pc = (CSlider*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ return CreateControl<CSlider>(pos, dim, icon, eventMsg);
}
// Creates a new list.
-CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
- float expand)
+CList* CInterface::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand)
{
- CList* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CList(m_iMan);
- pc = (CList*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg, expand);
- return pc;
- }
- }
- return 0;
+ CList* pc;
+ int index;
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
+
+ if ((index = GetNextFreeControl()) < 0)
+ return nullptr;
+
+ m_table[index] = new CList();
+ pc = static_cast<CList *>(m_table[index]);
+ pc->Create(pos, dim, icon, eventMsg, expand);
+ return pc;
}
// Creates a new shortcut.
-CShortcut* CInterface::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CShortcut* CInterface::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CShortcut* ps;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CShortcut(m_iMan);
- ps = (CShortcut*)m_table[i];
- ps->Create(pos, dim, icon, eventMsg);
- return ps;
- }
- }
- return 0;
+ return CreateControl<CShortcut>(pos, dim, icon, eventMsg);
}
// Creates a new compass.
-CCompass* CInterface::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CCompass* CInterface::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CCompass* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CCompass(m_iMan);
- pc = (CCompass*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ return CreateControl<CCompass>(pos, dim, icon, eventMsg);
}
// Creates a new target.
-CTarget* CInterface::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CTarget* CInterface::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CTarget* pc;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CTarget(m_iMan);
- pc = (CTarget*)m_table[i];
- pc->Create(pos, dim, icon, eventMsg);
- return pc;
- }
- }
- return 0;
+ return CreateControl<CTarget>(pos, dim, icon, eventMsg);
}
// Creates a new map.
-CMap* CInterface::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CMap* CInterface::CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- CMap* pm;
- int i;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
-
- for ( i=10 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] == 0 )
- {
- m_table[i] = new CMap(m_iMan);
- pm = (CMap*)m_table[i];
- pm->Create(pos, dim, icon, eventMsg);
- return pm;
- }
- }
- return 0;
+ return CreateControl<CMap>(pos, dim, icon, eventMsg);
}
// Removes a control.
-bool CInterface::DeleteControl(EventMsg eventMsg)
+bool CInterface::DeleteControl(EventType eventMsg)
{
- int i;
-
- for ( i=0 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] != 0 )
- {
- if ( eventMsg == m_table[i]->RetEventMsg() )
- {
+ for (int i = 0; i < MAXCONTROL; i++) {
+ if ( m_table[i] != nullptr ) {
+ if (eventMsg == m_table[i]->GetEventType()) {
delete m_table[i];
- m_table[i] = 0;
+ m_table[i] = nullptr;
return true;
}
}
@@ -508,47 +263,32 @@ bool CInterface::DeleteControl(EventMsg eventMsg)
// Gives a control.
-CControl* CInterface::SearchControl(EventMsg eventMsg)
+CControl* CInterface::SearchControl(EventType eventMsg)
{
- int i;
-
- for ( i=0 ; i<MAXCONTROL ; i++ )
- {
- if ( m_table[i] != 0 )
- {
- if ( eventMsg == m_table[i]->RetEventMsg() )
- {
+ for (int i = 0; i < MAXCONTROL; i++) {
+ if (m_table[i] != nullptr) {
+ if (eventMsg == m_table[i]->GetEventType())
return m_table[i];
- }
}
}
- return 0;
+ return nullptr;
}
// Management of an event.
bool CInterface::EventProcess(const Event &event)
{
- int i;
-
- if ( event.event == EVENT_MOUSEMOVE )
- {
- if ( m_camera == 0 )
- {
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
+ if (event.type == EVENT_MOUSE_MOVE) {
+ if (m_camera == nullptr) {
+ m_camera = static_cast<Gfx::CCamera *>(m_iMan->SearchInstance(CLASS_CAMERA));
}
- m_engine->SetMouseType(m_camera->RetMouseDef(event.pos));
+ m_engine->SetMouseType(m_camera->GetMouseDef(event.mouseMove.pos));
}
- for ( i=MAXCONTROL-1 ; i>=0 ; i-- )
- {
- if ( m_table[i] != 0 &&
- m_table[i]->TestState(STATE_ENABLE) )
- {
+ for (int i = MAXCONTROL-1; i >= 0; i--) {
+ if (m_table[i] != nullptr && m_table[i]->TestState(STATE_ENABLE)) {
if ( !m_table[i]->EventProcess(event) )
- {
return false;
- }
}
}
@@ -558,18 +298,12 @@ bool CInterface::EventProcess(const Event &event)
// Gives the tooltip binding to the window.
-bool CInterface::GetTooltip(Math::Point pos, char* name)
+bool CInterface::GetTooltip(Math::Point pos, std::string &name)
{
- int i;
-
- for ( i=MAXCONTROL-1 ; i>=0 ; i-- )
- {
- if ( m_table[i] != 0 )
- {
- if ( m_table[i]->GetTooltip(pos, name) )
- {
+ for (int i = MAXCONTROL-1; i >= 0; i--) {
+ if (m_table[i] != nullptr) {
+ if (m_table[i]->GetTooltip(pos, name))
return true;
- }
}
}
return false;
@@ -580,26 +314,19 @@ bool CInterface::GetTooltip(Math::Point pos, char* name)
void CInterface::Draw()
{
- D3DMATERIAL7 material;
- int i;
-
- ZeroMemory( &material, sizeof(D3DMATERIAL7) );
+ /*ZeroMemory( &material, sizeof(D3DMATERIAL7) );
material.diffuse.r = 1.0f;
material.diffuse.g = 1.0f;
material.diffuse.b = 1.0f;
material.ambient.r = 0.5f;
material.ambient.g = 0.5f;
material.ambient.b = 0.5f;
- m_engine->SetMaterial(material);
+ m_engine->SetMaterial(material);*/
- for ( i=0 ; i<MAXCONTROL ; i++ )
-//? for ( i=MAXCONTROL-1 ; i>=0 ; i-- )
- {
- if ( m_table[i] != 0 )
- {
+ for (int i = 0; i < MAXCONTROL; i++) {
+ if ( m_table[i] != nullptr )
m_table[i]->Draw();
- }
}
}
-
+}
diff --git a/src/ui/interface.h b/src/ui/interface.h
index 8aa7f44..1496541 100644
--- a/src/ui/interface.h
+++ b/src/ui/interface.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,78 +19,86 @@
#pragma once
+#include <string>
#include "common/event.h"
-#include "math/point.h"
-
+#include "common/misc.h"
+#include "common/iman.h"
-class CInstanceManager;
-class CD3DEngine;
-class CControl;
-class CWindow;
-class CButton;
-class CColor;
-class CCheck;
-class CKey;
-class CGroup;
-class CImage;
-class CLabel;
-class CEdit;
-class CEditValue;
-class CScroll;
-class CSlider;
-class CList;
-class CShortcut;
-class CMap;
-class CGauge;
-class CCompass;
-class CTarget;
-class CCamera;
+#include "math/point.h"
+#include "graphics/engine/camera.h"
+#include "graphics/engine/engine.h"
+
+#include "ui/control.h"
+#include "ui/button.h"
+#include "ui/color.h"
+#include "ui/check.h"
+#include "ui/key.h"
+#include "ui/group.h"
+#include "ui/image.h"
+#include "ui/label.h"
+#include "ui/edit.h"
+#include "ui/editvalue.h"
+#include "ui/scroll.h"
+#include "ui/slider.h"
+#include "ui/list.h"
+#include "ui/shortcut.h"
+#include "ui/compass.h"
+#include "ui/target.h"
+#include "ui/map.h"
+#include "ui/window.h"
+
+namespace Ui {
const int MAXCONTROL = 100;
class CInterface
{
-public:
- CInterface(CInstanceManager* iMan);
- ~CInterface();
-
- bool EventProcess(const Event &event);
- bool GetTooltip(Math::Point pos, char* name);
-
- void Flush();
- CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, char *name);
- CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand=1.2f);
- CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- bool DeleteControl(EventMsg eventMsg);
- CControl* SearchControl(EventMsg eventMsg);
-
- void Draw();
-
-protected:
-
-protected:
- CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CCamera* m_camera;
-
- CControl* m_table[MAXCONTROL];
+ public:
+ CInterface();
+ ~CInterface();
+
+ bool EventProcess(const Event &event);
+ bool GetTooltip(Math::Point pos, std::string &name);
+
+ void Flush();
+ CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+
+ CWindow* CreateWindows(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
+ CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
+
+ bool DeleteControl(EventType eventMsg);
+ CControl* SearchControl(EventType eventMsg);
+
+ void Draw();
+
+ protected:
+ int GetNextFreeControl();
+ template <typename T> inline T* CreateControl(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+
+ CInstanceManager* m_iMan;
+ CEventQueue* m_event;
+ Gfx::CEngine* m_engine;
+ Gfx::CCamera* m_camera;
+
+ CControl* m_table[MAXCONTROL];
};
+}
diff --git a/src/ui/key.cpp b/src/ui/key.cpp
index a1eebb3..2e627bd 100644
--- a/src/ui/key.cpp
+++ b/src/ui/key.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,54 +18,35 @@
// key.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "common/restext.h"
-#include "old/sound.h"
-#include "old/text.h"
#include "ui/key.h"
+#include <string.h>
-
-
-// Constructs the name of a button.
+namespace Ui {
void GetKeyName(char *name, int key)
{
- if ( !GetResource(RES_KEY, key, name) )
- {
- if ( (key >= '0' && key <= '9') ||
- (key >= 'A' && key <= 'Z') ||
- (key >= 'a' && key <= 'z') )
- {
+ if ( !GetResource(RES_KEY, key, name) ) {
+ if (isalnum(key)) {
name[0] = key;
name[1] = 0;
}
- else
- {
+ else {
sprintf(name, "Code %d", key);
}
}
}
-
-
// Object's constructor.
-CKey::CKey(CInstanceManager* iMan) : CControl(iMan)
+CKey::CKey() : CControl()
{
m_key[0] = 0;
m_key[1] = 0;
m_bCatch = false;
+
+ m_app = CApplication::GetInstancePointer();
}
// Object's destructor.
@@ -76,19 +58,15 @@ CKey::~CKey()
// Creates a new button.
-bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- char name[100];
- char* p;
-
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ char name[100];
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
-
GetResource(RES_EVENT, eventMsg, name);
- p = strchr(name, '\\');
- if ( p != 0 ) *p = 0;
- SetName(name);
+ SetName(std::string(name));
return true;
}
@@ -98,47 +76,33 @@ bool CKey::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
bool CKey::EventProcess(const Event &event)
{
- if ( m_state & STATE_DEAD ) return true;
+ if (m_state & STATE_DEAD)
+ return true;
CControl::EventProcess(event);
- if ( event.event == EVENT_LBUTTONDOWN )
- {
- if ( Detect(event.pos) )
- {
- m_bCatch = true;
- }
- else
- {
- m_bCatch = false;
- }
+ if (event.type == EVENT_MOUSE_BUTTON_DOWN) {
+ if (event.mouseButton.button == 1) // left
+ m_bCatch = Detect(event.mouseButton.pos);
}
- if ( event.event == EVENT_KEYDOWN && m_bCatch )
- {
+ if (event.type == EVENT_KEY_DOWN && m_bCatch) {
m_bCatch = false;
- if ( TestKey(event.param) ) // impossible ?
- {
+ if ( TestKey(event.key.key) ) { // impossible ?
m_sound->Play(SOUND_TZOING);
- }
- else
- {
- if ( event.param == m_key[0] ||
- event.param == m_key[1] )
- {
- m_key[0] = event.param;
+ } else {
+ if ( event.key.key == m_key[0] || event.key.key == m_key[1] ) {
+ m_key[0] = event.key.key;
m_key[1] = 0;
- }
- else
- {
+ } else {
m_key[1] = m_key[0];
m_key[0] = event.param;
}
m_sound->Play(SOUND_CLICK);
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
return false;
@@ -152,27 +116,20 @@ bool CKey::EventProcess(const Event &event)
bool CKey::TestKey(int key)
{
- int i, j;
-
- if ( key == VK_PAUSE ||
- key == VK_SNAPSHOT ) return true; // blocked key
-
- for ( i=0 ; i<20 ; i++ )
- {
- for ( j=0 ; j<2 ; j++ )
- {
- if ( key == m_engine->RetKey(i, j) ) // key used?
- {
- m_engine->SetKey(i, j, 0); // nothing!
- }
+ if ( key == KEY(PAUSE) || key == KEY(PRINT) ) return true; // blocked key
+
+ /* TODO: input bindings
+ for (int i = 0; i < 20; i++) {
+ for (int j = 0; j < 2; j++) {
+ if (key == m_app->GetKey(i, j) ) // key used?
+ m_app->SetKey(i, j, 0); // nothing!
}
- if ( m_engine->RetKey(i, 0) == 0 ) // first free option?
- {
- m_engine->SetKey(i, 0, m_engine->RetKey(i, 1)); // shift
- m_engine->SetKey(i, 1, 0);
+ if ( m_app->GetKey(i, 0) == 0 ) { // first free option?
+ m_app->SetKey(i, 0, m_app->GetKey(i, 1)); // shift
+ m_app->SetKey(i, 1, 0);
}
- }
+ } */
return false; // not used
}
@@ -182,107 +139,99 @@ bool CKey::TestKey(int key)
void CKey::Draw()
{
- Math::Point iDim, pos;
- float zoomExt, zoomInt, h;
- int icon;
- char text[100];
+ Math::Point iDim, pos;
+ float zoomExt, zoomInt, h;
+ int icon;
+ char text[100];
- if ( (m_state & STATE_VISIBLE) == 0 ) return;
+ if ( (m_state & STATE_VISIBLE) == 0 )
+ return;
iDim = m_dim;
m_dim.x = 200.0f/640.0f;
if ( m_state & STATE_SHADOW )
- {
DrawShadow(m_pos, m_dim);
- }
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); // was D3DSTATENORMAL
zoomExt = 1.00f;
zoomInt = 0.95f;
icon = 2;
- if ( m_key[0] == 0 &&
- m_key[1] == 0 ) // no shortcut?
- {
+ if ( m_key[0] == 0 && m_key[1] == 0 ) // no shortcut?
icon = 3;
- }
- if ( m_state & STATE_DEFAULT )
- {
+
+ if ( m_state & STATE_DEFAULT ) {
DrawPart(23, 1.3f, 0.0f);
zoomExt *= 1.15f;
zoomInt *= 1.15f;
}
+
if ( m_state & STATE_HILIGHT )
- {
icon = 1;
- }
+
if ( m_state & STATE_CHECK )
- {
icon = 0;
- }
- if ( m_state & STATE_PRESS )
- {
+
+ if ( m_state & STATE_PRESS ) {
icon = 3;
zoomInt *= 0.9f;
}
+
if ( (m_state & STATE_ENABLE) == 0 )
- {
icon = 7;
- }
+
if ( m_state & STATE_DEAD )
- {
icon = 17;
- }
+
if ( m_bCatch )
- {
icon = 23;
- }
- DrawPart(icon, zoomExt, 8.0f/256.0f); // draws the button
- h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f;
+ DrawPart(icon, zoomExt, 8.0f / 256.0f); // draws the button
+
+ h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
GetKeyName(text, m_key[0]);
- if ( m_key[1] != 0 )
- {
+ if ( m_key[1] != 0 ) {
GetResource(RES_TEXT, RT_KEY_OR, text+strlen(text));
GetKeyName(text+strlen(text), m_key[1]);
}
- pos.x = m_pos.x+m_dim.x*0.5f;
- pos.y = m_pos.y+m_dim.y*0.5f;
+ pos.x = m_pos.x + m_dim.x * 0.5f;
+ pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= h;
- m_engine->RetText()->DrawText(text, pos, m_dim.x, 0, m_fontSize, m_fontStretch, m_fontType, 0);
+ m_engine->GetText()->DrawText(std::string(text), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_CENTER, 0);
m_dim = iDim;
- if ( m_state & STATE_DEAD ) return;
+ if ( m_state & STATE_DEAD )
+ return;
// Draws the name.
- pos.x = m_pos.x+(214.0f/640.0f);
- pos.y = m_pos.y+m_dim.y*0.5f;
+ pos.x = m_pos.x + (214.0f / 640.0f);
+ pos.y = m_pos.y + m_dim.y * 0.5f;
pos.y -= h;
- m_engine->RetText()->DrawText(m_name, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0);
+ m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0);
}
void CKey::SetKey(int option, int key)
{
- if ( option < 0 ||
- option > 1 ) return;
+ if ( option < 0 || option > 1 ) return;
m_key[option] = key;
}
-int CKey::RetKey(int option)
+int CKey::GetKey(int option)
{
- if ( option < 0 ||
- option > 1 ) return 0;
+ if ( option < 0 || option > 1 ) return 0;
return m_key[option];
}
+}
diff --git a/src/ui/key.h b/src/ui/key.h
index 314f39b..be28b6e 100644
--- a/src/ui/key.h
+++ b/src/ui/key.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,35 +19,43 @@
#pragma once
+#include <cctype>
+#include <string>
#include "ui/control.h"
+#include "common/iman.h"
+#include "common/event.h"
+#include "common/restext.h"
+#include "common/key.h"
-class CD3DEngine;
-
+#include "app/app.h"
+namespace Ui {
class CKey : public CControl
{
-public:
- CKey(CInstanceManager* iMan);
- virtual ~CKey();
+ public:
+ CKey();
+ virtual ~CKey();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ bool EventProcess(const Event &event);
- bool EventProcess(const Event &event);
+ void Draw();
- void Draw();
+ void SetKey(int option, int key);
+ int GetKey(int option);
- void SetKey(int option, int key);
- int RetKey(int option);
+ protected:
+ bool TestKey(int key);
-protected:
- bool TestKey(int key);
+ int m_key[2];
+ bool m_bCatch;
-protected:
- int m_key[2];
- bool m_bCatch;
+ CApplication *m_app;
};
+}
+
diff --git a/src/ui/label.cpp b/src/ui/label.cpp
index cd96493..af65ab2 100644
--- a/src/ui/label.cpp
+++ b/src/ui/label.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,25 +18,14 @@
// label.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "old/text.h"
#include "ui/label.h"
-
+namespace Ui {
// Object's constructor.
-CLabel::CLabel(CInstanceManager* iMan) : CControl(iMan)
+CLabel::CLabel() : CControl()
{
}
@@ -48,9 +38,10 @@ CLabel::~CLabel()
// Creates a new button.
-bool CLabel::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CLabel::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
return true;
@@ -72,22 +63,18 @@ void CLabel::Draw()
{
Math::Point pos;
- if ( (m_state & STATE_VISIBLE) == 0 ) return;
+ if ( (m_state & STATE_VISIBLE) == 0 )
+ return;
- pos.y = m_pos.y+m_dim.y/2.0f;
+ pos.y = m_pos.y + m_dim.y / 2.0f;
- if ( m_justif > 0 )
- {
- pos.x = m_pos.x;
- }
- if ( m_justif == 0 )
- {
- pos.x = m_pos.x+m_dim.x/2.0f;
+ switch (m_textAlign) {
+ case Gfx::TEXT_ALIGN_LEFT: pos.x = m_pos.x; break;
+ case Gfx::TEXT_ALIGN_CENTER: pos.x = m_pos.x + m_dim.x / 2.0f; break;
+ case Gfx::TEXT_ALIGN_RIGHT: pos.x = m_pos.x + m_dim.x; break;
}
- if ( m_justif < 0 )
- {
- pos.x = m_pos.x+m_dim.x;
- }
- m_engine->RetText()->DrawText(m_name, pos, m_dim.x, m_justif, m_fontSize, m_fontStretch, m_fontType, 0);
+
+ m_engine->GetText()->DrawText(std::string(m_name), m_fontType, m_fontSize, pos, m_dim.x, m_textAlign, 0);
}
+}
diff --git a/src/ui/label.h b/src/ui/label.h
index d3cb915..c9e1050 100644
--- a/src/ui/label.h
+++ b/src/ui/label.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -21,26 +22,22 @@
#include "ui/control.h"
+#include "common/event.h"
+#include "common/misc.h"
-class CD3DEngine;
-
-
+namespace Ui {
class CLabel : public CControl
{
-public:
- CLabel(CInstanceManager* iMan);
- virtual ~CLabel();
-
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
-
- bool EventProcess(const Event &event);
-
- void Draw();
+ public:
+ CLabel();
+ virtual ~CLabel();
-protected:
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ bool EventProcess(const Event &event);
-protected:
+ void Draw();
};
+}
diff --git a/src/ui/list.cpp b/src/ui/list.cpp
index 9fbc5d9..f62d0ea 100644
--- a/src/ui/list.cpp
+++ b/src/ui/list.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,50 +18,32 @@
// list.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "ui/button.h"
-#include "ui/scroll.h"
-#include "old/text.h"
#include "ui/list.h"
+#include <string.h>
+namespace Ui {
const float MARGING = 4.0f;
-
// Object's constructor.
-CList::CList(CInstanceManager* iMan) : CControl(iMan)
+CList::CList() : CControl()
{
- int i;
-
- for ( i=0 ; i<LISTMAXDISPLAY ; i++ )
- {
- m_button[i] = 0;
- }
- m_scroll = 0;
+ for (int i = 0; i < LISTMAXDISPLAY; i++)
+ m_button[i] = nullptr;
- for ( i=0 ; i<LISTMAXTOTAL ; i++ )
- {
+ m_scroll = nullptr;
+ for (int i = 0; i < LISTMAXTOTAL; i++) {
m_text[i][0] = 0;
m_check[i] = false;
m_enable[i] = true;
}
- for ( i=0 ; i<10 ; i++ )
- {
+ for (int i = 0; i < 10; i++) {
m_tabs[i] = 0.0f;
- m_justifs[i] = 1;
+ m_justifs[i] = Gfx::TEXT_ALIGN_LEFT;
}
m_totalLine = 0;
@@ -76,29 +59,30 @@ CList::CList(CInstanceManager* iMan) : CControl(iMan)
CList::~CList()
{
- int i;
-
- for ( i=0 ; i<LISTMAXDISPLAY ; i++ )
- {
- delete m_button[i];
+ for (int i = 0; i < LISTMAXDISPLAY; i++) {
+ if (m_button[i] != nullptr)
+ delete m_button[i];
}
- delete m_scroll;
+
+ if (m_scroll != nullptr)
+ delete m_scroll;
}
// Creates a new list.
-bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
- float expand)
+bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand)
{
m_expand = expand;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
+
CControl::Create(pos, dim, icon, eventMsg);
- m_scroll = new CScroll(m_iMan);
+ m_scroll = new CScroll();
m_scroll->Create(pos, dim, 0, EVENT_NULL);
- m_eventScroll = m_scroll->RetEventMsg();
+ m_eventScroll = m_scroll->GetEventType();
return MoveAdjust();
}
@@ -107,52 +91,54 @@ bool CList::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg
bool CList::MoveAdjust()
{
- Math::Point ipos, idim, ppos, ddim;
- float marging, h;
- int i;
+ Math::Point ipos, idim, ppos, ddim;
+ float marging, h;
- for ( i=0 ; i<LISTMAXDISPLAY ; i++ )
- {
- delete m_button[i];
- m_button[i] = 0;
+ for (int i = 0; i < LISTMAXDISPLAY; i++) {
+ if (m_button[i] != nullptr) {
+ delete m_button[i];
+ m_button[i] = nullptr;
+ }
}
- if ( m_icon == 0 ) marging = MARGING;
- else marging = 0.0f;
+ if (m_icon == 0)
+ marging = MARGING;
+ else
+ marging = 0.0f;
- ipos.x = m_pos.x+marging/640.f;
- ipos.y = m_pos.y+marging/480.f;
- idim.x = m_dim.x-marging*2.0f/640.f;
- idim.y = m_dim.y-marging*2.0f/480.f;
+ ipos.x = m_pos.x + marging / 640.f;
+ ipos.y = m_pos.y + marging / 480.f;
+ idim.x = m_dim.x - marging * 2.0f / 640.f;
+ idim.y = m_dim.y - marging * 2.0f / 480.f;
- h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType)*m_expand;
+ h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) * m_expand;
- m_displayLine = (int)(idim.y/h);
- if ( m_displayLine == 0 ) return false;
- if ( m_displayLine > LISTMAXDISPLAY ) m_displayLine = LISTMAXDISPLAY;
- idim.y = h*m_displayLine;
- m_dim.y = idim.y+marging*2.0f/480.f;
+ m_displayLine = static_cast<int>(idim.y / h);
+ if (m_displayLine == 0)
+ return false;
+ if (m_displayLine > LISTMAXDISPLAY)
+ m_displayLine = LISTMAXDISPLAY;
+ idim.y = h * m_displayLine;
+ m_dim.y = idim.y + marging * 2.0f / 480.f;
ppos.x = ipos.x;
- ppos.y = ipos.y+idim.y-h;
- ddim.x = idim.x-SCROLL_WIDTH;
+ ppos.y = ipos.y + idim.y - h;
+ ddim.x = idim.x - SCROLL_WIDTH;
ddim.y = h;
- for ( i=0 ; i<m_displayLine ; i++ )
- {
- m_button[i] = new CButton(m_iMan);
+ for (int i = 0; i < m_displayLine; i++) {
+ m_button[i] = new CButton();
m_button[i]->Create(ppos, ddim, -1, EVENT_NULL);
- m_button[i]->SetJustif(1);
+ m_button[i]->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
m_button[i]->SetState(STATE_SIMPLY);
m_button[i]->SetFontType(m_fontType);
m_button[i]->SetFontSize(m_fontSize);
ppos.y -= h;
- m_eventButton[i] = m_button[i]->RetEventMsg();
+ m_eventButton[i] = m_button[i]->GetEventType();
}
- if ( m_scroll != 0 )
- {
- ppos.x = ipos.x+idim.x-SCROLL_WIDTH;
+ if ( m_scroll != nullptr ) {
+ ppos.x = ipos.x + idim.x - SCROLL_WIDTH;
ppos.y = ipos.y;
ddim.x = SCROLL_WIDTH;
ddim.y = idim.y;
@@ -168,19 +154,22 @@ bool CList::MoveAdjust()
// Returns the message of a button.
-EventMsg CList::RetEventMsgButton(int i)
+EventType CList::GetEventMsgButton(int i)
{
- if ( i < 0 || i >= m_displayLine ) return EVENT_NULL;
- if ( m_button[i] == 0 ) return EVENT_NULL;
- return m_button[i]->RetEventMsg();
+ if (i < 0 || i >= m_displayLine)
+ return EVENT_NULL;
+ if (m_button[i] == nullptr)
+ return EVENT_NULL;
+ return m_button[i]->GetEventType();
}
// Returns the message from the elevator.
-EventMsg CList::RetEventMsgScroll()
+EventType CList::GetEventMsgScroll()
{
- if ( m_scroll == 0 ) return EVENT_NULL;
- return m_scroll->RetEventMsg();
+ if (m_scroll == nullptr)
+ return EVENT_NULL;
+ return m_scroll->GetEventType();
}
@@ -189,6 +178,7 @@ void CList::SetPos(Math::Point pos)
CControl::SetPos(pos);
}
+
void CList::SetDim(Math::Point dim)
{
m_dim = dim;
@@ -199,47 +189,43 @@ void CList::SetDim(Math::Point dim)
bool CList::SetState(int state, bool bState)
{
- int i;
-
- if ( state & STATE_ENABLE )
- {
- for ( i=0 ; i<m_displayLine ; i++ )
- {
- if ( m_button[i] != 0 ) m_button[i]->SetState(state, bState);
+ if (state & STATE_ENABLE) {
+ for (int i = 0; i < m_displayLine; i++) {
+ if (m_button[i] != nullptr)
+ m_button[i]->SetState(state, bState);
}
- if ( m_scroll != 0 ) m_scroll->SetState(state, bState);
+ if (m_scroll != nullptr)
+ m_scroll->SetState(state, bState);
}
return CControl::SetState(state, bState);
}
+
bool CList::SetState(int state)
{
- int i;
-
- if ( state & STATE_ENABLE )
- {
- for ( i=0 ; i<m_displayLine ; i++ )
- {
- if ( m_button[i] != 0 ) m_button[i]->SetState(state);
+ if (state & STATE_ENABLE) {
+ for (int i = 0; i < m_displayLine; i++) {
+ if (m_button[i] != nullptr)
+ m_button[i]->SetState(state);
}
- if ( m_scroll != 0 ) m_scroll->SetState(state);
+ if (m_scroll != nullptr)
+ m_scroll->SetState(state);
}
return CControl::SetState(state);
}
+
bool CList::ClearState(int state)
{
- int i;
-
- if ( state & STATE_ENABLE )
- {
- for ( i=0 ; i<m_displayLine ; i++ )
- {
- if ( m_button[i] != 0 ) m_button[i]->ClearState(state);
+ if (state & STATE_ENABLE) {
+ for (int i = 0; i < m_displayLine; i++) {
+ if (m_button[i] != nullptr)
+ m_button[i]->ClearState(state);
}
- if ( m_scroll != 0 ) m_scroll->ClearState(state);
+ if (m_scroll != nullptr)
+ m_scroll->ClearState(state);
}
return CControl::ClearState(state);
@@ -250,47 +236,38 @@ bool CList::ClearState(int state)
bool CList::EventProcess(const Event &event)
{
- int i;
-
- if ( m_bBlink && // blinks?
- event.event == EVENT_FRAME )
- {
+ int i;
+ if (m_bBlink && event.type == EVENT_FRAME) {
i = m_selectLine-m_firstLine;
- if ( i >= 0 && i < 4 &&
- m_button[i] != 0 )
- {
+ if (i >= 0 && i < 4 && m_button[i] != nullptr) {
m_blinkTime += event.rTime;
- if ( Math::Mod(m_blinkTime, 0.7f) < 0.3f )
- {
+ if (Math::Mod(m_blinkTime, 0.7f) < 0.3f) {
m_button[i]->ClearState(STATE_ENABLE);
m_button[i]->ClearState(STATE_CHECK);
- }
- else
- {
+ } else {
m_button[i]->SetState(STATE_ENABLE);
m_button[i]->SetState(STATE_CHECK);
}
}
}
- if ( (m_state & STATE_VISIBLE) == 0 ) return true;
- if ( (m_state & STATE_ENABLE) == 0 ) return true;
+ if ((m_state & STATE_VISIBLE) == 0)
+ return true;
+ if ((m_state & STATE_ENABLE) == 0)
+ return true;
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELUP &&
- Detect(event.pos) )
- {
- if ( m_firstLine > 0 ) m_firstLine --;
+ if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_UP && Detect(event.mouseWheel.pos)) {
+ if (m_firstLine > 0)
+ m_firstLine--;
UpdateScroll();
UpdateButton();
return true;
}
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELDOWN &&
- Detect(event.pos) )
- {
- if ( m_firstLine < m_totalLine-m_displayLine ) m_firstLine ++;
+
+ if (event.type == EVENT_MOUSE_WHEEL && event.mouseWheel.dir == WHEEL_DOWN && Detect(event.mouseWheel.pos)) {
+ if (m_firstLine < m_totalLine - m_displayLine)
+ m_firstLine++;
UpdateScroll();
UpdateButton();
return true;
@@ -298,46 +275,41 @@ bool CList::EventProcess(const Event &event)
CControl::EventProcess(event);
- if ( event.event == EVENT_MOUSEMOVE && Detect(event.pos) )
- {
- m_engine->SetMouseType(D3DMOUSENORM);
- for ( i=0 ; i<m_displayLine ; i++ )
- {
- if ( i+m_firstLine >= m_totalLine ) break;
- if ( m_button[i] != 0 )
- {
+ if (event.type == EVENT_MOUSE_MOVE && Detect(event.mouseMove.pos)) {
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
+ for (i = 0; i < m_displayLine; i++) {
+ if (i + m_firstLine >= m_totalLine)
+ break;
+ if (m_button[i] != nullptr)
m_button[i]->EventProcess(event);
- }
}
}
- if ( m_bSelectCap )
- {
- for ( i=0 ; i<m_displayLine ; i++ )
- {
- if ( i+m_firstLine >= m_totalLine ) break;
- if ( m_button[i] != 0 )
- {
- if ( !m_button[i]->EventProcess(event) ) return false;
-
- if ( event.event == m_eventButton[i] )
- {
- SetSelect(m_firstLine+i);
+ if (m_bSelectCap) {
+ for (i = 0; i < m_displayLine; i++) {
+ if (i + m_firstLine >= m_totalLine)
+ break;
+
+ if (m_button[i] != nullptr) {
+ if (!m_button[i]->EventProcess(event))
+ return false;
+
+ if (event.type == m_eventButton[i]) {
+ SetSelect(m_firstLine + i);
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent); // selected line changes
}
}
}
}
- if ( m_scroll != 0 )
- {
- if ( !m_scroll->EventProcess(event) ) return false;
+ if (m_scroll != nullptr) {
+ if (!m_scroll->EventProcess(event))
+ return false;
- if ( event.event == m_eventScroll )
- {
+ if (event.type == m_eventScroll) {
MoveScroll();
UpdateButton();
}
@@ -353,46 +325,40 @@ void CList::Draw()
{
Math::Point uv1, uv2, corner, pos, dim, ppos, ddim;
float dp;
- int i, j;
+ int i;
char text[100];
char *pb, *pe;
- if ( (m_state & STATE_VISIBLE) == 0 ) return;
+ if ((m_state & STATE_VISIBLE) == 0)
+ return;
- if ( m_state & STATE_SHADOW )
- {
+ if (m_state & STATE_SHADOW)
DrawShadow(m_pos, m_dim);
- }
- dp = 0.5f/256.0f;
+ dp = 0.5f / 256.0f;
- if ( m_icon != -1 )
- {
+ if (m_icon != -1) {
dim = m_dim;
- if ( m_icon == 0 )
- {
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
-
- uv1.x = 128.0f/256.0f;
- uv1.y = 64.0f/256.0f; // u-v texture
- uv2.x = 160.0f/256.0f;
- uv2.y = 96.0f/256.0f;
- }
- else
- {
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
-
- uv1.x = 132.0f/256.0f;
- uv1.y = 68.0f/256.0f; // u-v texture
- uv2.x = 156.0f/256.0f;
- uv2.y = 92.0f/256.0f;
-
- if ( m_button[0] != 0 )
- {
- dim = m_button[0]->RetDim();
+ if (m_icon == 0) {
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+
+ uv1.x = 128.0f / 256.0f;
+ uv1.y = 64.0f / 256.0f; // u-v texture
+ uv2.x = 160.0f / 256.0f;
+ uv2.y = 96.0f / 256.0f;
+ } else {
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+
+ uv1.x = 132.0f / 256.0f;
+ uv1.y = 68.0f / 256.0f; // u-v texture
+ uv2.x = 156.0f / 256.0f;
+ uv2.y = 92.0f / 256.0f;
+
+ if (m_button[0] != nullptr) {
+ dim = m_button[0]->GetDim();
dim.y *= m_displayLine; // background sounds spot behind
}
}
@@ -402,28 +368,26 @@ void CList::Draw()
uv2.x -= dp;
uv2.y -= dp;
- corner.x = 10.0f/640.0f;
- corner.y = 10.0f/480.0f;
- DrawIcon(m_pos, dim, uv1, uv2, corner, 8.0f/256.0f);
+ corner.x = 10.0f / 640.0f;
+ corner.y = 10.0f / 480.0f;
+ DrawIcon(m_pos, dim, uv1, uv2, corner, 8.0f / 256.0f);
}
- if ( m_totalLine < m_displayLine ) // no buttons to the bottom?
- {
+ if ( m_totalLine < m_displayLine ) { // no buttons to the bottom?
i = m_totalLine;
- if ( m_button[i] != 0 )
- {
- pos = m_button[i]->RetPos();
- dim = m_button[i]->RetDim();
- pos.y += dim.y*1.1f;
+ if ( m_button[i] != 0 ) {
+ pos = m_button[i]->GetPos();
+ dim = m_button[i]->GetDim();
+ pos.y += dim.y * 1.1f;
dim.y *= 0.4f;
pos.y -= dim.y;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 120.0f/256.0f;
- uv1.y = 64.0f/256.0f;
- uv2.x = 128.0f/256.0f;
- uv2.y = 48.0f/256.0f;
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw
+ uv1.x = 120.0f / 256.0f;
+ uv1.y = 64.0f / 256.0f;
+ uv2.x = 128.0f / 256.0f;
+ uv2.y = 48.0f / 256.0f;
uv1.x += dp;
uv1.y -= dp;
uv2.x -= dp;
@@ -432,108 +396,93 @@ void CList::Draw()
}
}
- for ( i=0 ; i<m_displayLine ; i++ )
- {
- if ( i+m_firstLine >= m_totalLine ) break;
+ for (i = 0; i < m_displayLine; i++) {
+ if ( i + m_firstLine >= m_totalLine )
+ break;
- if ( m_button[i] != 0 )
- {
- if ( !m_bBlink && i+m_firstLine < m_totalLine )
- {
+ if ( m_button[i] != nullptr ) {
+ if ( !m_bBlink && i + m_firstLine < m_totalLine )
m_button[i]->SetState(STATE_ENABLE, m_enable[i+m_firstLine] && (m_state & STATE_ENABLE) );
- }
+
m_button[i]->Draw(); // draws a box without text
// draws text in the box
- pos = m_button[i]->RetPos();
- dim = m_button[i]->RetDim();
- if ( m_tabs[0] == 0.0f )
- {
- ppos.x = pos.x+dim.y*0.5f;
- ppos.y = pos.y+dim.y*0.5f;
- ppos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f;
+ pos = m_button[i]->GetPos();
+ dim = m_button[i]->GetDim();
+ if ( m_tabs[0] == 0.0f ) {
+ ppos.x = pos.x + dim.y * 0.5f;
+ ppos.y = pos.y + dim.y * 0.5f;
+ ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
ddim.x = dim.x-dim.y;
- DrawCase(m_text[i+m_firstLine], ppos, ddim.x, 1);
- }
- else
- {
- ppos.x = pos.x+dim.y*0.5f;
- ppos.y = pos.y+dim.y*0.5f;
- ppos.y -= m_engine->RetText()->RetHeight(m_fontSize, m_fontType)/2.0f;
- pb = m_text[i+m_firstLine];
- for ( j=0 ; j<10 ; j++ )
- {
+ DrawCase(m_text[i + m_firstLine], ppos, ddim.x, Gfx::TEXT_ALIGN_LEFT);
+ } else {
+ ppos.x = pos.x + dim.y * 0.5f;
+ ppos.y = pos.y + dim.y * 0.5f;
+ ppos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;
+ pb = m_text[i + m_firstLine];
+ for (int j = 0; j < 10; j++) {
pe = strchr(pb, '\t');
if ( pe == 0 )
- {
strcpy(text, pb);
- }
- else
- {
- strncpy(text, pb, pe-pb);
- text[pe-pb] = 0;
+ else {
+ strncpy(text, pb, pe - pb);
+ text[pe - pb] = 0;
}
DrawCase(text, ppos, m_tabs[j], m_justifs[j]);
- if ( pe == 0 ) break;
+ if ( pe == 0 )
+ break;
ppos.x += m_tabs[j];
- pb = pe+1;
+ pb = pe + 1;
}
}
- if ( (m_state & STATE_EXTEND) && i < m_totalLine )
- {
- pos = m_button[i]->RetPos();
- dim = m_button[i]->RetDim();
- pos.x += dim.x-dim.y*0.75f;
- dim.x = dim.y*0.75f;
- pos.x += 2.0f/640.0f;
- pos.y += 2.0f/480.0f;
- dim.x -= 4.0f/640.0f;
- dim.y -= 4.0f/480.0f;
-
- if ( m_check[i+m_firstLine] )
- {
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 64.0f/256.0f;
- uv1.y = 0.0f/256.0f;
- uv2.x = 96.0f/256.0f;
- uv2.y = 32.0f/256.0f;
+ if ( (m_state & STATE_EXTEND) && i < m_totalLine) {
+ pos = m_button[i]->GetPos();
+ dim = m_button[i]->GetDim();
+ pos.x += dim.x - dim.y * 0.75f;
+ dim.x = dim.y * 0.75f;
+ pos.x += 2.0f / 640.0f;
+ pos.y += 2.0f / 480.0f;
+ dim.x -= 4.0f / 640.0f;
+ dim.y -= 4.0f / 480.0f;
+
+ if ( m_check[i + m_firstLine] ) {
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 64.0f / 256.0f;
+ uv1.y = 0.0f / 256.0f;
+ uv2.x = 96.0f / 256.0f;
+ uv2.y = 32.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2); // square shape
- m_engine->SetState(D3DSTATETTw);
- uv1.x = 0.0f/256.0f; // v
- uv1.y = 64.0f/256.0f;
- uv2.x = 32.0f/256.0f;
- uv2.y = 96.0f/256.0f;
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw
+ uv1.x = 0.0f / 256.0f; // v
+ uv1.y = 64.0f / 256.0f;
+ uv2.x = 32.0f / 256.0f;
+ uv2.y = 96.0f / 256.0f;
uv1.x += dp;
uv1.y += dp;
uv2.x -= dp;
uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2); // draws v
- }
- else
- {
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATETTw);
- if ( i+m_firstLine == m_selectLine )
- {
- uv1.x =224.0f/256.0f; // <
- uv1.y =192.0f/256.0f;
- uv2.x =256.0f/256.0f;
- uv2.y =224.0f/256.0f;
- }
- else
- {
- uv1.x = 96.0f/256.0f; // x
- uv1.y = 32.0f/256.0f;
- uv2.x =128.0f/256.0f;
- uv2.y = 64.0f/256.0f;
+ } else {
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE); // was D3DSTATETTw
+ if ( i + m_firstLine == m_selectLine ) {
+ uv1.x =224.0f / 256.0f; // <
+ uv1.y =192.0f / 256.0f;
+ uv2.x =256.0f / 256.0f;
+ uv2.y =224.0f / 256.0f;
+ } else {
+ uv1.x = 96.0f / 256.0f; // x
+ uv1.y = 32.0f / 256.0f;
+ uv2.x =128.0f / 256.0f;
+ uv2.y = 64.0f / 256.0f;
}
uv1.x += dp;
uv1.y += dp;
@@ -546,29 +495,18 @@ void CList::Draw()
}
if ( m_scroll != 0 )
- {
m_scroll->Draw(); // draws the lift
- }
}
// Displays text in a box.
-void CList::DrawCase(char *text, Math::Point pos, float width, int justif)
+void CList::DrawCase(char *text, Math::Point pos, float width, Gfx::TextAlign justif)
{
- if ( justif == 1 )
- {
- m_engine->RetText()->DrawText(text, pos, width, 1, m_fontSize, m_fontStretch, m_fontType, 0);
- }
- else if ( justif == 0 )
- {
- pos.x += width/2.0f;
- m_engine->RetText()->DrawText(text, pos, width, 0, m_fontSize, m_fontStretch, m_fontType, 0);
- }
- else
- {
+ if (justif == Gfx::TEXT_ALIGN_CENTER)
+ pos.x += width / 2.0f;
+ else if (justif == Gfx::TEXT_ALIGN_RIGHT)
pos.x += width;
- m_engine->RetText()->DrawText(text, pos, width, -1, m_fontSize, m_fontStretch, m_fontType, 0);
- }
+ m_engine->GetText()->DrawText(std::string(text), m_fontType, m_fontSize, pos, width, justif, 0);
}
@@ -593,7 +531,7 @@ void CList::SetTotal(int i)
// Returns the total number of lines.
-int CList::RetTotal()
+int CList::GetTotal()
{
return m_totalLine;
}
@@ -604,11 +542,8 @@ int CList::RetTotal()
void CList::SetSelect(int i)
{
if ( m_bSelectCap )
- {
m_selectLine = i;
- }
- else
- {
+ else {
m_firstLine = i;
UpdateScroll();
}
@@ -618,16 +553,12 @@ void CList::SetSelect(int i)
// Returns the selected line.
-int CList::RetSelect()
+int CList::GetSelect()
{
if ( m_bSelectCap )
- {
return m_selectLine;
- }
else
- {
return m_firstLine;
- }
}
@@ -638,7 +569,7 @@ void CList::SetSelectCap(bool bEnable)
m_bSelectCap = bEnable;
}
-bool CList::RetSelectCap()
+bool CList::GetSelectCap()
{
return m_bSelectCap;
}
@@ -648,25 +579,22 @@ bool CList::RetSelectCap()
void CList::SetBlink(bool bEnable)
{
- int i;
+ int i;
m_bBlink = bEnable;
m_blinkTime = 0.0f;
i = m_selectLine-m_firstLine;
- if ( i >= 0 && i < 4 &&
- m_button[i] != 0 )
- {
- if ( !bEnable )
- {
+ if (i >= 0 && i < 4 && m_button[i] != nullptr) {
+ if ( !bEnable ) {
m_button[i]->SetState(STATE_CHECK);
m_button[i]->ClearState(STATE_ENABLE);
}
}
}
-bool CList::RetBlink()
+bool CList::GetBlink()
{
return m_bBlink;
}
@@ -674,32 +602,29 @@ bool CList::RetBlink()
// Specifies the text of a line.
-void CList::SetName(int i, char* name)
+void CList::SetName(int i, const char* name)
{
- if ( i < 0 || i >= LISTMAXTOTAL ) return;
+ if ( i < 0 || i >= LISTMAXTOTAL )
+ return;
if ( i >= m_totalLine )
- {
m_totalLine = i+1; // expands the list
- }
if ( name[0] == 0 )
- {
strcpy(m_text[i], " ");
- }
else
- {
strcpy(m_text[i], name);
- }
+
UpdateButton();
UpdateScroll();
}
// Returns the text of a line.
-char* CList::RetName(int i)
+char* CList::GetName(int i)
{
- if ( i < 0 || i >= m_totalLine ) return 0;
+ if ( i < 0 || i >= m_totalLine )
+ return 0;
return m_text[i];
}
@@ -709,16 +634,18 @@ char* CList::RetName(int i)
void CList::SetCheck(int i, bool bMode)
{
- if ( i < 0 || i >= m_totalLine ) return;
+ if ( i < 0 || i >= m_totalLine )
+ return;
m_check[i] = bMode;
}
// Returns the bit "check" for a box.
-bool CList::RetCheck(int i)
+bool CList::GetCheck(int i)
{
- if ( i < 0 || i >= m_totalLine ) return false;
+ if ( i < 0 || i >= m_totalLine )
+ return false;
return m_check[i];
}
@@ -728,16 +655,18 @@ bool CList::RetCheck(int i)
void CList::SetEnable(int i, bool bMode)
{
- if ( i < 0 || i >= m_totalLine ) return;
+ if ( i < 0 || i >= m_totalLine )
+ return;
m_enable[i] = bMode;
}
// Returns the bit "enable" for a box.
-bool CList::RetEnable(int i)
+bool CList::GetEnable(int i)
{
- if ( i < 0 || i >= m_totalLine ) return false;
+ if ( i < 0 || i >= m_totalLine )
+ return false;
return m_enable[i];
}
@@ -745,16 +674,18 @@ bool CList::RetEnable(int i)
// Management of the position of the tabs.
-void CList::SetTabs(int i, float pos, int justif)
+void CList::SetTabs(int i, float pos, Gfx::TextAlign justif)
{
- if ( i < 0 || i >= 10 ) return;
+ if ( i < 0 || i >= 10 )
+ return;
m_tabs[i] = pos;
m_justifs[i] = justif;
}
-float CList::RetTabs(int i)
+float CList::GetTabs(int i)
{
- if ( i < 0 || i >= 10 ) return 0.0f;
+ if ( i < 0 || i >= 10 )
+ return 0.0f;
return m_tabs[i];
}
@@ -765,19 +696,20 @@ void CList::ShowSelect(bool bFixed)
{
int sel;
- if ( bFixed &&
- m_selectLine >= m_firstLine &&
- m_selectLine < m_firstLine+m_displayLine ) return; // all good
+ if ( bFixed && m_selectLine >= m_firstLine && m_selectLine < m_firstLine+m_displayLine )
+ return; // all good
sel = m_selectLine;
// Down from 1/2 * h.
- sel += m_displayLine/2;
- if ( sel > m_totalLine-1 ) sel = m_totalLine-1;
+ sel += m_displayLine / 2;
+ if ( sel > m_totalLine - 1 )
+ sel = m_totalLine - 1;
// Back to h-1.
- sel -= m_displayLine-1;
- if ( sel < 0 ) sel = 0;
+ sel -= m_displayLine - 1;
+ if ( sel < 0 )
+ sel = 0;
m_firstLine = sel;
@@ -790,25 +722,22 @@ void CList::ShowSelect(bool bFixed)
void CList::UpdateButton()
{
- int state, i, j;
+ int state, i, j;
- state = CControl::RetState();
+ state = CControl::GetState();
j = m_firstLine;
- for ( i=0 ; i<m_displayLine ; i++ )
- {
- if ( m_button[i] == 0 ) continue;
+ for (i = 0; i < m_displayLine; i++) {
+ if (m_button[i] == nullptr)
+ continue;
m_button[i]->SetState(STATE_CHECK, (j == m_selectLine));
- if ( j < m_totalLine )
- {
+ if ( j < m_totalLine ) {
//? m_button[i]->SetName(m_text[j]);
m_button[i]->SetName(" "); // blank button
m_button[i]->SetState(STATE_ENABLE, (state & STATE_ENABLE));
- }
- else
- {
+ } else {
m_button[i]->SetName(" "); // blank button
m_button[i]->ClearState(STATE_ENABLE);
}
@@ -820,27 +749,28 @@ void CList::UpdateButton()
void CList::UpdateScroll()
{
- float ratio, value, step;
+ float ratio, value, step;
- if ( m_scroll == 0 ) return;
+ if (m_scroll == nullptr)
+ return;
- if ( m_totalLine <= m_displayLine )
- {
+ if (m_totalLine <= m_displayLine) {
ratio = 1.0f;
value = 0.0f;
step = 0.0f;
- }
- else
- {
- ratio = (float)m_displayLine/m_totalLine;
+ } else {
+ ratio = static_cast<float>(m_displayLine) / m_totalLine;
if ( ratio > 1.0f ) ratio = 1.0f;
- value = (float)m_firstLine/(m_totalLine-m_displayLine);
- if ( value < 0.0f ) value = 0.0f;
- if ( value > 1.0f ) value = 1.0f;
+ value = static_cast<float>(m_firstLine) / (m_totalLine - m_displayLine);
+ if ( value < 0.0f )
+ value = 0.0f;
+ if ( value > 1.0f )
+ value = 1.0f;
- step = (float)1.0f/(m_totalLine-m_displayLine);
- if ( step < 0.0f ) step = 0.0f;
+ step = static_cast<float>(1.0f)/ (m_totalLine - m_displayLine);
+ if ( step < 0.0f )
+ step = 0.0f;
}
m_scroll->SetVisibleRatio(ratio);
@@ -852,17 +782,21 @@ void CList::UpdateScroll()
void CList::MoveScroll()
{
- float pos;
- int n;
+ float pos;
+ int n;
- if ( m_scroll == 0 ) return;
+ if ( m_scroll == 0 )
+ return;
- n = m_totalLine-m_displayLine;
- pos = m_scroll->RetVisibleValue();
- pos += m_scroll->RetArrowStep()/2.0f; // it's magic!
- m_firstLine = (int)(pos*n);
- if ( m_firstLine < 0 ) m_firstLine = 0;
- if ( m_firstLine > n ) m_firstLine = n;
+ n = m_totalLine - m_displayLine;
+ pos = m_scroll->GetVisibleValue();
+ pos += m_scroll->GetArrowStep() / 2.0f; // it's magic!
+ m_firstLine = static_cast<int>(pos * n);
+ if ( m_firstLine < 0 )
+ m_firstLine = 0;
+ if ( m_firstLine > n )
+ m_firstLine = n;
}
+}
diff --git a/src/ui/list.h b/src/ui/list.h
index cc9e646..97bd48c 100644
--- a/src/ui/list.h
+++ b/src/ui/list.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -20,13 +21,16 @@
#include "ui/control.h"
+#include "ui/button.h"
+#include "ui/scroll.h"
+
#include "common/event.h"
+#include "common/misc.h"
+#include "graphics/engine/text.h"
-class CD3DEngine;
-class CButton;
-class CScroll;
+namespace Ui {
const int LISTMAXDISPLAY = 20; // maximum number of visible lines
const int LISTMAXTOTAL = 100; // maximum total number of lines
@@ -35,81 +39,83 @@ const int LISTMAXTOTAL = 100; // maximum total number of lines
class CList : public CControl
{
-public:
- CList(CInstanceManager* iMan);
- ~CList();
+ public:
+ CList();
+ ~CList();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand);
- void SetPos(Math::Point pos);
- void SetDim(Math::Point dim);
+ void SetPos(Math::Point pos);
+ void SetDim(Math::Point dim);
- bool SetState(int state, bool bState);
- bool SetState(int state);
- bool ClearState(int state);
+ bool SetState(int state, bool bState);
+ bool SetState(int state);
+ bool ClearState(int state);
- bool EventProcess(const Event &event);
- void Draw();
+ bool EventProcess(const Event &event);
+ void Draw();
- void Flush();
+ void Flush();
- void SetTotal(int i);
- int RetTotal();
+ void SetTotal(int i);
+ int GetTotal();
- void SetSelect(int i);
- int RetSelect();
+ void SetSelect(int i);
+ int GetSelect();
- void SetSelectCap(bool bEnable);
- bool RetSelectCap();
+ void SetSelectCap(bool bEnable);
+ bool GetSelectCap();
- void SetBlink(bool bEnable);
- bool RetBlink();
+ void SetBlink(bool bEnable);
+ bool GetBlink();
- void SetName(int i, char* name);
- char* RetName(int i);
+ void SetName(int i, const char* name);
+ char* GetName(int i);
- void SetCheck(int i, bool bMode);
- bool RetCheck(int i);
+ void SetCheck(int i, bool bMode);
+ bool GetCheck(int i);
- void SetEnable(int i, bool bEnable);
- bool RetEnable(int i);
+ void SetEnable(int i, bool bEnable);
+ bool GetEnable(int i);
- void SetTabs(int i, float pos, int justif=1);
- float RetTabs(int i);
+ void SetTabs(int i, float pos, Gfx::TextAlign justif=Gfx::TEXT_ALIGN_LEFT);
+ float GetTabs(int i);
- void ShowSelect(bool bFixed);
+ void ShowSelect(bool bFixed);
- EventMsg RetEventMsgButton(int i);
- EventMsg RetEventMsgScroll();
+ EventType GetEventMsgButton(int i);
+ EventType GetEventMsgScroll();
-protected:
- bool MoveAdjust();
- void UpdateButton();
- void UpdateScroll();
- void MoveScroll();
- void DrawCase(char *text, Math::Point pos, float width, int justif);
+ protected:
+ bool MoveAdjust();
+ void UpdateButton();
+ void UpdateScroll();
+ void MoveScroll();
+ void DrawCase(char *text, Math::Point pos, float width, Gfx::TextAlign justif);
-protected:
- CButton* m_button[LISTMAXDISPLAY];
- CScroll* m_scroll;
+ protected:
+ CButton* m_button[LISTMAXDISPLAY];
+ CScroll* m_scroll;
- EventMsg m_eventButton[LISTMAXDISPLAY];
- EventMsg m_eventScroll;
+ EventType m_eventButton[LISTMAXDISPLAY];
+ EventType m_eventScroll;
- float m_expand;
- int m_totalLine; // total number of lines
- int m_displayLine; // number of visible lines
- int m_selectLine; // selected line
- int m_firstLine; // first visible line
- bool m_bBlink;
- bool m_bSelectCap;
- float m_blinkTime;
- float m_tabs[10];
- int m_justifs[10];
+ float m_expand;
+ int m_totalLine; // total number of lines
+ int m_displayLine; // number of visible lines
+ int m_selectLine; // selected line
+ int m_firstLine; // first visible line
+ bool m_bBlink;
+ bool m_bSelectCap;
+ float m_blinkTime;
+ float m_tabs[10];
+ Gfx::TextAlign m_justifs[10];
- char m_text[LISTMAXTOTAL][100];
- char m_check[LISTMAXTOTAL];
- char m_enable[LISTMAXTOTAL];
+ char m_text[LISTMAXTOTAL][100];
+ char m_check[LISTMAXTOTAL];
+ char m_enable[LISTMAXTOTAL];
};
+}
+
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index c8759e0..a40cc27 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -8,7 +8,7 @@
// *
// * 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
+// * MERCHANTABILITY or FITNESS FOR A Gfx::PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
@@ -16,26 +16,17 @@
// maindialog.cpp
+#include "ui/maindialog.h"
-#include <windows.h>
-#include <stdio.h>
-#include <time.h>
-#include <direct.h>
-#include <io.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
#include "common/global.h"
-#include "common/language.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/profile.h"
#include "common/iman.h"
#include "common/restext.h"
-#include "old/math3d.h"
-#include "old/particule.h"
+#include "object/robotmain.h"
+#include "script/cmdtoken.h"
+#include "sound/sound.h"
#include "ui/interface.h"
#include "ui/button.h"
#include "ui/color.h"
@@ -50,24 +41,22 @@
#include "ui/window.h"
#include "ui/edit.h"
#include "ui/editvalue.h"
-#include "old/text.h"
-#include "old/camera.h"
-#include "old/sound.h"
-#include "script/cmdtoken.h"
-#include "object/robotmain.h"
-#include "ui/maindialog.h"
+#include <stdio.h>
+#include <string.h>
+namespace Ui
+{
+
const int KEY_VISIBLE = 6; // number of visible keys redefinable
-#if _SCHOOL & _TEEN
+/*TODO: #if _SCHOOL & _TEEN
const int KEY_TOTAL = 13; // total number of keys redefinable
-#else
+#else*/
const int KEY_TOTAL = 21; // total number of keys redefinable
-#endif
-const int WELCOME_LENGTH = 6.0f;
+const float WELCOME_LENGTH = 2.0f;
@@ -109,7 +98,7 @@ static int perso_color[3*10*3] =
};
-#if _NET
+/* TODO: ? #if _NET
// Check if the key "school" is present in the registry.
bool SchoolCheck()
@@ -138,24 +127,24 @@ bool SchoolCheck()
return true;
}
#endif
-
+*/
// Constructor of robot application.
CMainDialog::CMainDialog(CInstanceManager* iMan)
{
- int i;
-
m_iMan = iMan;
m_iMan->AddInstance(CLASS_DIALOG, this);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_particule = (CParticule*)m_iMan->SearchInstance(CLASS_PARTICULE);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_app = CApplication::GetInstancePointer();
+
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_eventQueue = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_particle = static_cast<Gfx::CParticle*>(m_iMan->SearchInstance(CLASS_PARTICULE));
+ m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
m_phase = PHASE_NAME;
m_phaseSetup = PHASE_SETUPg;
@@ -166,18 +155,18 @@ CMainDialog::CMainDialog(CInstanceManager* iMan)
m_sceneRank = 0;
m_bSceneSoluce = false;
m_bSimulSetup = false;
-#if _NET
+/* TODO: ? #if _NET
m_accessEnable = SchoolCheck();
m_accessMission= false;
m_accessUser = false;
-#else
+#else*/
m_accessEnable = true;
m_accessMission= true;
m_accessUser = true;
-#endif
+
m_bDeleteGamer = true;
- for ( i=0 ; i<10 ; i++ )
+ for (int i = 0; i < 10; i++)
{
m_chap[i] = 0;
m_sel[i] = 0;
@@ -185,7 +174,7 @@ CMainDialog::CMainDialog(CInstanceManager* iMan)
m_index = 0;
m_maxList = 0;
- ZeroMemory(&m_perso, sizeof(GamerPerso));
+ memset(&m_perso, 0, sizeof(GamerPerso));
DefPerso();
m_bTooltip = true;
@@ -195,11 +184,11 @@ CMainDialog::CMainDialog(CInstanceManager* iMan)
m_bMovies = true;
m_bNiceReset = true;
m_bHimselfDamage = true;
-#if _TEEN
+/* TODO: #if _TEEN
m_bCameraScroll = false;
-#else
+#else*/
m_bCameraScroll = true;
-#endif
+
m_bCameraInvertX = false;
m_bCameraInvertY = false;
m_bEffect = true;
@@ -208,7 +197,7 @@ CMainDialog::CMainDialog(CInstanceManager* iMan)
m_glintMouse = Math::Point(0.0f, 0.0f);
m_glintTime = 1000.0f;
- for ( i=0 ; i<10 ; i++ )
+ for (int i = 0; i < 10; i++)
{
m_partiPhase[i] = 0;
m_partiTime[i] = 0.0f;
@@ -252,9 +241,9 @@ void CMainDialog::ChangePhase(Phase phase)
char* gamer;
int res, i, j;
- m_camera->SetType(CAMERA_DIALOG);
+ m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
m_engine->SetOverFront(false);
- m_engine->SetOverColor(RetColor(0.0f), D3DSTATETCb);
+ m_engine->SetOverColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::ENG_RSTATE_TCOLOR_BLACK); // TODO: color ok?
if ( phase == PHASE_TERM )
{
@@ -276,11 +265,11 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y = 0.10f;
ddim.x = 0.30f;
ddim.y = 0.80f;
-#if _TEEN
+/* TODO: #if _TEEN
pw = m_interface->CreateWindows(pos, ddim, 12, EVENT_WINDOW5);
-#else
+#else*/
pw = m_interface->CreateWindows(pos, ddim, 10, EVENT_WINDOW5);
-#endif
+
GetResource(RES_TEXT, RT_TITLE_INIT, name);
pw->SetName(name);
@@ -295,7 +284,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 0.30f;
pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr); // blue corner
-#if _SCHOOL
+/* TODO: #if _SCHOOL
ddim.x = 0.20f;
ddim.y = dim.y*2.4f;
pos.x = 0.40f;
@@ -309,7 +298,7 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y = oy+sy*1.9f;
pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // red
pg->SetState(STATE_SHADOW);
-#else
+#else */
ddim.x = 0.20f;
ddim.y = dim.y*2.4f;
pos.x = 0.40f;
@@ -329,9 +318,8 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y = oy+sy*1.9f;
pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // red
pg->SetState(STATE_SHADOW);
-#endif
-#if _SCHOOL
+/* TODO: #if _SCHOOL
ddim.x = 0.18f;
ddim.y = dim.y*1;
pos.x = 0.41f;
@@ -349,7 +337,7 @@ void CMainDialog::ChangePhase(Phase phase)
pb->ClearState(STATE_ENABLE);
#endif
pb->SetState(STATE_SHADOW);
-#else
+#else */
ddim.x = 0.18f;
ddim.y = dim.y*1;
pos.x = 0.41f;
@@ -372,14 +360,15 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y = oy+sy*6.9f;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_DEFI);
pb->SetState(STATE_SHADOW);
-#endif
- if ( m_engine->RetSetupMode() )
+
+ /* TODO: setup mode?
+ if ( m_engine->GetSetupMode() )
{
pos.y = oy+sy*5.1f;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_SETUP);
pb->SetState(STATE_SHADOW);
- }
+ } */
pos.y = oy+sy*4.0f;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_NAME);
@@ -389,22 +378,22 @@ void CMainDialog::ChangePhase(Phase phase)
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_QUIT);
pb->SetState(STATE_SHADOW);
-#if !_DEMO & !_SCHOOL
+// TODO: #if !_DEMO & !_SCHOOL
if ( m_accessEnable && m_accessUser )
{
pos.x = 447.0f/640.0f;
pos.y = 313.0f/480.0f;
ddim.x = 0.09f;
-#if _POLISH
+/*#if _POLISH
pos.x -= 5.0f/640.0f;
ddim.x += 10.0f/640.0f;
-#endif
+#endif*/
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_USER);
pb->SetState(STATE_SHADOW);
}
-#endif
+// #endif
- if ( m_engine->RetDebugMode() )
+ if ( m_app->GetDebugMode() )
{
pos.x = 139.0f/640.0f;
pos.y = 313.0f/480.0f;
@@ -420,19 +409,16 @@ void CMainDialog::ChangePhase(Phase phase)
pg = pw->CreateGroup(pos, ddim, 1, EVENT_LABEL1);
pg->SetState(STATE_SHADOW);
pos.y -= 5.0f/480.0f;
-#if _WG
- pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, " ");
-#else
-#if _NEWLOOK
- pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "www.epsitec.ch");
-#else
- pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "www.ceebot.com");
-#endif
-#endif
- pl->SetFontType(FONT_COURIER);
+ pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, "PPC Team");
+ pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(8.0f);
- m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true);
+ m_engine->SetBackground("interface.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(1.0f, 768.0f / 1024.0f));
m_engine->SetBackForce(true);
}
@@ -446,7 +432,7 @@ void CMainDialog::ChangePhase(Phase phase)
GetResource(RES_TEXT, RT_TITLE_NAME, name);
pw->SetName(name);
-#if _NEWLOOK
+/* TODO: #if _NEWLOOK
pos.x = 80.0f/640.0f;
pos.y = 93.0f/480.0f;
ddim.x = 285.0f/640.0f;
@@ -457,7 +443,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 188.0f/640.0f;
pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
pg->SetState(STATE_SHADOW);
-#endif
+#endif*/
pos.x = 0.10f;
pos.y = 0.40f;
@@ -476,7 +462,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 32.0f/480.0f;
GetResource(RES_EVENT, EVENT_INTERFACE_NLABEL, name);
pl = pw->CreateLabel(pos, ddim, -1, EVENT_INTERFACE_NLABEL, name);
- pl->SetJustif(-1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_RIGHT);
pos.x = 200.0f/640.0f;
pos.y = 320.0f/480.0f;
@@ -491,7 +477,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 18.0f/480.0f;
pe = pw->CreateEdit(pos, ddim, 0, EVENT_INTERFACE_NEDIT);
pe->SetMaxChar(15);
- gamer = m_main->RetGamerName();
+ gamer = m_main->GetGamerName();
if ( gamer[0] == 0 )
{
GetResource(RES_TEXT, RT_NAME_DEFAULT, name);
@@ -511,14 +497,14 @@ void CMainDialog::ChangePhase(Phase phase)
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_NOK);
pb->SetState(STATE_SHADOW);
-#if !_TEEN
+/* TODO: #if !_TEEN
pos.x = 380.0f/640.0f;
pos.y = 250.0f/480.0f;
ddim.x =100.0f/640.0f;
ddim.y = 52.0f/480.0f;
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_PERSO);
pb->SetState(STATE_SHADOW);
-#endif
+#endif*/
pos.x = 200.0f/640.0f;
pos.y = 150.0f/480.0f;
@@ -549,7 +535,12 @@ void CMainDialog::ChangePhase(Phase phase)
UpdateNameControl();
UpdateNameFace();
- m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true);
+ m_engine->SetBackground("interface.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(1.0f, 768.0f / 1024.0f));
m_engine->SetBackForce(true);
}
@@ -563,14 +554,14 @@ void CMainDialog::ChangePhase(Phase phase)
GetResource(RES_TEXT, RT_TITLE_PERSO, name);
pw->SetName(name);
-#if _NEWLOOK
+/* TODO: #if _NEWLOOK
pos.x = 95.0f/640.0f;
pos.y = 66.0f/480.0f;
ddim.x = 443.0f/640.0f;
ddim.y = 42.0f/480.0f;
pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
pg->SetState(STATE_SHADOW);
-#endif
+#endif*/
pos.x = 0.10f;
pos.y = 0.40f;
@@ -628,7 +619,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 200.0f/640.0f;
ddim.y = 16.0f/480.0f;
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL11, "");
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = 340.0f/640.0f;
pos.y = 312.0f/480.0f;
@@ -652,7 +643,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 200.0f/640.0f;
ddim.y = 16.0f/480.0f;
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, "");
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = 340.0f/640.0f;
pos.y = 240.0f/480.0f;
@@ -661,7 +652,7 @@ void CMainDialog::ChangePhase(Phase phase)
for ( i=0 ; i<6 ; i++ )
{
int ti[6] = {11, 179, 180, 181, 182, 183};
- pb = pw->CreateButton(pos, ddim, ti[i], (EventMsg)(EVENT_INTERFACE_PGLASS0+i));
+ pb = pw->CreateButton(pos, ddim, ti[i], static_cast<EventType>(EVENT_INTERFACE_PGLASS0+i));
pb->SetState(STATE_SHADOW);
pos.x += (30.0f+2.8f)/640.0f;
}
@@ -672,7 +663,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 200.0f/640.0f;
ddim.y = 16.0f/480.0f;
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL14, "");
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.y = 282.0f/480.0f;
ddim.x = 18.0f/640.0f;
@@ -682,7 +673,7 @@ void CMainDialog::ChangePhase(Phase phase)
pos.x = 340.0f/640.0f;
for ( i=0 ; i<3 ; i++ )
{
- pco = pw->CreateColor(pos, ddim, -1, (EventMsg)(EVENT_INTERFACE_PC0a+j*3+i));
+ pco = pw->CreateColor(pos, ddim, -1, static_cast<EventType>(EVENT_INTERFACE_PC0a+j*3+i));
pco->SetState(STATE_SHADOW);
pos.x += 20.0f/640.0f;
}
@@ -695,7 +686,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 18.0f/480.0f;
for ( i=0 ; i<3 ; i++ )
{
- psl = pw->CreateSlider(pos, ddim, 0, (EventMsg)(EVENT_INTERFACE_PCRa+i));
+ psl = pw->CreateSlider(pos, ddim, 0, static_cast<EventType>(EVENT_INTERFACE_PCRa+i));
psl->SetState(STATE_SHADOW);
psl->SetLimit(0.0f, 255.0f);
psl->SetArrowStep(16.0f);
@@ -708,7 +699,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 200.0f/640.0f;
ddim.y = 16.0f/480.0f;
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL13, "");
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.y = 174.0f/480.0f;
ddim.x = 18.0f/640.0f;
@@ -718,7 +709,7 @@ void CMainDialog::ChangePhase(Phase phase)
pos.x = 340.0f/640.0f;
for ( i=0 ; i<3 ; i++ )
{
- pco = pw->CreateColor(pos, ddim, -1, (EventMsg)(EVENT_INTERFACE_PC0b+j*3+i));
+ pco = pw->CreateColor(pos, ddim, -1, static_cast<EventType>(EVENT_INTERFACE_PC0b+j*3+i));
pco->SetState(STATE_SHADOW);
pos.x += 20.0f/640.0f;
}
@@ -731,7 +722,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 18.0f/480.0f;
for ( i=0 ; i<3 ; i++ )
{
- psl = pw->CreateSlider(pos, ddim, 0, (EventMsg)(EVENT_INTERFACE_PCRb+i));
+ psl = pw->CreateSlider(pos, ddim, 0, static_cast<EventType>(EVENT_INTERFACE_PCRb+i));
psl->SetState(STATE_SHADOW);
psl->SetLimit(0.0f, 255.0f);
psl->SetArrowStep(16.0f);
@@ -804,7 +795,7 @@ void CMainDialog::ChangePhase(Phase phase)
{
strcpy(m_sceneName, "scene");
ReadGamerInfo();
- m_accessChap = RetChapPassed();
+ m_accessChap = GetChapPassed();
}
if ( m_phase == PHASE_TRAINER ) strcpy(m_sceneName, "train");
@@ -833,7 +824,7 @@ void CMainDialog::ChangePhase(Phase phase)
GetResource(RES_TEXT, res, name);
pw->SetName(name);
-#if _NEWLOOK
+/* TODO: #if _NEWLOOK
pos.x = 100.0f/640.0f;
pos.y = 226.0f/480.0f;
ddim.x = 216.0f/640.0f;
@@ -854,7 +845,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 42.0f/480.0f;
pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
pg->SetState(STATE_SHADOW);
-#endif
+#endif */
pos.x = 0.10f;
pos.y = 0.40f;
@@ -881,7 +872,7 @@ void CMainDialog::ChangePhase(Phase phase)
if ( m_phase == PHASE_PROTO ) res = RT_PLAY_CHAPp;
GetResource(RES_TEXT, res, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL11, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.y = oy+sy*6.7f;
ddim.y = dim.y*4.5f;
@@ -905,7 +896,7 @@ void CMainDialog::ChangePhase(Phase phase)
if ( m_phase == PHASE_PROTO ) res = RT_PLAY_LISTp;
GetResource(RES_TEXT, res, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.y = oy+sy*6.7f;
ddim.y = dim.y*4.5f;
@@ -914,8 +905,8 @@ void CMainDialog::ChangePhase(Phase phase)
pli->SetState(STATE_SHADOW);
UpdateSceneList(m_chap[m_index], m_sel[m_index]);
if ( m_phase != PHASE_USER ) pli->SetState(STATE_EXTEND);
- pos = pli->RetPos();
- ddim = pli->RetDim();
+ pos = pli->GetPos();
+ ddim = pli->GetDim();
// Displays the summary:
pos.x = ox+sx*3;
@@ -924,7 +915,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = dim.y*0.6f;
GetResource(RES_TEXT, RT_PLAY_RESUME, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL13, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*3;
pos.y = oy+sy*3.6f;
@@ -996,7 +987,12 @@ void CMainDialog::ChangePhase(Phase phase)
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_BACK);
pb->SetState(STATE_SHADOW);
- m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true);
+ m_engine->SetBackground("interface.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(1.0f, 768.0f / 1024.0f));
m_engine->SetBackForce(true);
}
@@ -1063,7 +1059,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 0.05f;
pw->CreateGroup(pos, ddim, 3, EVENT_NULL); // transparent -> gray
-#if _NEWLOOK
+/* TODO: #if _NEWLOOK
if ( m_phase == PHASE_SETUPd || // setup/display ?
m_phase == PHASE_SETUPds )
{
@@ -1135,7 +1131,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 42.0f/480.0f;
pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
pg->SetState(STATE_SHADOW);
-#endif
+#endif */
ddim.x = 0.78f/5-0.01f;
ddim.y = 0.06f;
@@ -1190,7 +1186,12 @@ void CMainDialog::ChangePhase(Phase phase)
if ( !m_bSimulSetup )
{
- m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true);
+ m_engine->SetBackground("interface.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(1.0f, 768.0f / 1024.0f));
m_engine->SetBackForce(true);
}
}
@@ -1204,7 +1205,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = dim.y*1;
GetResource(RES_TEXT, RT_SETUP_DEVICE, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*3;
pos.y = oy+sy*5.2f;
@@ -1220,9 +1221,9 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = dim.y*1;
GetResource(RES_TEXT, RT_SETUP_MODE, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
- m_setupFull = m_engine->RetFullScreen();
+ m_setupFull = m_app->GetVideoConfig().fullScreen;
pos.x = ox+sx*10;
pos.y = oy+sy*5.2f;
ddim.x = dim.x*6;
@@ -1263,7 +1264,8 @@ void CMainDialog::ChangePhase(Phase phase)
{
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_GROUND);
pc->SetState(STATE_SHADOW);
- if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE);
+ // TODO: video 8 MB?
+ //if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE);
}
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_DIRTY);
@@ -1271,7 +1273,8 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SKY);
pc->SetState(STATE_SHADOW);
- if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE);
+ // TODO: video 8 MB?
+ //if ( m_engine->IsVideo8MB() ) pc->ClearState(STATE_ENABLE);
pos.y -= 0.048f;
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_LENS);
pc->SetState(STATE_SHADOW);
@@ -1301,7 +1304,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_PARTI, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL10, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.59f;
@@ -1316,7 +1319,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_CLIP, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL11, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*8.5f;
pos.y = 0.53f;
@@ -1331,7 +1334,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_DETAIL, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
if ( !m_bSimulSetup )
{
@@ -1348,7 +1351,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_GADGET, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL13, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
}
#if 0
@@ -1369,7 +1372,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 0.40f;
GetResource(RES_EVENT, EVENT_INTERFACE_TEXTURE, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL14, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
}
#endif
@@ -1377,10 +1380,10 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = dim.y*1;
pos.x = ox+sx*10;
pos.y = oy+sy*2;
-#if _POLISH
+/* TODO: #if _POLISH
ddim.x += 20.0f/640.0f;
pos.x -= 20.0f/640.0f*3.0f;
-#endif
+#endif*/
pb = pw->CreateButton(pos, ddim, -1, EVENT_INTERFACE_MIN);
pb->SetState(STATE_SHADOW);
pos.x += ddim.x;
@@ -1403,17 +1406,17 @@ void CMainDialog::ChangePhase(Phase phase)
//? pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_TOTO);
//? pc->SetState(STATE_SHADOW);
//? pos.y -= 0.048f;
-#if _SCHOOL
+/*TODO: #if _SCHOOL
#if _EDU
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SOLUCE4);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
#endif
-#else
+#else*/
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_MOVIES);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
-#endif
+//#endif
pc = pw->CreateCheck(pos, ddim, -1, EVENT_INTERFACE_SCROLL);
pc->SetState(STATE_SHADOW);
pos.y -= 0.048f;
@@ -1470,7 +1473,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 18.0f/480.0f;
GetResource(RES_TEXT, RT_SETUP_KEY1, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_INTERFACE_KINFO1, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.x = ox+sx*3;
pos.y = 302.0f/480.0f;
@@ -1478,7 +1481,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 18.0f/480.0f;
GetResource(RES_TEXT, RT_SETUP_KEY2, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_INTERFACE_KINFO2, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
ddim.x = 428.0f/640.0f;
ddim.y = 128.0f/480.0f;
@@ -1494,8 +1497,8 @@ void CMainDialog::ChangePhase(Phase phase)
pos.x = 510.0f/640.0f;
pos.y = 168.0f/480.0f;
ps = pw->CreateScroll(pos, ddim, -1, EVENT_INTERFACE_KSCROLL);
- ps->SetVisibleRatio((float)KEY_VISIBLE/KEY_TOTAL);
- ps->SetArrowStep(1.0f/((float)KEY_TOTAL-KEY_VISIBLE));
+ ps->SetVisibleRatio(static_cast<float>(KEY_VISIBLE/KEY_TOTAL));
+ ps->SetArrowStep(1.0f/(static_cast<float>(KEY_TOTAL-KEY_VISIBLE)));
UpdateKey();
ddim.x = dim.x*6;
@@ -1529,9 +1532,9 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y += ddim.y;
GetResource(RES_EVENT, EVENT_INTERFACE_VOLSOUND, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
-#if (_FULL | _NET) & _SOUNDTRACKS
+// TODO: #if (_FULL | _NET) & _SOUNDTRACKS
pos.x = ox+sx*3;
pos.y = 0.40f;
ddim.x = dim.x*4.0f;
@@ -1543,8 +1546,8 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y += ddim.y;
GetResource(RES_EVENT, EVENT_INTERFACE_VOLMUSIC, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
- pl->SetJustif(1);
-#endif
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
+// #endif
ddim.x = dim.x*6;
ddim.y = dim.y*0.5f;
@@ -1589,14 +1592,14 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 0.50f;
pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr); // blue corner
-#if _NEWLOOK
+/* TODO: #if _NEWLOOK
pos.x = 100.0f/640.0f;
pos.y = 66.0f/480.0f;
ddim.x = 438.0f/640.0f;
ddim.y = 42.0f/480.0f;
pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
pg->SetState(STATE_SHADOW);
-#endif
+#endif */
pos.x = 290.0f/640.0f;
ddim.x = 245.0f/640.0f;
@@ -1605,13 +1608,13 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 18.0f/480.0f;
GetResource(RES_EVENT, EVENT_INTERFACE_IOLABEL, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_INTERFACE_IOLABEL, name);
- pl->SetJustif(1);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pos.y = 130.0f/480.0f;
ddim.y = 18.0f/480.0f;
pe = pw->CreateEdit(pos, ddim, 0, EVENT_INTERFACE_IONAME);
pe->SetState(STATE_SHADOW);
- pe->SetFontType(FONT_COLOBOT);
+ pe->SetFontType(Gfx::FONT_COLOBOT);
pe->SetMaxChar(35);
IOReadName();
@@ -1673,14 +1676,14 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 0.50f;
pw->CreateGroup(pos, ddim, 4, EVENT_INTERFACE_GLINTr); // blue corner
-#if _NEWLOOK
+/* TODO: #if _NEWLOOK
pos.x = 100.0f/640.0f;
pos.y = 66.0f/480.0f;
ddim.x = 438.0f/640.0f;
ddim.y = 42.0f/480.0f;
pg = pw->CreateGroup(pos, ddim, 26, EVENT_LABEL1); // violet
pg->SetState(STATE_SHADOW);
-#endif
+#endif*/
pos.x = 290.0f/640.0f;
ddim.x = 245.0f/640.0f;
@@ -1725,7 +1728,12 @@ void CMainDialog::ChangePhase(Phase phase)
if ( m_phase == PHASE_READ )
{
- m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true);
+ m_engine->SetBackground("interface.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(1.0f, 768.0f / 1024.0f));
m_engine->SetBackForce(true);
}
}
@@ -1736,11 +1744,11 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y = 0.10f;
ddim.x = 0.30f;
ddim.y = 0.80f;
-#if _TEEN
+/*TODO: #if _TEEN
pw = m_interface->CreateWindows(pos, ddim, 12, EVENT_WINDOW5);
-#else
+#else*/
pw = m_interface->CreateWindows(pos, ddim, 10, EVENT_WINDOW5);
-#endif
+
pw->SetName(" ");
pos.x = 0.35f;
@@ -1768,9 +1776,14 @@ void CMainDialog::ChangePhase(Phase phase)
GetResource(RES_TEXT, RT_DIALOG_LOADING, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
pl->SetFontSize(12.0f);
- pl->SetJustif(0);
-
- m_engine->SetBackground("inter01.tga", 0,0, 0,0, true, true);
+ pl->SetTextAlign(Gfx::TEXT_ALIGN_CENTER);
+
+ m_engine->SetBackground("interface.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(1.0f, 768.0f / 1024.0f));
m_engine->SetBackForce(true);
m_loadingCounter = 1; // enough time to display!
@@ -1787,30 +1800,21 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 0.0f;
pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5);
- m_engine->SetOverColor(RetColor(1.0f), D3DSTATETCb);
+ m_engine->SetOverColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f), Gfx::ENG_RSTATE_TCOLOR_BLACK); // TODO: color ok?
m_engine->SetOverFront(true);
-#if _FRENCH
- m_engine->SetBackground("alsyd.tga", 0,0, 0,0, true, false);
-#endif
-#if _POLISH
- m_engine->SetBackground("manta.tga", 0,0, 0,0, true, false);
-#endif
-#if _WG
- m_engine->SetBackground("wg.tga", 0,0, 0,0, true, false);
-#endif
+ m_engine->SetBackground("ppc.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(861.0f / 1024.0f, 646.0f / 1024.0f));
m_engine->SetBackForce(true);
}
if ( m_phase == PHASE_WELCOME2 )
{
-#if _ENGLISH
m_sound->StopMusic();
m_sound->PlayMusic(11, false);
-#endif
-#if _POLISH
- m_sound->StopMusic();
- m_sound->PlayMusic(11, false);
-#endif
pos.x = 0.0f;
pos.y = 0.0f;
@@ -1818,10 +1822,15 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 0.0f;
pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5);
- m_engine->SetOverColor(RetColor(1.0f), D3DSTATETCb);
+ m_engine->SetOverColor(Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f), Gfx::ENG_RSTATE_TCOLOR_BLACK); // TODO: color ok?
m_engine->SetOverFront(true);
- m_engine->SetBackground("colobot.tga", 0,0, 0,0, true, false);
+ m_engine->SetBackground("colobot.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(640.0f / 1024.0f, 480.0f / 512.0f));
m_engine->SetBackForce(true);
}
if ( m_phase == PHASE_WELCOME3 )
@@ -1832,21 +1841,15 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 0.0f;
pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5);
- m_engine->SetOverColor(RetColor(0.0f), D3DSTATETCw);
+ m_engine->SetOverColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f), Gfx::ENG_RSTATE_TCOLOR_WHITE); // TODO: color ok?
m_engine->SetOverFront(true);
-#if _FRENCH
- m_engine->SetBackground("epsitecf.tga", 0,0, 0,0, true, false);
-#endif
-#if _ENGLISH
- m_engine->SetBackground("epsitece.tga", 0,0, 0,0, true, false);
-#endif
-#if _GERMAN | _WG
- m_engine->SetBackground("epsitecd.tga", 0,0, 0,0, true, false);
-#endif
-#if _POLISH
- m_engine->SetBackground("epsitecp.tga", 0,0, 0,0, true, false);
-#endif
+ m_engine->SetBackground("epsitec.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(640.0f / 1024.0f, 480.0f / 512.0f));
m_engine->SetBackForce(true);
}
@@ -1858,7 +1861,7 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 0.0f;
pw = m_interface->CreateWindows(pos, ddim, -1, EVENT_WINDOW5);
-#if _FULL | _NET
+// TODO: #if _FULL | _NET
pos.x = 80.0f/640.0f;
pos.y = 240.0f/480.0f;
ddim.x = 490.0f/640.0f;
@@ -1867,7 +1870,7 @@ void CMainDialog::ChangePhase(Phase phase)
pe->SetGenericMode(true);
pe->SetEditCap(false);
pe->SetHiliteCap(false);
- pe->SetFontType(FONT_COURIER);
+ pe->SetFontType(Gfx::FONT_COURIER);
pe->SetFontSize(8.0f);
pe->ReadText("help\\authors.txt");
@@ -1879,11 +1882,11 @@ void CMainDialog::ChangePhase(Phase phase)
pe->SetGenericMode(true);
pe->SetEditCap(false);
pe->SetHiliteCap(false);
- pe->SetFontType(FONT_COURIER);
+ pe->SetFontType(Gfx::FONT_COURIER);
pe->SetFontSize(6.5f);
pe->ReadText("help\\licences.txt");
-#endif
-#if _SCHOOL
+// #endif
+/* TODO: #if _SCHOOL
#if _CEEBOTDEMO
pos.x = 80.0f/640.0f;
pos.y = 210.0f/480.0f;
@@ -1894,16 +1897,16 @@ void CMainDialog::ChangePhase(Phase phase)
pos.y = 200.0f/480.0f;
ddim.x = 490.0f/640.0f;
ddim.y = 150.0f/480.0f;
-#endif
+#endif*/
pe = pw->CreateEdit(pos, ddim, 0, EVENT_EDIT1);
pe->SetGenericMode(true);
pe->SetEditCap(false);
pe->SetHiliteCap(false);
- pe->SetFontType(FONT_COURIER);
+ pe->SetFontType(Gfx::FONT_COURIER);
pe->SetFontSize(8.0f);
pe->ReadText("help\\authors.txt");
-#endif
-#if _DEMO
+
+/* #if _DEMO
//? pos.x = 80.0f/640.0f;
//? pos.y = 240.0f/480.0f;
//? ddim.x = 490.0f/640.0f;
@@ -1912,7 +1915,7 @@ void CMainDialog::ChangePhase(Phase phase)
//? pe->SetGenericMode(true);
//? pe->SetEditCap(false);
//? pe->SetHiliteCap(false);
-//? pe->SetFontType(FONT_COURIER);
+//? pe->SetFontType(Gfx::FONT_COURIER);
//? pe->SetFontSize(8.0f);
//? pe->ReadText("help\\demo.txt");
@@ -1924,25 +1927,25 @@ void CMainDialog::ChangePhase(Phase phase)
//? pe->SetGenericMode(true);
//? pe->SetEditCap(false);
//? pe->SetHiliteCap(false);
-//? pe->SetFontType(FONT_COURIER);
+//? pe->SetFontType(Gfx::FONT_COURIER);
//? pe->SetFontSize(8.0f);
//? pe->ReadText("help\\authors.txt");
-#endif
+#endif */
-#if !_DEMO
+// TODO: #if !_DEMO
pos.x = 40.0f/640.0f;
pos.y = 83.0f/480.0f;
ddim.x = 246.0f/640.0f;
ddim.y = 16.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_DEV1, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
- pl->SetFontType(FONT_COURIER);
+ pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(8.0f);
pos.y = 13.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_DEV2, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL2, name);
- pl->SetFontType(FONT_COURIER);
+ pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(8.0f);
pos.x = 355.0f/640.0f;
@@ -1951,79 +1954,38 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.y = 16.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_EDIT1, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL3, name);
- pl->SetFontType(FONT_COURIER);
+ pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(8.0f);
pos.y = 13.0f/480.0f;
GetResource(RES_TEXT, RT_GENERIC_EDIT2, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL4, name);
- pl->SetFontType(FONT_COURIER);
+ pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(8.0f);
-#endif
+// #endif
-#if _DEMO
+/* TODO: #if _DEMO
pos.x = 481.0f/640.0f;
pos.y = 51.0f/480.0f;
ddim.x = 30.0f/640.0f;
ddim.y = 30.0f/480.0f;
pb = pw->CreateButton(pos, ddim, 49, EVENT_INTERFACE_ABORT);
pb->SetState(STATE_SHADOW);
-#else
+#else */
pos.x = 306.0f/640.0f;
pos.y = 17.0f/480.0f;
ddim.x = 30.0f/640.0f;
ddim.y = 30.0f/480.0f;
pb = pw->CreateButton(pos, ddim, 49, EVENT_INTERFACE_ABORT);
pb->SetState(STATE_SHADOW);
-#endif
-
-#if _NEWLOOK
-#if _CEEBOTDEMO
-#if _TEEN
- m_engine->SetBackground("genedt.tga", 0,0, 0,0, true, true);
-#else
- m_engine->SetBackground("geneda.tga", 0,0, 0,0, true, true);
-#endif
-#else
- m_engine->SetBackground("genern.tga", 0,0, 0,0, true, true);
-#endif
-#else
-#if _FRENCH
-#if _DEMO
- m_engine->SetBackground("genedf.tga", 0,0, 0,0, true, true);
-#else
- m_engine->SetBackground("generf.tga", 0,0, 0,0, true, true);
-#endif
-#endif
-#if _ENGLISH
-#if _DEMO
- m_engine->SetBackground("genede.tga", 0,0, 0,0, true, true);
-#else
- m_engine->SetBackground("genere.tga", 0,0, 0,0, true, true);
-#endif
-#endif
-#if _GERMAN
-#if _DEMO
- m_engine->SetBackground("genedd.tga", 0,0, 0,0, true, true);
-#else
- m_engine->SetBackground("genere.tga", 0,0, 0,0, true, true);
-#endif
-#endif
-#if _WG
-#if _DEMO
- m_engine->SetBackground("genedd.tga", 0,0, 0,0, true, true);
-#else
- m_engine->SetBackground("generd.tga", 0,0, 0,0, true, true);
-#endif
-#endif
-#if _POLISH
-#if _DEMO
- m_engine->SetBackground("genedp.tga", 0,0, 0,0, true, true);
-#else
- m_engine->SetBackground("generp.tga", 0,0, 0,0, true, true);
-#endif
-#endif
-#endif
+// #endif
+
+ m_engine->SetBackground("generic.png",
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f),
+ true, Math::Point(1.0f, 768.0f / 1024.0f));
m_engine->SetBackForce(true);
}
@@ -2044,7 +2006,7 @@ void CMainDialog::ChangePhase(Phase phase)
m_phase == PHASE_READ ||
m_phase == PHASE_LOADING )
{
-#if _SCHOOL
+/*TODO: #if _SCHOOL
#if _TEEN
pos.x = 50.0f/640.0f;
pos.y = 430.0f/480.0f;
@@ -2056,24 +2018,24 @@ void CMainDialog::ChangePhase(Phase phase)
ddim.x = 170.0f/640.0f;
ddim.y = 9.0f/480.0f;
#endif
-#else
+#else */
pos.x = 540.0f/640.0f;
pos.y = 9.0f/480.0f;
ddim.x = 90.0f/640.0f;
ddim.y = 10.0f/480.0f;
-#endif
+//#endif
GetResource(RES_TEXT, RT_VERSION_ID, name);
pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL1, name);
- pl->SetFontType(FONT_COURIER);
+ pl->SetFontType(Gfx::FONT_COURIER);
pl->SetFontSize(9.0f);
}
- m_engine->LoadAllTexture();
+ m_engine->LoadAllTextures();
}
// Processing an event.
-// Returns false if the event has been processed completely.
+// Geturns false if the event has been processed completely.
bool CMainDialog::EventProcess(const Event &event)
{
@@ -2084,7 +2046,7 @@ bool CMainDialog::EventProcess(const Event &event)
Event newEvent;
float welcomeLength;
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
m_phaseTime += event.rTime;
@@ -2097,7 +2059,7 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase == PHASE_WELCOME3 )
{
float intensity;
- int mode = D3DSTATETCb;
+ int mode = Gfx::ENG_RSTATE_TCOLOR_BLACK;
if ( m_phaseTime < 1.5f )
{
@@ -2118,10 +2080,10 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase == PHASE_WELCOME3 )
{
intensity = 1.0f-intensity;
- mode = D3DSTATETCw;
+ mode = Gfx::ENG_RSTATE_TCOLOR_WHITE;
}
- m_engine->SetOverColor(RetColor(intensity), mode);
+ m_engine->SetOverColor(Gfx::Color(intensity, intensity, intensity, intensity), mode); // TODO: color ok?
}
if ( m_phase == PHASE_WELCOME1 && m_phaseTime >= welcomeLength )
@@ -2163,7 +2125,7 @@ bool CMainDialog::EventProcess(const Event &event)
m_glintTime += event.rTime;
GlintMove(); // moves reflections
- FrameParticule(event.rTime);
+ FrameParticle(event.rTime);
if ( m_bDialog ) // this dialogue?
{
@@ -2173,18 +2135,18 @@ bool CMainDialog::EventProcess(const Event &event)
return true;
}
- if ( event.event == EVENT_MOUSEMOVE )
+ if ( event.type == EVENT_MOUSE_MOVE )
{
m_glintMouse = event.pos;
- NiceParticule(event.pos, event.keyState&KS_MLEFT);
+ NiceParticle(event.pos, event.keyState&KS_MLEFT);
}
if ( m_bDialog ) // this dialogue?
{
m_interface->EventProcess(event);
- if ( event.event == EVENT_DIALOG_OK ||
- (event.event == EVENT_KEYDOWN && event.param == VK_RETURN ) )
+ if ( event.type == EVENT_DIALOG_OK ||
+ (event.type == EVENT_KEY_DOWN && event.param == KEY(RETURN) ) )
{
StopDialog();
if ( m_phase == PHASE_NAME )
@@ -2193,8 +2155,8 @@ bool CMainDialog::EventProcess(const Event &event)
}
if ( m_phase == PHASE_INIT )
{
-//? m_event->MakeEvent(newEvent, EVENT_QUIT);
-//? m_event->AddEvent(newEvent);
+//? m_eventQueue->MakeEvent(newEvent, EVENT_QUIT);
+//? m_eventQueue->AddEvent(newEvent);
m_main->ChangePhase(PHASE_GENERIC);
}
if ( m_phase == PHASE_SIMUL )
@@ -2209,12 +2171,12 @@ bool CMainDialog::EventProcess(const Event &event)
}
}
}
- if ( event.event == EVENT_DIALOG_CANCEL ||
- (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE ) )
+ if ( event.type == EVENT_DIALOG_CANCEL ||
+ (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE) ) )
{
StopDialog();
}
- if ( event.event == EVENT_INTERFACE_SETUP )
+ if ( event.type == EVENT_INTERFACE_SETUP )
{
StopDialog();
StartSuspend();
@@ -2224,18 +2186,18 @@ bool CMainDialog::EventProcess(const Event &event)
if ( m_phaseSetup == PHASE_SETUPc ) ChangePhase(PHASE_SETUPcs);
if ( m_phaseSetup == PHASE_SETUPs ) ChangePhase(PHASE_SETUPss);
}
- if ( event.event == EVENT_INTERFACE_AGAIN )
+ if ( event.type == EVENT_INTERFACE_AGAIN )
{
StopDialog();
m_main->ChangePhase(PHASE_LOADING);
}
- if ( event.event == EVENT_INTERFACE_WRITE )
+ if ( event.type == EVENT_INTERFACE_WRITE )
{
StopDialog();
StartSuspend();
ChangePhase(PHASE_WRITEs);
}
- if ( event.event == EVENT_INTERFACE_READ )
+ if ( event.type == EVENT_INTERFACE_READ )
{
StopDialog();
StartSuspend();
@@ -2245,7 +2207,7 @@ bool CMainDialog::EventProcess(const Event &event)
return false;
}
- if ( !m_engine->RetMouseHide() &&
+ if ( /*TODO: m_engine->GetMouseVisible() &&*/
!m_interface->EventProcess(event) )
{
return false;
@@ -2253,10 +2215,10 @@ bool CMainDialog::EventProcess(const Event &event)
if ( m_phase == PHASE_INIT )
{
- switch( event.event )
+ switch( event.type )
{
- case EVENT_KEYDOWN:
- if ( event.param == VK_ESCAPE )
+ case EVENT_KEY_DOWN:
+ if ( event.param == KEY(ESCAPE) )
{
//? StartQuit(); // would you leave?
m_sound->Play(SOUND_TZOING);
@@ -2305,24 +2267,27 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_NAME:
m_main->ChangePhase(PHASE_NAME);
break;
+
+ default:
+ break;
}
return false;
}
if ( m_phase == PHASE_NAME )
{
- switch( event.event )
+ switch( event.type )
{
- case EVENT_KEYDOWN:
- if ( event.param == VK_RETURN )
+ case EVENT_KEY_DOWN:
+ if ( event.param == KEY(RETURN) )
{
NameSelect();
}
- if ( event.param == VK_ESCAPE )
+ if ( event.param == KEY(ESCAPE) )
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) break;
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NCANCEL);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NCANCEL));
if ( pb == 0 ) break;
if ( pb->TestState(STATE_ENABLE) )
{
@@ -2354,25 +2319,28 @@ bool CMainDialog::EventProcess(const Event &event)
break;
case EVENT_INTERFACE_NDELETE:
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) break;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
if ( pl == 0 ) break;
- StartDeleteGame(pl->RetName(pl->RetSelect()));
+ StartDeleteGame(pl->GetName(pl->GetSelect()));
+ break;
+
+ default:
break;
}
}
if ( m_phase == PHASE_PERSO )
{
- switch( event.event )
+ switch( event.type )
{
- case EVENT_KEYDOWN:
- if ( event.param == VK_RETURN )
+ case EVENT_KEY_DOWN:
+ if ( event.param == KEY(RETURN) )
{
m_main->ChangePhase(PHASE_INIT);
}
- if ( event.param == VK_ESCAPE )
+ if ( event.param == KEY(ESCAPE) )
{
m_main->ChangePhase(PHASE_NAME);
}
@@ -2395,8 +2363,8 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_PFACE2:
case EVENT_INTERFACE_PFACE3:
case EVENT_INTERFACE_PFACE4:
- m_perso.face = event.event-EVENT_INTERFACE_PFACE1;
- WriteGamerPerso(m_main->RetGamerName());
+ m_perso.face = event.type-EVENT_INTERFACE_PFACE1;
+ WriteGamerPerso(m_main->GetGamerName());
UpdatePerso();
m_main->ScenePerso();
break;
@@ -2411,8 +2379,8 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_PGLASS7:
case EVENT_INTERFACE_PGLASS8:
case EVENT_INTERFACE_PGLASS9:
- m_perso.glasses = event.event-EVENT_INTERFACE_PGLASS0;
- WriteGamerPerso(m_main->RetGamerName());
+ m_perso.glasses = event.type-EVENT_INTERFACE_PGLASS0;
+ WriteGamerPerso(m_main->GetGamerName());
UpdatePerso();
m_main->ScenePerso();
break;
@@ -2427,8 +2395,8 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_PC7a:
case EVENT_INTERFACE_PC8a:
case EVENT_INTERFACE_PC9a:
- FixPerso(event.event-EVENT_INTERFACE_PC0a, 0);
- WriteGamerPerso(m_main->RetGamerName());
+ FixPerso(event.type-EVENT_INTERFACE_PC0a, 0);
+ WriteGamerPerso(m_main->GetGamerName());
UpdatePerso();
m_main->ScenePerso();
break;
@@ -2443,8 +2411,8 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_PC7b:
case EVENT_INTERFACE_PC8b:
case EVENT_INTERFACE_PC9b:
- FixPerso(event.event-EVENT_INTERFACE_PC0b, 1);
- WriteGamerPerso(m_main->RetGamerName());
+ FixPerso(event.type-EVENT_INTERFACE_PC0b, 1);
+ WriteGamerPerso(m_main->GetGamerName());
UpdatePerso();
m_main->ScenePerso();
break;
@@ -2456,14 +2424,14 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_PCGb:
case EVENT_INTERFACE_PCBb:
ColorPerso();
- WriteGamerPerso(m_main->RetGamerName());
+ WriteGamerPerso(m_main->GetGamerName());
UpdatePerso();
m_main->ScenePerso();
break;
case EVENT_INTERFACE_PDEF:
DefPerso();
- WriteGamerPerso(m_main->RetGamerName());
+ WriteGamerPerso(m_main->GetGamerName());
UpdatePerso();
m_main->ScenePerso();
break;
@@ -2481,9 +2449,12 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_PCANCEL:
m_perso = m_persoCopy;
- WriteGamerPerso(m_main->RetGamerName());
+ WriteGamerPerso(m_main->GetGamerName());
m_main->ChangePhase(PHASE_NAME);
break;
+
+ default:
+ break;
}
}
@@ -2495,12 +2466,12 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase == PHASE_USER ||
m_phase == PHASE_PROTO )
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return false;
- if ( event.event == pw->RetEventMsgClose() ||
- event.event == EVENT_INTERFACE_BACK ||
- (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) )
+ if ( event.type == pw->GetEventTypeClose() ||
+ event.type == EVENT_INTERFACE_BACK ||
+ (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
{
m_main->ChangePhase(PHASE_INIT);
return false;
@@ -2515,25 +2486,25 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase == PHASE_USER ||
m_phase == PHASE_PROTO )
{
- switch( event.event )
+ switch( event.type )
{
case EVENT_INTERFACE_CHAP:
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_CHAP);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_CHAP));
if ( pl == 0 ) break;
- m_chap[m_index] = pl->RetSelect();
+ m_chap[m_index] = pl->GetSelect();
UpdateSceneList(m_chap[m_index], m_sel[m_index]);
UpdateSceneResume((m_chap[m_index]+1)*100+(m_sel[m_index]+1));
break;
case EVENT_INTERFACE_LIST:
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_LIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST));
if ( pl == 0 ) break;
- m_sel[m_index] = pl->RetSelect();
+ m_sel[m_index] = pl->GetSelect();
UpdateSceneResume((m_chap[m_index]+1)*100+(m_sel[m_index]+1));
break;
case EVENT_INTERFACE_SOLUCE:
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_SOLUCE);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE));
if ( pb == 0 ) break;
m_bSceneSoluce = !m_bSceneSoluce;
pb->SetState(STATE_CHECK, m_bSceneSoluce);
@@ -2554,6 +2525,9 @@ bool CMainDialog::EventProcess(const Event &event)
m_phaseTerm = m_phase;
m_main->ChangePhase(PHASE_READ);
break;
+
+ default:
+ break;
}
return false;
}
@@ -2564,12 +2538,12 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase == PHASE_SETUPc ||
m_phase == PHASE_SETUPs )
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return false;
- if ( event.event == pw->RetEventMsgClose() ||
- event.event == EVENT_INTERFACE_BACK ||
- (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) )
+ if ( event.type == pw->GetEventTypeClose() ||
+ event.type == EVENT_INTERFACE_BACK ||
+ (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
{
SetupMemorize();
m_engine->ApplyChange();
@@ -2577,7 +2551,7 @@ bool CMainDialog::EventProcess(const Event &event)
return false;
}
- switch( event.event )
+ switch( event.type )
{
case EVENT_INTERFACE_SETUPd:
m_main->ChangePhase(PHASE_SETUPd);
@@ -2598,6 +2572,9 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_SETUPs:
m_main->ChangePhase(PHASE_SETUPs);
break;
+
+ default:
+ break;
}
}
@@ -2607,12 +2584,12 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase == PHASE_SETUPcs ||
m_phase == PHASE_SETUPss )
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return false;
- if ( event.event == pw->RetEventMsgClose() ||
- event.event == EVENT_INTERFACE_BACK ||
- (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) )
+ if ( event.type == pw->GetEventTypeClose() ||
+ event.type == EVENT_INTERFACE_BACK ||
+ (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
{
SetupMemorize();
m_engine->ApplyChange();
@@ -2622,7 +2599,7 @@ bool CMainDialog::EventProcess(const Event &event)
return false;
}
- switch( event.event )
+ switch( event.type )
{
case EVENT_INTERFACE_SETUPd:
ChangePhase(PHASE_SETUPds);
@@ -2643,13 +2620,16 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_SETUPs:
ChangePhase(PHASE_SETUPss);
break;
+
+ default:
+ break;
}
}
if ( m_phase == PHASE_SETUPd || // setup/display ?
m_phase == PHASE_SETUPds )
{
- switch( event.event )
+ switch( event.type )
{
case EVENT_LIST1:
case EVENT_LIST2:
@@ -2657,11 +2637,11 @@ bool CMainDialog::EventProcess(const Event &event)
break;
case EVENT_INTERFACE_FULL:
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) break;
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FULL);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL));
if ( pc == 0 ) break;
- pl = (CList*)pw->SearchControl(EVENT_LIST2);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
if ( pl == 0 ) break;
if ( pc->TestState(STATE_CHECK) )
{
@@ -2677,15 +2657,18 @@ bool CMainDialog::EventProcess(const Event &event)
break;
case EVENT_INTERFACE_APPLY:
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) break;
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_APPLY);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_APPLY));
if ( pb == 0 ) break;
pb->ClearState(STATE_PRESS);
pb->ClearState(STATE_HILIGHT);
ChangeDisplay();
UpdateApply();
break;
+
+ default:
+ break;
}
return false;
}
@@ -2693,53 +2676,53 @@ bool CMainDialog::EventProcess(const Event &event)
if ( m_phase == PHASE_SETUPg || // setup/graphic ?
m_phase == PHASE_SETUPgs )
{
- switch( event.event )
+ switch( event.type )
{
case EVENT_INTERFACE_SHADOW:
- m_engine->SetShadow(!m_engine->RetShadow());
+ m_engine->SetShadow(!m_engine->GetShadow());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_GROUND:
- m_engine->SetGroundSpot(!m_engine->RetGroundSpot());
+ m_engine->SetGroundSpot(!m_engine->GetGroundSpot());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_DIRTY:
- m_engine->SetDirty(!m_engine->RetDirty());
+ m_engine->SetDirty(!m_engine->GetDirty());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_FOG:
- m_engine->SetFog(!m_engine->RetFog());
- m_camera->SetOverBaseColor(RetColor(RetColor(0.0f)));
+ m_engine->SetFog(!m_engine->GetFog());
+ m_camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); // TODO: color ok?
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_LENS:
- m_engine->SetLensMode(!m_engine->RetLensMode());
+ m_engine->SetLensMode(!m_engine->GetLensMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_SKY:
- m_engine->SetSkyMode(!m_engine->RetSkyMode());
+ m_engine->SetSkyMode(!m_engine->GetSkyMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_PLANET:
- m_engine->SetPlanetMode(!m_engine->RetPlanetMode());
+ m_engine->SetPlanetMode(!m_engine->GetPlanetMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_LIGHT:
- m_engine->SetLightMode(!m_engine->RetLightMode());
+ m_engine->SetLightMode(!m_engine->GetLightMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
@@ -2764,6 +2747,9 @@ bool CMainDialog::EventProcess(const Event &event)
ChangeSetupQuality(1);
UpdateSetupButtons();
break;
+
+ default:
+ break;
}
return false;
}
@@ -2771,10 +2757,10 @@ bool CMainDialog::EventProcess(const Event &event)
if ( m_phase == PHASE_SETUPp || // setup/game ?
m_phase == PHASE_SETUPps )
{
- switch( event.event )
+ switch( event.type )
{
case EVENT_INTERFACE_TOTO:
- m_engine->SetTotoMode(!m_engine->RetTotoMode());
+ m_engine->SetTotoMode(!m_engine->GetTotoMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
@@ -2798,19 +2784,20 @@ bool CMainDialog::EventProcess(const Event &event)
break;
case EVENT_INTERFACE_MOUSE:
- m_engine->SetNiceMouse(!m_engine->RetNiceMouse());
+ m_engine->SetMouseVisible(!m_engine->GetMouseVisible());
+ // TODO: system mouse visible
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_EDITMODE:
- m_engine->SetEditIndentMode(!m_engine->RetEditIndentMode());
+ m_engine->SetEditIndentMode(!m_engine->GetEditIndentMode());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_EDITVALUE:
- if ( m_engine->RetEditIndentValue() == 2 )
+ if ( m_engine->GetEditIndentValue() == 2 )
{
m_engine->SetEditIndentValue(4);
}
@@ -2873,6 +2860,9 @@ bool CMainDialog::EventProcess(const Event &event)
ChangeSetupButtons();
UpdateSetupButtons();
break;
+
+ default:
+ break;
}
return false;
}
@@ -2880,7 +2870,7 @@ bool CMainDialog::EventProcess(const Event &event)
if ( m_phase == PHASE_SETUPc || // setup/commands ?
m_phase == PHASE_SETUPcs )
{
- switch( event.event )
+ switch( event.type )
{
case EVENT_INTERFACE_KSCROLL:
UpdateKey();
@@ -2908,19 +2898,22 @@ bool CMainDialog::EventProcess(const Event &event)
case EVENT_INTERFACE_KSPEED20:
case EVENT_INTERFACE_KSPEED30:
case EVENT_INTERFACE_KVISIT:
- ChangeKey(event.event);
+ ChangeKey(event.type);
UpdateKey();
break;
case EVENT_INTERFACE_KDEF:
- m_engine->ResetKey();
+ m_app->ResetKeyStates();
UpdateKey();
break;
case EVENT_INTERFACE_JOYSTICK:
- m_engine->SetJoystick(!m_engine->RetJoystick());
+ m_app->SetJoystickEnabled(!m_app->GetJoystickEnabled());
UpdateSetupButtons();
break;
+
+ default:
+ break;
}
return false;
}
@@ -2928,7 +2921,7 @@ bool CMainDialog::EventProcess(const Event &event)
if ( m_phase == PHASE_SETUPs || // setup/sound ?
m_phase == PHASE_SETUPss )
{
- switch( event.event )
+ switch( event.type )
{
case EVENT_INTERFACE_VOLSOUND:
case EVENT_INTERFACE_VOLMUSIC:
@@ -2936,47 +2929,50 @@ bool CMainDialog::EventProcess(const Event &event)
break;
case EVENT_INTERFACE_SOUND3D:
- m_sound->SetSound3D(!m_sound->RetSound3D());
+ m_sound->SetSound3D(!m_sound->GetSound3D());
ChangeSetupButtons();
UpdateSetupButtons();
break;
case EVENT_INTERFACE_SILENT:
m_sound->SetAudioVolume(0);
- m_sound->SetMidiVolume(0);
+ //TODO: m_sound->SetMidiVolume(0);
UpdateSetupButtons();
break;
case EVENT_INTERFACE_NOISY:
m_sound->SetAudioVolume(MAXVOLUME);
- m_sound->SetMidiVolume(MAXVOLUME*3/4);
+ //TODO: m_sound->SetMidiVolume(MAXVOLUME*3/4);
UpdateSetupButtons();
break;
+
+ default:
+ break;
}
return false;
}
if ( m_phase == PHASE_READ )
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return false;
- if ( event.event == pw->RetEventMsgClose() ||
- event.event == EVENT_INTERFACE_BACK ||
- (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) )
+ if ( event.type == pw->GetEventTypeClose() ||
+ event.type == EVENT_INTERFACE_BACK ||
+ (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
{
ChangePhase(m_phaseTerm);
}
- if ( event.event == EVENT_INTERFACE_IOLIST )
+ if ( event.type == EVENT_INTERFACE_IOLIST )
{
IOUpdateList();
}
- if ( event.event == EVENT_INTERFACE_IODELETE )
+ if ( event.type == EVENT_INTERFACE_IODELETE )
{
IODeleteScene();
IOUpdateList();
}
- if ( event.event == EVENT_INTERFACE_IOREAD )
+ if ( event.type == EVENT_INTERFACE_IOREAD )
{
if ( IOReadScene() )
{
@@ -2990,35 +2986,35 @@ bool CMainDialog::EventProcess(const Event &event)
if ( m_phase == PHASE_WRITEs ||
m_phase == PHASE_READs )
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return false;
- if ( event.event == pw->RetEventMsgClose() ||
- event.event == EVENT_INTERFACE_BACK ||
- (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) )
+ if ( event.type == pw->GetEventTypeClose() ||
+ event.type == EVENT_INTERFACE_BACK ||
+ (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) )
{
m_interface->DeleteControl(EVENT_WINDOW5);
ChangePhase(PHASE_SIMUL);
StopSuspend();
}
- if ( event.event == EVENT_INTERFACE_IOLIST )
+ if ( event.type == EVENT_INTERFACE_IOLIST )
{
IOUpdateList();
}
- if ( event.event == EVENT_INTERFACE_IODELETE )
+ if ( event.type == EVENT_INTERFACE_IODELETE )
{
IODeleteScene();
IOUpdateList();
}
- if ( event.event == EVENT_INTERFACE_IOWRITE )
+ if ( event.type == EVENT_INTERFACE_IOWRITE )
{
IOWriteScene();
m_interface->DeleteControl(EVENT_WINDOW5);
ChangePhase(PHASE_SIMUL);
StopSuspend();
}
- if ( event.event == EVENT_INTERFACE_IOREAD )
+ if ( event.type == EVENT_INTERFACE_IOREAD )
{
if ( IOReadScene() )
{
@@ -3034,9 +3030,8 @@ bool CMainDialog::EventProcess(const Event &event)
if ( m_phase == PHASE_WELCOME1 )
{
- if ( event.event == EVENT_KEYDOWN ||
- event.event == EVENT_LBUTTONDOWN ||
- event.event == EVENT_RBUTTONDOWN )
+ if ( event.type == EVENT_KEY_DOWN ||
+ event.type == EVENT_MOUSE_BUTTON_DOWN )
{
ChangePhase(PHASE_WELCOME2);
return true;
@@ -3044,9 +3039,8 @@ bool CMainDialog::EventProcess(const Event &event)
}
if ( m_phase == PHASE_WELCOME2 )
{
- if ( event.event == EVENT_KEYDOWN ||
- event.event == EVENT_LBUTTONDOWN ||
- event.event == EVENT_RBUTTONDOWN )
+ if ( event.type == EVENT_KEY_DOWN ||
+ event.type == EVENT_MOUSE_BUTTON_DOWN )
{
ChangePhase(PHASE_WELCOME3);
return true;
@@ -3054,9 +3048,8 @@ bool CMainDialog::EventProcess(const Event &event)
}
if ( m_phase == PHASE_WELCOME3 )
{
- if ( event.event == EVENT_KEYDOWN ||
- event.event == EVENT_LBUTTONDOWN ||
- event.event == EVENT_RBUTTONDOWN )
+ if ( event.type == EVENT_KEY_DOWN ||
+ event.type == EVENT_MOUSE_BUTTON_DOWN )
{
ChangePhase(PHASE_NAME);
return true;
@@ -3065,29 +3058,26 @@ bool CMainDialog::EventProcess(const Event &event)
if ( m_phase == PHASE_GENERIC )
{
- if ( event.event == EVENT_INTERFACE_ABORT )
+ if ( event.type == EVENT_INTERFACE_ABORT )
{
ChangePhase(PHASE_INIT);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
- if ( event.param == VK_ESCAPE )
+ if ( event.param == KEY(ESCAPE) )
{
ChangePhase(PHASE_INIT);
}
else
{
- m_event->MakeEvent(newEvent, EVENT_QUIT);
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(Event(EVENT_QUIT));
}
}
- if ( event.event == EVENT_LBUTTONDOWN ||
- event.event == EVENT_RBUTTONDOWN )
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN )
{
- m_event->MakeEvent(newEvent, EVENT_QUIT);
- m_event->AddEvent(newEvent);
+ m_eventQueue->AddEvent(Event(EVENT_QUIT));
}
}
@@ -3105,12 +3095,12 @@ void CMainDialog::GlintMove()
if ( m_phase == PHASE_SIMUL ) return;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
if ( m_phase == PHASE_INIT )
{
- pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTl);
+ pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl));
if ( pg != 0 )
{
zoom.x = sinf(m_glintTime*0.23f);
@@ -3124,7 +3114,7 @@ void CMainDialog::GlintMove()
pg->SetDim(dim);
}
- pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr);
+ pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr));
if ( pg != 0 )
{
zoom.x = sinf(m_glintTime*0.21f);
@@ -3147,7 +3137,7 @@ void CMainDialog::GlintMove()
m_phase == PHASE_USER ||
m_phase == PHASE_PROTO )
{
- pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTl);
+ pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl));
if ( pg != 0 )
{
zoom.x = sinf(m_glintTime*0.22f);
@@ -3161,7 +3151,7 @@ void CMainDialog::GlintMove()
pg->SetDim(dim);
}
- pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr);
+ pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr));
if ( pg != 0 )
{
zoom.x = sinf(m_glintTime*0.19f);
@@ -3187,7 +3177,7 @@ void CMainDialog::GlintMove()
m_phase == PHASE_SETUPcs ||
m_phase == PHASE_SETUPss )
{
- pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTu);
+ pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTu));
if ( pg != 0 )
{
zoom.y = sinf(m_glintTime*0.27f);
@@ -3200,7 +3190,7 @@ void CMainDialog::GlintMove()
pg->SetDim(dim);
}
- pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr);
+ pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr));
if ( pg != 0 )
{
zoom.x = sinf(m_glintTime*0.29f);
@@ -3220,7 +3210,7 @@ void CMainDialog::GlintMove()
m_phase == PHASE_WRITEs ||
m_phase == PHASE_READs )
{
- pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTl);
+ pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTl));
if ( pg != 0 )
{
zoom.x = sinf(m_glintTime*0.22f);
@@ -3234,7 +3224,7 @@ void CMainDialog::GlintMove()
pg->SetDim(dim);
}
- pg = (CGroup*)pw->SearchControl(EVENT_INTERFACE_GLINTr);
+ pg = static_cast<CGroup*>(pw->SearchControl(EVENT_INTERFACE_GLINTr));
if ( pg != 0 )
{
zoom.x = sinf(m_glintTime*0.19f);
@@ -3251,7 +3241,7 @@ void CMainDialog::GlintMove()
}
-// Returns the position for a sound.
+// Geturns the position for a sound.
Math::Vector SoundPos(Math::Point pos)
{
@@ -3264,7 +3254,7 @@ Math::Vector SoundPos(Math::Point pos)
return s;
}
-// Returns a random position for a sound.
+// Geturns a random position for a sound.
Math::Vector SoundRand()
{
@@ -3279,10 +3269,10 @@ Math::Vector SoundRand()
// Makes pretty qq particles evolve.
-void CMainDialog::FrameParticule(float rTime)
+void CMainDialog::FrameParticle(float rTime)
{
-#if _NEWLOOK
-#else
+/* TODO: #if _NEWLOOK
+#else */
Math::Vector pos, speed;
Math::Point dim;
float *pParti, *pGlint;
@@ -3390,8 +3380,8 @@ void CMainDialog::FrameParticule(float rTime)
return;
}
- nParti = (int)(*pParti++);
- nGlint = (int)(*pGlint++);
+ nParti = static_cast<int>(*pParti++);
+ nGlint = static_cast<int>(*pGlint++);
for ( i=0 ; i<10 ; i++ )
{
@@ -3408,7 +3398,7 @@ void CMainDialog::FrameParticule(float rTime)
m_partiPos[i].x = pParti[ii*5+0]/640.0f;
m_partiPos[i].y = (480.0f-pParti[ii*5+1])/480.0f;
m_partiTime[i] = pParti[ii*5+2]+Math::Rand()*pParti[ii*5+3];
- m_partiPhase[i] = (int)pParti[ii*5+4];
+ m_partiPhase[i] = static_cast<int>(pParti[ii*5+4]);
if ( m_partiPhase[i] == 3 )
{
m_sound->Play(SOUND_PSHHH, SoundPos(m_partiPos[i]), 0.3f+Math::Rand()*0.3f);
@@ -3430,10 +3420,10 @@ void CMainDialog::FrameParticule(float rTime)
speed.z = 0.0f;
dim.x = 0.04f+Math::Rand()*0.04f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim,
- rand()%2?PARTIGLINT:PARTICONTROL,
+ m_particle->CreateParticle(pos, speed, dim,
+ rand()%2?Gfx::PARTIGLINT:Gfx::PARTICONTROL,
Math::Rand()*0.4f+0.4f, 0.0f, 0.0f,
- SH_INTERFACE);
+ Gfx::SH_INTERFACE);
m_partiTime[i] = 0.5f+Math::Rand()*0.5f;
}
@@ -3496,9 +3486,9 @@ void CMainDialog::FrameParticule(float rTime)
speed.z = 0.0f;
dim.x = 0.005f+Math::Rand()*0.005f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ,
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLITZ,
Math::Rand()*0.2f+0.2f, 0.0f, 0.0f,
- SH_INTERFACE);
+ Gfx::SH_INTERFACE);
pos.x = m_partiPos[i].x;
pos.y = m_partiPos[i].y;
pos.z = 0.0f;
@@ -3507,10 +3497,10 @@ void CMainDialog::FrameParticule(float rTime)
speed.z = 0.0f;
dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim,
- (ParticuleType)(PARTILENS1+rand()%3),
+ m_particle->CreateParticle(pos, speed, dim,
+ static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3),
Math::Rand()*0.5f+0.5f, 2.0f, 0.0f,
- SH_INTERFACE);
+ Gfx::SH_INTERFACE);
}
if ( m_partiPhase[i] == 2 ) // sparks?
{
@@ -3524,9 +3514,9 @@ void CMainDialog::FrameParticule(float rTime)
speed.z = 0.0f;
dim.x = 0.005f+Math::Rand()*0.005f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, PARTIBLITZ,
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIBLITZ,
Math::Rand()*0.2f+0.2f, 0.0f, 0.0f,
- SH_INTERFACE);
+ Gfx::SH_INTERFACE);
pos.x = m_partiPos[i].x;
pos.y = m_partiPos[i].y;
pos.z = 0.0f;
@@ -3535,9 +3525,9 @@ void CMainDialog::FrameParticule(float rTime)
speed.z = 0.0f;
dim.x = 0.005f+Math::Rand()*0.005f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, PARTISCRAPS,
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISCRAPS,
Math::Rand()*0.5f+0.5f, 2.0f, 0.0f,
- SH_INTERFACE);
+ Gfx::SH_INTERFACE);
}
if ( m_partiPhase[i] == 3 ) // smoke?
{
@@ -3551,9 +3541,9 @@ void CMainDialog::FrameParticule(float rTime)
speed.z = 0.0f;
dim.x = 0.03f+Math::Rand()*0.07f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, PARTICRASH,
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH,
Math::Rand()*0.4f+0.4f, 0.0f, 0.0f,
- SH_INTERFACE);
+ Gfx::SH_INTERFACE);
}
}
else
@@ -3563,12 +3553,12 @@ void CMainDialog::FrameParticule(float rTime)
}
}
}
-#endif
+// #endif
}
// Some nice particles following the mouse.
-void CMainDialog::NiceParticule(Math::Point mouse, bool bPress)
+void CMainDialog::NiceParticle(Math::Point mouse, bool bPress)
{
Math::Vector pos, speed;
Math::Point dim;
@@ -3590,9 +3580,9 @@ void CMainDialog::NiceParticule(Math::Point mouse, bool bPress)
speed.z = 0.0f;
dim.x = 0.005f+Math::Rand()*0.005f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim, PARTISCRAPS,
+ m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISCRAPS,
Math::Rand()*0.5f+0.5f, 2.0f, 0.0f,
- SH_INTERFACE);
+ Gfx::SH_INTERFACE);
}
else
{
@@ -3604,10 +3594,10 @@ void CMainDialog::NiceParticule(Math::Point mouse, bool bPress)
speed.z = 0.0f;
dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim,
- (ParticuleType)(PARTILENS1+rand()%3),
+ m_particle->CreateParticle(pos, speed, dim,
+ static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3),
Math::Rand()*0.5f+0.5f, 2.0f, 0.0f,
- SH_INTERFACE);
+ Gfx::SH_INTERFACE);
}
}
@@ -3651,9 +3641,9 @@ void CMainDialog::BuildResumeName(char *filename, char *base, int rank)
sprintf(filename, "Scene %s %d", base, rank);
}
-// Returns the name of the file or save the files.
+// Geturns the name of the file or save the files.
-char* CMainDialog::RetFilesDir()
+char* CMainDialog::GetFilesDir()
{
return m_filesDir;
}
@@ -3666,20 +3656,21 @@ void CMainDialog::ReadNameList()
CWindow* pw;
CList* pl;
long hFile;
- struct _finddata_t fBuffer;
+ //struct _finddata_t fBuffer;
bool bDo;
- char dir[_MAX_FNAME];
- char temp[_MAX_FNAME];
- char filenames[_MAX_FNAME][100];
+ char dir[MAX_FNAME];
+ char temp[MAX_FNAME];
+ char filenames[MAX_FNAME][100];
int nbFilenames, i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
if ( pl == 0 ) return;
pl->Flush();
nbFilenames = 0;
+ /* TODO: list dir
sprintf(dir, "%s\\*", m_savegameDir);
hFile = _findfirst(dir, &fBuffer);
if ( hFile != -1 )
@@ -3707,7 +3698,9 @@ void CMainDialog::ReadNameList()
}
}
}
- while ( bDo );
+ while ( bDo );*/
+
+ strcpy(filenames[nbFilenames++], "Test");
for ( i=0 ; i<nbFilenames ; i++ )
{
@@ -3727,37 +3720,37 @@ void CMainDialog::UpdateNameControl()
char* gamer;
int total, sel;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
if ( pl == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT);
+ pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
if ( pe == 0 ) return;
- gamer = m_main->RetGamerName();
- total = pl->RetTotal();
- sel = pl->RetSelect();
+ gamer = m_main->GetGamerName();
+ total = pl->GetTotal();
+ sel = pl->GetSelect();
pe->GetText(name, 100);
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NCANCEL);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NCANCEL));
if ( pb != 0 )
{
pb->SetState(STATE_ENABLE, gamer[0]!=0);
}
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NDELETE);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NDELETE));
if ( pb != 0 )
{
pb->SetState(STATE_ENABLE, total>0 && sel!=-1);
}
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_NOK);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NOK));
if ( pb != 0 )
{
pb->SetState(STATE_ENABLE, name[0]!=0 || sel!=-1);
}
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_PERSO);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PERSO));
if ( pb != 0 )
{
pb->SetState(STATE_ENABLE, name[0]!=0 || sel!=-1);
@@ -3772,22 +3765,22 @@ void CMainDialog::UpdateNameList()
CList* pl;
CEdit* pe;
char name[100];
- int total, sel, i;
+ int total, i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
if ( pl == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT);
+ pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
if ( pe == 0 ) return;
pe->GetText(name, 100);
- total = pl->RetTotal();
- sel = pl->RetSelect();
+ total = pl->GetTotal();
for ( i=0 ; i<total ; i++ )
{
- if ( stricmp(name, pl->RetName(i)) == 0 )
+ // TODO: stricmp?
+ if ( strcmp(name, pl->GetName(i)) == 0 )
{
pl->SetSelect(i);
pl->ShowSelect(false);
@@ -3808,14 +3801,14 @@ void CMainDialog::UpdateNameEdit()
char* name;
int sel;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
if ( pl == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT);
+ pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
if ( pe == 0 ) return;
- sel = pl->RetSelect();
+ sel = pl->GetSelect();
if ( sel == -1 )
{
pe->SetText("");
@@ -3823,7 +3816,7 @@ void CMainDialog::UpdateNameEdit()
}
else
{
- name = pl->RetName(sel);
+ name = pl->GetName(sel);
pe->SetText(name);
pe->SetCursor(strlen(name), 0);
}
@@ -3840,14 +3833,14 @@ void CMainDialog::UpdateNameFace()
char* name;
int sel;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
if ( pl == 0 ) return;
- sel = pl->RetSelect();
+ sel = pl->GetSelect();
if ( sel == -1 ) return;
- name = pl->RetName(sel);
+ name = pl->GetName(sel);
ReadGamerPerso(name);
}
@@ -3862,15 +3855,15 @@ void CMainDialog::NameSelect()
char name[100];
int sel;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
if ( pl == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT);
+ pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
if ( pe == 0 ) return;
pe->GetText(name, 100);
- sel = pl->RetSelect();
+ sel = pl->GetSelect();
if ( sel == -1 )
{
@@ -3878,13 +3871,13 @@ void CMainDialog::NameSelect()
}
else
{
- m_main->SetGamerName(pl->RetName(sel));
+ m_main->SetGamerName(pl->GetName(sel));
m_main->ChangePhase(PHASE_INIT);
}
- RetGamerFace(m_main->RetGamerName());
+ GetGamerFace(m_main->GetGamerName());
- SetLocalProfileString("Gamer", "LastName", m_main->RetGamerName());
+ // TODO: SetLocalProfileString("Gamer", "LastName", m_main->GetGamerName());
}
// Creates a new player.
@@ -3898,9 +3891,9 @@ void CMainDialog::NameCreate()
char c;
int len, i, j;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_NEDIT);
+ pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_NEDIT));
if ( pe == 0 ) return;
pe->GetText(name, 100);
@@ -3914,7 +3907,7 @@ void CMainDialog::NameCreate()
j = 0;
for ( i=0 ; i<len ; i++ )
{
- c = RetNoAccent(RetToLower(name[i]));
+ c = GetNoAccent(GetToLower(name[i]));
if ( (c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
c == ' ' ||
@@ -3934,10 +3927,10 @@ void CMainDialog::NameCreate()
return;
}
- _mkdir(m_savegameDir); // if does not exist yet!
+ // TODO: _mkdir(m_savegameDir); // if does not exist yet!
sprintf(dir, "%s\\%s", m_savegameDir, name);
- if ( _mkdir(dir) != 0 )
+ // TODO: if ( _mkdir(dir) != 0 )
{
m_sound->Play(SOUND_TZOING);
pe->SetText(name);
@@ -3956,6 +3949,7 @@ void CMainDialog::NameCreate()
bool RemoveDir(char *dirname)
{
+ /* TODO: remove dir
long hFile;
struct _finddata_t fBuffer;
char filename[100];
@@ -3986,7 +3980,7 @@ bool RemoveDir(char *dirname)
if ( _rmdir(dirname) != 0 )
{
return false;
- }
+ }*/
return true;
}
@@ -4000,18 +3994,18 @@ void CMainDialog::NameDelete()
char* gamer;
char dir[100];
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_NLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_NLIST));
if ( pl == 0 ) return;
- sel = pl->RetSelect();
+ sel = pl->GetSelect();
if ( sel == -1 )
{
m_sound->Play(SOUND_TZOING);
return;
}
- gamer = pl->RetName(sel);
+ gamer = pl->GetName(sel);
// Deletes all the contents of the file.
sprintf(dir, "%s\\%s", m_savegameDir, gamer);
@@ -4033,7 +4027,7 @@ void CMainDialog::NameDelete()
// ests whether two colors are equal or nearly are.
-bool EqColor(const D3DCOLORVALUE &c1, const D3DCOLORVALUE &c2)
+bool EqColor(const Gfx::Color &c1, const Gfx::Color &c2)
{
return (fabs(c1.r-c2.r) < 0.01f &&
fabs(c1.g-c2.g) < 0.01f &&
@@ -4049,25 +4043,25 @@ void CMainDialog::UpdatePerso()
CButton* pb;
CColor* pc;
CSlider* ps;
- D3DCOLORVALUE color;
+ Gfx::Color color;
char name[100];
int i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_PHEAD);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PHEAD));
if ( pb != 0 )
{
pb->SetState(STATE_CHECK, m_persoTab==0);
}
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_PBODY);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_PBODY));
if ( pb != 0 )
{
pb->SetState(STATE_CHECK, m_persoTab==1);
}
- pl = (CLabel*)pw->SearchControl(EVENT_LABEL11);
+ pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL11));
if ( pl != 0 )
{
if ( m_persoTab == 0 )
@@ -4082,7 +4076,7 @@ void CMainDialog::UpdatePerso()
}
}
- pl = (CLabel*)pw->SearchControl(EVENT_LABEL12);
+ pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL12));
if ( pl != 0 )
{
if ( m_persoTab == 0 )
@@ -4097,7 +4091,7 @@ void CMainDialog::UpdatePerso()
}
}
- pl = (CLabel*)pw->SearchControl(EVENT_LABEL13);
+ pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL13));
if ( pl != 0 )
{
if ( m_persoTab == 0 ) GetResource(RES_TEXT, RT_PERSO_HAIR, name);
@@ -4105,7 +4099,7 @@ void CMainDialog::UpdatePerso()
pl->SetName(name);
}
- pl = (CLabel*)pw->SearchControl(EVENT_LABEL14);
+ pl = static_cast<CLabel*>(pw->SearchControl(EVENT_LABEL14));
if ( pl != 0 )
{
if ( m_persoTab == 0 )
@@ -4122,7 +4116,7 @@ void CMainDialog::UpdatePerso()
for ( i=0 ; i<4 ; i++ )
{
- pb = (CButton*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PFACE1+i));
+ pb = static_cast<CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PFACE1+i)));
if ( pb == 0 ) break;
pb->SetState(STATE_VISIBLE, m_persoTab==0);
pb->SetState(STATE_CHECK, i==m_perso.face);
@@ -4130,7 +4124,7 @@ void CMainDialog::UpdatePerso()
for ( i=0 ; i<10 ; i++ )
{
- pb = (CButton*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PGLASS0+i));
+ pb = static_cast<CButton*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PGLASS0+i)));
if ( pb == 0 ) break;
pb->SetState(STATE_VISIBLE, m_persoTab==0);
pb->SetState(STATE_CHECK, i==m_perso.glasses);
@@ -4138,7 +4132,7 @@ void CMainDialog::UpdatePerso()
for ( i=0 ; i<3*3 ; i++ )
{
- pc = (CColor*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PC0a+i));
+ pc = static_cast<CColor*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PC0a+i)));
if ( pc == 0 ) break;
if ( m_persoTab == 0 )
{
@@ -4155,7 +4149,7 @@ void CMainDialog::UpdatePerso()
pc->SetState(STATE_CHECK, EqColor(color, m_perso.colorCombi));
}
- pc = (CColor*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PC0b+i));
+ pc = static_cast<CColor*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PC0b+i)));
if ( pc == 0 ) break;
color.r = perso_color[3*10*2*m_persoTab+3*i+0]/255.0f;
color.g = perso_color[3*10*2*m_persoTab+3*i+1]/255.0f;
@@ -4167,7 +4161,7 @@ void CMainDialog::UpdatePerso()
for ( i=0 ; i<3 ; i++ )
{
- ps = (CSlider*)pw->SearchControl((EventMsg)(EVENT_INTERFACE_PCRa+i));
+ ps = static_cast<CSlider*>(pw->SearchControl(static_cast<EventType>(EVENT_INTERFACE_PCRa+i)));
if ( ps == 0 ) break;
ps->SetState(STATE_VISIBLE, m_persoTab==1);
}
@@ -4175,21 +4169,21 @@ void CMainDialog::UpdatePerso()
if ( m_persoTab == 1 )
{
color = m_perso.colorCombi;
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRa);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRa));
if ( ps != 0 ) ps->SetVisibleValue(color.r*255.0f);
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGa);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGa));
if ( ps != 0 ) ps->SetVisibleValue(color.g*255.0f);
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBa);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBa));
if ( ps != 0 ) ps->SetVisibleValue(color.b*255.0f);
}
if ( m_persoTab == 0 ) color = m_perso.colorHair;
else color = m_perso.colorBand;
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRb);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRb));
if ( ps != 0 ) ps->SetVisibleValue(color.r*255.0f);
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGb);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGb));
if ( ps != 0 ) ps->SetVisibleValue(color.g*255.0f);
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBb);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBb));
if ( ps != 0 ) ps->SetVisibleValue(color.b*255.0f);
}
@@ -4210,7 +4204,7 @@ void CMainDialog::CameraPerso()
Math::Vector(0.0f, 1.6f, 4.5f), 0.0f);
}
- m_camera->SetType(CAMERA_SCRIPT);
+ m_camera->SetType(Gfx::CAM_TYPE_SCRIPT);
m_camera->FixCamera();
}
@@ -4250,27 +4244,27 @@ void CMainDialog::ColorPerso()
{
CWindow* pw;
CSlider* ps;
- D3DCOLORVALUE color;
+ Gfx::Color color;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
color.a = 0.0f;
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRa);
- if ( ps != 0 ) color.r = ps->RetVisibleValue()/255.0f;
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGa);
- if ( ps != 0 ) color.g = ps->RetVisibleValue()/255.0f;
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBa);
- if ( ps != 0 ) color.b = ps->RetVisibleValue()/255.0f;
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRa));
+ if ( ps != 0 ) color.r = ps->GetVisibleValue()/255.0f;
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGa));
+ if ( ps != 0 ) color.g = ps->GetVisibleValue()/255.0f;
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBa));
+ if ( ps != 0 ) color.b = ps->GetVisibleValue()/255.0f;
if ( m_persoTab == 1 ) m_perso.colorCombi = color;
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCRb);
- if ( ps != 0 ) color.r = ps->RetVisibleValue()/255.0f;
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCGb);
- if ( ps != 0 ) color.g = ps->RetVisibleValue()/255.0f;
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_PCBb);
- if ( ps != 0 ) color.b = ps->RetVisibleValue()/255.0f;
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCRb));
+ if ( ps != 0 ) color.r = ps->GetVisibleValue()/255.0f;
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCGb));
+ if ( ps != 0 ) color.g = ps->GetVisibleValue()/255.0f;
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_PCBb));
+ if ( ps != 0 ) color.b = ps->GetVisibleValue()/255.0f;
if ( m_persoTab == 0 ) m_perso.colorHair = color;
else m_perso.colorBand = color;
}
@@ -4328,7 +4322,7 @@ bool CMainDialog::IsIOReadScene()
FILE* file;
char filename[100];
- sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], 0);
+ sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], 0);
file = fopen(filename, "r");
if ( file == NULL ) return false;
fclose(file);
@@ -4342,7 +4336,7 @@ void CMainDialog::IOReadName()
FILE* file;
CWindow* pw;
CEdit* pe;
- char filename[_MAX_FNAME];
+ char filename[MAX_FNAME];
char op[100];
char line[500];
char resume[100];
@@ -4350,9 +4344,9 @@ void CMainDialog::IOReadName()
time_t now;
int i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_IONAME);
+ pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_IONAME));
if ( pe == 0 ) return;
sprintf(resume, "%s %d", m_sceneName, m_chap[m_index]+1);
@@ -4372,7 +4366,8 @@ void CMainDialog::IOReadName()
}
}
- sprintf(op, "Title.%c", RetLanguageLetter());
+ // TODO: language letters
+ sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/ );
if ( Cmd(line, op) )
{
OpString(line, "resume", resume);
@@ -4402,20 +4397,19 @@ void CMainDialog::IOReadList()
char name[100];
int i, j;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST));
if ( pl == 0 ) return;
pl->Flush();
for ( j=0 ; j<999 ; j++ )
{
- sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], j);
+ sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], j);
file = fopen(filename, "r");
if ( file == NULL ) break;
- strcmp(name, filename); // default name
while ( fgets(line, 500, file) != NULL )
{
for ( i=0 ; i<500 ; i++ )
@@ -4463,17 +4457,17 @@ void CMainDialog::IOUpdateList()
char filename[100];
int sel, max;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST));
if ( pl == 0 ) return;
- pi = (CImage*)pw->SearchControl(EVENT_INTERFACE_IOIMAGE);
+ pi = static_cast<CImage*>(pw->SearchControl(EVENT_INTERFACE_IOIMAGE));
if ( pi == 0 ) return;
- sel = pl->RetSelect();
- max = pl->RetTotal();
+ sel = pl->GetSelect();
+ max = pl->GetTotal();
- sprintf(filename, "%s\\%s\\save%c%.3d\\screen.bmp", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel);
+ sprintf(filename, "%s\\%s\\save%c%.3d\\screen.png", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
if ( m_phase == PHASE_WRITE ||
m_phase == PHASE_WRITEs )
@@ -4487,7 +4481,7 @@ void CMainDialog::IOUpdateList()
pi->SetFilenameImage("");
}
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_IODELETE);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_IODELETE));
if ( pb != 0 )
{
pb->SetState(STATE_ENABLE, sel < max-1);
@@ -4508,23 +4502,24 @@ void CMainDialog::IODeleteScene()
char dir[100];
char old[100];
long hFile;
- struct _finddata_t fBuffer;
+ //struct _finddata_t fBuffer;
int sel, max, i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST));
if ( pl == 0 ) return;
- sel = pl->RetSelect();
+ sel = pl->GetSelect();
if ( sel == -1 )
{
m_sound->Play(SOUND_TZOING);
return;
}
+ /* TODO: remove files
// Deletes all the contents of the file.
- sprintf(dir, "%s\\%s\\save%c%.3d\\*", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel);
+ sprintf(dir, "%s\\%s\\save%c%.3d\\*", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
hFile = _findfirst(dir, &fBuffer);
if ( hFile != -1 )
{
@@ -4532,27 +4527,28 @@ void CMainDialog::IODeleteScene()
{
if ( fBuffer.name[0] != '.' )
{
- sprintf(dir, "%s\\%s\\save%c%.3d\\%s", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel, fBuffer.name);
+ sprintf(dir, "%s\\%s\\save%c%.3d\\%s", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel, fBuffer.name);
remove(dir);
}
}
while ( _findnext(hFile, &fBuffer) == 0 );
}
- sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel);
+ sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
if ( _rmdir(dir) != 0 )
{
m_sound->Play(SOUND_TZOING);
return;
- }
+ }*/
- max = pl->RetTotal();
+ /* TODO: rename
+ max = pl->GetTotal();
for ( i=sel+1 ; i<max ; i++ )
{
- sprintf(old, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], i);
- sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], i-1);
+ sprintf(old, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], i);
+ sprintf(dir, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], i-1);
rename(old, dir);
- }
+ }*/
IOReadList();
}
@@ -4568,29 +4564,29 @@ bool CMainDialog::IOWriteScene()
char info[100];
int sel;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return false;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST));
if ( pl == 0 ) return false;
- pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_IONAME);
+ pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_IONAME));
if ( pe == 0 ) return false;
- sel = pl->RetSelect();
+ sel = pl->GetSelect();
if ( sel == -1 ) return false;
- _mkdir("Savegame"); // if doesn't exist yet!
- sprintf(filename, "%s\\%s", m_savegameDir, m_main->RetGamerName());
- _mkdir(filename);
- sprintf(filename, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel);
- _mkdir(filename);
+ // TODO: _mkdir("Savegame"); // if doesn't exist yet!
+ sprintf(filename, "%s\\%s", m_savegameDir, m_main->GetGamerName());
+ // TODO: _mkdir(filename);
+ sprintf(filename, "%s\\%s\\save%c%.3d", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
+ // TODO: _mkdir(filename);
- sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel);
- sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel);
+ sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
+ sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
pe->GetText(info, 100);
m_main->IOWriteScene(filename, filecbot, info);
m_shotDelay = 3;
- sprintf(m_shotName, "%s\\%s\\save%c%.3d\\screen.bmp", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel);
+ sprintf(m_shotName, "%s\\%s\\save%c%.3d\\screen.png", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
return true;
}
@@ -4608,16 +4604,16 @@ bool CMainDialog::IOReadScene()
char dir[100];
int sel, i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return false;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_IOLIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_IOLIST));
if ( pl == 0 ) return false;
- sel = pl->RetSelect();
+ sel = pl->GetSelect();
if ( sel == -1 ) return false;
- sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel);
- sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->RetGamerName(), m_sceneName[0], sel);
+ sprintf(filename, "%s\\%s\\save%c%.3d\\data.sav", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
+ sprintf(filecbot, "%s\\%s\\save%c%.3d\\cbot.run", m_savegameDir, m_main->GetGamerName(), m_sceneName[0], sel);
file = fopen(filename, "r");
if ( file == NULL ) return false;
@@ -4670,17 +4666,17 @@ bool CMainDialog::IOReadScene()
}
-// Returns the number of accessible chapters.
+// Geturns the number of accessible chapters.
-int CMainDialog::RetChapPassed()
+int CMainDialog::GetChapPassed()
{
int j;
- if ( m_main->RetShowAll() ) return 9;
+ if ( m_main->GetShowAll() ) return 9;
for ( j=0 ; j<9 ; j++ )
{
- if ( !RetGamerInfoPassed((j+1)*100) )
+ if ( !GetGamerInfoPassed((j+1)*100) )
{
return j;
}
@@ -4713,17 +4709,17 @@ void CMainDialog::UpdateSceneChap(int &chap)
CWindow* pw;
CList* pl;
long hFile;
- struct _finddata_t fileBuffer;
- char filename[_MAX_FNAME];
+ //struct _finddata_t fileBuffer;
+ char filename[MAX_FNAME];
char op[100];
char line[500];
char name[100];
int i, j;
bool bPassed, bDo;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_CHAP);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_CHAP));
if ( pl == 0 ) return;
pl->Flush();
@@ -4731,6 +4727,7 @@ void CMainDialog::UpdateSceneChap(int &chap)
if ( m_phase == PHASE_USER )
{
j = 0;
+ /* TODO: list files
hFile = _findfirst("user\\*", &fileBuffer);
if ( hFile != -1 )
{
@@ -4743,7 +4740,7 @@ void CMainDialog::UpdateSceneChap(int &chap)
}
}
while ( _findnext(hFile, &fileBuffer) == 0 && j < 100 );
- }
+ }*/
m_userTotal = j;
do // sorts all names:
@@ -4785,7 +4782,8 @@ void CMainDialog::UpdateSceneChap(int &chap)
}
}
- sprintf(op, "Title.%c", RetLanguageLetter());
+ /* TODO: language letters */
+ sprintf(op, "Title.%c", 'E' /*GetLanguageLetter()*/);
if ( Cmd(line, op) )
{
OpString(line, "text", name);
@@ -4803,7 +4801,7 @@ void CMainDialog::UpdateSceneChap(int &chap)
{
for ( j=0 ; j<9 ; j++ )
{
-#if _SCHOOL
+/* TODO: #if _SCHOOL
if ( m_phase == PHASE_MISSION ) break;
if ( m_phase == PHASE_FREE ) break;
#if _CEEBOTDEMO
@@ -4813,7 +4811,7 @@ void CMainDialog::UpdateSceneChap(int &chap)
#if _DEMO
if ( m_phase == PHASE_MISSION && j >= 4 ) break;
if ( m_phase == PHASE_TRAINER && j >= 1 ) break;
-#endif
+#endif */
BuildSceneName(filename, m_sceneName, (j+1)*100);
file = fopen(filename, "r");
if ( file == NULL ) break;
@@ -4831,7 +4829,8 @@ void CMainDialog::UpdateSceneChap(int &chap)
}
}
- sprintf(op, "Title.%c", RetLanguageLetter());
+ // TODO: language letters
+ sprintf(op, "Title.%c", 'E'/*GetLanguageLetter()*/);
if ( Cmd(line, op) )
{
OpString(line, "text", name);
@@ -4840,25 +4839,25 @@ void CMainDialog::UpdateSceneChap(int &chap)
}
fclose(file);
- bPassed = RetGamerInfoPassed((j+1)*100);
+ bPassed = GetGamerInfoPassed((j+1)*100);
sprintf(line, "%d: %s", j+1, name);
pl->SetName(j, line);
pl->SetCheck(j, bPassed);
pl->SetEnable(j, true);
- if ( m_phase == PHASE_MISSION && !m_main->RetShowAll() && !bPassed )
+ if ( m_phase == PHASE_MISSION && !m_main->GetShowAll() && !bPassed )
{
j ++;
break;
}
-#if _TEEN
- if ( m_phase == PHASE_TRAINER && !m_main->RetShowAll() && !bPassed )
+/* TODO: #if _TEEN
+ if ( m_phase == PHASE_TRAINER && !m_main->GetShowAll() && !bPassed )
{
j ++;
break;
}
-#endif
+#endif*/
if ( m_phase == PHASE_FREE && j == m_accessChap )
{
@@ -4881,23 +4880,23 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
FILE* file = NULL;
CWindow* pw;
CList* pl;
- char filename[_MAX_FNAME];
+ char filename[MAX_FNAME];
char op[100];
char line[500];
char name[100];
int i, j;
bool bPassed;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_INTERFACE_LIST);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST));
if ( pl == 0 ) return;
pl->Flush();
for ( j=0 ; j<99 ; j++ )
{
-#if _SCHOOL
+/* TODO: #if _SCHOOL
if ( m_phase == PHASE_MISSION ) break;
if ( m_phase == PHASE_FREE ) break;
#if _CEEBOTDEMO
@@ -4911,7 +4910,7 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
#if _DEMO
if ( m_phase == PHASE_MISSION && j >= 3 ) break;
if ( m_phase == PHASE_TRAINER && j >= 5 ) break;
-#endif
+#endif */
BuildSceneName(filename, m_sceneName, (chap+1)*100+(j+1));
file = fopen(filename, "r");
if ( file == NULL ) break;
@@ -4929,7 +4928,8 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
}
}
- sprintf(op, "Title.%c", RetLanguageLetter());
+ // TODO: language letters
+ sprintf(op, "Title.%c", 'E' /*MAX_FNAME()*/);
if ( Cmd(line, op) )
{
OpString(line, "text", name);
@@ -4938,25 +4938,25 @@ void CMainDialog::UpdateSceneList(int chap, int &sel)
}
fclose(file);
- bPassed = RetGamerInfoPassed((chap+1)*100+(j+1));
+ bPassed = GetGamerInfoPassed((chap+1)*100+(j+1));
sprintf(line, "%d: %s", j+1, name);
pl->SetName(j, line);
pl->SetCheck(j, bPassed);
pl->SetEnable(j, true);
- if ( m_phase == PHASE_MISSION && !m_main->RetShowAll() && !bPassed )
+ if ( m_phase == PHASE_MISSION && !m_main->GetShowAll() && !bPassed )
{
j ++;
break;
}
-#if _TEEN
- if ( m_phase == PHASE_TRAINER && !m_main->RetShowAll() && !bPassed )
+/* TODO: #if _TEEN
+ if ( m_phase == PHASE_TRAINER && !m_main->GetShowAll() && !bPassed )
{
j ++;
break;
}
-#endif
+#endif*/
}
BuildSceneName(filename, m_sceneName, (chap+1)*100+(j+1));
@@ -4995,14 +4995,14 @@ void CMainDialog::ShowSoluceUpdate()
{
m_bSceneSoluce = false;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_RESUME);
+ pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_RESUME));
if ( pe == 0 ) return;
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOLUCE);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE));
if ( pc == 0 ) return;
- if ( m_main->RetShowSoluce() )
+ if ( m_main->GetShowSoluce() )
{
pc->SetState(STATE_VISIBLE);
pc->SetState(STATE_CHECK);
@@ -5025,18 +5025,18 @@ void CMainDialog::UpdateSceneResume(int rank)
CWindow* pw;
CEdit* pe;
CCheck* pc;
- char filename[_MAX_FNAME];
+ char filename[MAX_FNAME];
char op[100];
char line[500];
char name[500];
int i, numTry;
bool bPassed, bVisible;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_INTERFACE_RESUME);
+ pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_RESUME));
if ( pe == 0 ) return;
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOLUCE);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE));
if ( pc == 0 )
{
@@ -5044,10 +5044,10 @@ void CMainDialog::UpdateSceneResume(int rank)
}
else
{
- numTry = RetGamerInfoTry(rank);
- bPassed = RetGamerInfoPassed(rank);
- bVisible = ( numTry > 2 || bPassed || m_main->RetShowSoluce() );
- if ( !RetSoluce4() ) bVisible = false;
+ numTry = GetGamerInfoTry(rank);
+ bPassed = GetGamerInfoPassed(rank);
+ bVisible = ( numTry > 2 || bPassed || m_main->GetShowSoluce() );
+ if ( !GetSoluce4() ) bVisible = false;
pc->SetState(STATE_VISIBLE, bVisible);
if ( !bVisible )
{
@@ -5073,7 +5073,8 @@ void CMainDialog::UpdateSceneResume(int rank)
}
}
- sprintf(op, "Resume.%c", RetLanguageLetter());
+ // TODO: language letters
+ sprintf(op, "Resume.%c", 'E' /*MAX_FNAME()*/);
if ( Cmd(line, op) )
{
OpString(line, "text", name);
@@ -5095,16 +5096,18 @@ void CMainDialog::UpdateDisplayDevice()
char bufModes[5000];
int i, j, totalDevices, selectDevices, totalModes, selectModes;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_LIST1);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1));
if ( pl == 0 ) return;
pl->Flush();
+ bufModes[0] = 0;
+ /* TODO: remove device choice
m_engine->EnumDevices(bufDevices, 1000,
bufModes, 5000,
totalDevices, selectDevices,
- totalModes, selectModes);
+ totalModes, selectModes);*/
i = 0;
j = 0;
@@ -5130,16 +5133,18 @@ void CMainDialog::UpdateDisplayMode()
char bufModes[5000];
int i, j, totalDevices, selectDevices, totalModes, selectModes;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_LIST2);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
if ( pl == 0 ) return;
pl->Flush();
+ bufModes[0] = 0;
+ /* TODO: remove device choice
m_engine->EnumDevices(bufDevices, 1000,
bufModes, 5000,
totalDevices, selectDevices,
- totalModes, selectModes);
+ totalModes, selectModes);*/
i = 0;
j = 0;
@@ -5166,25 +5171,26 @@ void CMainDialog::ChangeDisplay()
char* mode;
bool bFull;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_LIST1);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1));
if ( pl == 0 ) return;
- m_setupSelDevice = pl->RetSelect();
- device = pl->RetName(m_setupSelDevice);
+ m_setupSelDevice = pl->GetSelect();
+ device = pl->GetName(m_setupSelDevice);
- pl = (CList*)pw->SearchControl(EVENT_LIST2);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
if ( pl == 0 ) return;
- m_setupSelMode = pl->RetSelect();
- mode = pl->RetName(m_setupSelMode);
+ m_setupSelMode = pl->GetSelect();
+ mode = pl->GetName(m_setupSelMode);
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FULL);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL));
if ( pc == 0 ) return;
bFull = pc->TestState(STATE_CHECK);
m_setupFull = bFull;
- m_engine->ChangeDevice(device, mode, bFull);
+ // TODO: remove device choice
+ // m_engine->ChangeDevice(device, mode, bFull);
if ( m_bSimulSetup )
{
@@ -5206,21 +5212,21 @@ void CMainDialog::UpdateApply()
int sel1, sel2;
bool bFull;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pb = (CButton*)pw->SearchControl(EVENT_INTERFACE_APPLY);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_APPLY));
if ( pb == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_LIST1);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST1));
if ( pl == 0 ) return;
- sel1 = pl->RetSelect();
+ sel1 = pl->GetSelect();
- pl = (CList*)pw->SearchControl(EVENT_LIST2);
+ pl = static_cast<CList*>(pw->SearchControl(EVENT_LIST2));
if ( pl == 0 ) return;
- sel2 = pl->RetSelect();
+ sel2 = pl->GetSelect();
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FULL);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FULL));
bFull = pc->TestState(STATE_CHECK);
if ( sel1 == m_setupSelDevice &&
@@ -5245,208 +5251,210 @@ void CMainDialog::UpdateSetupButtons()
CSlider* ps;
float value;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_TOTO);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_TOTO));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetTotoMode());
+ pc->SetState(STATE_CHECK, m_engine->GetTotoMode());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_TOOLTIP);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_TOOLTIP));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bTooltip);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_GLINT);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_GLINT));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bGlint);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_RAIN);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_RAIN));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bRain);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_MOUSE);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_MOUSE));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetNiceMouse());
- pc->SetState(STATE_ENABLE, m_engine->RetNiceMouseCap());
+ /* TODO: nice mouse?
+ pc->SetState(STATE_CHECK, m_engine->GetNiceMouse());
+ pc->SetState(STATE_ENABLE, m_engine->GetNiceMouseCap());*/
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_EDITMODE);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EDITMODE));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetEditIndentMode());
+ pc->SetState(STATE_CHECK, m_engine->GetEditIndentMode());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_EDITVALUE);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EDITVALUE));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetEditIndentValue()>2);
+ pc->SetState(STATE_CHECK, m_engine->GetEditIndentValue()>2);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOLUCE4);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE4));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bSoluce4);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_MOVIES);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_MOVIES));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bMovies);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_NICERST);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_NICERST));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bNiceReset);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_HIMSELF);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_HIMSELF));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bHimselfDamage);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SCROLL);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SCROLL));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bCameraScroll);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_INVERTX);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTX));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bCameraInvertX);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_INVERTY);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_INVERTY));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bCameraInvertY);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_EFFECT);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_EFFECT));
if ( pc != 0 )
{
pc->SetState(STATE_CHECK, m_bEffect);
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SHADOW);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SHADOW));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetShadow());
+ pc->SetState(STATE_CHECK, m_engine->GetShadow());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_GROUND);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_GROUND));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetGroundSpot());
+ pc->SetState(STATE_CHECK, m_engine->GetGroundSpot());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_DIRTY);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_DIRTY));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetDirty());
+ pc->SetState(STATE_CHECK, m_engine->GetDirty());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_FOG);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_FOG));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetFog());
+ pc->SetState(STATE_CHECK, m_engine->GetFog());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_LENS);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_LENS));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetLensMode());
+ pc->SetState(STATE_CHECK, m_engine->GetLensMode());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SKY);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SKY));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetSkyMode());
+ pc->SetState(STATE_CHECK, m_engine->GetSkyMode());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_PLANET);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_PLANET));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetPlanetMode());
+ pc->SetState(STATE_CHECK, m_engine->GetPlanetMode());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_LIGHT);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_LIGHT));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetLightMode());
+ pc->SetState(STATE_CHECK, m_engine->GetLightMode());
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_JOYSTICK);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_JOYSTICK));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_engine->RetJoystick());
+ pc->SetState(STATE_CHECK, m_app->GetJoystickEnabled());
}
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_PARTI);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_PARTI));
if ( pv != 0 )
{
- value = m_engine->RetParticuleDensity();
+ value = m_engine->GetParticleDensity();
pv->SetValue(value);
}
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_CLIP);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_CLIP));
if ( pv != 0 )
{
- value = m_engine->RetClippingDistance();
+ value = m_engine->GetClippingDistance();
pv->SetValue(value);
}
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_DETAIL);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_DETAIL));
if ( pv != 0 )
{
- value = m_engine->RetObjectDetail();
+ value = m_engine->GetObjectDetail();
pv->SetValue(value);
}
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_GADGET);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_GADGET));
if ( pv != 0 )
{
- value = m_engine->RetGadgetQuantity();
+ value = m_engine->GetGadgetQuantity();
pv->SetValue(value);
}
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_TEXTURE);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE));
if ( pv != 0 )
{
- value = (float)m_engine->RetTextureQuality();
+ value = static_cast<float>(m_engine->GetTextureQuality());
pv->SetValue(value);
}
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLSOUND);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLSOUND));
if ( ps != 0 )
{
- value = (float)m_sound->RetAudioVolume();
+ value = static_cast<float>(m_sound->GetAudioVolume());
ps->SetVisibleValue(value);
}
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLMUSIC);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC));
if ( ps != 0 )
{
- value = (float)m_sound->RetMidiVolume();
- ps->SetVisibleValue(value);
+ /* TODO: midi volume
+ value = (float)m_sound->GetMidiVolume();
+ ps->SetVisibleValue(value);*/
}
- pc = (CCheck*)pw->SearchControl(EVENT_INTERFACE_SOUND3D);
+ pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOUND3D));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_sound->RetSound3D());
- pc->SetState(STATE_ENABLE, m_sound->RetSound3DCap());
+ pc->SetState(STATE_CHECK, m_sound->GetSound3D());
+ pc->SetState(STATE_ENABLE, m_sound->GetSound3DCap());
}
}
@@ -5459,56 +5467,58 @@ void CMainDialog::ChangeSetupButtons()
CSlider* ps;
float value;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_PARTI);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_PARTI));
if ( pv != 0 )
{
- value = pv->RetValue();
- m_engine->SetParticuleDensity(value);
+ value = pv->GetValue();
+ m_engine->SetParticleDensity(value);
}
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_CLIP);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_CLIP));
if ( pv != 0 )
{
- value = pv->RetValue();
+ value = pv->GetValue();
m_engine->SetClippingDistance(value);
}
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_DETAIL);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_DETAIL));
if ( pv != 0 )
{
- value = pv->RetValue();
+ value = pv->GetValue();
m_engine->SetObjectDetail(value);
}
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_GADGET);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_GADGET));
if ( pv != 0 )
{
- value = pv->RetValue();
+ value = pv->GetValue();
m_engine->SetGadgetQuantity(value);
}
- pv = (CEditValue*)pw->SearchControl(EVENT_INTERFACE_TEXTURE);
+ pv = static_cast<CEditValue*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE));
if ( pv != 0 )
{
- value = pv->RetValue();
- m_engine->SetTextureQuality((int)value);
+ value = pv->GetValue();
+ m_engine->SetTextureQuality(static_cast<int>(value));
}
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLSOUND);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLSOUND));
if ( ps != 0 )
{
- value = ps->RetVisibleValue();
- m_sound->SetAudioVolume((int)value);
+ value = ps->GetVisibleValue();
+ m_sound->SetAudioVolume(static_cast<int>(value));
}
- ps = (CSlider*)pw->SearchControl(EVENT_INTERFACE_VOLMUSIC);
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_INTERFACE_VOLMUSIC));
if ( ps != 0 )
{
- value = ps->RetVisibleValue();
- m_sound->SetMidiVolume((int)value);
+ /*
+ TODO: midi volume
+ value = ps->GetVisibleValue();
+ m_sound->SetMidiVolume((int)value);*/
}
}
@@ -5522,13 +5532,14 @@ void CMainDialog::SetupMemorize()
char key[500];
char num[10];
+ /* TODO: profile
SetLocalProfileString("Directory", "scene", m_sceneDir);
SetLocalProfileString("Directory", "savegame", m_savegameDir);
SetLocalProfileString("Directory", "public", m_publicDir);
SetLocalProfileString("Directory", "user", m_userDir);
SetLocalProfileString("Directory", "files", m_filesDir);
- iValue = m_engine->RetTotoMode();
+ iValue = m_engine->GetTotoMode();
SetLocalProfileInt("Setup", "TotoMode", iValue);
iValue = m_bTooltip;
@@ -5540,7 +5551,7 @@ void CMainDialog::SetupMemorize()
iValue = m_bRain;
SetLocalProfileInt("Setup", "InterfaceGlint", iValue);
- iValue = m_engine->RetNiceMouse();
+ iValue = m_engine->GetNiceMouse();
SetLocalProfileInt("Setup", "NiceMouse", iValue);
iValue = m_bSoluce4;
@@ -5564,78 +5575,80 @@ void CMainDialog::SetupMemorize()
iValue = m_bEffect;
SetLocalProfileInt("Setup", "InterfaceEffect", iValue);
- iValue = m_engine->RetShadow();
+ iValue = m_engine->GetShadow();
SetLocalProfileInt("Setup", "GroundShadow", iValue);
- iValue = m_engine->RetGroundSpot();
+ iValue = m_engine->GetGroundSpot();
SetLocalProfileInt("Setup", "GroundSpot", iValue);
- iValue = m_engine->RetDirty();
+ iValue = m_engine->GetDirty();
SetLocalProfileInt("Setup", "ObjectDirty", iValue);
- iValue = m_engine->RetFog();
+ iValue = m_engine->GetFog();
SetLocalProfileInt("Setup", "FogMode", iValue);
- iValue = m_engine->RetLensMode();
+ iValue = m_engine->GetLensMode();
SetLocalProfileInt("Setup", "LensMode", iValue);
- iValue = m_engine->RetSkyMode();
+ iValue = m_engine->GetSkyMode();
SetLocalProfileInt("Setup", "SkyMode", iValue);
- iValue = m_engine->RetPlanetMode();
+ iValue = m_engine->GetPlanetMode();
SetLocalProfileInt("Setup", "PlanetMode", iValue);
- iValue = m_engine->RetLightMode();
+ iValue = m_engine->GetLightMode();
SetLocalProfileInt("Setup", "LightMode", iValue);
- iValue = m_engine->RetJoystick();
+ iValue = m_engine->GetJoystick();
SetLocalProfileInt("Setup", "UseJoystick", iValue);
- fValue = m_engine->RetParticuleDensity();
- SetLocalProfileFloat("Setup", "ParticuleDensity", fValue);
+ fValue = m_engine->GetParticleDensity();
+ SetLocalProfileFloat("Setup", "ParticleDensity", fValue);
- fValue = m_engine->RetClippingDistance();
+ fValue = m_engine->GetClippingDistance();
SetLocalProfileFloat("Setup", "ClippingDistance", fValue);
- fValue = m_engine->RetObjectDetail();
+ fValue = m_engine->GetObjectDetail();
SetLocalProfileFloat("Setup", "ObjectDetail", fValue);
- fValue = m_engine->RetGadgetQuantity();
+ fValue = m_engine->GetGadgetQuantity();
SetLocalProfileFloat("Setup", "GadgetQuantity", fValue);
- iValue = m_engine->RetTextureQuality();
+ iValue = m_engine->GetTextureQuality();
SetLocalProfileInt("Setup", "TextureQuality", iValue);
- iValue = m_sound->RetAudioVolume();
+ iValue = m_sound->GetAudioVolume();
SetLocalProfileInt("Setup", "AudioVolume", iValue);
- iValue = m_sound->RetMidiVolume();
+ iValue = m_sound->GetMidiVolume();
SetLocalProfileInt("Setup", "MidiVolume", iValue);
- iValue = m_sound->RetSound3D();
+ iValue = m_sound->GetSound3D();
SetLocalProfileInt("Setup", "Sound3D", iValue);
- iValue = m_engine->RetEditIndentMode();
+ iValue = m_engine->GetEditIndentMode();
SetLocalProfileInt("Setup", "EditIndentMode", iValue);
- iValue = m_engine->RetEditIndentValue();
- SetLocalProfileInt("Setup", "EditIndentValue", iValue);
+ iValue = m_engine->GetEditIndentValue();
+ SetLocalProfileInt("Setup", "EditIndentValue", iValue);*/
- key[0] = 0;
+ /* key[0] = 0;
for ( i=0 ; i<100 ; i++ )
{
- if ( m_engine->RetKey(i, 0) == 0 ) break;
+ if ( m_engine->GetKey(i, 0) == 0 ) break;
for ( j=0 ; j<2 ; j++ )
{
- iValue = m_engine->RetKey(i, j);
+ iValue = m_engine->GetKey(i, j);
sprintf(num, "%d%c", iValue, j==0?'+':' ');
strcat(key, num);
}
- }
- SetLocalProfileString("Setup", "KeyMap", key);
+ }*/
+
+ /* TODO: profile
+ SetLocalProfileString("Setup", "KeyMap", key); */
-#if _NET
+/* TODO: #if _NET
if ( m_accessEnable )
{
iValue = m_accessMission;
@@ -5644,12 +5657,14 @@ void CMainDialog::SetupMemorize()
iValue = m_accessUser;
SetLocalProfileInt("Setup", "AccessUser", iValue);
}
-#endif
+#endif */
+ /* TODO: profile
iValue = m_bDeleteGamer;
- SetLocalProfileInt("Setup", "DeleteGamer", iValue);
+ SetLocalProfileInt("Setup", "DeleteGamer", iValue); */
- m_engine->WriteProfile();
+ // TODO: write profile
+ //m_engine->WriteProfile();
}
// Remember all the settings.
@@ -5661,27 +5676,28 @@ void CMainDialog::SetupRecall()
char key[500];
char* p;
- if ( GetLocalProfileString("Directory", "scene", key, _MAX_FNAME) )
+ /* TODO: profile
+ if ( GetLocalProfileString("Directory", "scene", key, MAX_FNAME) )
{
strcpy(m_sceneDir, key);
}
- if ( GetLocalProfileString("Directory", "savegame", key, _MAX_FNAME) )
+ if ( GetLocalProfileString("Directory", "savegame", key, MAX_FNAME) )
{
strcpy(m_savegameDir, key);
}
- if ( GetLocalProfileString("Directory", "public", key, _MAX_FNAME) )
+ if ( GetLocalProfileString("Directory", "public", key, MAX_FNAME) )
{
strcpy(m_publicDir, key);
}
- if ( GetLocalProfileString("Directory", "user", key, _MAX_FNAME) )
+ if ( GetLocalProfileString("Directory", "user", key, MAX_FNAME) )
{
strcpy(m_userDir, key);
}
- if ( GetLocalProfileString("Directory", "files", key, _MAX_FNAME) )
+ if ( GetLocalProfileString("Directory", "files", key, MAX_FNAME) )
{
strcpy(m_filesDir, key);
}
@@ -5773,7 +5789,7 @@ void CMainDialog::SetupRecall()
if ( GetLocalProfileInt("Setup", "FogMode", iValue) )
{
m_engine->SetFog(iValue);
- m_camera->SetOverBaseColor(RetColor(RetColor(0.0f)));
+ m_camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f))); // TODO: color ok?
}
if ( GetLocalProfileInt("Setup", "LensMode", iValue) )
@@ -5801,9 +5817,9 @@ void CMainDialog::SetupRecall()
m_engine->SetJoystick(iValue);
}
- if ( GetLocalProfileFloat("Setup", "ParticuleDensity", fValue) )
+ if ( GetLocalProfileFloat("Setup", "ParticleDensity", fValue) )
{
- m_engine->SetParticuleDensity(fValue);
+ m_engine->SetParticleDensity(fValue);
}
if ( GetLocalProfileFloat("Setup", "ClippingDistance", fValue) )
@@ -5861,9 +5877,9 @@ void CMainDialog::SetupRecall()
while ( *p == ' ' || *p == '+' ) p++;
}
}
- }
+ } */
-#if _NET
+/* TODO: #if _NET
if ( m_accessEnable )
{
if ( GetLocalProfileInt("Setup", "AccessMission", iValue) )
@@ -5876,12 +5892,13 @@ void CMainDialog::SetupRecall()
m_accessUser = iValue;
}
}
-#endif
+#endif */
+ /* TODO: profile
if ( GetLocalProfileInt("Setup", "DeleteGamer", iValue) )
{
m_bDeleteGamer = iValue;
- }
+ } */
}
@@ -5902,12 +5919,12 @@ void CMainDialog::ChangeSetupQuality(int quality)
m_engine->SetSkyMode(bEnable);
m_engine->SetPlanetMode(bEnable);
m_engine->SetLightMode(bEnable);
- m_camera->SetOverBaseColor(RetColor(RetColor(0.0f)));
+ m_camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); // TODO: color ok?
if ( quality < 0 ) value = 0.0f;
if ( quality == 0 ) value = 1.0f;
if ( quality > 0 ) value = 2.0f;
- m_engine->SetParticuleDensity(value);
+ m_engine->SetParticleDensity(value);
if ( quality < 0 ) value = 0.5f;
if ( quality == 0 ) value = 1.0f;
@@ -5929,7 +5946,8 @@ void CMainDialog::ChangeSetupQuality(int quality)
if ( quality > 0 ) iValue = 2;
m_engine->SetTextureQuality(iValue);
- m_engine->FirstExecuteAdapt(false);
+ // TODO: first execute adapt?
+ //m_engine->FirstExecuteAdapt(false);
}
@@ -5937,48 +5955,48 @@ void CMainDialog::ChangeSetupQuality(int quality)
static int key_table[KEY_TOTAL] =
{
-#if _SCHOOL & _TEEN
- KEYRANK_LEFT,
- KEYRANK_RIGHT,
- KEYRANK_UP,
- KEYRANK_DOWN,
- KEYRANK_CAMERA,
- KEYRANK_NEAR,
- KEYRANK_AWAY,
- KEYRANK_HELP,
- KEYRANK_PROG,
- KEYRANK_SPEED10,
- KEYRANK_SPEED15,
- KEYRANK_SPEED20,
- KEYRANK_QUIT,
-#else
- KEYRANK_LEFT,
- KEYRANK_RIGHT,
- KEYRANK_UP,
- KEYRANK_DOWN,
- KEYRANK_GUP,
- KEYRANK_GDOWN,
- KEYRANK_ACTION,
- KEYRANK_CAMERA,
- KEYRANK_VISIT,
- KEYRANK_NEXT,
- KEYRANK_HUMAN,
- KEYRANK_DESEL,
- KEYRANK_NEAR,
- KEYRANK_AWAY,
- KEYRANK_HELP,
- KEYRANK_PROG,
- KEYRANK_CBOT,
- KEYRANK_SPEED10,
- KEYRANK_SPEED15,
- KEYRANK_SPEED20,
- KEYRANK_QUIT,
-#endif
+/* TODO: #if _SCHOOL & _TEEN
+ INPUT_SLOT_LEFT,
+ INPUT_SLOT_RIGHT,
+ INPUT_SLOT_UP,
+ INPUT_SLOT_DOWN,
+ INPUT_SLOT_CAMERA,
+ INPUT_SLOT_NEAR,
+ INPUT_SLOT_AWAY,
+ INPUT_SLOT_HELP,
+ INPUT_SLOT_PROG,
+ INPUT_SLOT_SPEED10,
+ INPUT_SLOT_SPEED15,
+ INPUT_SLOT_SPEED20,
+ INPUT_SLOT_QUIT,
+#else */
+ INPUT_SLOT_LEFT,
+ INPUT_SLOT_RIGHT,
+ INPUT_SLOT_UP,
+ INPUT_SLOT_DOWN,
+ INPUT_SLOT_GUP,
+ INPUT_SLOT_GDOWN,
+ INPUT_SLOT_ACTION,
+ INPUT_SLOT_CAMERA,
+ INPUT_SLOT_VISIT,
+ INPUT_SLOT_NEXT,
+ INPUT_SLOT_HUMAN,
+ INPUT_SLOT_DESEL,
+ INPUT_SLOT_NEAR,
+ INPUT_SLOT_AWAY,
+ INPUT_SLOT_HELP,
+ INPUT_SLOT_PROG,
+ INPUT_SLOT_CBOT,
+ INPUT_SLOT_SPEED10,
+ INPUT_SLOT_SPEED15,
+ INPUT_SLOT_SPEED20,
+ INPUT_SLOT_QUIT,
+// #endif
};
-static EventMsg key_event[KEY_TOTAL] =
+static EventType key_event[KEY_TOTAL] =
{
-#if _SCHOOL & _TEEN
+/* TODO: #if _SCHOOL & _TEEN
EVENT_INTERFACE_KLEFT,
EVENT_INTERFACE_KRIGHT,
EVENT_INTERFACE_KUP,
@@ -5992,7 +6010,7 @@ static EventMsg key_event[KEY_TOTAL] =
EVENT_INTERFACE_KSPEED15,
EVENT_INTERFACE_KSPEED20,
EVENT_INTERFACE_KQUIT,
-#else
+#else */
EVENT_INTERFACE_KLEFT,
EVENT_INTERFACE_KRIGHT,
EVENT_INTERFACE_KUP,
@@ -6014,7 +6032,7 @@ static EventMsg key_event[KEY_TOTAL] =
EVENT_INTERFACE_KSPEED15,
EVENT_INTERFACE_KSPEED20,
EVENT_INTERFACE_KQUIT,
-#endif
+//#endif
};
// Updates the list of keys.
@@ -6027,13 +6045,13 @@ void CMainDialog::UpdateKey()
Math::Point pos, dim;
int first, i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- ps = (CScroll*)pw->SearchControl(EVENT_INTERFACE_KSCROLL);
+ ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if ( ps == 0 ) return;
- first = (int)(ps->RetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE));
+ first = static_cast<int>(ps->GetVisibleValue()*(KEY_TOTAL-KEY_VISIBLE));
for ( i=0 ; i<KEY_TOTAL ; i++ )
{
@@ -6047,37 +6065,39 @@ void CMainDialog::UpdateKey()
for ( i=0 ; i<KEY_VISIBLE ; i++ )
{
pw->CreateKey(pos, dim, -1, key_event[first+i]);
- pk = (CKey*)pw->SearchControl(key_event[first+i]);
+ pk = static_cast<CKey*>(pw->SearchControl(key_event[first+i]));
if ( pk == 0 ) break;
- pk->SetKey(0, m_engine->RetKey(key_table[first+i], 0));
- pk->SetKey(1, m_engine->RetKey(key_table[first+i], 1));
+ /* TODO: set input bindings
+ pk->SetKey(0, m_engine->GetKey(key_table[first+i], 0));
+ pk->SetKey(1, m_engine->GetKey(key_table[first+i], 1)); */
pos.y -= dim.y;
}
}
// Change a key.
-void CMainDialog::ChangeKey(EventMsg event)
+void CMainDialog::ChangeKey(EventType event)
{
CWindow* pw;
CScroll* ps;
CKey* pk;
int i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw == 0 ) return;
- ps = (CScroll*)pw->SearchControl(EVENT_INTERFACE_KSCROLL);
+ ps = static_cast<CScroll*>(pw->SearchControl(EVENT_INTERFACE_KSCROLL));
if ( ps == 0 ) return;
for ( i=0 ; i<KEY_TOTAL ; i++ )
{
if ( key_event[i] == event )
{
- pk = (CKey*)pw->SearchControl(key_event[i]);
+ pk = static_cast<CKey*>(pw->SearchControl(key_event[i]));
if ( pk == 0 ) break;
- m_engine->SetKey(key_table[i], 0, pk->RetKey(0));
- m_engine->SetKey(key_table[i], 1, pk->RetKey(1));
+ /* TODO: set key binding
+ m_engine->SetKey(key_table[i], 0, pk->GetKey(0));
+ m_engine->SetKey(key_table[i], 1, pk->GetKey(1)); */
}
}
}
@@ -6096,7 +6116,7 @@ void CMainDialog::StartAbort()
StartDialog(Math::Point(0.3f, 0.8f), true, false, false);
m_bDialogDelete = false;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == 0 ) return;
pos.x = 0.35f;
@@ -6112,10 +6132,10 @@ void CMainDialog::StartAbort()
pos.x = 0.40f;
dim.x = 0.20f;
-#if _POLISH
+/* TODO: #if _POLISH
pos.x -= 7.0f/640.0f;
dim.x += 14.0f/640.0f;
-#endif
+#endif*/
dim.y = 32.0f/480.0f;
pos.y = 0.74f;
@@ -6146,12 +6166,13 @@ void CMainDialog::StartAbort()
pb->SetState(STATE_WARNING);
}
- if ( m_engine->RetSetupMode() )
+ /* TODO: setup mode?
+ if ( m_engine->GetSetupMode() )
{
pos.y = 0.39f;
pb = pw->CreateButton(pos, dim, -1, EVENT_INTERFACE_SETUP);
pb->SetState(STATE_SHADOW);
- }
+ }*/
pos.y = 0.25f;
pb = pw->CreateButton(pos, dim, -1, EVENT_INTERFACE_AGAIN);
@@ -6178,7 +6199,7 @@ void CMainDialog::StartDeleteObject()
StartDialog(Math::Point(0.7f, 0.3f), false, true, true);
m_bDialogDelete = true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == 0 ) return;
pos.x = 0.00f;
@@ -6188,13 +6209,13 @@ void CMainDialog::StartDeleteObject()
GetResource(RES_TEXT, RT_DIALOG_DELOBJ, name);
pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, name);
- pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_YESDEL, name);
pb->SetName(name);
pb->SetState(STATE_WARNING);
- pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_NODEL, name);
pb->SetName(name);
@@ -6213,7 +6234,7 @@ void CMainDialog::StartDeleteGame(char *gamer)
StartDialog(Math::Point(0.7f, 0.3f), false, true, true);
m_bDialogDelete = true;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == 0 ) return;
pos.x = 0.00f;
@@ -6224,13 +6245,13 @@ void CMainDialog::StartDeleteGame(char *gamer)
sprintf(text, name, gamer);
pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, text);
- pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_YESDEL, name);
pb->SetName(name);
pb->SetState(STATE_WARNING);
- pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_NODEL, name);
pb->SetName(name);
@@ -6247,7 +6268,7 @@ void CMainDialog::StartQuit()
StartDialog(Math::Point(0.6f, 0.3f), false, true, true);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw == 0 ) return;
pos.x = 0.00f;
@@ -6257,13 +6278,13 @@ void CMainDialog::StartQuit()
GetResource(RES_TEXT, RT_DIALOG_QUIT, name);
pw->CreateLabel(pos, dim, -1, EVENT_DIALOG_LABEL, name);
- pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_OK));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_YESQUIT, name);
pb->SetName(name);
pb->SetState(STATE_WARNING);
- pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL);
+ pb = static_cast<CButton*>(pw->SearchControl(EVENT_DIALOG_CANCEL));
if ( pb == 0 ) return;
GetResource(RES_TEXT, RT_DIALOG_NOQUIT, name);
pb->SetName(name);
@@ -6280,34 +6301,34 @@ void CMainDialog::StartDialog(Math::Point dim, bool bFire, bool bOK, bool bCance
StartSuspend();
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW7));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW8));
if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
- pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT);
+ pb = static_cast<CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if ( pb != 0 )
{
pb->ClearState(STATE_VISIBLE);
@@ -6371,7 +6392,7 @@ void CMainDialog::FrameDialog(float rTime)
m_dialogTime += rTime;
if ( m_dialogTime < 1.0f )
{
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW9));
if ( pw != 0 )
{
if ( m_dialogTime < 0.50f )
@@ -6400,7 +6421,7 @@ void CMainDialog::FrameDialog(float rTime)
if ( !m_bGlint ) return;
m_dialogParti += rTime;
- if ( m_dialogParti < m_engine->ParticuleAdapt(0.05f) ) return;
+ if ( m_dialogParti < m_engine->ParticleAdapt(0.05f) ) return;
m_dialogParti = 0.0f;
if ( !m_bDialogFire ) return;
@@ -6420,9 +6441,9 @@ void CMainDialog::FrameDialog(float rTime)
pos.y += Math::Rand()*(16.0f/480.0f)-(10.0f/480.0f);
dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim,
- (ParticuleType)(PARTILENS1+rand()%3),
- 1.0f, 0.0f, 0.0f, SH_INTERFACE);
+ m_particle->CreateParticle(pos, speed, dim,
+ static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3),
+ 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE);
// Top.
pos.x = dpos.x + ddim.x*Math::Rand();
@@ -6431,9 +6452,9 @@ void CMainDialog::FrameDialog(float rTime)
pos.y -= Math::Rand()*(16.0f/480.0f)-(10.0f/480.0f);
dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim,
- (ParticuleType)(PARTILENS1+rand()%3),
- 1.0f, 0.0f, 0.0f, SH_INTERFACE);
+ m_particle->CreateParticle(pos, speed, dim,
+ static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3),
+ 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE);
// Left.
pos.y = dpos.y + ddim.y*Math::Rand();
@@ -6442,9 +6463,9 @@ void CMainDialog::FrameDialog(float rTime)
pos.y += (Math::Rand()-0.5f)*(6.0f/480.0f);
dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim,
- (ParticuleType)(PARTILENS1+rand()%3),
- 1.0f, 0.0f, 0.0f, SH_INTERFACE);
+ m_particle->CreateParticle(pos, speed, dim,
+ static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3),
+ 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE);
// Right.
pos.y = dpos.y + ddim.y*Math::Rand();
@@ -6453,9 +6474,9 @@ void CMainDialog::FrameDialog(float rTime)
pos.y += (Math::Rand()-0.5f)*(6.0f/480.0f);
dim.x = 0.01f+Math::Rand()*0.01f;
dim.y = dim.x/0.75f;
- m_particule->CreateParticule(pos, speed, dim,
- (ParticuleType)(PARTILENS1+rand()%3),
- 1.0f, 0.0f, 0.0f, SH_INTERFACE);
+ m_particle->CreateParticle(pos, speed, dim,
+ static_cast<Gfx::ParticleType>(Gfx::PARTILENS1+rand()%3),
+ 1.0f, 0.0f, 0.0f, Gfx::SH_INTERFACE);
}
}
@@ -6466,34 +6487,34 @@ void CMainDialog::StopDialog()
CWindow* pw;
CButton* pb;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW2);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW2));
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW3));
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW4));
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW6));
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW7));
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8);
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW8));
if ( pw != 0 ) pw->SetState(STATE_ENABLE);
- pb = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT);
+ pb = static_cast<CButton*>(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if ( pb != 0 )
{
pb->SetState(STATE_VISIBLE);
@@ -6510,13 +6531,13 @@ void CMainDialog::StartSuspend()
{
m_sound->MuteAll(true);
m_main->ClearInterface();
- m_bInitPause = m_engine->RetPause();
+ m_bInitPause = m_engine->GetPause();
m_engine->SetPause(true);
m_engine->SetOverFront(false); // over flat behind
m_main->CreateShortcuts();
m_main->StartSuspend();
- m_initCamera = m_camera->RetType();
- m_camera->SetType(CAMERA_DIALOG);
+ m_initCamera = m_camera->GetType();
+ m_camera->SetType(Gfx::CAM_TYPE_DIALOG);
}
// Resume the simulation after a period of dialog.
@@ -6535,7 +6556,7 @@ void CMainDialog::StopSuspend()
// Whether to use tooltips.
-bool CMainDialog::RetTooltip()
+bool CMainDialog::GetTooltip()
{
return m_bTooltip;
}
@@ -6552,42 +6573,42 @@ bool CMainDialog::IsDialog()
// Specifies the name of the scene to read.
-void CMainDialog::SetSceneRead(char* name)
+void CMainDialog::SetSceneRead(const char* name)
{
strcpy(m_sceneRead, name);
}
-// Returns the name of the scene to read.
+// Geturns the name of the scene to read.
-char* CMainDialog::RetSceneRead()
+char* CMainDialog::GetSceneRead()
{
return m_sceneRead;
}
// Specifies the name of the scene to read.
-void CMainDialog::SetStackRead(char* name)
+void CMainDialog::SetStackRead(const char* name)
{
strcpy(m_stackRead, name);
}
-// Returns the name of the scene to read.
+// Geturns the name of the scene to read.
-char* CMainDialog::RetStackRead()
+char* CMainDialog::GetStackRead()
{
return m_stackRead;
}
// Specifies the name of the chosen to play scene.
-void CMainDialog::SetSceneName(char* name)
+void CMainDialog::SetSceneName(const char* name)
{
strcpy(m_sceneName, name);
}
-// Returns the name of the chosen to play scene.
+// Geturns the name of the chosen to play scene.
-char* CMainDialog::RetSceneName()
+char* CMainDialog::GetSceneName()
{
return m_sceneName;
}
@@ -6599,16 +6620,16 @@ void CMainDialog::SetSceneRank(int rank)
m_sceneRank = rank;
}
-// Returns the rank of the chosen to play scene.
+// Geturns the rank of the chosen to play scene.
-int CMainDialog::RetSceneRank()
+int CMainDialog::GetSceneRank()
{
return m_sceneRank;
}
-// Returns folder name of the scene that user selected to play.
+// Geturns folder name of the scene that user selected to play.
-char* CMainDialog::RetSceneDir()
+char* CMainDialog::GetSceneDir()
{
int i;
@@ -6620,21 +6641,21 @@ char* CMainDialog::RetSceneDir()
// Whether to show the solution.
-bool CMainDialog::RetSceneSoluce()
+bool CMainDialog::GetSceneSoluce()
{
return m_bSceneSoluce;
}
-// Returns the name of the folder to save.
+// Geturns the name of the folder to save.
-char* CMainDialog::RetSavegameDir()
+char* CMainDialog::GetSavegameDir()
{
return m_savegameDir;
}
-// Returns the name of public folder.
+// Geturns the name of public folder.
-char* CMainDialog::RetPublicDir()
+char* CMainDialog::GetPublicDir()
{
return m_publicDir;
}
@@ -6642,35 +6663,35 @@ char* CMainDialog::RetPublicDir()
// Indicates if there are reflections on the buttons.
-bool CMainDialog::RetGlint()
+bool CMainDialog::GetGlint()
{
return m_bGlint;
}
// Whether to show 4:solutions.
-bool CMainDialog::RetSoluce4()
+bool CMainDialog::GetSoluce4()
{
return m_bSoluce4;
}
// Whether to show the cinematics.
-bool CMainDialog::RetMovies()
+bool CMainDialog::GetMovies()
{
return m_bMovies;
}
// IWhether to make an animation in CTaskReset.
-bool CMainDialog::RetNiceReset()
+bool CMainDialog::GetNiceReset()
{
return m_bNiceReset;
}
// Indicates whether the fire causes damage to its own units.
-bool CMainDialog::RetHimselfDamage()
+bool CMainDialog::GetHimselfDamage()
{
return m_bHimselfDamage;
}
@@ -6709,7 +6730,7 @@ void CMainDialog::ReadGamerPerso(char *gamer)
FILE* file;
char filename[100];
char line[100];
- D3DCOLORVALUE color;
+ Gfx::Color color;
m_perso.face = 0;
DefPerso();
@@ -6729,7 +6750,7 @@ void CMainDialog::ReadGamerPerso(char *gamer)
color.g = 0.0f;
color.b = 0.0f;
color.a = 0.0f;
- m_perso.colorHair = OpColorValue(line, "hair", color);
+ m_perso.colorHair = OpColor(line, "hair", color);
}
if ( Cmd(line, "Body") )
@@ -6738,13 +6759,13 @@ void CMainDialog::ReadGamerPerso(char *gamer)
color.g = 0.0f;
color.b = 0.0f;
color.a = 0.0f;
- m_perso.colorCombi = OpColorValue(line, "combi", color);
+ m_perso.colorCombi = OpColor(line, "combi", color);
color.r = 0.0f;
color.g = 0.0f;
color.b = 0.0f;
color.a = 0.0f;
- m_perso.colorBand = OpColorValue(line, "band", color);
+ m_perso.colorBand = OpColor(line, "band", color);
}
}
@@ -6761,7 +6782,7 @@ void CMainDialog::SetGamerFace(char *gamer, int face)
// Gives the face of the player.
-int CMainDialog::RetGamerFace(char *gamer)
+int CMainDialog::GetGamerFace(char *gamer)
{
ReadGamerPerso(gamer);
return m_perso.face;
@@ -6769,37 +6790,37 @@ int CMainDialog::RetGamerFace(char *gamer)
// Gives the face of the player.
-int CMainDialog::RetGamerFace()
+int CMainDialog::GetGamerFace()
{
return m_perso.face;
}
-int CMainDialog::RetGamerGlasses()
+int CMainDialog::GetGamerGlasses()
{
return m_perso.glasses;
}
-bool CMainDialog::RetGamerOnlyHead()
+bool CMainDialog::GetGamerOnlyHead()
{
return (m_phase == PHASE_PERSO && m_persoTab == 0);
}
-float CMainDialog::RetPersoAngle()
+float CMainDialog::GetPersoAngle()
{
return m_persoAngle;
}
-D3DCOLORVALUE CMainDialog::RetGamerColorHair()
+Gfx::Color CMainDialog::GetGamerColorHair()
{
return m_perso.colorHair;
}
-D3DCOLORVALUE CMainDialog::RetGamerColorCombi()
+Gfx::Color CMainDialog::GetGamerColorCombi()
{
return m_perso.colorCombi;
}
-D3DCOLORVALUE CMainDialog::RetGamerColorBand()
+Gfx::Color CMainDialog::GetGamerColorBand()
{
return m_perso.colorBand;
}
@@ -6819,7 +6840,7 @@ bool CMainDialog::ReadGamerInfo()
m_sceneInfo[i].bPassed = false;
}
- sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->RetGamerName(), m_sceneName);
+ sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->GetGamerName(), m_sceneName);
file = fopen(line, "r");
if ( file == NULL ) return false;
@@ -6855,7 +6876,7 @@ bool CMainDialog::WriteGamerInfo()
char line[100];
int i;
- sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->RetGamerName(), m_sceneName);
+ sprintf(line, "%s\\%s\\%s.gam", m_savegameDir, m_main->GetGamerName(), m_sceneName);
file = fopen(line, "w");
if ( file == NULL ) return false;
@@ -6883,7 +6904,7 @@ void CMainDialog::SetGamerInfoTry(int rank, int numTry)
m_sceneInfo[rank].numTry = numTry;
}
-int CMainDialog::RetGamerInfoTry(int rank)
+int CMainDialog::GetGamerInfoTry(int rank)
{
if ( rank < 0 || rank >= MAXSCENE ) return 0;
return m_sceneInfo[rank].numTry;
@@ -6910,7 +6931,7 @@ void CMainDialog::SetGamerInfoPassed(int rank, bool bPassed)
}
}
-bool CMainDialog::RetGamerInfoPassed(int rank)
+bool CMainDialog::GetGamerInfoPassed(int rank)
{
if ( rank < 0 || rank >= MAXSCENE ) return false;
return m_sceneInfo[rank].bPassed;
@@ -6932,4 +6953,5 @@ bool CMainDialog::NextMission()
return true;
}
+} // namespace Ui
diff --git a/src/ui/maindialog.h b/src/ui/maindialog.h
index cfd9564..8b0ef81 100644
--- a/src/ui/maindialog.h
+++ b/src/ui/maindialog.h
@@ -19,24 +19,32 @@
#pragma once
-#include "common/struct.h"
-#include "old/camera.h"
+#include "graphics/core/color.h"
#include "object/robotmain.h"
-
class CInstanceManager;
-class CEvent;
-class CD3DEngine;
+class CEventQueue;
+class CSoundInterface;
+
+namespace Gfx
+{
+class CEngine;
+class CParticle;
+};
+
+namespace Ui
+{
+
class CInterface;
class CWindow;
class CControl;
-class CParticule;
-class CSound;
const int USERLISTMAX = 100;
const int MAXSCENE = 1000;
+const int MAX_FNAME = 255; // TODO: remove after rewrite to std::string
+
struct SceneInfo
{
char numTry;
@@ -47,9 +55,9 @@ struct GamerPerso
{
int face; // face
int glasses; // glasses
- D3DCOLORVALUE colorHair; // hair color
- D3DCOLORVALUE colorCombi; // spacesuit volor
- D3DCOLORVALUE colorBand; // strips color
+ Gfx::Color colorHair; // hair color
+ Gfx::Color colorCombi; // spacesuit volor
+ Gfx::Color colorBand; // strips color
};
@@ -63,30 +71,30 @@ public:
bool EventProcess(const Event &event);
void ChangePhase(Phase phase);
- void SetSceneRead(char* name);
- void SetStackRead(char* name);
- void SetSceneName(char* name);
+ void SetSceneRead(const char* name);
+ void SetStackRead(const char* name);
+ void SetSceneName(const char* name);
void SetSceneRank(int rank);
- char* RetSceneRead();
- char* RetStackRead();
- char* RetSceneName();
- int RetSceneRank();
- char* RetSceneDir();
- bool RetSceneSoluce();
- char* RetSavegameDir();
- char* RetPublicDir();
-
- bool RetTooltip();
- bool RetGlint();
- bool RetSoluce4();
- bool RetMovies();
- bool RetNiceReset();
- bool RetHimselfDamage();
+ char* GetSceneRead();
+ char* GetStackRead();
+ char* GetSceneName();
+ int GetSceneRank();
+ char* GetSceneDir();
+ bool GetSceneSoluce();
+ char* GetSavegameDir();
+ char* GetPublicDir();
+
+ bool GetTooltip();
+ bool GetGlint();
+ bool GetSoluce4();
+ bool GetMovies();
+ bool GetNiceReset();
+ bool GetHimselfDamage();
void SetUserDir(char *base, int rank);
void BuildSceneName(char *filename, char *base, int rank);
void BuildResumeName(char *filename, char *base, int rank);
- char* RetFilesDir();
+ char* GetFilesDir();
void StartAbort();
void StartDeleteObject();
@@ -106,30 +114,30 @@ public:
bool ReadGamerInfo();
bool WriteGamerInfo();
void SetGamerInfoTry(int rank, int numTry);
- int RetGamerInfoTry(int rank);
+ int GetGamerInfoTry(int rank);
void SetGamerInfoPassed(int rank, bool bPassed);
- bool RetGamerInfoPassed(int rank);
+ bool GetGamerInfoPassed(int rank);
bool NextMission();
void WriteGamerPerso(char *gamer);
void ReadGamerPerso(char *gamer);
void SetGamerFace(char *gamer, int face);
- int RetGamerFace(char *gamer);
- int RetGamerFace();
- int RetGamerGlasses();
- bool RetGamerOnlyHead();
- float RetPersoAngle();
- D3DCOLORVALUE RetGamerColorHair();
- D3DCOLORVALUE RetGamerColorCombi();
- D3DCOLORVALUE RetGamerColorBand();
+ int GetGamerFace(char *gamer);
+ int GetGamerFace();
+ int GetGamerGlasses();
+ bool GetGamerOnlyHead();
+ float GetPersoAngle();
+ Gfx::Color GetGamerColorHair();
+ Gfx::Color GetGamerColorCombi();
+ Gfx::Color GetGamerColorBand();
void AllMissionUpdate();
void ShowSoluceUpdate();
protected:
void GlintMove();
- void FrameParticule(float rTime);
- void NiceParticule(Math::Point mouse, bool bPress);
+ void FrameParticle(float rTime);
+ void NiceParticle(Math::Point mouse, bool bPress);
void ReadNameList();
void UpdateNameList();
void UpdateNameEdit();
@@ -150,7 +158,7 @@ protected:
void IODeleteScene();
bool IOWriteScene();
bool IOReadScene();
- int RetChapPassed();
+ int GetChapPassed();
void UpdateSceneChap(int &chap);
void UpdateSceneList(int chap, int &sel);
void UpdateSceneResume(int rank);
@@ -162,17 +170,18 @@ protected:
void ChangeSetupButtons();
void ChangeSetupQuality(int quality);
void UpdateKey();
- void ChangeKey(EventMsg event);
+ void ChangeKey(EventType event);
protected:
CInstanceManager* m_iMan;
- CRobotMain* m_main;
- CEvent* m_event;
- CD3DEngine* m_engine;
- CInterface* m_interface;
- CParticule* m_particule;
- CCamera* m_camera;
- CSound* m_sound;
+ CApplication* m_app;
+ CRobotMain* m_main;
+ CEventQueue* m_eventQueue;
+ Gfx::CEngine* m_engine;
+ CInterface* m_interface;
+ Gfx::CParticle* m_particle;
+ Gfx::CCamera* m_camera;
+ CSoundInterface* m_sound;
Phase m_phase; // copy of CRobotMain
Phase m_phaseSetup; // tab selected
@@ -184,11 +193,11 @@ protected:
int m_persoTab; // perso: tab selected
float m_persoAngle; // perso: angle of presentation
- char m_sceneDir[_MAX_FNAME]; // scene folder
- char m_savegameDir[_MAX_FNAME]; // savegame folder
- char m_publicDir[_MAX_FNAME]; // program folder
- char m_userDir[_MAX_FNAME]; // user folder
- char m_filesDir[_MAX_FNAME]; // case files
+ char m_sceneDir[MAX_FNAME]; // scene folder
+ char m_savegameDir[MAX_FNAME]; // savegame folder
+ char m_publicDir[MAX_FNAME]; // program folder
+ char m_userDir[MAX_FNAME]; // user folder
+ char m_filesDir[MAX_FNAME]; // case files
int m_index; // 0..4
int m_chap[10]; // selected chapter (0..8)
@@ -241,7 +250,7 @@ protected:
float m_dialogParti;
float m_dialogTime;
bool m_bInitPause;
- CameraType m_initCamera;
+ Gfx::CameraType m_initCamera;
int m_partiPhase[10];
float m_partiTime[10];
@@ -250,4 +259,4 @@ protected:
SceneInfo m_sceneInfo[MAXSCENE];
};
-
+} // namespace Ui
diff --git a/src/ui/mainmap.cpp b/src/ui/mainmap.cpp
index 76e3627..b70bad9 100644
--- a/src/ui/mainmap.cpp
+++ b/src/ui/mainmap.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,42 +18,26 @@
// mainmap.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/global.h"
-#include "common/event.h"
-#include "common/iman.h"
-#include "ui/interface.h"
-#include "ui/map.h"
-#include "ui/image.h"
-#include "ui/group.h"
-#include "ui/slider.h"
-#include "ui/scroll.h"
-#include "ui/window.h"
#include "ui/mainmap.h"
+namespace Ui {
+
const float ZOOM_MIN = 1.0f;
const float ZOOM_MAX = 16.0f;
-
// Constructor of the application card.
-CMainMap::CMainMap(CInstanceManager* iMan)
+CMainMap::CMainMap()
{
- m_iMan = iMan;
+ m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_MAP, this);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
+ m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
m_mapMode = 1;
m_bFixImage = false;
@@ -72,9 +57,8 @@ void CMainMap::CreateMap()
CWindow* pw;
Math::Point pos, dim;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 )
- {
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr) {
pos.x = 0.0f;
pos.y = 0.0f;
dim.x = 0.0f;
@@ -82,10 +66,10 @@ void CMainMap::CreateMap()
pw = m_interface->CreateWindows(pos, dim, 10, EVENT_WINDOW1);
}
- dim.x = 10.0f/640.0f;
- dim.y = 10.0f/480.0f;
- pos.x = 10.0f/640.0f;
- pos.y = 10.0f/480.0f;
+ dim.x = 10.0f / 640.0f;
+ dim.y = 10.0f / 480.0f;
+ pos.x = 10.0f / 640.0f;
+ pos.y = 10.0f / 480.0f;
pw->CreateMap (pos, dim, 2, EVENT_OBJECT_MAP);
pw->CreateSlider(pos, dim, 0, EVENT_OBJECT_MAPZOOM);
@@ -94,16 +78,18 @@ void CMainMap::CreateMap()
// Indicates whether the mini-map should display a still image.
-void CMainMap::SetFixImage(char *filename)
+void CMainMap::SetFixImage(const char *filename)
{
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm == 0 ) return;
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm == nullptr)
+ return;
pw->DeleteControl(EVENT_OBJECT_MAPZOOM);
m_bFixImage = true;
@@ -113,17 +99,17 @@ void CMainMap::SetFixImage(char *filename)
// Choosing colors of soil and water for the mini-map.
-void CMainMap::FloorColorMap(D3DCOLORVALUE floor, D3DCOLORVALUE water)
+void CMainMap::FloorColorMap(Gfx::Color floor, Gfx::Color water)
{
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm != 0 )
- {
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm != nullptr) {
pm->SetFloorColor(floor);
pm->SetWaterColor(water);
}
@@ -137,26 +123,20 @@ void CMainMap::ShowMap(bool bShow)
CMap* pm;
CSlider* ps;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
- if ( bShow )
- {
+ if (bShow) {
DimMap();
- }
- else
- {
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm != 0 )
- {
+ } else {
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm != nullptr)
pm->ClearState(STATE_VISIBLE);
- }
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
- if ( ps != 0 )
- {
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
+ if (ps != nullptr)
ps->ClearState(STATE_VISIBLE);
- }
}
}
@@ -170,10 +150,12 @@ void CMainMap::DimMap()
Math::Point pos, dim;
float value;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm == nullptr)
+ return;
pm->SetState(STATE_VISIBLE, (m_mapMode != 0));
@@ -184,20 +166,19 @@ void CMainMap::DimMap()
pm->SetPos(pos);
pm->SetDim(dim);
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
- if ( ps != 0 )
- {
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
+ if (ps != nullptr) {
ps->SetState(STATE_VISIBLE, (m_mapMode != 0));
dim.x = SCROLL_WIDTH;
- dim.y = 66.0f/480.0f;
- pos.x = 523.0f/640.0f;
- pos.y = 3.0f/480.0f;
+ dim.y = 66.0f / 480.0f;
+ pos.x = 523.0f / 640.0f;
+ pos.y = 3.0f / 480.0f;
ps->SetPos(pos);
ps->SetDim(dim);
- value = pm->RetZoom();
- value = (value-ZOOM_MIN)/(ZOOM_MAX-ZOOM_MIN);
+ value = pm->GetZoom();
+ value = (value-ZOOM_MIN) / (ZOOM_MAX-ZOOM_MIN);
value = powf(value, 0.5f);
ps->SetVisibleValue(value);
ps->SetArrowStep(0.2f);
@@ -206,22 +187,25 @@ void CMainMap::DimMap()
// Returns the current zoom of the minimap.
-float CMainMap::RetZoomMap()
+float CMainMap::GetZoomMap()
{
CWindow* pw;
CMap* pm;
CSlider* ps;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return ZOOM_MIN;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return ZOOM_MIN;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm == 0 ) return ZOOM_MIN;
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm == nullptr)
+ return ZOOM_MIN;
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
- if ( ps == 0 ) return ZOOM_MIN;
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
+ if (ps == nullptr)
+ return ZOOM_MIN;
- return pm->RetZoom();
+ return pm->GetZoom();
}
// Zoom the mini-map of any factor.
@@ -232,16 +216,21 @@ void CMainMap::ZoomMap(float zoom)
CMap* pm;
CSlider* ps;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm == 0 ) return;
-
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
- if ( ps == 0 ) return;
-
- if ( zoom < ZOOM_MIN ) zoom = ZOOM_MIN;
- if ( zoom > ZOOM_MAX ) zoom = ZOOM_MAX;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm == nullptr)
+ return;
+
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
+ if (ps == nullptr)
+ return;
+
+ if (zoom < ZOOM_MIN)
+ zoom = ZOOM_MIN;
+ if (zoom > ZOOM_MAX)
+ zoom = ZOOM_MAX;
pm->SetZoom(zoom);
DimMap();
@@ -256,17 +245,21 @@ void CMainMap::ZoomMap()
CSlider* ps;
float zoom;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm == nullptr)
+ return;
+
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
+ if (ps == nullptr)
+ return;
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
- if ( ps == 0 ) return;
- zoom = ps->RetVisibleValue();
+ zoom = ps->GetVisibleValue();
zoom = powf(zoom, 2.0f);
- zoom = ZOOM_MIN+zoom*(ZOOM_MAX-ZOOM_MIN);
+ zoom = ZOOM_MIN+zoom*(ZOOM_MAX - ZOOM_MIN);
pm->SetZoom(zoom);
DimMap();
@@ -280,20 +273,17 @@ void CMainMap::MapEnable(bool bEnable)
CMap* pm;
CSlider* ps;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm != 0 )
- {
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm != nullptr)
pm->SetEnable(bEnable);
- }
- ps = (CSlider*)pw->SearchControl(EVENT_OBJECT_MAPZOOM);
- if ( ps != 0 )
- {
+ ps = static_cast<CSlider*>(pw->SearchControl(EVENT_OBJECT_MAPZOOM));
+ if (ps != nullptr)
ps->SetState(STATE_ENABLE, bEnable);
- }
}
// Specifies the type of icon for the selected object.
@@ -303,11 +293,13 @@ void CMainMap::SetToy(bool bToy)
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm == 0 ) return;
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm == nullptr)
+ return;
pm->SetToy(bToy);
}
@@ -320,11 +312,13 @@ void CMainMap::SetFixParam(float zoom, float ox, float oy, float angle,
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm == 0 ) return;
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm == nullptr)
+ return;
pm->SetZoom(zoom);
pm->SetOffset(ox, oy);
@@ -340,26 +334,25 @@ void CMainMap::UpdateMap()
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm != 0 )
- {
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm != nullptr)
pm->UpdateTerrain();
- }
}
// Indicates if the mini-map is visible.
-bool CMainMap::RetShowMap()
+bool CMainMap::GetShowMap()
{
return ( m_mapMode != 0 );
}
// Indicates whether the mini-map displays a still image.
-bool CMainMap::RetFixImage()
+bool CMainMap::GetFixImage()
{
return m_bFixImage;
}
@@ -372,31 +365,33 @@ CObject* CMainMap::DetectMap(Math::Point pos, bool &bInMap)
CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return 0;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return 0;
bInMap = false;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm == 0 ) return 0;
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm == nullptr)
+ return 0;
return pm->DetectObject(pos, bInMap);
}
// Indicates the object with the mouse hovers over.
-void CMainMap::SetHilite(CObject* pObj)
+void CMainMap::SetHighlight(CObject* pObj)
{
- CWindow* pw;
+ CWindow* pw;
CMap* pm;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw == 0 ) return;
+ pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW1));
+ if (pw == nullptr)
+ return;
- pm = (CMap*)pw->SearchControl(EVENT_OBJECT_MAP);
- if ( pm != 0 )
- {
- pm->SetHilite(pObj);
- }
+ pm = static_cast<CMap*>(pw->SearchControl(EVENT_OBJECT_MAP));
+ if (pm != nullptr)
+ pm->SetHighlight(pObj);
}
+}
diff --git a/src/ui/mainmap.h b/src/ui/mainmap.h
index dba87fc..35aae4c 100644
--- a/src/ui/mainmap.h
+++ b/src/ui/mainmap.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,53 +19,50 @@
#pragma once
-
-#include "common/struct.h"
+#include "common/event.h"
+#include "graphics/core/color.h"
#include "math/point.h"
+#include "object/object.h"
+#include "ui/interface.h"
-class CInstanceManager;
-class CEvent;
-class CD3DEngine;
-class CInterface;
-class CObject;
-
-
+namespace Ui {
class CMainMap
{
-public:
- CMainMap(CInstanceManager* iMan);
- ~CMainMap();
+ public:
+ CMainMap();
+ ~CMainMap();
- void UpdateMap();
- void CreateMap();
- void SetFixImage(char *filename);
- void FloorColorMap(D3DCOLORVALUE floor, D3DCOLORVALUE water);
- void ShowMap(bool bShow);
- void DimMap();
- float RetZoomMap();
- void ZoomMap(float zoom);
- void ZoomMap();
- void MapEnable(bool bEnable);
- bool RetShowMap();
- bool RetFixImage();
- CObject* DetectMap(Math::Point pos, bool &bInMap);
- void SetHilite(CObject* pObj);
- void SetToy(bool bToy);
- void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug);
+ void UpdateMap();
+ void CreateMap();
+ void SetFixImage(const char *filename);
+ void FloorColorMap(Gfx::Color floor, Gfx::Color water);
+ void ShowMap(bool bShow);
+ void DimMap();
+ float GetZoomMap();
+ void ZoomMap(float zoom);
+ void ZoomMap();
+ void MapEnable(bool bEnable);
+ bool GetShowMap();
+ bool GetFixImage();
+ CObject* DetectMap(Math::Point pos, bool &bInMap);
+ void SetHighlight(CObject* pObj);
+ void SetToy(bool bToy);
+ void SetFixParam(float zoom, float ox, float oy, float angle, int mode, bool bDebug);
-protected:
- void CenterMap();
+ protected:
+ void CenterMap();
-protected:
- CInstanceManager* m_iMan;
- CEvent* m_event;
- CD3DEngine* m_engine;
- CInterface* m_interface;
+ protected:
+ CInstanceManager* m_iMan;
+ CEventQueue* m_event;
+ Gfx::CEngine* m_engine;
+ CInterface* m_interface;
- int m_mapMode;
- bool m_bFixImage;
+ int m_mapMode;
+ bool m_bFixImage;
};
+}
diff --git a/src/ui/mainshort.cpp b/src/ui/mainshort.cpp
index f23354b..ac6d7fc 100644
--- a/src/ui/mainshort.cpp
+++ b/src/ui/mainshort.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,36 +18,21 @@
// mainshort.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "common/global.h"
-#include "common/event.h"
-#include "common/iman.h"
-#include "object/object.h"
-#include "ui/interface.h"
-#include "ui/map.h"
-#include "ui/button.h"
-#include "object/robotmain.h"
#include "ui/mainshort.h"
-
-
+namespace Ui {
// Constructor of the application card.
-CMainShort::CMainShort(CInstanceManager* iMan)
+CMainShort::CMainShort()
{
- m_iMan = iMan;
+ m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_SHORT, this);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
+ m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_event = static_cast<CEvent*>(m_iMan->SearchInstance(CLASS_EVENT));
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
FlushShortcuts();
}
@@ -78,7 +64,7 @@ void CMainShort::FlushShortcuts()
}
}
-static EventMsg table_sc_em[20] =
+static EventType table_sc_em[20] =
{
EVENT_OBJECT_SHORTCUT00,
EVENT_OBJECT_SHORTCUT01,
@@ -113,13 +99,13 @@ bool CMainShort::CreateShortcuts()
int i, rank, icon;
char name[100];
- if ( m_main->RetFixScene() ) return false;
+ if ( m_main->GetFixScene() ) return false;
m_interface->DeleteControl(EVENT_OBJECT_MOVIELOCK);
m_interface->DeleteControl(EVENT_OBJECT_EDITLOCK);
for ( i=0 ; i<20 ; i++ )
{
- if ( i != 0 && m_shortcuts[i] == 0 ) continue;
+ if ( i != 0 && m_shortcuts[i] == nullptr ) continue;
m_interface->DeleteControl(table_sc_em[i]);
m_shortcuts[i] = 0;
@@ -130,15 +116,15 @@ bool CMainShort::CreateShortcuts()
pos.x = 4.0f/640.0f;
pos.y = (480.0f-32.0f)/480.0f;
- if ( m_main->RetMovieLock() &&
- !m_main->RetEditLock() ) // hangs during film?
+ if ( m_main->GetMovieLock() &&
+ !m_main->GetEditLock() ) // hangs during film?
{
m_interface->CreateShortcut(pos, dim, 7, EVENT_OBJECT_MOVIELOCK);
return true;
}
- if ( !m_main->RetFreePhoto() &&
- (m_main->RetEditLock() ||
- m_engine->RetPause()) ) // hangs during edition?
+ if ( !m_main->GetFreePhoto() &&
+ (m_main->GetEditLock() ||
+ m_engine->GetPause()) ) // hangs during edition?
{
m_interface->CreateShortcut(pos, dim, 6, EVENT_OBJECT_EDITLOCK);
return true;
@@ -153,14 +139,14 @@ bool CMainShort::CreateShortcuts()
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
- if ( pObj == 0 ) break;
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
+ if ( pObj == nullptr ) break;
- if ( !pObj->RetActif() ) continue;
- if ( !pObj->RetSelectable() ) continue;
- if ( pObj->RetProxyActivate() ) continue;
+ if ( !pObj->GetActif() ) continue;
+ if ( !pObj->GetSelectable() ) continue;
+ if ( pObj->GetProxyActivate() ) continue;
- type = pObj->RetType();
+ type = pObj->GetType();
icon = -1;
if ( m_bBuilding )
{
@@ -243,12 +229,12 @@ bool CMainShort::UpdateShortcuts()
for ( i=0 ; i<20 ; i++ )
{
- if ( m_shortcuts[i] == 0 ) continue;
+ if ( m_shortcuts[i] == nullptr ) continue;
pc = m_interface->SearchControl(table_sc_em[i]);
- if ( pc != 0 )
+ if ( pc != nullptr )
{
- pc->SetState(STATE_CHECK, m_shortcuts[i]->RetSelect());
+ pc->SetState(STATE_CHECK, m_shortcuts[i]->GetSelect());
pc->SetState(STATE_RUN, m_shortcuts[i]->IsProgram());
}
}
@@ -257,7 +243,7 @@ bool CMainShort::UpdateShortcuts()
// Selects an object through a shortcut.
-void CMainShort::SelectShortcut(EventMsg event)
+void CMainShort::SelectShortcut(EventType event)
{
int i;
@@ -265,7 +251,7 @@ void CMainShort::SelectShortcut(EventMsg event)
{
if ( event == table_sc_em[i] )
{
- if ( i != 0 && m_shortcuts[i] == 0 ) continue;
+ if ( i != 0 && m_shortcuts[i] == nullptr ) continue;
if ( i == 0 ) // buildings <-> vehicles?
{
@@ -289,9 +275,9 @@ void CMainShort::SelectNext()
CObject* pPrev;
int i;
- if ( m_main->RetMovieLock() ||
- m_main->RetEditLock() ||
- m_engine->RetPause() ) return;
+ if ( m_main->GetMovieLock() ||
+ m_main->GetEditLock() ||
+ m_engine->GetPause() ) return;
pPrev = m_main->DeselectAll();
@@ -299,12 +285,12 @@ void CMainShort::SelectNext()
{
if ( m_shortcuts[i] == pPrev )
{
- if ( m_shortcuts[++i] == 0 ) i = 1;
+ if ( m_shortcuts[++i] == nullptr ) i = 1;
break;
}
}
- if ( i == 20 || m_shortcuts[i] == 0 )
+ if ( i == 20 || m_shortcuts[i] == nullptr )
{
m_main->SelectHuman();
}
@@ -325,13 +311,13 @@ CObject* CMainShort::DetectShort(Math::Point pos)
for ( i=0 ; i<20 ; i++ )
{
- if ( m_shortcuts[i] == 0 ) continue;
+ if ( m_shortcuts[i] == nullptr ) continue;
pc = m_interface->SearchControl(table_sc_em[i]);
if ( pc != 0 )
{
- cpos = pc->RetPos();
- cdim = pc->RetDim();
+ cpos = pc->GetPos();
+ cdim = pc->GetDim();
if ( pos.x >= cpos.x &&
pos.x <= cpos.x+cdim.x &&
@@ -347,17 +333,17 @@ CObject* CMainShort::DetectShort(Math::Point pos)
// Reports the object with the mouse hovers over.
-void CMainShort::SetHilite(CObject* pObj)
+void CMainShort::SetHighlight(CObject* pObj)
{
CControl* pc;
int i;
for ( i=0 ; i<20 ; i++ )
{
- if ( m_shortcuts[i] == 0 ) continue;
+ if ( m_shortcuts[i] == nullptr ) continue;
pc = m_interface->SearchControl(table_sc_em[i]);
- if ( pc == 0 ) continue;
+ if ( pc == nullptr ) continue;
if ( m_shortcuts[i] == pObj )
{
@@ -372,3 +358,5 @@ void CMainShort::SetHilite(CObject* pObj)
}
}
+}
+
diff --git a/src/ui/mainshort.h b/src/ui/mainshort.h
index f260f0e..e97bdcc 100644
--- a/src/ui/mainshort.h
+++ b/src/ui/mainshort.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,45 +19,41 @@
#pragma once
-
+#include "ui/interface.h"
#include "common/event.h"
#include "math/point.h"
+#include "object/object.h"
+#include "graphics/engine/engine.h"
-
-class CInstanceManager;
-class CD3DEngine;
-class CInterface;
-class CRobotMain;
-class CObject;
-
+namespace Ui {
class CMainShort
{
-public:
- CMainShort(CInstanceManager* iMan);
- ~CMainShort();
-
- void SetMode(bool bBuilding);
- void FlushShortcuts();
- bool CreateShortcuts();
- bool UpdateShortcuts();
- void SelectShortcut(EventMsg event);
- void SelectNext();
- CObject* DetectShort(Math::Point pos);
- void SetHilite(CObject* pObj);
-
-protected:
-
-protected:
- CInstanceManager* m_iMan;
- CEvent* m_event;
- CD3DEngine* m_engine;
- CInterface* m_interface;
- CRobotMain* m_main;
-
- CObject* m_shortcuts[20];
- bool m_bBuilding;
+ public:
+ CMainShort();
+ ~CMainShort();
+
+ void SetMode(bool bBuilding);
+ void FlushShortcuts();
+ bool CreateShortcuts();
+ bool UpdateShortcuts();
+ void SelectShortcut(EventType event);
+ void SelectNext();
+ CObject* DetectShort(Math::Point pos);
+ void SetHighlight(CObject* pObj);
+
+ protected:
+
+ protected:
+ CInstanceManager* m_iMan;
+ CEvent* m_event;
+ Gfx::CEngine* m_engine;
+ CInterface* m_interface;
+ CRobotMain* m_main;
+
+ CObject* m_shortcuts[20];
+ bool m_bBuilding;
};
-
+}
diff --git a/src/ui/map.cpp b/src/ui/map.cpp
index a74e557..3a3d30f 100644
--- a/src/ui/map.cpp
+++ b/src/ui/map.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,34 +18,20 @@
// map.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "math/geometry.h"
-#include "old/d3dengine.h"
-#include "common/event.h"
-#include "old/math3d.h"
-#include "old/terrain.h"
-#include "old/water.h"
-#include "object/object.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "object/robotmain.h"
-#include "common/iman.h"
#include "ui/map.h"
+#include <string.h>
+namespace Ui {
// Object's constructor.
-CMap::CMap(CInstanceManager* iMan) : CControl(iMan)
+CMap::CMap() : CControl()
{
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_terrain = (CTerrain*)m_iMan->SearchInstance(CLASS_TERRAIN);
- m_water = (CWater*)m_iMan->SearchInstance(CLASS_WATER);
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_terrain = static_cast<Gfx::CTerrain*>(m_iMan->SearchInstance(CLASS_TERRAIN));
+ m_water = static_cast<Gfx::CWater*>(m_iMan->SearchInstance(CLASS_WATER));
m_bEnable = true;
m_time = 0.0f;
@@ -61,9 +48,9 @@ CMap::CMap(CInstanceManager* iMan) : CControl(iMan)
m_waterColor.g = 0.80f;
m_waterColor.b = 1.00f; // blue
- m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f;
+ m_half = m_terrain->GetMosaicCount() * m_terrain->GetBrickCount() * m_terrain->GetBrickSize() / 2.0f;
- m_hiliteRank = -1;
+ m_highlightRank = -1;
FlushObject();
m_fixImage[0] = 0;
@@ -81,9 +68,10 @@ CMap::~CMap()
// Creates a new button.
-bool CMap::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CMap::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if (eventMsg == EVENT_NULL)
+ eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
return true;
@@ -96,7 +84,7 @@ void CMap::SetOffset(float ox, float oy)
{
m_offset.x = ox;
m_offset.y = oy;
- m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f;
+ m_half = m_terrain->GetMosaicCount() * m_terrain->GetBrickCount() * m_terrain->GetBrickSize() / 2.0f;
}
// Choice of the global angle of rotation.
@@ -131,10 +119,10 @@ void CMap::SetDebug(bool bDebug)
void CMap::SetZoom(float value)
{
m_zoom = value;
- m_half = m_terrain->RetMosaic()*m_terrain->RetBrick()*m_terrain->RetSize()/2.0f;
+ m_half = m_terrain->GetMosaicCount() * m_terrain->GetBrickCount() * m_terrain->GetBrickSize() / 2.0f;
}
-float CMap::RetZoom()
+float CMap::GetZoom()
{
return m_zoom;
}
@@ -149,7 +137,7 @@ void CMap::SetEnable(bool bEnable)
SetState(STATE_DEAD, !bEnable);
}
-bool CMap::RetEnable()
+bool CMap::GetEnable()
{
return m_bEnable;
}
@@ -157,14 +145,14 @@ bool CMap::RetEnable()
// Choosing the color of the soil.
-void CMap::SetFloorColor(D3DCOLORVALUE color)
+void CMap::SetFloorColor(Gfx::Color color)
{
m_floorColor = color;
}
// Choosing the color of the water.
-void CMap::SetWaterColor(D3DCOLORVALUE color)
+void CMap::SetWaterColor(Gfx::Color color)
{
m_waterColor = color;
}
@@ -172,14 +160,14 @@ void CMap::SetWaterColor(D3DCOLORVALUE color)
// Specifies a fixed image in place of the drawing of the relief.
-void CMap::SetFixImage(char *filename)
+void CMap::SetFixImage(const char *filename)
{
strcpy(m_fixImage, filename);
}
// Whether to use a still image.
-bool CMap::RetFixImage()
+bool CMap::GetFixImage()
{
return (m_fixImage[0] != 0);
}
@@ -189,31 +177,25 @@ bool CMap::RetFixImage()
bool CMap::EventProcess(const Event &event)
{
- bool bInMap;
+ bool bInMap;
- if ( (m_state & STATE_VISIBLE) == 0 ) return true;
+ if ( (m_state & STATE_VISIBLE) == 0 )
+ return true;
CControl::EventProcess(event);
- if ( event.event == EVENT_FRAME )
- {
+ if ( event.type == EVENT_FRAME )
m_time += event.rTime;
- }
- if ( event.event == EVENT_MOUSEMOVE && Detect(event.pos) )
- {
- m_engine->SetMouseType(D3DMOUSENORM);
- if ( DetectObject(event.pos, bInMap) != 0 )
- {
- m_engine->SetMouseType(D3DMOUSEHAND);
- }
+ if ( event.type == EVENT_MOUSE_MOVE && Detect(event.pos) ) {
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
+ if ( DetectObject(event.mouseMove.pos, bInMap) != 0 )
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_HAND);
}
- if ( event.event == EVENT_LBUTTONDOWN )
- {
- if ( CControl::Detect(event.pos) )
- {
- SelectObject(event.pos);
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN && event.mouseButton.button == 1 ) {
+ if ( CControl::Detect(event.mouseButton.pos) ) {
+ SelectObject(event.mouseButton.pos);
return false;
}
}
@@ -227,7 +209,7 @@ Math::Point CMap::AdjustOffset(Math::Point offset)
{
float limit;
- limit = m_half - m_half/m_zoom;
+ limit = m_half - m_half / m_zoom;
if ( offset.x < -limit ) offset.x = -limit;
if ( offset.x > limit ) offset.x = limit;
if ( offset.y < -limit ) offset.y = -limit;
@@ -238,21 +220,20 @@ Math::Point CMap::AdjustOffset(Math::Point offset)
// Indicates the object with the mouse hovers over.
-void CMap::SetHilite(CObject* pObj)
+void CMap::SetHighlight(CObject* pObj)
{
- int i;
-
- m_hiliteRank = -1;
- if ( m_bToy || m_fixImage[0] != 0 ) return; // card with still image?
- if ( pObj == 0 ) return;
+ m_highlightRank = -1;
+ if ( m_bToy || m_fixImage[0] != 0 )
+ return; // card with still image?
+ if ( pObj == nullptr )
+ return;
- for ( i=0 ; i<MAPMAXOBJECT ; i++ )
- {
- if ( !m_map[i].bUsed ) continue;
+ for (int i = 0; i < MAPMAXOBJECT; i++) {
+ if ( !m_map[i].bUsed )
+ continue;
- if ( m_map[i].object == pObj )
- {
- m_hiliteRank = i;
+ if ( m_map[i].object == pObj ) {
+ m_highlightRank = i;
break;
}
}
@@ -262,39 +243,43 @@ void CMap::SetHilite(CObject* pObj)
CObject* CMap::DetectObject(Math::Point pos, bool &bInMap)
{
- float dist, min;
- int i, best;
+ float dist, min;
+ int best;
bInMap = false;
- if ( pos.x < m_pos.x ||
- pos.y < m_pos.y ||
- pos.x > m_pos.x+m_dim.x ||
- pos.y > m_pos.y+m_dim.y ) return 0;
+ if ( pos.x < m_pos.x ||
+ pos.y < m_pos.y ||
+ pos.x > m_pos.x + m_dim.x ||
+ pos.y > m_pos.y + m_dim.y )
+ return 0;
bInMap = true;
- pos.x = (pos.x-m_pos.x)/m_dim.x*256.0f;
- pos.y = (pos.y-m_pos.y)/m_dim.y*256.0f; // 0..256
- pos.x = (pos.x-128.0f)*m_half/(m_zoom*128.0f)+m_offset.x;
- pos.y = (pos.y-128.0f)*m_half/(m_zoom*128.0f)+m_offset.y;
+ pos.x = (pos.x - m_pos.x) / m_dim.x * 256.0f;
+ pos.y = (pos.y - m_pos.y) / m_dim.y * 256.0f; // 0..256
+ pos.x = (pos.x - 128.0f) * m_half / (m_zoom * 128.0f) + m_offset.x;
+ pos.y = (pos.y - 128.0f) * m_half / (m_zoom * 128.0f) + m_offset.y;
min = 10000.0f;
best = -1;
- for ( i=MAPMAXOBJECT-1 ; i>=0 ; i-- )
- {
- if ( !m_map[i].bUsed ) continue;
- if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar ) continue;
- if ( m_map[i].color == MAPCOLOR_ALIEN && !m_bRadar ) continue;
-
- dist = Math::Point(m_map[i].pos.x-pos.x, m_map[i].pos.y-pos.y).Length();
- if ( dist > m_half/m_zoom*8.0f/100.0f ) continue; // too far?
- if ( dist < min )
- {
+ for (int i = MAPMAXOBJECT - 1; i >= 0; i--) {
+ if ( !m_map[i].bUsed )
+ continue;
+ if ( m_map[i].color == MAPCOLOR_BBOX && !m_bRadar )
+ continue;
+ if ( m_map[i].color == MAPCOLOR_ALIEN && !m_bRadar )
+ continue;
+
+ dist = Math::Point(m_map[i].pos.x - pos.x, m_map[i].pos.y - pos.y).Length();
+ if ( dist > m_half / m_zoom * 8.0f / 100.0f )
+ continue; // too far?
+ if ( dist < min ) {
min = dist;
best = i;
}
}
- if ( best == -1 ) return 0;
+ if ( best == -1 )
+ return 0;
return m_map[best].object;
}
@@ -302,14 +287,12 @@ CObject* CMap::DetectObject(Math::Point pos, bool &bInMap)
void CMap::SelectObject(Math::Point pos)
{
- CObject *pObj;
- bool bInMap;
+ CObject *pObj;
+ bool bInMap;
pObj = DetectObject(pos, bInMap);
if ( pObj != 0 )
- {
m_main->SelectObject(pObj);
- }
}
@@ -318,34 +301,31 @@ void CMap::SelectObject(Math::Point pos)
void CMap::Draw()
{
Math::Point uv1, uv2;
- int i;
+ int i;
- if ( (m_state & STATE_VISIBLE) == 0 ) return;
+ if ( (m_state & STATE_VISIBLE) == 0 )
+ return;
CControl::Draw(); // draws the bottom (button)
- if ( !m_bEnable ) return;
+ if ( !m_bEnable )
+ return;
- if ( m_fixImage[0] == 0 && m_map[MAPMAXOBJECT-1].bUsed )
- {
- m_offset = AdjustOffset(m_map[MAPMAXOBJECT-1].pos);
- }
+ if ( m_fixImage[0] == 0 && m_map[MAPMAXOBJECT - 1].bUsed )
+ m_offset = AdjustOffset(m_map[MAPMAXOBJECT - 1].pos);
- if ( m_fixImage[0] == 0 ) // drawing of the relief?
- {
- m_engine->SetTexture("map.tga");
- m_engine->SetState(D3DSTATENORMAL);
- uv1.x = 0.5f+(m_offset.x-(m_half/m_zoom))/(m_half*2.0f);
- uv1.y = 0.5f-(m_offset.y+(m_half/m_zoom))/(m_half*2.0f);
- uv2.x = 0.5f+(m_offset.x+(m_half/m_zoom))/(m_half*2.0f);
- uv2.y = 0.5f-(m_offset.y-(m_half/m_zoom))/(m_half*2.0f);
+ if ( m_fixImage[0] == 0 ) { // drawing of the relief?
+ m_engine->SetTexture("map.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
+ uv1.x = 0.5f + (m_offset.x - (m_half / m_zoom)) / (m_half * 2.0f);
+ uv1.y = 0.5f - (m_offset.y + (m_half / m_zoom)) / (m_half * 2.0f);
+ uv2.x = 0.5f + (m_offset.x + (m_half / m_zoom)) / (m_half * 2.0f);
+ uv2.y = 0.5f - (m_offset.y - (m_half / m_zoom)) / (m_half * 2.0f);
DrawVertex(uv1, uv2, 0.97f); // drawing the map
- }
- else // still image?
- {
+ } else { // still image?
m_engine->LoadTexture(m_fixImage);
m_engine->SetTexture(m_fixImage);
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f;
uv1.y = 0.0f;
uv2.x = 1.0f;
@@ -355,33 +335,28 @@ void CMap::Draw()
i = MAPMAXOBJECT-1;
if ( m_map[i].bUsed ) // selection:
- {
DrawFocus(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color);
- }
- for ( i=0 ; i<m_totalFix ; i++ ) // fixed objects:
- {
- if ( i == m_hiliteRank ) continue;
+ for ( i=0 ; i<m_totalFix ; i++ ) { // fixed objects:
+ if ( i == m_highlightRank )
+ continue;
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false);
}
- for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) // moving objects:
- {
- if ( i == m_hiliteRank ) continue;
+ for ( i=MAPMAXOBJECT-2 ; i>m_totalMove ; i-- ) { // moving objects:
+ if ( i == m_highlightRank )
+ continue;
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, false);
}
i = MAPMAXOBJECT-1;
- if ( m_map[i].bUsed && i != m_hiliteRank ) // selection:
- {
+ if ( m_map[i].bUsed && i != m_highlightRank ) // selection:
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, true, false);
- }
- if ( m_hiliteRank != -1 && m_map[m_hiliteRank].bUsed )
- {
- i = m_hiliteRank;
+ if ( m_highlightRank != -1 && m_map[m_highlightRank].bUsed ) {
+ i = m_highlightRank;
DrawObject(m_map[i].pos, m_map[i].dir, m_map[i].type, m_map[i].color, false, true);
- DrawHilite(m_map[i].pos);
+ DrawHighlight(m_map[i].pos);
}
}
@@ -392,35 +367,32 @@ Math::Point CMap::MapInter(Math::Point pos, float dir)
Math::Point p1;
float limit;
- p1.x = pos.x+1.0f;
+ p1.x = pos.x + 1.0f;
p1.y = pos.y;
p1 = Math::RotatePoint(pos, dir, p1);
p1.x -= pos.x;
p1.y -= pos.y;
- limit = m_mapPos.x+m_mapDim.x-pos.x;
- if ( p1.x > limit ) // exceeds the right?
- {
+ limit = m_mapPos.x + m_mapDim.x - pos.x;
+ if ( p1.x > limit ) { // exceeds the right?
p1.y = limit*p1.y/p1.x;
p1.x = limit;
}
- limit = m_mapPos.y*0.75f+m_mapDim.y*0.75f-pos.y;
- if ( p1.y > limit ) // exceeds the top?
- {
- p1.x = limit*p1.x/p1.y;
+ limit = m_mapPos.y * 0.75f + m_mapDim.y * 0.75f - pos.y;
+ if ( p1.y > limit ) { // exceeds the top?
+ p1.x = limit * p1.x / p1.y;
p1.y = limit;
}
- limit = m_mapPos.x-pos.x;
- if ( p1.x < limit ) // exceeds the left?
- {
- p1.y = limit*p1.y/p1.x;
+ limit = m_mapPos.x - pos.x;
+ if ( p1.x < limit ) { // exceeds the left?
+ p1.y = limit * p1.y / p1.x;
p1.x = limit;
}
- limit = m_mapPos.y*0.75f-pos.y;
- if ( p1.y < limit ) // exceeds the bottom?
- {
- p1.x = limit*p1.x/p1.y;
+
+ limit = m_mapPos.y * 0.75f - pos.y;
+ if ( p1.y < limit ) { // exceeds the bottom?
+ p1.x = limit * p1.x / p1.y;
p1.y = limit;
}
@@ -454,7 +426,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
pos.x = m_mapPos.x+m_mapDim.x*pos.x;
pos.y = m_mapPos.y*0.75f+m_mapDim.y*pos.y*0.75f;
- focus = m_engine->RetFocus();
+ focus = m_engine->GetFocus();
dir += Math::PI/2.0f;
aMin = Math::NormAngle(dir-Math::PI/4.0f*focus);
aMax = Math::NormAngle(dir+Math::PI/4.0f*focus);
@@ -483,8 +455,8 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
uv2.x = 126.0f/256.0f;
uv2.y = 255.0f/256.0f;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
bEnding = false;
do
@@ -492,7 +464,7 @@ void CMap::DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color
quart ++;
aOct = limit[quart%4];
if ( quart >= 4 ) aOct += Math::PI*2.0f;
- if ( aOct >= aMax-Math::VERY_SMALL )
+ if ( aOct >= aMax - Math::VERY_SMALL_NUM )
{
aOct = aMax;
bEnding = true;
@@ -543,8 +515,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
return; // flashes
}
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
if ( bUp )
{
uv1.x = 160.5f/256.0f; // yellow triangle ^
@@ -686,8 +658,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
{
if ( bSelect )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
if ( m_bToy )
{
uv1.x = 164.5f/256.0f; // black pentagon
@@ -712,8 +684,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
{
if ( m_bRadar )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 64.5f/256.0f; // blue triangle
uv1.y = 240.5f/256.0f;
uv2.x = 79.0f/256.0f;
@@ -732,8 +704,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
if ( color == MAPCOLOR_WAYPOINTb )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 192.5f/256.0f; // blue cross
uv1.y = 240.5f/256.0f;
uv2.x = 207.0f/256.0f;
@@ -742,8 +714,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
}
if ( color == MAPCOLOR_WAYPOINTr )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 208.5f/256.0f; // red cross
uv1.y = 240.5f/256.0f;
uv2.x = 223.0f/256.0f;
@@ -752,8 +724,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
}
if ( color == MAPCOLOR_WAYPOINTg )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 224.5f/256.0f; // green cross
uv1.y = 240.5f/256.0f;
uv2.x = 239.0f/256.0f;
@@ -762,8 +734,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
}
if ( color == MAPCOLOR_WAYPOINTy )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 240.5f/256.0f; // yellow cross
uv1.y = 240.5f/256.0f;
uv2.x = 255.0f/256.0f;
@@ -772,8 +744,8 @@ void CMap::DrawObject(Math::Point pos, float dir, ObjectType type, MapColor colo
}
if ( color == MAPCOLOR_WAYPOINTv )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 192.5f/256.0f; // violet cross
uv1.y = 224.5f/256.0f;
uv2.x = 207.0f/256.0f;
@@ -793,8 +765,8 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
dp = 0.5f/256.0f;
- m_engine->SetTexture("button3.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button3.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
if ( color == MAPCOLOR_MOVE )
{
uv1.x = 160.0f/256.0f; // blue
@@ -877,7 +849,7 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
if ( type == OBJECT_TEEN34 ) icon = 48; // stone
if ( icon == -1 ) return;
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = (32.0f/256.0f)*(icon%8);
uv1.y = (32.0f/256.0f)*(icon/8);
uv2.x = uv1.x+32.0f/256.0f;
@@ -892,22 +864,15 @@ void CMap::DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color,
// Draw the object with the mouse hovers over.
-void CMap::DrawHilite(Math::Point pos)
+void CMap::DrawHighlight(Math::Point pos)
{
- Math::Point dim, uv1, uv2;
- bool bOut, bUp, bDown, bLeft, bRight;
+ Math::Point dim, uv1, uv2;
if ( m_bToy || m_fixImage[0] != 0 ) return; // map with still image?
pos.x = (pos.x-m_offset.x)*(m_zoom*0.5f)/m_half+0.5f;
pos.y = (pos.y-m_offset.y)*(m_zoom*0.5f)/m_half+0.5f;
- bOut = bUp = bDown = bLeft = bRight = false;
- if ( pos.x < 0.06f ) { pos.x = 0.02f; bOut = bLeft = true; }
- if ( pos.y < 0.06f ) { pos.y = 0.02f; bOut = bDown = true; }
- if ( pos.x > 0.94f ) { pos.x = 0.98f; bOut = bRight = true; }
- if ( pos.y > 0.94f ) { pos.y = 0.98f; bOut = bUp = true; }
-
pos.x = m_mapPos.x+m_mapDim.x*pos.x;
pos.y = m_mapPos.y+m_mapDim.y*pos.y;
dim.x = 2.0f/128.0f*0.75f;
@@ -915,8 +880,8 @@ void CMap::DrawHilite(Math::Point pos)
dim.x *= 2.0f+cosf(m_time*8.0f)*0.5f;
dim.y *= 2.0f+cosf(m_time*8.0f)*0.5f;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 160.5f/256.0f; // hilite
uv1.y = 224.5f/256.0f;
uv2.x = 175.0f/256.0f;
@@ -930,19 +895,19 @@ void CMap::DrawHilite(Math::Point pos)
void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2)
{
- LPDIRECT3DDEVICE7 device;
- D3DVERTEX2 vertex[3]; // 1 triangle
+ Gfx::CDevice* device;
+ Gfx::VertexTex2 vertex[3]; // 1 triangle
Math::Vector n;
- device = m_engine->RetD3DDevice();
+ device = m_engine->GetDevice();
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y);
- vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y);
- vertex[2] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y);
+ vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
+ vertex[1] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
+ vertex[2] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
- device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL);
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3);
m_engine->AddStatisticTriangle(1);
}
@@ -950,28 +915,28 @@ void CMap::DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Po
void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2)
{
- LPDIRECT3DDEVICE7 device;
- D3DVERTEX2 vertex[5]; // 1 pentagon
+ Gfx::CDevice* device;
+ Gfx::VertexTex2 vertex[5]; // 1 pentagon
Math::Vector n;
- device = m_engine->RetD3DDevice();
+ device = m_engine->GetDevice();
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
#if 1
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv1.y);
- vertex[1] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv2.y);
- vertex[2] = D3DVERTEX2(Math::Vector(p5.x, p5.y, 0.0f), n, uv2.x,uv2.y);
- vertex[3] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv2.x,uv2.y);
- vertex[4] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x,uv2.y);
+ vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
+ vertex[1] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
+ vertex[2] = Gfx::VertexTex2(Math::Vector(p5.x, p5.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
+ vertex[3] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
+ vertex[4] = Gfx::VertexTex2(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 5, NULL);
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 5);
#else
- vertex[0] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv1.x,uv1.y);
- vertex[1] = D3DVERTEX2(Math::Vector(p3.x, p3.y, 0.0f), n, uv1.x,uv2.y);
- vertex[2] = D3DVERTEX2(Math::Vector(p4.x, p4.y, 0.0f), n, uv2.x,uv2.y);
+ vertex[0] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
+ vertex[1] = Gfx::VertexTex2(Math::Vector(p3.x, p3.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
+ vertex[2] = Gfx::VertexTex2(Math::Vector(p4.x, p4.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
- device->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_VERTEX2, vertex, 3, NULL);
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLES, vertex, 3);
#endif
m_engine->AddStatisticTriangle(3);
}
@@ -980,12 +945,12 @@ void CMap::DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point
void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
{
- LPDIRECT3DDEVICE7 device;
- D3DVERTEX2 vertex[4]; // 2 triangles
+ Gfx::CDevice* device;
+ Gfx::VertexTex2 vertex[4]; // 2 triangles
Math::Point p1, p2, c;
Math::Vector n;
- device = m_engine->RetD3DDevice();
+ device = m_engine->GetDevice();
p1.x = m_pos.x;
p1.y = m_pos.y;
@@ -1007,12 +972,12 @@ void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, uv1.x,uv2.y);
- vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, uv1.x,uv1.y);
- vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, uv2.x,uv2.y);
- vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, uv2.x,uv1.y);
+ vertex[0] = Gfx::VertexTex2(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(uv1.x,uv2.y));
+ vertex[1] = Gfx::VertexTex2(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(uv1.x,uv1.y));
+ vertex[2] = Gfx::VertexTex2(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(uv2.x,uv2.y));
+ vertex[3] = Gfx::VertexTex2(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(uv2.x,uv1.y));
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2);
}
@@ -1021,30 +986,34 @@ void CMap::DrawVertex(Math::Point uv1, Math::Point uv2, float zoom)
void CMap::UpdateTerrain()
{
- D3DCOLORVALUE color;
+ Gfx::Color color;
Math::Vector pos;
float scale, water, level, intensity;
int x, y;
if ( m_fixImage[0] != 0 ) return; // still image?
- if ( !m_engine->OpenImage("map.tga") ) return;
- scale = m_terrain->RetScaleRelief();
- water = m_water->RetLevel();
+ // TODO: map texture manipulation
+ return;
+
+ // if ( !m_engine->OpenImage("map.png") ) return;
+
+ scale = m_terrain->GetReliefScale();
+ water = m_water->GetLevel();
color.a = 0.0f;
for ( y=0 ; y<256 ; y++ )
{
for ( x=0 ; x<256 ; x++ )
{
- pos.x = ((float)x-128.0f)*m_half/128.0f;
- pos.z = -((float)y-128.0f)*m_half/128.0f;
+ pos.x = (static_cast<float>(x)-128.0f)*m_half/128.0f;
+ pos.z = -(static_cast<float>(y)-128.0f)*m_half/128.0f;
pos.y = 0.0f;
if ( pos.x >= -m_half && pos.x <= m_half &&
pos.z >= -m_half && pos.z <= m_half )
{
- level = m_terrain->RetFloorLevel(pos, true)/scale;
+ level = m_terrain->GetFloorLevel(pos, true)/scale;
}
else
{
@@ -1068,43 +1037,47 @@ void CMap::UpdateTerrain()
color.b = m_waterColor.b + (intensity-0.5f);
}
- m_engine->SetDot(x, y, color);
+ //m_engine->SetDot(x, y, color);
}
}
- m_engine->CopyImage(); // copy the ground drawing
- m_engine->CloseImage();
+ //m_engine->CopyImage(); // copy the ground drawing
+ //m_engine->CloseImage();
}
// Updates the field in the map.
void CMap::UpdateTerrain(int bx, int by, int ex, int ey)
{
- D3DCOLORVALUE color;
+ Gfx::Color color;
Math::Vector pos;
float scale, water, level, intensity;
int x, y;
if ( m_fixImage[0] != 0 ) return; // still image?
- if ( !m_engine->OpenImage("map.tga") ) return;
- m_engine->LoadImage();
- scale = m_terrain->RetScaleRelief();
- water = m_water->RetLevel();
+ // TODO: map texture manipulation
+ return;
+
+ //if ( !m_engine->OpenImage("map.png") ) return;
+ //m_engine->LoadImage();
+
+ scale = m_terrain->GetReliefScale();
+ water = m_water->GetLevel();
color.a = 0.0f;
for ( y=by ; y<ey ; y++ )
{
for ( x=bx ; x<ex ; x++ )
{
- pos.x = ((float)x-128.0f)*m_half/128.0f;
- pos.z = -((float)y-128.0f)*m_half/128.0f;
+ pos.x = (static_cast<float>(x)-128.0f)*m_half/128.0f;
+ pos.z = -(static_cast<float>(y)-128.0f)*m_half/128.0f;
pos.y = 0.0f;
if ( pos.x >= -m_half && pos.x <= m_half &&
pos.z >= -m_half && pos.z <= m_half )
{
- level = m_terrain->RetFloorLevel(pos, true)/scale;
+ level = m_terrain->GetFloorLevel(pos, true)/scale;
}
else
{
@@ -1128,12 +1101,12 @@ void CMap::UpdateTerrain(int bx, int by, int ex, int ey)
color.b = m_waterColor.b + (intensity-0.5f);
}
- m_engine->SetDot(x, y, color);
+ //m_engine->SetDot(x, y, color);
}
}
- m_engine->CopyImage(); // copy the ground drawing
- m_engine->CloseImage();
+ //m_engine->CopyImage(); // copy the ground drawing
+ //m_engine->CloseImage();
}
@@ -1145,7 +1118,7 @@ void CMap::FlushObject()
m_totalFix = 0; // object index fixed
m_totalMove = MAPMAXOBJECT-2; // moving vehicles index
- m_bRadar = m_main->RetCheatRadar(); // no radar
+ //m_bRadar = m_main->GetCheatRadar(); // no radar
for ( i=0 ; i<MAPMAXOBJECT ; i++ )
{
@@ -1166,14 +1139,14 @@ void CMap::UpdateObject(CObject* pObj)
if ( !m_bEnable ) return;
if ( m_totalFix >= m_totalMove ) return; // full table?
- if ( !pObj->RetActif() ) return;
- if ( !pObj->RetSelectable() ) return;
- if ( pObj->RetProxyActivate() ) return;
- if ( pObj->RetTruck() != 0 ) return;
+ if ( !pObj->GetActif() ) return;
+ if ( !pObj->GetSelectable() ) return;
+ if ( pObj->GetProxyActivate() ) return;
+ if ( pObj->GetTruck() != 0 ) return;
- type = pObj->RetType();
- pos = pObj->RetPosition(0);
- dir = -(pObj->RetAngleY(0)+Math::PI/2.0f);
+ type = pObj->GetType();
+ pos = pObj->GetPosition(0);
+ dir = -(pObj->GetAngleY(0)+Math::PI/2.0f);
if ( m_angle != 0.0f )
{
@@ -1299,7 +1272,7 @@ void CMap::UpdateObject(CObject* pObj)
color != MAPCOLOR_MOVE ) return;
}
- if ( pObj->RetSelect() )
+ if ( pObj->GetSelect() )
{
m_map[MAPMAXOBJECT-1].type = type;
m_map[MAPMAXOBJECT-1].object = pObj;
@@ -1337,3 +1310,4 @@ void CMap::UpdateObject(CObject* pObj)
}
}
+}
diff --git a/src/ui/map.h b/src/ui/map.h
index efdf54b..9e1767c 100644
--- a/src/ui/map.h
+++ b/src/ui/map.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -20,15 +21,23 @@
#include "ui/control.h"
+
#include "object/object.h"
+#include "object/robotmain.h"
+
+#include "common/event.h"
+#include "common/iman.h"
+#include "graphics/engine/terrain.h"
+#include "graphics/engine/water.h"
+#include "graphics/engine/engine.h"
+#include "graphics/core/device.h"
+#include "graphics/core/vertex.h"
-class CD3DEngine;
-class CTerrain;
-class CWater;
-class CRobotMain;
+#include "math/geometry.h"
+namespace Ui {
const int MAPMAXOBJECT = 100;
@@ -61,77 +70,78 @@ struct MapObject
class CMap : public CControl
{
-public:
- CMap(CInstanceManager* iMan);
- ~CMap();
-
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- bool EventProcess(const Event &event);
- void Draw();
-
- void UpdateTerrain();
- void UpdateTerrain(int bx, int by, int ex, int ey);
-
- void SetFixImage(char *filename);
- bool RetFixImage();
-
- void SetOffset(float ox, float oy);
- void SetAngle(float angle);
- void SetMode(int mode);
- void SetToy(bool bToy);
- void SetDebug(bool bDebug);
-
- void SetZoom(float value);
- float RetZoom();
-
- void SetEnable(bool bEnable);
- bool RetEnable();
-
- void SetFloorColor(D3DCOLORVALUE color);
- void SetWaterColor(D3DCOLORVALUE color);
-
- void FlushObject();
- void UpdateObject(CObject* pObj);
-
- CObject* DetectObject(Math::Point pos, bool &bInMap);
- void SetHilite(CObject* pObj);
-
-protected:
- Math::Point AdjustOffset(Math::Point offset);
- void SelectObject(Math::Point pos);
- Math::Point MapInter(Math::Point pos, float dir);
- void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color);
- void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
- void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
- void DrawHilite(Math::Point pos);
- void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2);
- void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2);
- void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom);
-
-protected:
- CTerrain* m_terrain;
- CWater* m_water;
- CRobotMain* m_main;
-
- bool m_bEnable;
- float m_time;
- float m_half;
- float m_zoom;
- Math::Point m_offset;
- float m_angle;
- D3DCOLORVALUE m_floorColor;
- D3DCOLORVALUE m_waterColor;
- MapObject m_map[MAPMAXOBJECT];
- int m_totalFix;
- int m_totalMove;
- int m_hiliteRank;
- Math::Point m_mapPos;
- Math::Point m_mapDim;
- bool m_bRadar;
- char m_fixImage[100];
- int m_mode;
- bool m_bToy;
- bool m_bDebug;
+ public:
+ CMap();
+ ~CMap();
+
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ bool EventProcess(const Event &event);
+ void Draw();
+
+ void UpdateTerrain();
+ void UpdateTerrain(int bx, int by, int ex, int ey);
+
+ void SetFixImage(const char *filename);
+ bool GetFixImage();
+
+ void SetOffset(float ox, float oy);
+ void SetAngle(float angle);
+ void SetMode(int mode);
+ void SetToy(bool bToy);
+ void SetDebug(bool bDebug);
+
+ void SetZoom(float value);
+ float GetZoom();
+
+ void SetEnable(bool bEnable);
+ bool GetEnable();
+
+ void SetFloorColor(Gfx::Color color);
+ void SetWaterColor(Gfx::Color color);
+
+ void FlushObject();
+ void UpdateObject(CObject* pObj);
+
+ CObject* DetectObject(Math::Point pos, bool &bInMap);
+ void SetHighlight(CObject* pObj);
+
+ protected:
+ Math::Point AdjustOffset(Math::Point offset);
+ void SelectObject(Math::Point pos);
+ Math::Point MapInter(Math::Point pos, float dir);
+ void DrawFocus(Math::Point pos, float dir, ObjectType type, MapColor color);
+ void DrawObject(Math::Point pos, float dir, ObjectType type, MapColor color, bool bSelect, bool bHilite);
+ void DrawObjectIcon(Math::Point pos, Math::Point dim, MapColor color, ObjectType type, bool bHilite);
+ void DrawHighlight(Math::Point pos);
+ void DrawTriangle(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point uv1, Math::Point uv2);
+ void DrawPenta(Math::Point p1, Math::Point p2, Math::Point p3, Math::Point p4, Math::Point p5, Math::Point uv1, Math::Point uv2);
+ void DrawVertex(Math::Point uv1, Math::Point uv2, float zoom);
+
+ protected:
+ Gfx::CTerrain* m_terrain;
+ Gfx::CWater* m_water;
+ CRobotMain* m_main;
+
+ bool m_bEnable;
+ float m_time;
+ float m_half;
+ float m_zoom;
+ Math::Point m_offset;
+ float m_angle;
+ Gfx::Color m_floorColor;
+ Gfx::Color m_waterColor;
+ MapObject m_map[MAPMAXOBJECT];
+ int m_totalFix;
+ int m_totalMove;
+ int m_highlightRank;
+ Math::Point m_mapPos;
+ Math::Point m_mapDim;
+ bool m_bRadar;
+ char m_fixImage[100];
+ int m_mode;
+ bool m_bToy;
+ bool m_bDebug;
};
+}
diff --git a/src/ui/scroll.cpp b/src/ui/scroll.cpp
index 051de8d..d3d0ed2 100644
--- a/src/ui/scroll.cpp
+++ b/src/ui/scroll.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -16,26 +17,21 @@
// scroll.cpp
+#include "ui/scroll.h"
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
+#include "graphics/engine/engine.h"
#include "ui/button.h"
-#include "ui/scroll.h"
+namespace Ui {
// Object's constructor.
-CScroll::CScroll(CInstanceManager* iMan) : CControl(iMan)
+CScroll::CScroll() : CControl()
{
m_buttonUp = 0;
m_buttonDown = 0;
@@ -61,9 +57,9 @@ CScroll::~CScroll()
// Creates a new button.
-bool CScroll::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CScroll::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
MoveAdjust();
@@ -102,20 +98,20 @@ void CScroll::MoveAdjust()
{
if ( m_buttonUp == 0 )
{
- m_buttonUp = new CButton(m_iMan);
- pc = (CButton*)m_buttonUp;
+ m_buttonUp = new CButton();
+ pc = m_buttonUp;
pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 49, EVENT_NULL);
pc->SetRepeat(true);
- m_eventUp = pc->RetEventMsg();
+ m_eventUp = pc->GetEventType();
}
if ( m_buttonDown == 0 )
{
- m_buttonDown = new CButton(m_iMan);
- pc = (CButton*)m_buttonDown;
+ m_buttonDown = new CButton();
+ pc = m_buttonDown;
pc->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), 50, EVENT_NULL);
pc->SetRepeat(true);
- m_eventDown = pc->RetEventMsg();
+ m_eventDown = pc->GetEventType();
}
}
@@ -213,66 +209,67 @@ bool CScroll::EventProcess(const Event &event)
if ( !m_buttonDown->EventProcess(event) ) return false;
}
- if ( event.event == m_eventUp && m_step > 0.0f )
+ if ( event.type == m_eventUp && m_step > 0.0f )
{
m_visibleValue -= m_step;
if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f;
AdjustGlint();
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
- if ( event.event == m_eventDown && m_step > 0.0f )
+ if ( event.type == m_eventDown && m_step > 0.0f )
{
m_visibleValue += m_step;
if ( m_visibleValue > 1.0f ) m_visibleValue = 1.0f;
AdjustGlint();
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
hButton = m_buttonUp?m_dim.x/0.75f:0.0f;
- if ( event.event == EVENT_LBUTTONDOWN &&
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
pos.y = m_pos.y+hButton;
dim.y = m_dim.y-hButton*2.0f;
pos.y += dim.y*(1.0f-m_visibleRatio)*(1.0f-m_visibleValue);
dim.y *= m_visibleRatio;
- if ( event.pos.y < pos.y ||
- event.pos.y > pos.y+dim.y ) // click outside cabin?
+ if ( event.mouseButton.pos.y < pos.y ||
+ event.mouseButton.pos.y > pos.y+dim.y ) // click outside cabin?
{
h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio);
- value = 1.0f-(event.pos.y-(m_pos.y+hButton+dim.y*0.5f))/h;
+ value = 1.0f-(event.mouseButton.pos.y-(m_pos.y+hButton+dim.y*0.5f))/h;
if ( value < 0.0f ) value = 0.0f;
if ( value > 1.0f ) value = 1.0f;
m_visibleValue = value;
AdjustGlint();
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
m_bCapture = true;
- m_pressPos = event.pos;
+ m_pressPos = event.mouseButton.pos;
m_pressValue = m_visibleValue;
}
}
- if ( event.event == EVENT_MOUSEMOVE && m_bCapture )
+ if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
h = (m_dim.y-hButton*2.0f)*(1.0f-m_visibleRatio);
if ( h != 0 )
{
- value = m_pressValue - (event.pos.y-m_pressPos.y)/h;
+ value = m_pressValue - (event.mouseMove.pos.y-m_pressPos.y)/h;
if ( value < 0.0f ) value = 0.0f;
if ( value > 1.0f ) value = 1.0f;
@@ -282,33 +279,35 @@ bool CScroll::EventProcess(const Event &event)
AdjustGlint();
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
}
}
- if ( event.event == EVENT_LBUTTONUP && m_bCapture )
+ if ( event.type == EVENT_MOUSE_BUTTON_UP &&
+ event.mouseButton.button == 1 &&
+ m_bCapture )
{
m_bCapture = false;
}
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELUP &&
- Detect(event.pos) &&
- m_buttonUp != 0 )
+ if (event.type == EVENT_MOUSE_WHEEL &&
+ event.mouseWheel.dir == WHEEL_UP &&
+ Detect(event.mouseWheel.pos) &&
+ m_buttonUp != 0)
{
Event newEvent = event;
- newEvent.event = m_buttonUp->RetEventMsg();
+ newEvent.type = m_buttonUp->GetEventType();
m_event->AddEvent(newEvent);
}
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELDOWN &&
- Detect(event.pos) &&
- m_buttonDown != 0 )
+ if (event.type == EVENT_MOUSE_WHEEL &&
+ event.mouseWheel.dir == WHEEL_DOWN &&
+ Detect(event.mouseWheel.pos) &&
+ m_buttonDown != 0)
{
Event newEvent = event;
- newEvent.event = m_buttonDown->RetEventMsg();
+ newEvent.type = m_buttonDown->GetEventType();
m_event->AddEvent(newEvent);
}
@@ -346,7 +345,7 @@ void CScroll::Draw()
dim.y *= m_visibleRatio;
DrawVertex(pos, dim, 2);
- n = (int)(dim.y*0.8f/0.012f);
+ n = static_cast<int>(dim.y*0.8f/0.012f);
if ( n < 1 ) n = 1;
if ( n > 5 ) n = 5;
@@ -380,8 +379,8 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
if ( icon == 0 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // yellow rectangle
uv1.y = 32.0f/256.0f;
uv2.x = 32.0f/256.0f;
@@ -390,8 +389,8 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 1 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // gray rectangle
uv1.y = 32.0f/256.0f;
uv2.x = 160.0f/256.0f;
@@ -400,8 +399,8 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 2 )
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; // blue rectangle
uv1.y = 0.0f/256.0f;
uv2.x = 96.0f/256.0f;
@@ -410,8 +409,8 @@ void CScroll::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 104.0f/256.0f; // blue line -
uv1.y = 32.0f/256.0f;
uv2.x = 128.0f/256.0f;
@@ -437,7 +436,7 @@ void CScroll::SetVisibleValue(float value)
AdjustGlint();
}
-float CScroll::RetVisibleValue()
+float CScroll::GetVisibleValue()
{
return m_visibleValue;
}
@@ -451,7 +450,7 @@ void CScroll::SetVisibleRatio(float value)
AdjustGlint();
}
-float CScroll::RetVisibleRatio()
+float CScroll::GetVisibleRatio()
{
return m_visibleRatio;
}
@@ -462,8 +461,9 @@ void CScroll::SetArrowStep(float step)
m_step = step;
}
-float CScroll::RetArrowStep()
+float CScroll::GetArrowStep()
{
return m_step;
}
+}
diff --git a/src/ui/scroll.h b/src/ui/scroll.h
index 6854e61..52b60bc 100644
--- a/src/ui/scroll.h
+++ b/src/ui/scroll.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -20,62 +21,63 @@
#include "ui/control.h"
+#include "common/event.h"
+namespace Ui {
-class CD3DEngine;
class CButton;
-
const float SCROLL_WIDTH = (15.0f/640.0f);
class CScroll : public CControl
{
-public:
- CScroll(CInstanceManager* iMan);
- ~CScroll();
+ public:
+ CScroll();
+ ~CScroll();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
- void SetPos(Math::Point pos);
- void SetDim(Math::Point dim);
+ void SetPos(Math::Point pos);
+ void SetDim(Math::Point dim);
- bool SetState(int state, bool bState);
- bool SetState(int state);
- bool ClearState(int state);
+ bool SetState(int state, bool bState);
+ bool SetState(int state);
+ bool ClearState(int state);
- bool EventProcess(const Event &event);
- void Draw();
+ bool EventProcess(const Event &event);
+ void Draw();
- void SetVisibleValue(float value);
- float RetVisibleValue();
+ void SetVisibleValue(float value);
+ float GetVisibleValue();
- void SetVisibleRatio(float value);
- float RetVisibleRatio();
+ void SetVisibleRatio(float value);
+ float GetVisibleRatio();
- void SetArrowStep(float step);
- float RetArrowStep();
+ void SetArrowStep(float step);
+ float GetArrowStep();
-protected:
- void MoveAdjust();
- void AdjustGlint();
- void DrawVertex(Math::Point pos, Math::Point dim, int icon);
+ protected:
+ void MoveAdjust();
+ void AdjustGlint();
+ void DrawVertex(Math::Point pos, Math::Point dim, int icon);
-protected:
- CButton* m_buttonUp;
- CButton* m_buttonDown;
+ protected:
+ CButton* m_buttonUp;
+ CButton* m_buttonDown;
- float m_visibleValue;
- float m_visibleRatio;
- float m_step;
+ float m_visibleValue;
+ float m_visibleRatio;
+ float m_step;
- bool m_bCapture;
- Math::Point m_pressPos;
- float m_pressValue;
+ bool m_bCapture;
+ Math::Point m_pressPos;
+ float m_pressValue;
- EventMsg m_eventUp;
- EventMsg m_eventDown;
+ EventType m_eventUp;
+ EventType m_eventDown;
};
+}
diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp
index fe9ca9b..c8d3890 100644
--- a/src/ui/shortcut.cpp
+++ b/src/ui/shortcut.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -16,25 +17,22 @@
// shortcut.cpp
+#include "ui/shortcut.h"
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
-#include "ui/shortcut.h"
-
+#include "graphics/engine/engine.h"
+#include "graphics/core/device.h"
+#include <math.h>
+namespace Ui {
// Object's constructor.
-CShortcut::CShortcut(CInstanceManager* iMan) : CControl(iMan)
+//CShortcut::CShortcut(CInstanceManager* iMan) : CControl(iMan)
+CShortcut::CShortcut() : CControl()
{
m_time = 0.0f;
}
@@ -48,11 +46,11 @@ CShortcut::~CShortcut()
// Creates a new button.
-bool CShortcut::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CShortcut::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
- CControl::Create(pos, dim, icon, eventMsg);
+ CControl::Create(pos, dim, icon, eventType);
return true;
}
@@ -63,17 +61,18 @@ bool CShortcut::EventProcess(const Event &event)
{
CControl::EventProcess(event);
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
m_time += event.rTime;
}
- if ( event.event == EVENT_LBUTTONDOWN )
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1)
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
@@ -92,24 +91,24 @@ void CShortcut::Draw()
icon = 0;
zoom = 0.8f;
- mode = D3DSTATETTw;
+ mode = Gfx::ENG_RSTATE_TTEXTURE_WHITE;
if ( m_state & STATE_HILIGHT )
{
icon = 4;
zoom = 0.9f;
- mode = D3DSTATENORMAL;
+ mode = Gfx::ENG_RSTATE_NORMAL;
}
if ( m_state & STATE_CHECK )
{
icon = 1;
zoom = 0.8f;
- mode = D3DSTATENORMAL;
+ mode = Gfx::ENG_RSTATE_NORMAL;
}
if ( m_state & STATE_PRESS )
{
icon = 1;
zoom = 1.0f;
- mode = D3DSTATENORMAL;
+ mode = Gfx::ENG_RSTATE_NORMAL;
}
if ( m_icon == 6 || m_icon == 7 ) // pause or film?
{
@@ -117,7 +116,7 @@ void CShortcut::Draw()
zoom = 1.0f;
}
- m_engine->SetTexture("button3.tga");
+ m_engine->SetTexture("button3.png");
if ( icon != -1 )
{
@@ -125,7 +124,7 @@ void CShortcut::Draw()
DrawVertex(icon, 0.95f);
}
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
DrawVertex(m_icon, zoom);
if ( m_state & STATE_FRAME )
@@ -133,8 +132,8 @@ void CShortcut::Draw()
Math::Point p1, p2, c, uv1, uv2;
float zoom, dp;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
zoom = 0.9f+sinf(m_time*8.0f)*0.1f;
@@ -173,8 +172,8 @@ void CShortcut::Draw()
Math::Point uv1, uv2;
float dp;
- m_engine->SetTexture("button3.tga");
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetTexture("button3.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 160.0f/256.0f;
uv1.y = 0.0f/256.0f;
@@ -195,13 +194,13 @@ void CShortcut::Draw()
void CShortcut::DrawVertex(int icon, float zoom)
{
- LPDIRECT3DDEVICE7 device;
- D3DVERTEX2 vertex[4]; // 2 triangles
+ Gfx::CDevice* device;
+ Gfx::Vertex vertex[4]; // 2 triangles
Math::Point p1, p2, c;
Math::Vector n;
float u1, u2, v1, v2, dp;
- device = m_engine->RetD3DDevice();
+ device = m_engine->GetDevice();
p1.x = m_pos.x;
p1.y = m_pos.y;
@@ -230,12 +229,13 @@ void CShortcut::DrawVertex(int icon, float zoom)
n = Math::Vector(0.0f, 0.0f, -1.0f); // normal
- vertex[0] = D3DVERTEX2(Math::Vector(p1.x, p1.y, 0.0f), n, u1,v2);
- vertex[1] = D3DVERTEX2(Math::Vector(p1.x, p2.y, 0.0f), n, u1,v1);
- vertex[2] = D3DVERTEX2(Math::Vector(p2.x, p1.y, 0.0f), n, u2,v2);
- vertex[3] = D3DVERTEX2(Math::Vector(p2.x, p2.y, 0.0f), n, u2,v1);
+ vertex[0] = Gfx::Vertex(Math::Vector(p1.x, p1.y, 0.0f), n, Math::Point(u1, v2));
+ vertex[1] = Gfx::Vertex(Math::Vector(p1.x, p2.y, 0.0f), n, Math::Point(u1, v1));
+ vertex[2] = Gfx::Vertex(Math::Vector(p2.x, p1.y, 0.0f), n, Math::Point(u2, v2));
+ vertex[3] = Gfx::Vertex(Math::Vector(p2.x, p2.y, 0.0f), n, Math::Point(u2, v1));
- device->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX2, vertex, 4, NULL);
+ device->DrawPrimitive(Gfx::PRIMITIVE_TRIANGLE_STRIP, vertex, 4);
m_engine->AddStatisticTriangle(2);
}
+}
diff --git a/src/ui/shortcut.h b/src/ui/shortcut.h
index b918ccc..7e7899e 100644
--- a/src/ui/shortcut.h
+++ b/src/ui/shortcut.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,31 +19,30 @@
#pragma once
-
#include "ui/control.h"
+#include "common/event.h"
-class CD3DEngine;
-
-
+namespace Ui {
class CShortcut : public CControl
{
-public:
- CShortcut(CInstanceManager* iMan);
- ~CShortcut();
+ public:
+ CShortcut();
+ ~CShortcut();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType);
- bool EventProcess(const Event &event);
+ bool EventProcess(const Event &event);
- void Draw();
+ void Draw();
-protected:
- void DrawVertex(int icon, float zoom);
+ protected:
+ void DrawVertex(int icon, float zoom);
-protected:
- float m_time;
+ protected:
+ float m_time;
};
+}
diff --git a/src/ui/slider.cpp b/src/ui/slider.cpp
index be8af18..70dd2cc 100644
--- a/src/ui/slider.cpp
+++ b/src/ui/slider.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -16,22 +17,19 @@
// slider.cpp
+#include "ui/slider.h"
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
#include "common/event.h"
#include "common/misc.h"
#include "common/iman.h"
-#include "old/text.h"
+#include "graphics/engine/engine.h"
+#include "graphics/engine/text.h"
#include "ui/button.h"
-#include "ui/slider.h"
+
+#include <stdio.h>
+namespace Ui {
const float CURSOR_WIDTH = (10.0f/640.0f);
const float HOLE_WIDTH = (5.0f/480.0f);
@@ -41,7 +39,7 @@ const float HOLE_WIDTH = (5.0f/480.0f);
// Object's constructor.
-CSlider::CSlider(CInstanceManager* iMan) : CControl(iMan)
+CSlider::CSlider() : CControl()
{
m_buttonLeft = 0;
m_buttonRight = 0;
@@ -71,10 +69,10 @@ CSlider::~CSlider()
// Creates a new button.
-bool CSlider::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CSlider::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
- CControl::Create(pos, dim, icon, eventMsg);
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
+ CControl::Create(pos, dim, icon, eventType);
MoveAdjust();
return true;
@@ -115,20 +113,20 @@ void CSlider::MoveAdjust()
#if 1
if ( m_buttonLeft == 0 )
{
- m_buttonLeft = new CButton(m_iMan);
+ m_buttonLeft = new CButton();
m_buttonLeft->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?55:49, EVENT_NULL); // </^
m_buttonLeft->SetRepeat(true);
if ( m_state & STATE_SHADOW ) m_buttonLeft->SetState(STATE_SHADOW);
- m_eventUp = m_buttonLeft->RetEventMsg();
+ m_eventUp = m_buttonLeft->GetEventType();
}
if ( m_buttonRight == 0 )
{
- m_buttonRight = new CButton(m_iMan);
+ m_buttonRight = new CButton();
m_buttonRight->Create(Math::Point(0.0f, 0.0f), Math::Point(0.0f, 0.0f), m_bHoriz?48:50, EVENT_NULL); // >/v
m_buttonRight->SetRepeat(true);
if ( m_state & STATE_SHADOW ) m_buttonRight->SetState(STATE_SHADOW);
- m_eventDown = m_buttonRight->RetEventMsg();
+ m_eventDown = m_buttonRight->GetEventType();
}
m_marginButton = m_bHoriz?(m_dim.y*0.75f):(m_dim.x/0.75f);
@@ -261,7 +259,7 @@ bool CSlider::EventProcess(const Event &event)
if ( !m_buttonRight->EventProcess(event) ) return false;
}
- if ( event.event == m_eventUp && m_step > 0.0f )
+ if ( event.type == m_eventUp && m_step > 0.0f )
{
m_visibleValue -= m_bHoriz?m_step:-m_step;
if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f;
@@ -269,11 +267,11 @@ bool CSlider::EventProcess(const Event &event)
AdjustGlint();
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
- if ( event.event == m_eventDown && m_step > 0.0f )
+ if ( event.type == m_eventDown && m_step > 0.0f )
{
m_visibleValue += m_bHoriz?m_step:-m_step;
if ( m_visibleValue < 0.0f ) m_visibleValue = 0.0f;
@@ -281,28 +279,29 @@ bool CSlider::EventProcess(const Event &event)
AdjustGlint();
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
- if ( event.event == EVENT_LBUTTONDOWN &&
- (m_state & STATE_VISIBLE) &&
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ (event.mouseButton.button == 1 ) &&
+ (m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
if ( m_bHoriz )
{
pos.x = m_pos.x+m_marginButton;
dim.x = m_dim.x-m_marginButton*2.0f;
- value = (event.pos.x-pos.x-CURSOR_WIDTH/2.0f);
+ value = (event.mouseButton.pos.x-pos.x-CURSOR_WIDTH/2.0f);
value /= (dim.x-CURSOR_WIDTH);
}
else
{
pos.y = m_pos.y+m_marginButton;
dim.y = m_dim.y-m_marginButton*2.0f;
- value = (event.pos.y-pos.y-CURSOR_WIDTH/2.0f);
+ value = (event.mouseButton.pos.y-pos.y-CURSOR_WIDTH/2.0f);
value /= (dim.y-CURSOR_WIDTH);
}
if ( value < 0.0f ) value = 0.0f;
@@ -311,29 +310,29 @@ bool CSlider::EventProcess(const Event &event)
AdjustGlint();
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
m_bCapture = true;
- m_pressPos = event.pos;
+ m_pressPos = event.mouseButton.pos;
m_pressValue = m_visibleValue;
}
}
- if ( event.event == EVENT_MOUSEMOVE && m_bCapture )
+ if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
if ( m_bHoriz )
{
pos.x = m_pos.x+m_marginButton;
dim.x = m_dim.x-m_marginButton*2.0f;
- value = (event.pos.x-pos.x-CURSOR_WIDTH/2.0f);
+ value = (event.mouseMove.pos.x-pos.x-CURSOR_WIDTH/2.0f);
value /= (dim.x-CURSOR_WIDTH);
}
else
{
pos.y = m_pos.y+m_marginButton;
dim.y = m_dim.y-m_marginButton*2.0f;
- value = (event.pos.y-pos.y-CURSOR_WIDTH/2.0f);
+ value = (event.mouseMove.pos.y-pos.y-CURSOR_WIDTH/2.0f);
value /= (dim.y-CURSOR_WIDTH);
}
if ( value < 0.0f ) value = 0.0f;
@@ -345,32 +344,35 @@ bool CSlider::EventProcess(const Event &event)
AdjustGlint();
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
}
- if ( event.event == EVENT_LBUTTONUP && m_bCapture )
+ if ( ( event.type == EVENT_MOUSE_BUTTON_UP ) &&
+ ( event.mouseButton.button == 1 ) &&
+ m_bCapture )
{
m_bCapture = false;
}
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELUP &&
- Detect(event.pos) &&
- m_buttonLeft != 0 )
+ if (event.type == EVENT_MOUSE_WHEEL &&
+ event.mouseWheel.dir == WHEEL_UP &&
+ Detect(event.mouseWheel.pos) &&
+ m_buttonLeft != 0)
{
Event newEvent = event;
- newEvent.event = m_buttonLeft->RetEventMsg();
+ newEvent.type = m_buttonLeft->GetEventType();
m_event->AddEvent(newEvent);
}
- if ( event.event == EVENT_KEYDOWN &&
- event.param == VK_WHEELDOWN &&
- Detect(event.pos) &&
- m_buttonRight != 0 )
+
+ if (event.type == EVENT_MOUSE_WHEEL &&
+ event.mouseButton.button == WHEEL_DOWN &&
+ Detect(event.mouseWheel.pos) &&
+ m_buttonRight != 0)
{
Event newEvent = event;
- newEvent.event = m_buttonRight->RetEventMsg();
+ newEvent.type = m_buttonRight->GetEventType();
m_event->AddEvent(newEvent);
}
@@ -465,11 +467,11 @@ void CSlider::Draw()
if ( m_bHoriz )
{
- sprintf(text, "%d", (int)(m_min+m_visibleValue*(m_max-m_min)));
- h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType);
+ sprintf(text, "%d", static_cast<int>(m_min+m_visibleValue*(m_max-m_min)));
+ h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
pos.x = m_pos.x+m_dim.x+(10.0f/640.0f);
pos.y = m_pos.y+(m_dim.y-h)/2.0f;
- m_engine->RetText()->DrawText(text, pos, m_dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0);
+ m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0);
}
else
{
@@ -481,8 +483,8 @@ void CSlider::Draw()
pos.y += (h-CURSOR_WIDTH)*m_visibleValue;
dim.x = 50.0f/640.0f;
dim.y = 16.0f/480.0f;
- sprintf(text, "%d", (int)(m_min+(m_visibleValue*(m_max-m_min))));
- m_engine->RetText()->DrawText(text, pos, dim.x, 1, m_fontSize, m_fontStretch, m_fontType, 0);
+ sprintf(text, "%d", static_cast<int>(m_min+(m_visibleValue*(m_max-m_min))));
+ m_engine->GetText()->DrawText(text, m_fontType, m_fontSize, pos, dim.x, Gfx::TEXT_ALIGN_RIGHT, 0);
}
}
}
@@ -496,8 +498,8 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
if ( icon == 0 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // yellow rectangle
uv1.y = 32.0f/256.0f;
uv2.x = 32.0f/256.0f;
@@ -508,8 +510,8 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 1 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // gray rectangle
uv1.y = 32.0f/256.0f;
uv2.x = 160.0f/256.0f;
@@ -520,8 +522,8 @@ void CSlider::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 224.0f/256.0f; // cursor
uv1.y = 32.0f/256.0f;
uv2.x = 256.0f/256.0f;
@@ -561,7 +563,7 @@ void CSlider::SetVisibleValue(float value)
AdjustGlint();
}
-float CSlider::RetVisibleValue()
+float CSlider::GetVisibleValue()
{
return m_min+m_visibleValue*(m_max-m_min);
}
@@ -572,9 +574,10 @@ void CSlider::SetArrowStep(float step)
m_step = step/(m_max-m_min);
}
-float CSlider::RetArrowStep()
+float CSlider::GetArrowStep()
{
return m_step*(m_max-m_min);
}
+}
diff --git a/src/ui/slider.h b/src/ui/slider.h
index 1ec9ea5..4912453 100644
--- a/src/ui/slider.h
+++ b/src/ui/slider.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -20,62 +21,62 @@
#include "ui/control.h"
+#include "common/event.h"
+namespace Ui {
-class CD3DEngine;
class CButton;
-
-
class CSlider : public CControl
{
-public:
- CSlider(CInstanceManager* iMan);
- ~CSlider();
+ public:
+ CSlider();
+ ~CSlider();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
- void SetPos(Math::Point pos);
- void SetDim(Math::Point dim);
+ void SetPos(Math::Point pos);
+ void SetDim(Math::Point dim);
- bool SetState(int state, bool bState);
- bool SetState(int state);
- bool ClearState(int state);
+ bool SetState(int state, bool bState);
+ bool SetState(int state);
+ bool ClearState(int state);
- bool EventProcess(const Event &event);
- void Draw();
+ bool EventProcess(const Event &event);
+ void Draw();
- void SetLimit(float min, float max);
+ void SetLimit(float min, float max);
- void SetVisibleValue(float value);
- float RetVisibleValue();
+ void SetVisibleValue(float value);
+ float GetVisibleValue();
- void SetArrowStep(float step);
- float RetArrowStep();
+ void SetArrowStep(float step);
+ float GetArrowStep();
-protected:
- void MoveAdjust();
- void AdjustGlint();
- void DrawVertex(Math::Point pos, Math::Point dim, int icon);
+ protected:
+ void MoveAdjust();
+ void AdjustGlint();
+ void DrawVertex(Math::Point pos, Math::Point dim, int icon);
-protected:
- CButton* m_buttonLeft;
- CButton* m_buttonRight;
+ protected:
+ CButton* m_buttonLeft;
+ CButton* m_buttonRight;
- float m_min;
- float m_max;
- float m_visibleValue;
- float m_step;
+ float m_min;
+ float m_max;
+ float m_visibleValue;
+ float m_step;
- bool m_bHoriz;
- float m_marginButton;
+ bool m_bHoriz;
+ float m_marginButton;
- bool m_bCapture;
- Math::Point m_pressPos;
- float m_pressValue;
+ bool m_bCapture;
+ Math::Point m_pressPos;
+ float m_pressValue;
- EventMsg m_eventUp;
- EventMsg m_eventDown;
+ EventType m_eventUp;
+ EventType m_eventDown;
};
+}
diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp
index cba19d6..c546c57 100644
--- a/src/ui/studio.cpp
+++ b/src/ui/studio.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,58 +18,59 @@
// studio.cpp
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <windows.h>
-#include <direct.h>
-#include <io.h>
-#include <time.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/d3dmath.h"
-#include "common/language.h"
+#include "studio.h"
+
+#include "CBot/CBotDll.h"
+
+#include "app/app.h"
#include "common/event.h"
-#include "common/misc.h"
#include "common/iman.h"
-#include "common/restext.h"
-#include "old/math3d.h"
-#include "object/robotmain.h"
+#include "common/misc.h"
+#include "graphics/engine/camera.h"
+#include "graphics/engine/engine.h"
#include "object/object.h"
-#include "old/camera.h"
-#include "old/sound.h"
+#include "script/cbottoken.h"
#include "script/script.h"
-#include "ui/interface.h"
-#include "ui/button.h"
+#include "sound/sound.h"
#include "ui/check.h"
-#include "ui/slider.h"
+#include "ui/control.h"
+#include "ui/color.h"
+#include "ui/compass.h"
#include "ui/edit.h"
-#include "ui/list.h"
-#include "ui/label.h"
#include "ui/group.h"
+#include "ui/image.h"
+#include "ui/interface.h"
+#include "ui/key.h"
+#include "ui/label.h"
+#include "ui/list.h"
+#include "ui/map.h"
+#include "ui/shortcut.h"
+#include "ui/target.h"
#include "ui/window.h"
-#include "old/text.h"
-#include "script/cbottoken.h"
-#include "ui/studio.h"
+
+#include <stdio.h>
+
+
+const int MAX_FNAME = 255;
+namespace Ui {
// Object's constructor.
-CStudio::CStudio(CInstanceManager* iMan)
+CStudio::CStudio()
{
- m_iMan = iMan;
+ m_iMan = CInstanceManager::GetInstancePointer();
m_iMan->AddInstance(CLASS_STUDIO, this);
- m_engine = (CD3DEngine*)m_iMan->SearchInstance(CLASS_ENGINE);
- m_event = (CEvent*)m_iMan->SearchInstance(CLASS_EVENT);
- m_interface = (CInterface*)m_iMan->SearchInstance(CLASS_INTERFACE);
- m_main = (CRobotMain*)m_iMan->SearchInstance(CLASS_MAIN);
- m_camera = (CCamera*)m_iMan->SearchInstance(CLASS_CAMERA);
- m_sound = (CSound*)m_iMan->SearchInstance(CLASS_SOUND);
+ m_engine = static_cast<Gfx::CEngine*>(m_iMan->SearchInstance(CLASS_ENGINE));
+ m_event = static_cast<CEventQueue*>(m_iMan->SearchInstance(CLASS_EVENT));
+ m_interface = static_cast<CInterface*>(m_iMan->SearchInstance(CLASS_INTERFACE));
+ m_main = static_cast<CRobotMain*>(m_iMan->SearchInstance(CLASS_MAIN));
+ m_camera = static_cast<Gfx::CCamera*>(m_iMan->SearchInstance(CLASS_CAMERA));
+ m_sound = static_cast<CSoundInterface*>(m_iMan->SearchInstance(CLASS_SOUND));
+ m_app = CApplication::GetInstancePointer();
m_bEditMaximized = false;
m_bEditMinimized = false;
@@ -103,85 +105,85 @@ bool CStudio::EventProcess(const Event &event)
return EventDialog(event);
}
- if ( event.event == EVENT_FRAME )
+ if ( event.type == EVENT_FRAME )
{
EventFrame(event);
}
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw == 0 ) return false;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw == nullptr ) return false;
- edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
+ edit = static_cast<CEdit*>(pw->SearchControl(EVENT_STUDIO_EDIT));
if ( edit == 0 ) return false;
- if ( event.event == pw->RetEventMsgClose() )
+ if ( event.type == pw->GetEventTypeClose() )
{
Event newEvent = event;
- newEvent.event = EVENT_STUDIO_OK;
+ newEvent.type = EVENT_STUDIO_OK;
m_event->AddEvent(newEvent);
}
- if ( event.event == EVENT_STUDIO_EDIT ) // text modifief?
+ if ( event.type == EVENT_STUDIO_EDIT ) // text modifief?
{
ColorizeScript(edit);
}
- if ( event.event == EVENT_STUDIO_LIST ) // list clicked?
+ if ( event.type == EVENT_STUDIO_LIST ) // list clicked?
{
- m_main->StartDisplayInfo(m_helpFilename, -1);
+ m_main->StartDisplayInfo(const_cast<char *>(m_helpFilename.c_str()), -1); // TODO change to std::string when RobotMain changes
}
- if ( event.event == EVENT_STUDIO_NEW ) // new?
+ if ( event.type == EVENT_STUDIO_NEW ) // new?
{
m_script->New(edit, "");
}
- if ( event.event == EVENT_STUDIO_OPEN ) // open?
+ if ( event.type == EVENT_STUDIO_OPEN ) // open?
{
StartDialog(SD_OPEN);
}
- if ( event.event == EVENT_STUDIO_SAVE ) // save?
+ if ( event.type == EVENT_STUDIO_SAVE ) // save?
{
StartDialog(SD_SAVE);
}
- if ( event.event == EVENT_STUDIO_UNDO ) // undo?
+ if ( event.type == EVENT_STUDIO_UNDO ) // undo?
{
edit->Undo();
}
- if ( event.event == EVENT_STUDIO_CUT ) // cut?
+ if ( event.type == EVENT_STUDIO_CUT ) // cut?
{
edit->Cut();
}
- if ( event.event == EVENT_STUDIO_COPY ) // copy?
+ if ( event.type == EVENT_STUDIO_COPY ) // copy?
{
edit->Copy();
}
- if ( event.event == EVENT_STUDIO_PASTE ) // paste?
+ if ( event.type == EVENT_STUDIO_PASTE ) // paste?
{
edit->Paste();
}
- if ( event.event == EVENT_STUDIO_SIZE ) // size?
+ if ( event.type == EVENT_STUDIO_SIZE ) // size?
{
- slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
- if ( slider == 0 ) return false;
- m_main->SetFontSize(9.0f+slider->RetVisibleValue()*6.0f);
+ slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE));
+ if ( slider == nullptr ) return false;
+ m_main->SetFontSize(9.0f+slider->GetVisibleValue()*6.0f);
ViewEditScript();
}
- if ( event.event == EVENT_STUDIO_TOOL && // instructions?
+ if ( event.type == EVENT_STUDIO_TOOL && // instructions?
m_dialog == SD_NULL )
{
m_main->StartDisplayInfo(SATCOM_HUSTON, false);
}
- if ( event.event == EVENT_STUDIO_HELP && // help?
+ if ( event.type == EVENT_STUDIO_HELP && // help?
m_dialog == SD_NULL )
{
m_main->StartDisplayInfo(SATCOM_PROG, false);
}
- if ( event.event == EVENT_STUDIO_COMPILE ) // compile?
+ if ( event.type == EVENT_STUDIO_COMPILE ) // compile?
{
char buffer[100];
@@ -197,12 +199,12 @@ bool CStudio::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_STUDIO_RUN ) // run/stop?
+ if ( event.type == EVENT_STUDIO_RUN ) // run/stop?
{
if ( m_script->IsRunning() )
{
Event newEvent = event;
- newEvent.event = EVENT_OBJECT_PROGSTOP;
+ newEvent.type = EVENT_OBJECT_PROGSTOP;
m_event->AddEvent(newEvent); // stop
}
else
@@ -212,7 +214,7 @@ bool CStudio::EventProcess(const Event &event)
SetInfoText("", false);
Event newEvent = event;
- newEvent.event = EVENT_OBJECT_PROGSTART;
+ newEvent.type = EVENT_OBJECT_PROGSTART;
m_event->AddEvent(newEvent); // start
}
else
@@ -224,7 +226,7 @@ bool CStudio::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_STUDIO_REALTIME ) // real time?
+ if ( event.type == EVENT_STUDIO_REALTIME ) // real time?
{
m_bRealTime = !m_bRealTime;
m_script->SetStepMode(!m_bRealTime);
@@ -232,37 +234,37 @@ bool CStudio::EventProcess(const Event &event)
UpdateButtons();
}
- if ( event.event == EVENT_STUDIO_STEP ) // step?
+ if ( event.type == EVENT_STUDIO_STEP ) // step?
{
m_script->Step(event);
}
- if ( event.event == EVENT_KEYDOWN )
+ if ( event.type == EVENT_KEY_DOWN )
{
- if ( event.param == m_engine->RetKey(KEYRANK_CBOT, 0) ||
- event.param == m_engine->RetKey(KEYRANK_CBOT, 1) )
+ if ( event.key.key == m_main->GetInputBinding(INPUT_SLOT_CBOT).key ||
+ event.param == m_main->GetInputBinding(INPUT_SLOT_CBOT).joy )
{
- if ( m_helpFilename[0] != 0 )
+ if ( m_helpFilename.length() > 0 )
{
- m_main->StartDisplayInfo(m_helpFilename, -1);
+ m_main->StartDisplayInfo(const_cast<char *>(m_helpFilename.c_str()), -1); // TODO change to std::string when RobotMain changes
}
}
}
- if ( event.event == EVENT_WINDOW3 ) // window is moved?
+ if ( event.type == EVENT_WINDOW3 ) // window is moved?
{
- m_editActualPos = m_editFinalPos = pw->RetPos();
- m_editActualDim = m_editFinalDim = pw->RetDim();
+ m_editActualPos = m_editFinalPos = pw->GetPos();
+ m_editActualDim = m_editFinalDim = pw->GetDim();
m_main->SetWindowPos(m_editActualPos);
m_main->SetWindowDim(m_editActualDim);
AdjustEditScript();
}
- if ( event.event == pw->RetEventMsgReduce() )
+ if ( event.type == pw->GetEventTypeReduce() )
{
if ( m_bEditMinimized )
{
- m_editFinalPos = m_main->RetWindowPos();
- m_editFinalDim = m_main->RetWindowDim();
+ m_editFinalPos = m_main->GetWindowPos();
+ m_editFinalDim = m_main->GetWindowDim();
m_bEditMinimized = false;
m_bEditMaximized = false;
}
@@ -276,19 +278,19 @@ bool CStudio::EventProcess(const Event &event)
m_bEditMaximized = false;
}
m_main->SetEditFull(m_bEditMaximized);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw != 0 )
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw != nullptr )
{
pw->SetMaximized(m_bEditMaximized);
pw->SetMinimized(m_bEditMinimized);
}
}
- if ( event.event == pw->RetEventMsgFull() )
+ if ( event.type == pw->GetEventTypeFull() )
{
if ( m_bEditMaximized )
{
- m_editFinalPos = m_main->RetWindowPos();
- m_editFinalDim = m_main->RetWindowDim();
+ m_editFinalPos = m_main->GetWindowPos();
+ m_editFinalDim = m_main->GetWindowDim();
m_bEditMinimized = false;
m_bEditMaximized = false;
}
@@ -302,8 +304,8 @@ bool CStudio::EventProcess(const Event &event)
m_bEditMaximized = true;
}
m_main->SetEditFull(m_bEditMaximized);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw != 0 )
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw != nullptr )
{
pw->SetMaximized(m_bEditMaximized);
pw->SetMinimized(m_bEditMinimized);
@@ -348,13 +350,13 @@ bool CStudio::EventFrame(const Event &event)
m_time += event.rTime;
m_fixInfoTextTime -= event.rTime;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw == 0 ) return false;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw == nullptr ) return false;
- edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
+ edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
if ( edit == 0 ) return false;
- list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST);
+ list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST));
if ( list == 0 ) return false;
if ( !m_script->IsRunning() && m_bRunning ) // stop?
@@ -366,7 +368,7 @@ bool CStudio::EventFrame(const Event &event)
SetInfoText(res, false);
Event newEvent = event;
- newEvent.event = EVENT_OBJECT_PROGSTOP;
+ newEvent.type = EVENT_OBJECT_PROGSTOP;
m_event->AddEvent(newEvent); // stop
}
@@ -419,7 +421,7 @@ bool IsToken(int character)
{
char c;
- c = tolower(RetNoAccent(character));
+ c = tolower(GetNoAccent(character));
return ( (c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') ||
@@ -435,20 +437,20 @@ void CStudio::SearchToken(CEdit* edit)
char* text;
char token[100];
- text = edit->RetText();
- len = edit->RetTextLength();
+ text = edit->GetText();
+ len = edit->GetTextLength();
edit->GetCursor(cursor1, cursor2);
i = cursor1;
if ( i > 0 )
{
- character = (unsigned char)text[i-1];
+ character = static_cast< unsigned char > (text[i-1]);
if ( !IsToken(character) )
{
level = 1;
while ( i > 0 )
{
- character = (unsigned char)text[i-1];
+ character = static_cast< unsigned char > (text[i-1]);
if ( character == ')' )
{
level ++;
@@ -468,7 +470,7 @@ void CStudio::SearchToken(CEdit* edit)
}
while ( i > 0 )
{
- character = (unsigned char)text[i-1];
+ character = static_cast< unsigned char > (text[i-1]);
if ( IsToken(character) ) break;
i --;
}
@@ -477,7 +479,7 @@ void CStudio::SearchToken(CEdit* edit)
while ( i > 0 )
{
- character = (unsigned char)text[i-1];
+ character = static_cast< unsigned char > (text[i-1]);
if ( !IsToken(character) ) break;
i --;
}
@@ -485,7 +487,7 @@ void CStudio::SearchToken(CEdit* edit)
while ( i < len )
{
- character = (unsigned char)text[i];
+ character = static_cast< unsigned char > (text[i]);
if ( !IsToken(character) ) break;
i ++;
}
@@ -499,39 +501,39 @@ void CStudio::SearchToken(CEdit* edit)
}
token[i] = 0;
- strcpy(m_helpFilename, RetHelpFilename(token));
- if ( m_helpFilename[0] == 0 )
+ m_helpFilename = std::string(GetHelpFilename(token));
+ if ( m_helpFilename.length() == 0 )
{
for ( i=0 ; i<OBJECT_MAX ; i++ )
{
- type = (ObjectType)i;
- text = RetObjectName(type);
+ type = static_cast< ObjectType >(i);
+ text = const_cast<char *>(GetObjectName(type));
if ( text[0] != 0 )
{
if ( strcmp(token, text) == 0 )
{
- strcpy(m_helpFilename, RetHelpFilename(type));
- SetInfoText(token, true);
+ m_helpFilename = GetHelpFilename(type);
+ SetInfoText(std::string(token), true);
return;
}
}
- text = RetObjectAlias(type);
+ text = const_cast<char *>(GetObjectAlias(type));
if ( text[0] != 0 )
{
if ( strcmp(token, text) == 0 )
{
- strcpy(m_helpFilename, RetHelpFilename(type));
- SetInfoText(token, true);
+ m_helpFilename = GetHelpFilename(type);
+ SetInfoText(std::string(token), true);
return;
}
}
}
}
- text = RetHelpText(token);
- if ( text[0] == 0 && m_helpFilename[0] != 0 )
+ text = const_cast<char *>(GetHelpText(token));
+ if ( text[0] == 0 && m_helpFilename.length() > 0 )
{
- SetInfoText(token, true);
+ SetInfoText(std::string(token), true);
}
else
{
@@ -549,7 +551,7 @@ void CStudio::ColorizeScript(CEdit* edit)
// Starts editing a program.
-void CStudio::StartEditScript(CScript *script, char* name, int rank)
+void CStudio::StartEditScript(CScript *script, std::string name, int rank)
{
Math::Point pos, dim;
CWindow* pw;
@@ -564,25 +566,25 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
m_main->SetEditLock(true, true);
m_main->SetEditFull(false);
- m_bInitPause = m_engine->RetPause();
+ m_bInitPause = m_engine->GetPause();
m_main->SetSpeed(1.0f);
- m_editCamera = m_camera->RetType();
- m_camera->SetType(CAMERA_EDIT);
+ m_editCamera = m_camera->GetType();
+ m_camera->SetType(Gfx::CAM_TYPE_EDIT);
m_bRunning = m_script->IsRunning();
m_bRealTime = m_bRunning;
m_script->SetStepMode(!m_bRealTime);
- button = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT);
+ button = static_cast< CButton* >(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if ( button != 0 )
{
button->ClearState(STATE_VISIBLE);
}
- pos = m_editFinalPos = m_editActualPos = m_main->RetWindowPos();
- dim = m_editFinalDim = m_editActualDim = m_main->RetWindowDim();
+ pos = m_editFinalPos = m_editActualPos = m_main->GetWindowPos();
+ dim = m_editFinalDim = m_editActualDim = m_main->GetWindowDim();
pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW3);
- if ( pw == 0 ) return;
+ if ( pw == nullptr ) return;
pw->SetState(STATE_SHADOW);
pw->SetRedim(true); // before SetName!
pw->SetMovable(true);
@@ -600,20 +602,21 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
edit->SetInsideScroll(false);
//? if ( m_bRunning ) edit->SetEdit(false);
edit->SetMaxChar(EDITSTUDIOMAX);
- edit->SetFontType(FONT_COURIER);
+ edit->SetFontType(Gfx::FONT_COURIER);
edit->SetFontStretch(0.7f);
edit->SetDisplaySpec(true);
- edit->SetAutoIndent(m_engine->RetEditIndentMode());
- m_script->PutScript(edit, name);
+ edit->SetAutoIndent(m_engine->GetEditIndentMode());
+
+ m_script->PutScript(edit, name.c_str());
ColorizeScript(edit);
ViewEditScript();
list = pw->CreateList(pos, dim, 1, EVENT_STUDIO_LIST, 1.2f);
list->SetState(STATE_SHADOW);
- list->SetFontType(FONT_COURIER);
+ list->SetFontType(Gfx::FONT_COURIER);
list->SetSelectCap(false);
- list->SetFontSize(SMALLFONT*0.85f);
+ list->SetFontSize(Gfx::FONT_SIZE_SMALL*0.85f);
//? list->SetFontStretch(1.0f);
button = pw->CreateButton(pos, dim, 56, EVENT_STUDIO_NEW);
@@ -632,7 +635,7 @@ void CStudio::StartEditScript(CScript *script, char* name, int rank)
button->SetState(STATE_SHADOW);
slider = pw->CreateSlider(pos, dim, 0, EVENT_STUDIO_SIZE);
slider->SetState(STATE_SHADOW);
- slider->SetVisibleValue((m_main->RetFontSize()-9.0f)/6.0f);
+ slider->SetVisibleValue((m_main->GetFontSize()-9.0f)/6.0f);
pw->CreateGroup(pos, dim, 19, EVENT_LABEL1); // SatCom logo
button = pw->CreateButton(pos, dim, 128+57, EVENT_STUDIO_TOOL);
button->SetState(STATE_SHADOW);
@@ -673,12 +676,12 @@ void CStudio::AdjustEditScript()
wpos = m_editActualPos;
wdim = m_editActualDim;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw != 0 )
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw != nullptr )
{
pw->SetPos(wpos);
pw->SetDim(wdim);
- wdim = pw->RetDim();
+ wdim = pw->GetDim();
}
if ( m_bRunning ) hList = 80.0f/480.0f;
@@ -688,7 +691,7 @@ void CStudio::AdjustEditScript()
pos.y = wpos.y+0.09f+hList;
dim.x = wdim.x-0.02f;
dim.y = wdim.y-0.22f-hList;
- edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
+ edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
if ( edit != 0 )
{
edit->SetPos(pos);
@@ -699,7 +702,7 @@ void CStudio::AdjustEditScript()
pos.y = wpos.y+0.09f;
dim.x = wdim.x-0.02f;
dim.y = hList;
- list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST);
+ list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST));
if ( list != 0 )
{
list->SetPos(pos);
@@ -712,56 +715,56 @@ void CStudio::AdjustEditScript()
pos.y = wpos.y+wdim.y-dim.y-0.06f;
pos.x = wpos.x+0.01f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_NEW);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_NEW));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.05f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_OPEN);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OPEN));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.09f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_SAVE);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_SAVE));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.14f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_UNDO);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_UNDO));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.19f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_CUT);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CUT));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.23f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_COPY);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COPY));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.27f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_PASTE);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_PASTE));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.32f;
- slider = (CSlider*)pw->SearchControl(EVENT_STUDIO_SIZE);
+ slider = static_cast< CSlider* >(pw->SearchControl(EVENT_STUDIO_SIZE));
if ( slider != 0 )
{
ppos = pos;
@@ -773,21 +776,21 @@ void CStudio::AdjustEditScript()
slider->SetDim(ddim);
}
pos.x = wpos.x+0.36f;
- group = (CGroup*)pw->SearchControl(EVENT_LABEL1);
+ group = static_cast< CGroup* >(pw->SearchControl(EVENT_LABEL1));
if ( group != 0 )
{
group->SetPos(pos);
group->SetDim(dim);
}
pos.x = wpos.x+0.40f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_TOOL);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_TOOL));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.44f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_HELP);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_HELP));
if ( button != 0 )
{
button->SetPos(pos);
@@ -798,14 +801,14 @@ void CStudio::AdjustEditScript()
pos.x = wpos.x+0.01f;
dim.x = 80.0f/640.0f;
dim.y = 25.0f/480.0f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_OK);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_OK));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.14f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_CANCEL);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_CANCEL));
if ( button != 0 )
{
button->SetPos(pos);
@@ -813,28 +816,28 @@ void CStudio::AdjustEditScript()
}
pos.x = wpos.x+0.28f;
dim.x = dim.y*0.75f;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_COMPILE);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.28f+dim.x*1;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_RUN);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_RUN));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.28f+dim.x*2;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_REALTIME);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_REALTIME));
if ( button != 0 )
{
button->SetPos(pos);
button->SetDim(dim);
}
pos.x = wpos.x+0.28f+dim.x*3;
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_STEP);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_STEP));
if ( button != 0 )
{
button->SetPos(pos);
@@ -851,12 +854,12 @@ bool CStudio::StopEditScript(bool bCancel)
CButton* button;
char buffer[100];
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw == 0 ) return false;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw == nullptr ) return false;
if ( !bCancel && !m_script->IsRunning() )
{
- edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
+ edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
if ( edit != 0 )
{
if ( !m_script->GetScript(edit) ) // compile
@@ -871,7 +874,7 @@ bool CStudio::StopEditScript(bool bCancel)
m_interface->DeleteControl(EVENT_WINDOW3);
- button = (CButton*)m_interface->SearchControl(EVENT_BUTTON_QUIT);
+ button = static_cast< CButton* >(m_interface->SearchControl(EVENT_BUTTON_QUIT));
if ( button != 0 )
{
button->SetState(STATE_VISIBLE);
@@ -888,23 +891,21 @@ bool CStudio::StopEditScript(bool bCancel)
// The messages are not clickable 8 seconds,
// even if a message was clickable poster before.
-void CStudio::SetInfoText(char *text, bool bClickable)
+void CStudio::SetInfoText(std::string text, bool bClickable)
{
- CWindow* pw;
- CList* list;
char res[100];
if ( bClickable && m_fixInfoTextTime > 0.0f ) return;
if ( !bClickable ) m_fixInfoTextTime = 8.0f;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw == 0 ) return;
+ CWindow* pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw == nullptr ) return;
- list = (CList*)pw->SearchControl(EVENT_STUDIO_LIST);
+ CList* list = static_cast< CList* >(pw->SearchControl(EVENT_STUDIO_LIST));
if ( list == 0 ) return;
list->Flush(); // just text
- list->SetName(0, text);
+ list->SetName(0, text.c_str());
if ( text[0] == 0 ) bClickable = false;
list->SetSelectCap(bClickable);
@@ -930,16 +931,16 @@ void CStudio::ViewEditScript()
{
CWindow* pw;
CEdit* edit;
- POINT dim;
+ Math::IntPoint dim;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw == 0 ) return;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw == nullptr ) return;
- edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
+ edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
if ( edit == 0 ) return;
- dim = m_engine->RetDim();
- edit->SetFontSize(m_main->RetFontSize()/(dim.x/640.0f));
+ dim = m_engine->GetWindowSize();
+ edit->SetFontSize(m_main->GetFontSize()/(dim.x/640.0f));
}
@@ -980,10 +981,10 @@ void CStudio::UpdateButtons()
CEdit* edit;
CButton* button;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw == 0 ) return;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw == nullptr ) return;
- edit = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
+ edit = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
if ( edit == 0 ) return;
if ( m_bRunning )
@@ -999,20 +1000,20 @@ void CStudio::UpdateButtons()
edit->SetHiliteCap(true);
}
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_COMPILE);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_COMPILE));
if ( button == 0 ) return;
button->SetState(STATE_ENABLE, !m_bRunning);
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_RUN);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_RUN));
if ( button == 0 ) return;
button->SetIcon(m_bRunning?8:21); // stop/run
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_REALTIME);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_REALTIME));
if ( button == 0 ) return;
button->SetIcon(m_bRealTime?64+22:64+21);
button->SetState(STATE_ENABLE, (!m_bRunning || !m_script->IsContinue()));
- button = (CButton*)pw->SearchControl(EVENT_STUDIO_STEP);
+ button = static_cast< CButton* >(pw->SearchControl(EVENT_STUDIO_STEP));
if ( button == 0 ) return;
button->SetState(STATE_ENABLE, (m_bRunning && !m_bRealTime && !m_script->IsContinue()));
}
@@ -1033,38 +1034,38 @@ void CStudio::StartDialog(StudioDialog type)
m_dialog = type;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW1));
+ if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
- if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW4));
+ if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
- if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW5));
+ if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6);
- if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW6));
+ if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7);
- if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW7));
+ if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8);
- if ( pw != 0 ) pw->ClearState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW8));
+ if ( pw != nullptr ) pw->ClearState(STATE_ENABLE);
if ( m_dialog == SD_OPEN ||
m_dialog == SD_SAVE )
{
- pos = m_main->RetIOPos();
- dim = m_main->RetIODim();
+ pos = m_main->GetIOPos();
+ dim = m_main->GetIODim();
}
//? pw = m_interface->CreateWindows(pos, dim, 8, EVENT_WINDOW9);
pw = m_interface->CreateWindows(pos, dim, m_dialog==SD_OPEN?14:13, EVENT_WINDOW9);
@@ -1084,25 +1085,25 @@ void CStudio::StartDialog(StudioDialog type)
{
GetResource(RES_TEXT, RT_IO_LIST, name);
pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL1, name);
- pla->SetJustif(1);
+ pla->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pli = pw->CreateList(pos, dim, 0, EVENT_DIALOG_LIST);
pli->SetState(STATE_SHADOW);
GetResource(RES_TEXT, RT_IO_NAME, name);
pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL2, name);
- pla->SetJustif(1);
+ pla->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pe = pw->CreateEdit(pos, dim, 0, EVENT_DIALOG_EDIT);
pe->SetState(STATE_SHADOW);
if ( m_dialog == SD_SAVE )
{
- pe->SetText(m_script->RetFilename());
+ pe->SetText(m_script->GetFilename());
}
GetResource(RES_TEXT, RT_IO_DIR, name);
pla = pw->CreateLabel(pos, dim, 0, EVENT_DIALOG_LABEL3, name);
- pla->SetJustif(1);
+ pla->SetTextAlign(Gfx::TEXT_ALIGN_LEFT);
pc = pw->CreateCheck(pos, dim, 0, EVENT_DIALOG_CHECK1);
GetResource(RES_TEXT, RT_IO_PRIVATE, name);
@@ -1152,32 +1153,32 @@ void CStudio::StopDialog()
if ( m_dialog == SD_NULL ) return;
m_dialog = SD_NULL;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW0);
- if ( pw != 0 ) pw->SetState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
+ if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW1);
- if ( pw != 0 ) pw->SetState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW1));
+ if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw != 0 ) pw->SetState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW2));
+ if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw != 0 ) pw->SetState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW4);
- if ( pw != 0 ) pw->SetState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW4));
+ if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW5);
- if ( pw != 0 ) pw->SetState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW5));
+ if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW6);
- if ( pw != 0 ) pw->SetState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW6));
+ if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW7);
- if ( pw != 0 ) pw->SetState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW7));
+ if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW8);
- if ( pw != 0 ) pw->SetState(STATE_ENABLE);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW8));
+ if ( pw != nullptr ) pw->SetState(STATE_ENABLE);
m_interface->DeleteControl(EVENT_WINDOW9);
m_main->SetSatComLock(false); // possible to use the SatCom
@@ -1197,11 +1198,11 @@ void CStudio::AdjustDialog()
int nli, nch;
char name[100];
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
- if ( pw == 0 ) return;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
+ if ( pw == nullptr ) return;
- wpos = pw->RetPos();
- wdim = pw->RetDim();
+ wpos = pw->GetPos();
+ wdim = pw->GetDim();
pw->SetPos(wpos); // to move the buttons on the titlebar
if ( m_dialog == SD_OPEN ||
@@ -1211,23 +1212,23 @@ void CStudio::AdjustDialog()
ppos.y = wpos.y+wdim.y-55.0f/480.0f;
ddim.x = wdim.x-20.0f/640.0f;
ddim.y = 20.0f/480.0f;
- pla = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL1);
+ pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1));
if ( pla != 0 )
{
pla->SetPos(ppos);
pla->SetDim(ddim);
}
- nli = (int)((wdim.y-120.0f/480.0f)/(18.0f/480.0f));
+ nli = static_cast<int>((wdim.y-120.0f/480.0f)/(18.0f/480.0f));
ddim.y = nli*18.0f/480.0f+9.0f/480.0f;
ppos.y = wpos.y+wdim.y-48.0f/480.0f-ddim.y;
- pli = (CList*)pw->SearchControl(EVENT_DIALOG_LIST);
+ pli = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST));
if ( pli != 0 )
{
pli->SetPos(ppos);
pli->SetDim(ddim);
pli->SetTabs(0, ddim.x-(50.0f+130.0f+16.0f)/640.0f);
- pli->SetTabs(1, 50.0f/640.0f, -1);
+ pli->SetTabs(1, 50.0f/640.0f, Gfx::TEXT_ALIGN_RIGHT);
pli->SetTabs(2, 130.0f/640.0f);
//? pli->ShowSelect();
}
@@ -1235,7 +1236,7 @@ void CStudio::AdjustDialog()
ppos.y = wpos.y+30.0f/480.0f;
ddim.x = 50.0f/640.0f;
ddim.y = 20.0f/480.0f;
- pla = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL2);
+ pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL2));
if ( pla != 0 )
{
pla->SetPos(ppos);
@@ -1245,13 +1246,13 @@ void CStudio::AdjustDialog()
ppos.x += 50.0f/640.0f;
ppos.y = wpos.y+36.0f/480.0f;
ddim.x = wdim.x-170.0f/640.0f;
- pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
+ pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT));
if ( pe != 0 )
{
pe->SetPos(ppos);
pe->SetDim(ddim);
- nch = (int)((ddim.x*640.0f-22.0f)/8.0f);
+ nch = static_cast< int >((ddim.x*640.0f-22.0f)/8.0f);
pe->GetText(name, 100);
pe->SetMaxChar(nch);
name[nch] = 0; // truncates the text according to max
@@ -1262,7 +1263,7 @@ void CStudio::AdjustDialog()
ppos.y = wpos.y+5.0f/480.0f;
ddim.x = 50.0f/640.0f;
ddim.y = 16.0f/480.0f;
- pla = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL3);
+ pla = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL3));
if ( pla != 0 )
{
pla->SetPos(ppos);
@@ -1272,7 +1273,7 @@ void CStudio::AdjustDialog()
ppos.x += 50.0f/640.0f;
ppos.y = wpos.y+12.0f/480.0f;
ddim.x = 70.0f/640.0f;
- pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK1);
+ pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK1));
if ( pc != 0 )
{
pc->SetPos(ppos);
@@ -1280,7 +1281,7 @@ void CStudio::AdjustDialog()
}
ppos.x += 80.0f/640.0f;
- pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK2);
+ pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK2));
if ( pc != 0 )
{
pc->SetPos(ppos);
@@ -1291,7 +1292,7 @@ void CStudio::AdjustDialog()
ppos.y = wpos.y+34.0f/480.0f;
ddim.x = 90.0f/640.0f;
ddim.y = 23.0f/480.0f;
- pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK);
+ pb = static_cast< CButton* >(pw->SearchControl(EVENT_DIALOG_OK));
if ( pb != 0 )
{
pb->SetPos(ppos);
@@ -1299,7 +1300,7 @@ void CStudio::AdjustDialog()
}
ppos.y -= 26.0f/480.0f;
- pb = (CButton*)pw->SearchControl(EVENT_DIALOG_CANCEL);
+ pb = static_cast< CButton* >(pw->SearchControl(EVENT_DIALOG_CANCEL));
if ( pb != 0 )
{
pb->SetPos(ppos);
@@ -1315,13 +1316,13 @@ bool CStudio::EventDialog(const Event &event)
CWindow* pw;
Math::Point wpos, wdim;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
- if ( pw == 0 ) return false;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
+ if ( pw == nullptr ) return false;
- if ( event.event == EVENT_WINDOW9 ) // window is moved?
+ if ( event.type == EVENT_WINDOW9 ) // window is moved?
{
- wpos = pw->RetPos();
- wdim = pw->RetDim();
+ wpos = pw->GetPos();
+ wdim = pw->GetDim();
m_main->SetIOPos(wpos);
m_main->SetIODim(wdim);
AdjustDialog();
@@ -1330,22 +1331,22 @@ bool CStudio::EventDialog(const Event &event)
if ( m_dialog == SD_OPEN ||
m_dialog == SD_SAVE )
{
- if ( event.event == EVENT_DIALOG_LIST )
+ if ( event.type == EVENT_DIALOG_LIST )
{
UpdateChangeList();
}
- if ( event.event == EVENT_DIALOG_EDIT )
+ if ( event.type == EVENT_DIALOG_EDIT )
{
UpdateChangeEdit();
}
- if ( event.event == EVENT_DIALOG_CHECK1 ) // private?
+ if ( event.type == EVENT_DIALOG_CHECK1 ) // private?
{
m_main->SetIOPublic(false);
UpdateDialogPublic();
UpdateDialogList();
}
- if ( event.event == EVENT_DIALOG_CHECK2 ) // public?
+ if ( event.type == EVENT_DIALOG_CHECK2 ) // public?
{
m_main->SetIOPublic(true);
UpdateDialogPublic();
@@ -1353,8 +1354,8 @@ bool CStudio::EventDialog(const Event &event)
}
}
- if ( event.event == EVENT_DIALOG_OK ||
- (event.event == EVENT_KEYDOWN && event.param == VK_RETURN) )
+ if ( event.type == EVENT_DIALOG_OK ||
+ (event.type == EVENT_KEY_DOWN && event.param == KEY(RETURN)) )
{
if ( m_dialog == SD_OPEN )
{
@@ -1369,9 +1370,9 @@ bool CStudio::EventDialog(const Event &event)
return true;
}
- if ( event.event == EVENT_DIALOG_CANCEL ||
- (event.event == EVENT_KEYDOWN && event.param == VK_ESCAPE) ||
- event.event == pw->RetEventMsgClose() )
+ if ( event.type == EVENT_DIALOG_CANCEL ||
+ (event.type == EVENT_KEY_DOWN && event.param == KEY(ESCAPE)) ||
+ event.type == pw->GetEventTypeClose() )
{
StopDialog();
return true;
@@ -1390,15 +1391,15 @@ void CStudio::UpdateChangeList()
char name[100];
char* p;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
- if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
+ if ( pw == nullptr ) return;
+ pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST));
if ( pl == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
- if ( pe == 0 ) return;
+ pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT));
+ if ( pe == nullptr ) return;
- strcpy(name, pl->RetName(pl->RetSelect()));
- name[pe->RetMaxChar()] = 0; // truncates according lg max editable
+ strcpy(name, pl->GetName(pl->GetSelect()));
+ name[pe->GetMaxChar()] = 0; // truncates according lg max editable
p = strchr(name, '\t'); // seeks first tab
if ( p != 0 ) *p = 0;
pe->SetText(name);
@@ -1415,9 +1416,9 @@ void CStudio::UpdateChangeEdit()
CWindow* pw;
CList* pl;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
- if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
+ if ( pw == nullptr ) return;
+ pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST));
if ( pl == 0 ) return;
pl->SetSelect(-1);
@@ -1436,12 +1437,12 @@ void CStudio::UpdateDialogAction()
int len, i;
bool bError;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
- if ( pw == 0 ) return;
- pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
- if ( pe == 0 ) return;
- pb = (CButton*)pw->SearchControl(EVENT_DIALOG_OK);
- if ( pb == 0 ) return;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
+ if ( pw == nullptr ) return;
+ pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT));
+ if ( pe == nullptr ) return;
+ pb = static_cast< CButton* >(pw->SearchControl(EVENT_DIALOG_OK));
+ if ( pb == nullptr ) return;
pe->GetText(name, 100);
len = strlen(name);
@@ -1477,25 +1478,25 @@ void CStudio::UpdateDialogPublic()
CCheck* pc;
CLabel* pl;
char name[100];
- char dir[_MAX_FNAME];
- char text[_MAX_FNAME+100];
+ char dir[MAX_FNAME];
+ char text[MAX_FNAME+100];
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
- if ( pw == 0 ) return;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
+ if ( pw == nullptr ) return;
- pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK1);
+ pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK1));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, !m_main->RetIOPublic());
+ pc->SetState(STATE_CHECK, !m_main->GetIOPublic());
}
- pc = (CCheck*)pw->SearchControl(EVENT_DIALOG_CHECK2);
+ pc = static_cast< CCheck* >(pw->SearchControl(EVENT_DIALOG_CHECK2));
if ( pc != 0 )
{
- pc->SetState(STATE_CHECK, m_main->RetIOPublic());
+ pc->SetState(STATE_CHECK, m_main->GetIOPublic());
}
- pl = (CLabel*)pw->SearchControl(EVENT_DIALOG_LABEL1);
+ pl = static_cast< CLabel* >(pw->SearchControl(EVENT_DIALOG_LABEL1));
if ( pl != 0 )
{
GetResource(RES_TEXT, RT_IO_LIST, name);
@@ -1509,19 +1510,20 @@ void CStudio::UpdateDialogPublic()
void CStudio::UpdateDialogList()
{
- CWindow* pw;
+ // TODO rewrite to multiplatform
+ /*CWindow* pw;
CList* pl;
long hFile;
struct _finddata_t fileBuffer;
struct _finddata_t* listBuffer;
bool bDo;
- char dir[_MAX_FNAME];
- char temp[_MAX_FNAME];
+ char dir[MAX_FNAME];
+ char temp[MAX_FNAME];
int nbFilenames, i;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
- if ( pw == 0 ) return;
- pl = (CList*)pw->SearchControl(EVENT_DIALOG_LIST);
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9);
+ if ( pw == nullptr ) return;
+ pl = static_cast< CList* >(pw->SearchControl(EVENT_DIALOG_LIST);
if ( pl == 0 ) return;
pl->Flush();
@@ -1565,7 +1567,7 @@ void CStudio::UpdateDialogList()
pl->SetName(i, temp);
}
- free(listBuffer);
+ free(listBuffer);*/
}
// Constructs the name of the folder or open/save.
@@ -1573,18 +1575,18 @@ void CStudio::UpdateDialogList()
void CStudio::SearchDirectory(char *dir, bool bCreate)
{
- if ( m_main->RetIOPublic() )
+ if ( m_main->GetIOPublic() )
{
- sprintf(dir, "%s\\", m_main->RetPublicDir());
+ sprintf(dir, "%s\\", m_main->GetPublicDir());
}
else
{
- sprintf(dir, "%s\\%s\\Program\\", m_main->RetSavegameDir(), m_main->RetGamerName());
+ sprintf(dir, "%s\\%s\\Program\\", m_main->GetSavegameDir(), m_main->GetGamerName());
}
if ( bCreate )
- {
- _mkdir(dir); // if does not exist yet!
+ {// TODO
+// mkdir(dir,0777); // if does not exist yet!
}
}
@@ -1598,11 +1600,11 @@ bool CStudio::ReadProgram()
char dir[100];
char* p;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
- if ( pw == 0 ) return false;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
+ if ( pw == nullptr ) return false;
- pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
- if ( pe == 0 ) return false;
+ pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT));
+ if ( pe == nullptr ) return false;
pe->GetText(filename, 100);
if ( filename[0] == 0 ) return false;
@@ -1614,10 +1616,10 @@ bool CStudio::ReadProgram()
SearchDirectory(dir, true);
strcat(dir, filename);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw == 0 ) return false;
- pe = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
- if ( pe == 0 ) return false;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw == nullptr ) return false;
+ pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
+ if ( pe == nullptr ) return false;
if ( !pe->ReadText(dir) ) return false;
@@ -1636,11 +1638,11 @@ bool CStudio::WriteProgram()
char dir[100];
char* p;
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW9);
- if ( pw == 0 ) return false;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW9));
+ if ( pw == nullptr ) return false;
- pe = (CEdit*)pw->SearchControl(EVENT_DIALOG_EDIT);
- if ( pe == 0 ) return false;
+ pe = static_cast< CEdit* >(pw->SearchControl(EVENT_DIALOG_EDIT));
+ if ( pe == nullptr ) return false;
pe->GetText(filename, 100);
if ( filename[0] == 0 ) return false;
@@ -1652,10 +1654,10 @@ bool CStudio::WriteProgram()
SearchDirectory(dir, true);
strcat(dir, filename);
- pw = (CWindow*)m_interface->SearchControl(EVENT_WINDOW3);
- if ( pw == 0 ) return false;
- pe = (CEdit*)pw->SearchControl(EVENT_STUDIO_EDIT);
- if ( pe == 0 ) return false;
+ pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW3));
+ if ( pw == nullptr ) return false;
+ pe = static_cast< CEdit* >(pw->SearchControl(EVENT_STUDIO_EDIT));
+ if ( pe == nullptr ) return false;
if ( !pe->WriteText(dir) ) return false;
@@ -1663,3 +1665,4 @@ bool CStudio::WriteProgram()
return true;
}
+}
diff --git a/src/ui/studio.h b/src/ui/studio.h
index 687ab22..905baa6 100644
--- a/src/ui/studio.h
+++ b/src/ui/studio.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012 Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,24 +18,28 @@
// studio.h
#pragma once
+#include "common/event.h"
+#include "graphics/engine/camera.h"
-#include "object/object.h"
-#include "script/script.h"
+#include <string>
+class CEventQueue;
class CInstanceManager;
-class CD3DEngine;
-class CEvent;
class CRobotMain;
-class CCamera;
-class CSound;
-class CInterface;
class CScript;
-class CList;
-class CEdit;
+class CSoundInterface;
+namespace Gfx {
+class CEngine;
+class CCamera;
+};
+namespace Ui {
+
+class CEdit;
+class CInterface;
enum StudioDialog
{
@@ -49,67 +54,70 @@ enum StudioDialog
class CStudio
{
-public:
- CStudio(CInstanceManager* iMan);
- ~CStudio();
-
- bool EventProcess(const Event &event);
-
- void StartEditScript(CScript *script, char* name, int rank);
- bool StopEditScript(bool bCancel);
-
-protected:
- bool EventFrame(const Event &event);
- void SearchToken(CEdit* edit);
- void ColorizeScript(CEdit* edit);
- void AdjustEditScript();
- void SetInfoText(char *text, bool bClickable);
- void ViewEditScript();
- void UpdateFlux();
- void UpdateButtons();
-
- void StartDialog(StudioDialog type);
- void StopDialog();
- void AdjustDialog();
- bool EventDialog(const Event &event);
- void UpdateChangeList();
- void UpdateChangeEdit();
- void UpdateDialogAction();
- void UpdateDialogPublic();
- void UpdateDialogList();
- void SearchDirectory(char *dir, bool bCreate);
- bool ReadProgram();
- bool WriteProgram();
-
-protected:
- CInstanceManager* m_iMan;
- CD3DEngine* m_engine;
- CEvent* m_event;
- CRobotMain* m_main;
- CCamera* m_camera;
- CSound* m_sound;
- CInterface* m_interface;
-
- int m_rank;
- CScript* m_script;
-
- bool m_bEditMaximized;
- bool m_bEditMinimized;
-
- CameraType m_editCamera;
- Math::Point m_editActualPos;
- Math::Point m_editActualDim;
- Math::Point m_editFinalPos;
- Math::Point m_editFinalDim;
-
- float m_time;
- float m_fixInfoTextTime;
- bool m_bRunning;
- bool m_bRealTime;
- bool m_bInitPause;
- char m_helpFilename[100];
+ public:
+ CStudio();
+ ~CStudio();
+
+ bool EventProcess(const Event &event);
+
+ void StartEditScript(CScript *script, std::string name, int rank);
+ bool StopEditScript(bool bCancel);
+
+ protected:
+ bool EventFrame(const Event &event);
+ void SearchToken(CEdit* edit);
+ void ColorizeScript(CEdit* edit);
+ void AdjustEditScript();
+ void SetInfoText(std::string text, bool bClickable);
+ void ViewEditScript();
+ void UpdateFlux();
+ void UpdateButtons();
+
+ void StartDialog(StudioDialog type);
+ void StopDialog();
+ void AdjustDialog();
+ bool EventDialog(const Event &event);
+ void UpdateChangeList();
+ void UpdateChangeEdit();
+ void UpdateDialogAction();
+ void UpdateDialogPublic();
+ void UpdateDialogList();
+ void SearchDirectory(char* dir, bool bCreate);
+ bool ReadProgram();
+ bool WriteProgram();
+
+ protected:
+ CInstanceManager* m_iMan;
+ Gfx::CEngine* m_engine;
+ CEventQueue* m_event;
+ CRobotMain* m_main;
+ Gfx::CCamera* m_camera;
+ CSoundInterface* m_sound;
+ CInterface* m_interface;
+ CApplication *m_app;
+
+ int m_rank;
+ CScript* m_script;
+ Gfx::CameraType m_editCamera;
+
+ bool m_bEditMaximized;
+ bool m_bEditMinimized;
+
+ Math::Point m_editActualPos;
+ Math::Point m_editActualDim;
+ Math::Point m_editFinalPos;
+ Math::Point m_editFinalDim;
+
+ float m_time;
+ float m_fixInfoTextTime;
+ bool m_bRunning;
+ bool m_bRealTime;
+ bool m_bInitPause;
+ std::string m_helpFilename;
StudioDialog m_dialog;
};
+}
+
diff --git a/src/ui/target.cpp b/src/ui/target.cpp
index f94ae02..f398e58 100644
--- a/src/ui/target.cpp
+++ b/src/ui/target.cpp
@@ -17,27 +17,14 @@
// target.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/iman.h"
-#include "object/robotmain.h"
-#include "object/object.h"
-#include "common/restext.h"
#include "ui/target.h"
-
+namespace Ui {
// Object's constructor.
-CTarget::CTarget(CInstanceManager* iMan) : CControl(iMan)
+CTarget::CTarget() : CControl()
{
}
@@ -50,11 +37,11 @@ CTarget::~CTarget()
// Creates a new button.
-bool CTarget::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CTarget::Create(Math::Point pos, Math::Point dim, int icon, EventType eventType)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventType == EVENT_NULL ) eventType = GetUniqueEventType();
- CControl::Create(pos, dim, icon, eventMsg);
+ CControl::Create(pos, dim, icon, eventType);
return true;
}
@@ -70,26 +57,27 @@ bool CTarget::EventProcess(const Event &event)
CControl::EventProcess(event);
- if ( event.event == EVENT_MOUSEMOVE )
+ if ( event.type == EVENT_MOUSE_MOVE )
{
if ( CControl::Detect(event.pos) )
{
- m_engine->SetMouseType(D3DMOUSETARGET);
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET);
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
}
- if ( event.event == EVENT_LBUTTONDOWN &&
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
if ( CControl::Detect(event.pos) )
{
Event newEvent = event;
- newEvent.event = EVENT_OBJECT_FIRE;
+ newEvent.type = EVENT_OBJECT_FIRE;
m_event->AddEvent(newEvent);
return false;
}
@@ -104,40 +92,41 @@ bool CTarget::EventProcess(const Event &event)
CControl::EventProcess(event);
- if ( event.event == EVENT_MOUSEMOVE )
+ if ( event.type == EVENT_MOUSE_MOVE )
{
m_main->SetFriendAim(false);
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseMove.pos) )
{
- pObj = DetectFriendObject(event.pos);
+ pObj = DetectFriendObject(event.mouseMove.pos);
if ( pObj == 0 )
{
- m_engine->SetMouseType(D3DMOUSETARGET);
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_TARGET);
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
return false;
}
else
{
m_main->SetFriendAim(true);
- m_engine->SetMouseType(D3DMOUSENORM);
+ m_engine->SetMouseType(Gfx::ENG_MOUSE_NORM);
}
}
}
- if ( event.event == EVENT_LBUTTONDOWN &&
+ if ( event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1 &&
(m_state & STATE_VISIBLE) &&
(m_state & STATE_ENABLE) )
{
- if ( CControl::Detect(event.pos) )
+ if ( CControl::Detect(event.mouseButton.pos) )
{
- if ( !m_main->RetFriendAim() )
+ if ( !m_main->GetFriendAim() )
{
Event newEvent = event;
- newEvent.event = EVENT_OBJECT_FIRE;
+ newEvent.type = EVENT_OBJECT_FIRE;
m_event->AddEvent(newEvent);
return false;
}
@@ -159,7 +148,7 @@ void CTarget::Draw()
// Returns the tooltip.
-bool CTarget::GetTooltip(Math::Point pos, char* name)
+bool CTarget::GetTooltip(Math::Point pos, std::string &name)
{
#if 0
if ( (m_state&STATE_VISIBLE) && Detect(pos) ) // in the window?
@@ -178,9 +167,9 @@ bool CTarget::GetTooltip(Math::Point pos, char* name)
{
//? pObj = DetectFriendObject(pos);
//? if ( pObj == 0 )
- if ( !m_main->RetFriendAim() )
+ if ( !m_main->GetFriendAim() )
{
- strcpy(name, m_tooltip);
+ m_tooltip = name;
return true; // does not detect objects below!
}
}
@@ -202,15 +191,15 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
for ( i=0 ; i<1000000 ; i++ )
{
- pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
+ pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
- if ( !pObj->RetActif() ) continue;
- if ( pObj->RetProxyActivate() ) continue;
- if ( pObj->RetSelect() ) continue;
+ if ( !pObj->GetActif() ) continue;
+ if ( pObj->GetProxyActivate() ) continue;
+ if ( pObj->GetSelect() ) continue;
pTarget = 0;
- type = pObj->RetType();
+ type = pObj->GetType();
if ( type == OBJECT_DERRICK ||
type == OBJECT_FACTORY ||
type == OBJECT_REPAIR ||
@@ -261,10 +250,10 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
}
else if ( (type == OBJECT_POWER ||
type == OBJECT_ATOMIC ) &&
- pObj->RetTruck() != 0 ) // battery used?
+ pObj->GetTruck() != 0 ) // battery used?
{
- pTarget = pObj->RetTruck();
- if ( pTarget->RetType() == OBJECT_MOBILEtg )
+ pTarget = pObj->GetTruck();
+ if ( pTarget->GetType() == OBJECT_MOBILEtg )
{
pTarget = 0;
}
@@ -272,7 +261,7 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
for ( j=0 ; j<OBJECTMAXPART ; j++ )
{
- rank = pObj->RetObjectRank(j);
+ rank = pObj->GetObjectRank(j);
if ( rank == -1 ) continue;
if ( rank != objRank ) continue;
return pTarget;
@@ -281,3 +270,4 @@ CObject* CTarget::DetectFriendObject(Math::Point pos)
return 0;
}
+}
diff --git a/src/ui/target.h b/src/ui/target.h
index ae0c7af..05a3651 100644
--- a/src/ui/target.h
+++ b/src/ui/target.h
@@ -18,31 +18,38 @@
#pragma once
+#include <string>
#include "ui/control.h"
+#include "common/misc.h"
+#include "common/iman.h"
+#include "common/restext.h"
+#include "common/event.h"
-class CD3DEngine;
-class CObject;
+#include "graphics/engine/engine.h"
+#include "object/robotmain.h"
+#include "object/object.h"
+namespace Ui {
+
class CTarget : public CControl
{
-public:
- CTarget(CInstanceManager* iMan);
- ~CTarget();
-
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
+ public:
+ CTarget();
+ ~CTarget();
- bool EventProcess(const Event &event);
- void Draw();
- bool GetTooltip(Math::Point pos, char* name);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
-protected:
- CObject* DetectFriendObject(Math::Point pos);
+ bool EventProcess(const Event &event);
+ void Draw();
+ bool GetTooltip(Math::Point pos, std::string &name);
-protected:
+ protected:
+ CObject* DetectFriendObject(Math::Point pos);
};
+}
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 8866643..4967795 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -17,44 +18,15 @@
// window.cpp
-#include <windows.h>
-#include <stdio.h>
-#include <d3d.h>
-
-#include "common/struct.h"
-#include "old/d3dengine.h"
-#include "common/language.h"
-#include "old/math3d.h"
-#include "common/event.h"
-#include "common/misc.h"
-#include "common/restext.h"
-#include "common/iman.h"
-#include "ui/button.h"
-#include "ui/color.h"
-#include "ui/check.h"
-#include "ui/key.h"
-#include "ui/group.h"
-#include "ui/image.h"
-#include "ui/label.h"
-#include "ui/edit.h"
-#include "ui/editvalue.h"
-#include "ui/scroll.h"
-#include "ui/slider.h"
-#include "ui/list.h"
-#include "ui/shortcut.h"
-#include "ui/map.h"
-#include "ui/gauge.h"
-#include "ui/compass.h"
-#include "ui/target.h"
-#include "old/text.h"
#include "ui/window.h"
-
+namespace Ui {
// Object's constructor.
-CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan)
+//CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan)
+CWindow::CWindow() : CControl()
{
int i;
@@ -80,7 +52,7 @@ CWindow::CWindow(CInstanceManager* iMan) : CControl(iMan)
m_bClosable = false;
m_bCapture = false;
- m_fontStretch = NORMSTRETCH*1.2f;
+// m_fontStretch = NORMSTRETCH*1.2f;
}
// Object's destructor.
@@ -128,9 +100,9 @@ void CWindow::Flush()
// Creates a new window.
-bool CWindow::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+bool CWindow::Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
CControl::Create(pos, dim, icon, eventMsg);
return true;
@@ -139,19 +111,20 @@ bool CWindow::Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventM
// Creates a new button.
-CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CButton* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CButton(m_iMan);
- pc = (CButton*)m_table[i];
+// m_table[i] = new CButton(m_iMan);
+ m_table[i] = new CButton();
+ pc = static_cast<CButton*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -161,19 +134,20 @@ CButton* CWindow::CreateButton(Math::Point pos, Math::Point dim, int icon, Event
// Creates a new button.
-CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CColor* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CColor(m_iMan);
- pc = (CColor*)m_table[i];
+// m_table[i] = new CColor(m_iMan);
+ m_table[i] = new CColor();
+ pc = static_cast<CColor*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -183,19 +157,20 @@ CColor* CWindow::CreateColor(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new button.
-CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CCheck* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CCheck(m_iMan);
- pc = (CCheck*)m_table[i];
+// m_table[i] = new CCheck(m_iMan);
+ m_table[i] = new CCheck();
+ pc = static_cast<CCheck*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -205,19 +180,20 @@ CCheck* CWindow::CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new button.
-CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CKey* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CKey(m_iMan);
- pc = (CKey*)m_table[i];
+// m_table[i] = new CKey(m_iMan);
+ m_table[i] = new CKey();
+ pc = static_cast<CKey*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -227,19 +203,20 @@ CKey* CWindow::CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg ev
// Creates a new button.
-CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CGroup* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CGroup(m_iMan);
- pc = (CGroup*)m_table[i];
+// m_table[i] = new CGroup(m_iMan);
+ m_table[i] = new CGroup();
+ pc = static_cast<CGroup*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -249,19 +226,20 @@ CGroup* CWindow::CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new button.
-CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CImage* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CImage(m_iMan);
- pc = (CImage*)m_table[i];
+// m_table[i] = new CImage(m_iMan);
+ m_table[i] = new CImage();
+ pc = static_cast<CImage*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -271,39 +249,27 @@ CImage* CWindow::CreateImage(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new label.
-CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
- char *name)
+CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name)
{
CLabel* pc;
- char* p;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CLabel(m_iMan);
- pc = (CLabel*)m_table[i];
+// m_table[i] = new CLabel(m_iMan);
+ m_table[i] = new CLabel();
+ pc = static_cast<CLabel*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
- p = strchr(name, '\\');
- if ( p == 0 )
- {
+ auto p = name.find("\\");
+ if ( p == std::string::npos )
pc->SetName(name);
- }
else
- {
- char text[100];
- strncpy(text, name, 100);
- text[100-1] = 0;
- if ( p-name < 100 )
- {
- text[p-name] = 0; // deletes text after "\\" (tooltip)
- }
- pc->SetName(text);
- }
+ pc->SetName(name.substr(0, p));
return pc;
}
}
@@ -312,19 +278,20 @@ CLabel* CWindow::CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new editable pave.
-CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CEdit* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CEdit(m_iMan);
- pc = (CEdit*)m_table[i];
+// m_table[i] = new CEdit(m_iMan);
+ m_table[i] = new CEdit();
+ pc = static_cast<CEdit*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -334,19 +301,20 @@ CEdit* CWindow::CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg
// Creates a new editable pave.
-CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CEditValue* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CEditValue(m_iMan);
- pc = (CEditValue*)m_table[i];
+// m_table[i] = new CEditValue(m_iMan);
+ m_table[i] = new CEditValue();
+ pc = static_cast<CEditValue*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -356,19 +324,20 @@ CEditValue* CWindow::CreateEditValue(Math::Point pos, Math::Point dim, int icon,
// Creates a new elevator.
-CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CScroll* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CScroll(m_iMan);
- pc = (CScroll*)m_table[i];
+// m_table[i] = new CScroll(m_iMan);
+ m_table[i] = new CScroll();
+ pc = static_cast<CScroll*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -378,19 +347,20 @@ CScroll* CWindow::CreateScroll(Math::Point pos, Math::Point dim, int icon, Event
// Creates a new cursor.
-CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CSlider* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CSlider(m_iMan);
- pc = (CSlider*)m_table[i];
+// m_table[i] = new CSlider(m_iMan);
+ m_table[i] = new CSlider();
+ pc = static_cast<CSlider*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -400,20 +370,21 @@ CSlider* CWindow::CreateSlider(Math::Point pos, Math::Point dim, int icon, Event
// Creates a new list.
-CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg,
+CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg,
float expand)
{
CList* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CList(m_iMan);
- pc = (CList*)m_table[i];
+// m_table[i] = new CList(m_iMan);
+ m_table[i] = new CList();
+ pc = static_cast<CList*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg, expand);
return pc;
}
@@ -423,19 +394,19 @@ CList* CWindow::CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg
// Creates a new shortcut.
-CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CShortcut* ps;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CShortcut(m_iMan);
- ps = (CShortcut*)m_table[i];
+ m_table[i] = new CShortcut();
+ ps = static_cast<CShortcut*>(m_table[i]);
ps->Create(pos, dim, icon, eventMsg);
return ps;
}
@@ -445,19 +416,19 @@ CShortcut* CWindow::CreateShortcut(Math::Point pos, Math::Point dim, int icon, E
// Creates a new card.
-CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CMap* pm;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CMap(m_iMan);
- pm = (CMap*)m_table[i];
+ m_table[i] = new CMap();
+ pm = static_cast<CMap*>(m_table[i]);
pm->Create(pos, dim, icon, eventMsg);
return pm;
}
@@ -467,19 +438,19 @@ CMap* CWindow::CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg ev
// Creates a new gauge.
-CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CGauge* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CGauge(m_iMan);
- pc = (CGauge*)m_table[i];
+ m_table[i] = new CGauge();
+ pc = static_cast<CGauge*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -489,19 +460,19 @@ CGauge* CWindow::CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMs
// Creates a new compass.
-CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CCompass* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CCompass(m_iMan);
- pc = (CCompass*)m_table[i];
+ m_table[i] = new CCompass();
+ pc = static_cast<CCompass*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -511,19 +482,19 @@ CCompass* CWindow::CreateCompass(Math::Point pos, Math::Point dim, int icon, Eve
// Creates a new target.
-CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg)
+CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg)
{
CTarget* pc;
int i;
- if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventMsg();
+ if ( eventMsg == EVENT_NULL ) eventMsg = GetUniqueEventType();
for ( i=0 ; i<MAXWINDOW ; i++ )
{
if ( m_table[i] == 0 )
{
- m_table[i] = new CTarget(m_iMan);
- pc = (CTarget*)m_table[i];
+ m_table[i] = new CTarget();
+ pc = static_cast<CTarget*>(m_table[i]);
pc->Create(pos, dim, icon, eventMsg);
return pc;
}
@@ -533,7 +504,7 @@ CTarget* CWindow::CreateTarget(Math::Point pos, Math::Point dim, int icon, Event
// Removes a control.
-bool CWindow::DeleteControl(EventMsg eventMsg)
+bool CWindow::DeleteControl(EventType eventMsg)
{
int i;
@@ -541,7 +512,7 @@ bool CWindow::DeleteControl(EventMsg eventMsg)
{
if ( m_table[i] != 0 )
{
- if ( eventMsg == m_table[i]->RetEventMsg() )
+ if ( eventMsg == m_table[i]->GetEventType() )
{
delete m_table[i];
m_table[i] = 0;
@@ -554,7 +525,7 @@ bool CWindow::DeleteControl(EventMsg eventMsg)
// Gives a control.
-CControl* CWindow::SearchControl(EventMsg eventMsg)
+CControl* CWindow::SearchControl(EventType eventMsg)
{
int i;
@@ -562,7 +533,7 @@ CControl* CWindow::SearchControl(EventMsg eventMsg)
{
if ( m_table[i] != 0 )
{
- if ( eventMsg == m_table[i]->RetEventMsg() )
+ if ( eventMsg == m_table[i]->GetEventType() )
{
return m_table[i];
}
@@ -574,7 +545,7 @@ CControl* CWindow::SearchControl(EventMsg eventMsg)
// Makes the tooltip binds to the window.
-bool CWindow::GetTooltip(Math::Point pos, char* name)
+bool CWindow::GetTooltip(Math::Point pos, std::string &name)
{
int i;
@@ -607,7 +578,7 @@ bool CWindow::GetTooltip(Math::Point pos, char* name)
if ( Detect(pos) ) // in the window?
{
- strcpy(name, m_tooltip);
+ name = m_tooltip;
return true;
}
@@ -617,7 +588,7 @@ bool CWindow::GetTooltip(Math::Point pos, char* name)
// Specifies the name for the title bar.
-void CWindow::SetName(char* name)
+void CWindow::SetName(std::string name)
{
CButton* pc;
bool bAdjust;
@@ -644,23 +615,23 @@ void CWindow::SetName(char* name)
bAdjust = false;
- if ( m_name[0] != 0 && m_bRedim ) // title bar exists?
+ if ( m_name.length() > 0 && m_bRedim ) // title bar exists?
{
- m_buttonReduce = new CButton(m_iMan);
- pc = (CButton*)m_buttonReduce;
+ m_buttonReduce = new CButton();
+ pc = m_buttonReduce;
pc->Create(m_pos, m_dim, 0, EVENT_NULL);
- m_buttonFull = new CButton(m_iMan);
- pc = (CButton*)m_buttonFull;
+ m_buttonFull = new CButton();
+ pc = m_buttonFull;
pc->Create(m_pos, m_dim, 0, EVENT_NULL);
bAdjust = true;
}
- if ( m_name[0] != 0 && m_bClosable ) // title bar exists?
+ if ( m_name.length() > 0 && m_bClosable ) // title bar exists?
{
- m_buttonClose = new CButton(m_iMan);
- pc = (CButton*)m_buttonClose;
+ m_buttonClose = new CButton();
+ pc = m_buttonClose;
pc->Create(m_pos, m_dim, 0, EVENT_NULL);
bAdjust = true;
@@ -697,7 +668,7 @@ void CWindow::MoveAdjust()
Math::Point pos, dim;
float h, offset;
- h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType);
+ h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
dim.y = h*1.2f;
dim.x = dim.y*0.75f;
@@ -742,12 +713,12 @@ void CWindow::SetMaxDim(Math::Point dim)
m_maxDim = dim;
}
-Math::Point CWindow::RetMinDim()
+Math::Point CWindow::GetMinDim()
{
return m_minDim;
}
-Math::Point CWindow::RetMaxDim()
+Math::Point CWindow::GetMaxDim()
{
return m_maxDim;
}
@@ -760,7 +731,7 @@ void CWindow::SetMovable(bool bMode)
m_bMovable = bMode;
}
-bool CWindow::RetMovable()
+bool CWindow::GetMovable()
{
return m_bMovable;
}
@@ -773,7 +744,7 @@ void CWindow::SetRedim(bool bMode)
m_bRedim = bMode;
}
-bool CWindow::RetRedim()
+bool CWindow::GetRedim()
{
return m_bRedim;
}
@@ -786,7 +757,7 @@ void CWindow::SetClosable(bool bMode)
m_bClosable = bMode;
}
-bool CWindow::RetClosable()
+bool CWindow::GetClosable()
{
return m_bClosable;
}
@@ -798,7 +769,7 @@ void CWindow::SetMaximized(bool bMaxi)
AdjustButtons();
}
-bool CWindow::RetMaximized()
+bool CWindow::GetMaximized()
{
return m_bMaximized;
}
@@ -809,7 +780,7 @@ void CWindow::SetMinimized(bool bMini)
AdjustButtons();
}
-bool CWindow::RetMinimized()
+bool CWindow::GetMinimized()
{
return m_bMinimized;
}
@@ -819,7 +790,7 @@ void CWindow::SetFixed(bool bFix)
m_bFixed = bFix;
}
-bool CWindow::RetFixed()
+bool CWindow::GetFixed()
{
return m_bFixed;
}
@@ -837,13 +808,13 @@ void CWindow::AdjustButtons()
{
m_buttonFull->SetIcon(54);
GetResource(RES_TEXT, RT_WINDOW_STANDARD, res);
- m_buttonFull->SetTooltip(res);
+ m_buttonFull->SetTooltip(std::string(res));
}
else
{
m_buttonFull->SetIcon(52);
GetResource(RES_TEXT, RT_WINDOW_MAXIMIZED, res);
- m_buttonFull->SetTooltip(res);
+ m_buttonFull->SetTooltip(std::string(res));
}
}
@@ -853,13 +824,13 @@ void CWindow::AdjustButtons()
{
m_buttonReduce->SetIcon(54);
GetResource(RES_TEXT, RT_WINDOW_STANDARD, res);
- m_buttonReduce->SetTooltip(res);
+ m_buttonReduce->SetTooltip(std::string(res));
}
else
{
m_buttonReduce->SetIcon(51);
GetResource(RES_TEXT, RT_WINDOW_MINIMIZED, res);
- m_buttonReduce->SetTooltip(res);
+ m_buttonReduce->SetTooltip(std::string(res));
}
}
@@ -867,7 +838,7 @@ void CWindow::AdjustButtons()
{
m_buttonClose->SetIcon(11); // x
GetResource(RES_TEXT, RT_WINDOW_CLOSE, res);
- m_buttonClose->SetTooltip(res);
+ m_buttonClose->SetTooltip(std::string(res));
}
}
@@ -877,7 +848,7 @@ void CWindow::SetTrashEvent(bool bTrash)
m_bTrashEvent = bTrash;
}
-bool CWindow::RetTrashEvent()
+bool CWindow::GetTrashEvent()
{
return m_bTrashEvent;
}
@@ -885,26 +856,26 @@ bool CWindow::RetTrashEvent()
// Returns the message from the button "reduce".
-EventMsg CWindow::RetEventMsgReduce()
+EventType CWindow::GetEventTypeReduce()
{
if ( m_buttonReduce == 0 ) return EVENT_NULL;
- return m_buttonReduce->RetEventMsg();
+ return m_buttonReduce->GetEventType();
}
// Returns the message from the button "full".
-EventMsg CWindow::RetEventMsgFull()
+EventType CWindow::GetEventTypeFull()
{
if ( m_buttonFull == 0 ) return EVENT_NULL;
- return m_buttonFull->RetEventMsg();
+ return m_buttonFull->GetEventType();
}
// Returns the message from the button "close".
-EventMsg CWindow::RetEventMsgClose()
+EventType CWindow::GetEventTypeClose()
{
if ( m_buttonClose == 0 ) return EVENT_NULL;
- return m_buttonClose->RetEventMsg();
+ return m_buttonClose->GetEventType();
}
@@ -947,7 +918,7 @@ int CWindow::BorderDetect(Math::Point pos)
if ( flags == 0 )
{
- h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType);
+ h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
dim.y = h*1.2f;
dim.x = dim.y*0.75f;
if ( pos.x < m_pos.x+m_dim.x-0.01f-dim.x*3.0f &&
@@ -967,7 +938,7 @@ bool CWindow::EventProcess(const Event &event)
Math::Point pos;
int i, flags;
- if ( event.event == EVENT_MOUSEMOVE )
+ if ( event.type == EVENT_MOUSE_MOVE )
{
if ( m_bCapture )
{
@@ -975,37 +946,37 @@ bool CWindow::EventProcess(const Event &event)
}
else
{
- m_pressMouse = D3DMOUSENORM;
+ m_pressMouse = Gfx::ENG_MOUSE_NORM;
- if ( m_name[0] != 0 && m_bMovable && // title bar?
+ if ( m_name.length() > 0 && m_bMovable && // title bar?
Detect(event.pos) )
{
flags = BorderDetect(event.pos);
if ( flags == -1 )
{
- m_pressMouse = D3DMOUSEMOVE; // +
+ m_pressMouse = Gfx::ENG_MOUSE_MOVE; // +
}
else if ( ((flags & (1<<0)) && (flags & (1<<3))) ||
((flags & (1<<1)) && (flags & (1<<2))) )
{
- m_pressMouse = D3DMOUSEMOVEI; // \ //
+ m_pressMouse = Gfx::ENG_MOUSE_MOVEI; // \ //
}
else if ( ((flags & (1<<0)) && (flags & (1<<1))) ||
((flags & (1<<2)) && (flags & (1<<3))) )
{
- m_pressMouse = D3DMOUSEMOVED; // /
+ m_pressMouse = Gfx::ENG_MOUSE_MOVED; // /
}
else if ( (flags & (1<<0)) || (flags & (1<<2)) )
{
- m_pressMouse = D3DMOUSEMOVEH; // -
+ m_pressMouse = Gfx::ENG_MOUSE_MOVEH; // -
}
else if ( (flags & (1<<1)) || (flags & (1<<3)) )
{
- m_pressMouse = D3DMOUSEMOVEV; // |
+ m_pressMouse = Gfx::ENG_MOUSE_MOVEV; // |
}
}
- if ( m_pressMouse != D3DMOUSENORM )
+ if ( m_pressMouse != Gfx::ENG_MOUSE_NORM )
{
m_engine->SetMouseType(m_pressMouse);
}
@@ -1039,11 +1010,12 @@ bool CWindow::EventProcess(const Event &event)
}
}
- if ( m_bTrashEvent && event.event == EVENT_LBUTTONDOWN )
+ if ( m_bTrashEvent && event.type == EVENT_MOUSE_BUTTON_DOWN &&
+ event.mouseButton.button == 1)
{
if ( Detect(event.pos) )
{
- if ( m_name[0] != 0 && m_bMovable ) // title bar?
+ if ( m_name.length() > 0 && m_bMovable ) // title bar?
{
m_pressFlags = BorderDetect(event.pos);
if ( m_pressFlags != 0 )
@@ -1056,7 +1028,7 @@ bool CWindow::EventProcess(const Event &event)
}
}
- if ( event.event == EVENT_MOUSEMOVE && m_bCapture )
+ if ( event.type == EVENT_MOUSE_MOVE && m_bCapture )
{
pos = event.pos;
if ( m_pressFlags == -1 ) // all moves?
@@ -1105,11 +1077,11 @@ bool CWindow::EventProcess(const Event &event)
AdjustButtons();
Event newEvent = event;
- newEvent.event = m_eventMsg;
+ newEvent.type = m_eventType;
m_event->AddEvent(newEvent);
}
- if ( event.event == EVENT_LBUTTONUP && m_bCapture )
+ if ( event.type == EVENT_MOUSE_BUTTON_UP && event.mouseButton.button == 1 && m_bCapture )
{
m_bCapture = false;
}
@@ -1135,9 +1107,9 @@ void CWindow::Draw()
DrawVertex(m_pos, m_dim, m_icon); // draws the background
- if ( m_name[0] != 0 ) // title bar?
+ if ( m_name.length() > 0 ) // title bar?
{
- h = m_engine->RetText()->RetHeight(m_fontSize, m_fontType);
+ h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize);
// Draws the shadow under the title bar.
{
@@ -1160,7 +1132,7 @@ void CWindow::Draw()
dim.y = h*1.2f;
DrawVertex(pos, dim, (m_state&STATE_ENABLE)?2:9);
- sw = m_engine->RetText()->RetStringWidth(m_name, strlen(m_name), m_fontSize, m_fontStretch, m_fontType);
+ sw = m_engine->GetText()->GetStringWidth(m_name, m_fontType, m_fontSize);
if ( m_state&STATE_ENABLE )
{
@@ -1175,7 +1147,7 @@ void CWindow::Draw()
pos.x = m_pos.x+width/2.0f;
pos.y = m_pos.y+m_dim.y-0.01f-h*1.10f;
- m_engine->RetText()->DrawText(m_name, pos, width, 0, m_fontSize, m_fontStretch, m_fontType, 0);
+ m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, width, Gfx::TEXT_ALIGN_CENTER, 0);
if ( m_buttonReduce != 0 )
{
@@ -1214,8 +1186,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
if ( icon == 0 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 64.0f/256.0f; // dark blue transparent
uv1.y = 64.0f/256.0f;
uv2.x = 128.0f/256.0f;
@@ -1230,8 +1202,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 1 )
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 128.0f/256.0f; // yellow tooltip
uv1.y = 0.0f/256.0f;
uv2.x = 224.0f/256.0f;
@@ -1244,8 +1216,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 2 )
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // yellow
uv1.y = 16.0f/256.0f;
uv2.x = 224.0f/256.0f;
@@ -1258,8 +1230,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 3 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 0.0f/256.0f; // transparent blue bar with yellow upper
uv1.y = 64.0f/256.0f;
uv2.x = 64.0f/256.0f;
@@ -1277,8 +1249,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.x += 100.0f/640.0f;
dim.y += 60.0f/480.0f;
- m_engine->SetTexture("human.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("human.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 140.0f/256.0f;
uv1.y = 32.0f/256.0f;
uv2.x = 182.0f/256.0f;
@@ -1294,8 +1266,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.x -= 20.0f/640.0f;
dim.y += 0.0f/480.0f;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTw);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);
uv1.x = 192.0f/256.0f;
uv1.y = 32.0f/256.0f;
uv2.x = 224.0f/256.0f;
@@ -1313,8 +1285,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.x -= 20.0f/640.0f;
dim.y -= 20.0f/480.0f;
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f;
uv1.y = 0.0f/256.0f;
uv2.x = 96.0f/256.0f;
@@ -1349,7 +1321,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
dim.x -= 20.0f/640.0f;
dim.y -= 20.0f/480.0f;
- m_engine->SetTexture("button3.tga");
+ m_engine->SetTexture("button3.png");
uv1.x = 0.0f/256.0f;
uv1.y = 224.0f/256.0f;
uv2.x = 32.0f/256.0f;
@@ -1360,7 +1332,7 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
uv2.y -= dp;
DrawIcon(pos, dim, uv1, uv2); // dark blue background
- m_engine->SetTexture("button2.tga");
+ m_engine->SetTexture("button2.png");
uv1.x = 224.0f/256.0f;
uv1.y = 224.0f/256.0f;
uv2.x = 249.0f/256.0f;
@@ -1432,8 +1404,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 5 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent green
uv1.y = 160.0f/256.0f;
uv2.x = 160.0f/256.0f;
@@ -1446,8 +1418,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 6 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent red
uv1.y = 176.0f/256.0f;
uv2.x = 160.0f/256.0f;
@@ -1460,8 +1432,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 7 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent blue
uv1.y = 192.0f/256.0f;
uv2.x = 160.0f/256.0f;
@@ -1474,8 +1446,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 8 )
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 0.0f/256.0f; // opaque orange
uv1.y = 0.0f/256.0f;
uv2.x = 32.0f/256.0f;
@@ -1490,8 +1462,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 9 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 32.0f/256.0f; // opaque gray
uv1.y = 32.0f/256.0f;
uv2.x = 64.0f/256.0f;
@@ -1510,8 +1482,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 11 )
{
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATETTb);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_BLACK);
uv1.x = 64.0f/256.0f; // transparent yellow
uv1.y = 224.0f/256.0f;
uv2.x = 160.0f/256.0f;
@@ -1524,8 +1496,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 12 )
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 128.0f/256.0f; // dirty opaque gray
uv1.y = 128.0f/256.0f;
uv2.x = 160.0f/256.0f;
@@ -1540,8 +1512,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 13 )
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 192.0f/256.0f; // dirty opaque blue
uv1.y = 128.0f/256.0f;
uv2.x = 224.0f/256.0f;
@@ -1556,8 +1528,8 @@ void CWindow::DrawVertex(Math::Point pos, Math::Point dim, int icon)
}
else if ( icon == 14 )
{
- m_engine->SetTexture("button1.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button1.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 160.0f/256.0f; // dirty opaque red
uv1.y = 128.0f/256.0f;
uv2.x = 192.0f/256.0f;
@@ -1584,8 +1556,8 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim)
dp = 0.5f/256.0f;
- m_engine->SetTexture("button2.tga");
- m_engine->SetState(D3DSTATENORMAL);
+ m_engine->SetTexture("button2.png");
+ m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
uv1.x = 64.0f/256.0f; // hatching
uv1.y = 208.0f/256.0f;
uv2.x = 145.0f/256.0f;
@@ -1618,3 +1590,4 @@ void CWindow::DrawHach(Math::Point pos, Math::Point dim)
#endif
}
+}
diff --git a/src/ui/window.h b/src/ui/window.h
index 3acf3b4..8d7090c 100644
--- a/src/ui/window.h
+++ b/src/ui/window.h
@@ -1,5 +1,6 @@
// * This file is part of the COLOBOT source code
// * Copyright (C) 2001-2008, Daniel ROUX & EPSITEC SA, www.epsitec.ch
+// * Copyright (C) 2012, Polish Portal of Colobot (PPC)
// *
// * 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
@@ -18,29 +19,34 @@
#pragma once
-
+#include <string>
+
+#include "common/event.h"
+#include "common/misc.h"
+#include "common/restext.h"
+
+#include "ui/button.h"
+#include "ui/color.h"
+#include "ui/check.h"
+#include "ui/key.h"
+#include "ui/group.h"
+#include "ui/image.h"
+#include "ui/label.h"
+#include "ui/edit.h"
+#include "ui/editvalue.h"
+#include "ui/scroll.h"
+#include "ui/slider.h"
+#include "ui/list.h"
+#include "ui/shortcut.h"
+#include "ui/map.h"
+#include "ui/gauge.h"
+#include "ui/compass.h"
+#include "ui/target.h"
#include "ui/control.h"
+#include "graphics/engine/text.h"
-class CD3DEngine;
-class CButton;
-class CColor;
-class CCheck;
-class CKey;
-class CGroup;
-class CImage;
-class CLabel;
-class CEdit;
-class CEditValue;
-class CScroll;
-class CSlider;
-class CList;
-class CShortcut;
-class CMap;
-class CGauge;
-class CCompass;
-class CTarget;
-
+namespace Ui {
const int MAXWINDOW = 100;
@@ -48,65 +54,65 @@ const int MAXWINDOW = 100;
class CWindow : public CControl
{
public:
- CWindow(CInstanceManager* iMan);
+ CWindow();
~CWindow();
void Flush();
- bool Create(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, char *name);
- CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg, float expand=1.2f);
- CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventMsg eventMsg);
- bool DeleteControl(EventMsg eventMsg);
- CControl* SearchControl(EventMsg eventMsg);
-
- EventMsg RetEventMsgReduce();
- EventMsg RetEventMsgFull();
- EventMsg RetEventMsgClose();
-
- void SetName(char* name);
+ bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CButton* CreateButton(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CColor* CreateColor(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CCheck* CreateCheck(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CKey* CreateKey(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CGroup* CreateGroup(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CImage* CreateImage(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CLabel* CreateLabel(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, std::string name);
+ CEdit* CreateEdit(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CEditValue* CreateEditValue(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CScroll* CreateScroll(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CSlider* CreateSlider(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CList* CreateList(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand=1.2f);
+ CShortcut* CreateShortcut(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CMap* CreateMap(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CGauge* CreateGauge(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CCompass* CreateCompass(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ CTarget* CreateTarget(Math::Point pos, Math::Point dim, int icon, EventType eventMsg);
+ bool DeleteControl(EventType eventMsg);
+ CControl* SearchControl(EventType eventMsg);
+
+ EventType GetEventTypeReduce();
+ EventType GetEventTypeFull();
+ EventType GetEventTypeClose();
+
+ void SetName(std::string name);
void SetTrashEvent(bool bTrash);
- bool RetTrashEvent();
+ bool GetTrashEvent();
void SetPos(Math::Point pos);
void SetDim(Math::Point dim);
void SetMinDim(Math::Point dim);
void SetMaxDim(Math::Point dim);
- Math::Point RetMinDim();
- Math::Point RetMaxDim();
+ Math::Point GetMinDim();
+ Math::Point GetMaxDim();
void SetMovable(bool bMode);
- bool RetMovable();
+ bool GetMovable();
void SetRedim(bool bMode);
- bool RetRedim();
+ bool GetRedim();
void SetClosable(bool bMode);
- bool RetClosable();
+ bool GetClosable();
void SetMaximized(bool bMaxi);
- bool RetMaximized();
+ bool GetMaximized();
void SetMinimized(bool bMini);
- bool RetMinimized();
+ bool GetMinimized();
void SetFixed(bool bFix);
- bool RetFixed();
+ bool GetFixed();
- bool GetTooltip(Math::Point pos, char* name);
+ bool GetTooltip(Math::Point pos, std::string &name);
bool EventProcess(const Event &event);
@@ -140,7 +146,8 @@ protected:
bool m_bCapture;
Math::Point m_pressPos;
int m_pressFlags;
- D3DMouse m_pressMouse;
+ Gfx::EngineMouseType m_pressMouse;
};
+}