Bring to zero some types of issues reported by colobot-lint
parent
883e07ad6a
commit
d11ebc891c
|
@ -72,6 +72,10 @@ CBotClass::~CBotClass()
|
||||||
delete m_next; // releases all of them on this level
|
delete m_next; // releases all of them on this level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CBotClass* CBotClass::Create(const char* name, CBotClass* parent, bool intrinsic)
|
||||||
|
{
|
||||||
|
return new CBotClass(name, parent, intrinsic);
|
||||||
|
}
|
||||||
|
|
||||||
void CBotClass::Free()
|
void CBotClass::Free()
|
||||||
{
|
{
|
||||||
|
|
|
@ -610,6 +610,8 @@ virtual ~CBotVar( ); // destructor
|
||||||
static
|
static
|
||||||
CBotVar* Create( CBotVar* pVar );
|
CBotVar* Create( CBotVar* pVar );
|
||||||
|
|
||||||
|
static void Destroy(CBotVar* var);
|
||||||
|
|
||||||
|
|
||||||
void SetUserPtr(void* pUser);
|
void SetUserPtr(void* pUser);
|
||||||
// associate a user pointer to an instance
|
// associate a user pointer to an instance
|
||||||
|
@ -807,6 +809,8 @@ public:
|
||||||
|
|
||||||
~CBotClass( ); // destructor
|
~CBotClass( ); // destructor
|
||||||
|
|
||||||
|
static CBotClass* Create(const char* name, CBotClass* parent, bool intrinsic = false);
|
||||||
|
|
||||||
bool AddFunction(const char* name,
|
bool AddFunction(const char* name,
|
||||||
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
|
bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
|
||||||
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar));
|
CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar));
|
||||||
|
|
|
@ -444,6 +444,11 @@ CBotVar* CBotVar::Create( const char* name, CBotClass* pClass)
|
||||||
return pVar;
|
return pVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBotVar::Destroy(CBotVar* var)
|
||||||
|
{
|
||||||
|
delete var;
|
||||||
|
}
|
||||||
|
|
||||||
CBotTypResult CBotVar::GetTypResult(int mode)
|
CBotTypResult CBotVar::GetTypResult(int mode)
|
||||||
{
|
{
|
||||||
CBotTypResult r = m_type;
|
CBotTypResult r = m_type;
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "common/version.h"
|
|
||||||
|
|
||||||
#include "app/controller.h"
|
#include "app/controller.h"
|
||||||
#include "app/input.h"
|
#include "app/input.h"
|
||||||
#include "app/system.h"
|
#include "app/system.h"
|
||||||
|
@ -32,6 +30,7 @@
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
#include "common/pathman.h"
|
#include "common/pathman.h"
|
||||||
#include "common/stringutils.h"
|
#include "common/stringutils.h"
|
||||||
|
#include "common/version.h"
|
||||||
|
|
||||||
#include "common/resources/resourcemanager.h"
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
||||||
|
@ -39,10 +38,10 @@
|
||||||
|
|
||||||
#include "graphics/opengl/glutil.h"
|
#include "graphics/opengl/glutil.h"
|
||||||
|
|
||||||
#include "object/object_manager.h"
|
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
|
#include "object/object_manager.h"
|
||||||
|
|
||||||
#ifdef OPENAL_SOUND
|
#ifdef OPENAL_SOUND
|
||||||
#include "sound/oalsound/alsound.h"
|
#include "sound/oalsound/alsound.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -479,7 +478,7 @@ bool CApplication::Create()
|
||||||
#ifdef OPENAL_SOUND
|
#ifdef OPENAL_SOUND
|
||||||
if (!m_headless)
|
if (!m_headless)
|
||||||
{
|
{
|
||||||
m_sound = MakeUnique<ALSound>();
|
m_sound = MakeUnique<CALSound>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -404,19 +404,19 @@ InputSlot CInput::SearchKeyById(std::string id)
|
||||||
return INPUT_SLOT_MAX;
|
return INPUT_SLOT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CInput::GetKeysString(InputBinding b)
|
std::string CInput::GetKeysString(InputBinding binding)
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
if ( b.primary != KEY_INVALID )
|
if ( binding.primary != KEY_INVALID )
|
||||||
{
|
{
|
||||||
std::string iNameStr;
|
std::string iNameStr;
|
||||||
if ( GetResource(RES_KEY, b.primary, iNameStr) )
|
if ( GetResource(RES_KEY, binding.primary, iNameStr) )
|
||||||
{
|
{
|
||||||
ss << iNameStr;
|
ss << iNameStr;
|
||||||
|
|
||||||
if ( b.secondary != KEY_INVALID )
|
if ( binding.secondary != KEY_INVALID )
|
||||||
{
|
{
|
||||||
if ( GetResource(RES_KEY, b.secondary, iNameStr) )
|
if ( GetResource(RES_KEY, binding.secondary, iNameStr) )
|
||||||
{
|
{
|
||||||
std::string textStr;
|
std::string textStr;
|
||||||
GetResource(RES_TEXT, RT_KEY_OR, textStr);
|
GetResource(RES_TEXT, RT_KEY_OR, textStr);
|
||||||
|
|
|
@ -131,7 +131,7 @@ public:
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//! Seeks a InputSlot by id. Returns INPUT_SLOT_MAX if not found
|
//! Seeks a InputSlot by id. Returns INPUT_SLOT_MAX if not found
|
||||||
InputSlot SearchKeyById(std::string name);
|
InputSlot SearchKeyById(std::string id);
|
||||||
|
|
||||||
//! Returns string describing keys to be pressed
|
//! Returns string describing keys to be pressed
|
||||||
//@{
|
//@{
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "common/version.h"
|
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/signal_handlers.h"
|
#include "app/signal_handlers.h"
|
||||||
|
@ -35,6 +34,7 @@
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
#include "common/restext.h"
|
#include "common/restext.h"
|
||||||
|
#include "common/version.h"
|
||||||
|
|
||||||
#include "common/resources/resourcemanager.h"
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,20 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
struct ActivePause
|
||||||
|
{
|
||||||
|
explicit ActivePause(PauseType type, PauseMusic music = PAUSE_MUSIC_NONE)
|
||||||
|
: type(type),
|
||||||
|
music(music)
|
||||||
|
{}
|
||||||
|
|
||||||
|
ActivePause(const ActivePause&) = delete;
|
||||||
|
ActivePause& operator=(const ActivePause&) = delete;
|
||||||
|
|
||||||
|
PauseType type;
|
||||||
|
PauseMusic music;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
CPauseManager::CPauseManager()
|
CPauseManager::CPauseManager()
|
||||||
{
|
{
|
||||||
|
@ -39,7 +53,7 @@ CPauseManager::~CPauseManager()
|
||||||
ActivePause* CPauseManager::ActivatePause(PauseType type, PauseMusic music)
|
ActivePause* CPauseManager::ActivatePause(PauseType type, PauseMusic music)
|
||||||
{
|
{
|
||||||
//GetLogger()->Debug("Activated pause mode - %s\n", GetPauseName(type).c_str());
|
//GetLogger()->Debug("Activated pause mode - %s\n", GetPauseName(type).c_str());
|
||||||
auto pause = std::unique_ptr<ActivePause>(new ActivePause(type, music)); // TODO: Can't use MakeUnique here because the constructor is private
|
auto pause = MakeUnique<ActivePause>(type, music);
|
||||||
ActivePause* ptr = pause.get();
|
ActivePause* ptr = pause.get();
|
||||||
m_activePause.push_back(std::move(pause));
|
m_activePause.push_back(std::move(pause));
|
||||||
Update();
|
Update();
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -63,22 +65,7 @@ enum PauseMusic
|
||||||
PAUSE_MUSIC_SATCOM = 2,
|
PAUSE_MUSIC_SATCOM = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ActivePause
|
struct ActivePause;
|
||||||
{
|
|
||||||
private:
|
|
||||||
friend class CPauseManager;
|
|
||||||
|
|
||||||
explicit ActivePause(PauseType type, PauseMusic music = PAUSE_MUSIC_NONE)
|
|
||||||
: type(type)
|
|
||||||
, music(music)
|
|
||||||
{}
|
|
||||||
|
|
||||||
ActivePause(const ActivePause&) = delete;
|
|
||||||
ActivePause& operator=(const ActivePause&) = delete;
|
|
||||||
|
|
||||||
PauseType type;
|
|
||||||
PauseMusic music;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CPauseManager
|
class CPauseManager
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,13 +19,12 @@
|
||||||
|
|
||||||
#include "app/signal_handlers.h"
|
#include "app/signal_handlers.h"
|
||||||
|
|
||||||
#include "common/version.h"
|
|
||||||
|
|
||||||
#include "common/resources/resourcemanager.h"
|
|
||||||
|
|
||||||
#include "app/system.h"
|
#include "app/system.h"
|
||||||
|
|
||||||
#include "common/stringutils.h"
|
#include "common/stringutils.h"
|
||||||
|
#include "common/version.h"
|
||||||
|
|
||||||
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,6 @@
|
||||||
|
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
|
|
||||||
#include "common/make_unique.h"
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(PLATFORM_WINDOWS)
|
#if defined(PLATFORM_WINDOWS)
|
||||||
#include "app/system_windows.h"
|
#include "app/system_windows.h"
|
||||||
#elif defined(PLATFORM_LINUX)
|
#elif defined(PLATFORM_LINUX)
|
||||||
|
@ -35,6 +32,8 @@
|
||||||
#include "app/system_other.h"
|
#include "app/system_other.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
|
@ -151,9 +151,9 @@ bool CLogger::IsOpened()
|
||||||
return m_file != nullptr;
|
return m_file != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogger::SetLogLevel(LogLevel type)
|
void CLogger::SetLogLevel(LogLevel level)
|
||||||
{
|
{
|
||||||
m_logLevel = type;
|
m_logLevel = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLogger::ParseLogLevel(const std::string& str, LogLevel& logLevel)
|
bool CLogger::ParseLogLevel(const std::string& str, LogLevel& logLevel)
|
||||||
|
|
|
@ -25,7 +25,7 @@ std::string FormatAssertRegexMatchError(const std::string& text,
|
||||||
return "Text \"" + text + "\" did not match regex \"" + pattern + "\"";
|
return "Text \"" + text + "\" did not match regex \"" + pattern + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
RegexUtils::AssertRegexMatchError::AssertRegexMatchError(
|
RegexUtils::CAssertRegexMatchError::CAssertRegexMatchError(
|
||||||
const std::string& text, const std::string& pattern) NOEXCEPT
|
const std::string& text, const std::string& pattern) NOEXCEPT
|
||||||
: std::runtime_error(FormatAssertRegexMatchError(text, pattern))
|
: std::runtime_error(FormatAssertRegexMatchError(text, pattern))
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ boost::smatch RegexUtils::AssertRegexMatch(const std::string& text, const std::s
|
||||||
boost::smatch matches;
|
boost::smatch matches;
|
||||||
bool ok = boost::regex_match(text, matches, regex);
|
bool ok = boost::regex_match(text, matches, regex);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
throw AssertRegexMatchError(text, pattern);
|
throw CAssertRegexMatchError(text, pattern);
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,11 @@
|
||||||
namespace RegexUtils
|
namespace RegexUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
class AssertRegexMatchError : public std::runtime_error
|
class CAssertRegexMatchError : public std::runtime_error
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit AssertRegexMatchError(const std::string& text,
|
explicit CAssertRegexMatchError(const std::string& text,
|
||||||
const std::string& pattern) NOEXCEPT;
|
const std::string& pattern) NOEXCEPT;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Match string with regex and return list of matches; throw exception on mismatch
|
//! Match string with regex and return list of matches; throw exception on mismatch
|
||||||
|
|
|
@ -859,8 +859,8 @@ void CCamera::FixCamera()
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCamera::SetViewTime(const Math::Vector &eyePt,
|
void CCamera::SetViewTime(const Math::Vector &eyePt,
|
||||||
const Math::Vector &lookatPt,
|
const Math::Vector &lookatPt,
|
||||||
float rTime)
|
float rTime)
|
||||||
{
|
{
|
||||||
Math::Vector eye, lookat;
|
Math::Vector eye, lookat;
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ protected:
|
||||||
bool EventFrameScript(const Event &event);
|
bool EventFrameScript(const Event &event);
|
||||||
|
|
||||||
//! Specifies the location and direction of view to the 3D engine
|
//! Specifies the location and direction of view to the 3D engine
|
||||||
void SetViewTime(const Math::Vector &vEyePt, const Math::Vector &vLookatPt, float rTime);
|
void SetViewTime(const Math::Vector &eyePt, const Math::Vector &lookatPt, float rTime);
|
||||||
//! Avoid the obstacles
|
//! Avoid the obstacles
|
||||||
bool IsCollision(Math::Vector &eye, Math::Vector lookat);
|
bool IsCollision(Math::Vector &eye, Math::Vector lookat);
|
||||||
//! Avoid the obstacles
|
//! Avoid the obstacles
|
||||||
|
|
|
@ -74,7 +74,7 @@ public:
|
||||||
|
|
||||||
//! Management of clouds
|
//! Management of clouds
|
||||||
//@{
|
//@{
|
||||||
void SetEnabled(bool enable);
|
void SetEnabled(bool enabled);
|
||||||
bool GetEnabled();
|
bool GetEnabled();
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
|
@ -4932,11 +4932,11 @@ int CEngine::GetEngineState(const ModelTriangle& triangle)
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::UpdateObjectShadowSpotNormal(int rank)
|
void CEngine::UpdateObjectShadowSpotNormal(int objRank)
|
||||||
{
|
{
|
||||||
assert(rank >= 0 && rank < static_cast<int>( m_objects.size() ));
|
assert(objRank >= 0 && objRank < static_cast<int>( m_objects.size() ));
|
||||||
|
|
||||||
int shadowRank = m_objects[rank].shadowRank;
|
int shadowRank = m_objects[objRank].shadowRank;
|
||||||
if (shadowRank == -1)
|
if (shadowRank == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
class CApplication;
|
class CApplication;
|
||||||
class CSoundInterface;
|
class CSoundInterface;
|
||||||
class CImage;
|
class CImage;
|
||||||
class CPauseManager;
|
|
||||||
class CSystemUtils;
|
class CSystemUtils;
|
||||||
struct SystemTimeStamp;
|
struct SystemTimeStamp;
|
||||||
struct Event;
|
struct Event;
|
||||||
|
@ -717,7 +716,7 @@ public:
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//! Increments the triangle counter for the current frame
|
//! Increments the triangle counter for the current frame
|
||||||
void AddStatisticTriangle(int nb);
|
void AddStatisticTriangle(int count);
|
||||||
//! Returns the number of triangles in current frame
|
//! Returns the number of triangles in current frame
|
||||||
int GetStatisticTriangle();
|
int GetStatisticTriangle();
|
||||||
|
|
||||||
|
@ -778,7 +777,7 @@ public:
|
||||||
// Objects
|
// Objects
|
||||||
|
|
||||||
//! Print debug info about an object
|
//! Print debug info about an object
|
||||||
void DebugObject(int rank);
|
void DebugObject(int objRank);
|
||||||
|
|
||||||
//! Creates a new object and returns its rank
|
//! Creates a new object and returns its rank
|
||||||
int CreateObject();
|
int CreateObject();
|
||||||
|
@ -942,7 +941,7 @@ public:
|
||||||
void SetTexture(const Texture& tex, int stage = 0);
|
void SetTexture(const Texture& tex, int stage = 0);
|
||||||
|
|
||||||
//! Deletes the given texture, unloading it and removing from cache
|
//! Deletes the given texture, unloading it and removing from cache
|
||||||
void DeleteTexture(const std::string& name);
|
void DeleteTexture(const std::string& texName);
|
||||||
//! Deletes the given texture, unloading it and removing from cache
|
//! Deletes the given texture, unloading it and removing from cache
|
||||||
void DeleteTexture(const Texture& tex);
|
void DeleteTexture(const Texture& tex);
|
||||||
|
|
||||||
|
@ -1215,7 +1214,7 @@ protected:
|
||||||
//! Draws the mouse cursor
|
//! Draws the mouse cursor
|
||||||
void DrawMouse();
|
void DrawMouse();
|
||||||
//! Draw part of mouse cursor sprite
|
//! Draw part of mouse cursor sprite
|
||||||
void DrawMouseSprite(Math::Point pos, Math::Point dim, int icon);
|
void DrawMouseSprite(Math::Point pos, Math::Point size, int icon);
|
||||||
//! Draw statistic texts
|
//! Draw statistic texts
|
||||||
void DrawStats();
|
void DrawStats();
|
||||||
//! Draw mission timer
|
//! Draw mission timer
|
||||||
|
@ -1225,7 +1224,7 @@ protected:
|
||||||
EngineBaseObjTexTier& AddLevel2(EngineBaseObject& p1, const std::string& tex1Name, const std::string& tex2Name);
|
EngineBaseObjTexTier& AddLevel2(EngineBaseObject& p1, const std::string& tex1Name, const std::string& tex2Name);
|
||||||
//! Creates a new tier 3 object (data)
|
//! Creates a new tier 3 object (data)
|
||||||
EngineBaseObjDataTier& AddLevel3(EngineBaseObjTexTier &p3, EngineTriangleType type,
|
EngineBaseObjDataTier& AddLevel3(EngineBaseObjTexTier &p3, EngineTriangleType type,
|
||||||
const Material& mat, int state);
|
const Material& material, int state);
|
||||||
|
|
||||||
//! Create texture and add it to cache
|
//! Create texture and add it to cache
|
||||||
Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr);
|
Texture CreateTexture(const std::string &texName, const TextureCreateParams ¶ms, CImage* image = nullptr);
|
||||||
|
|
|
@ -448,7 +448,7 @@ void CLightManager::UpdateDeviceLights(EngineObjectType type)
|
||||||
m_lightMap[i] = -1;
|
m_lightMap[i] = -1;
|
||||||
|
|
||||||
std::vector<DynamicLight> sortedLights = m_dynLights;
|
std::vector<DynamicLight> sortedLights = m_dynLights;
|
||||||
LightsComparator lightsComparator(m_engine->GetEyePt(), type);
|
CLightsComparator lightsComparator(m_engine->GetEyePt(), type);
|
||||||
std::sort(sortedLights.begin(), sortedLights.end(), lightsComparator);
|
std::sort(sortedLights.begin(), sortedLights.end(), lightsComparator);
|
||||||
|
|
||||||
int lightMapIndex = 0;
|
int lightMapIndex = 0;
|
||||||
|
@ -497,13 +497,13 @@ void CLightManager::UpdateDeviceLights(EngineObjectType type)
|
||||||
|
|
||||||
// -----------
|
// -----------
|
||||||
|
|
||||||
CLightManager::LightsComparator::LightsComparator(Math::Vector eyePos, EngineObjectType objectType)
|
CLightManager::CLightsComparator::CLightsComparator(Math::Vector eyePos, EngineObjectType objectType)
|
||||||
{
|
{
|
||||||
m_eyePos = eyePos;
|
m_eyePos = eyePos;
|
||||||
m_objectType = objectType;
|
m_objectType = objectType;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CLightManager::LightsComparator::GetLightWeight(const DynamicLight& dynLight)
|
float CLightManager::CLightsComparator::GetLightWeight(const DynamicLight& dynLight)
|
||||||
{
|
{
|
||||||
if (dynLight.priority == LIGHT_PRI_HIGHEST)
|
if (dynLight.priority == LIGHT_PRI_HIGHEST)
|
||||||
return -1.0f;
|
return -1.0f;
|
||||||
|
@ -519,7 +519,7 @@ float CLightManager::LightsComparator::GetLightWeight(const DynamicLight& dynLig
|
||||||
return enabled ? ( (dynLight.light.position - m_eyePos).Length() * dynLight.priority ) : 10000.0f;
|
return enabled ? ( (dynLight.light.position - m_eyePos).Length() * dynLight.priority ) : 10000.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLightManager::LightsComparator::operator()(const DynamicLight& left, const DynamicLight& right)
|
bool CLightManager::CLightsComparator::operator()(const DynamicLight& left, const DynamicLight& right)
|
||||||
{
|
{
|
||||||
float leftWeight = GetLightWeight(left);
|
float leftWeight = GetLightWeight(left);
|
||||||
float rightWeight = GetLightWeight(right);
|
float rightWeight = GetLightWeight(right);
|
||||||
|
|
|
@ -168,7 +168,7 @@ public:
|
||||||
//! Returns the light parameters for given dynamic light
|
//! Returns the light parameters for given dynamic light
|
||||||
bool GetLight(int lightRank, Light &light);
|
bool GetLight(int lightRank, Light &light);
|
||||||
//! Enables/disables the given dynamic light
|
//! Enables/disables the given dynamic light
|
||||||
bool SetLightEnabled(int lightRank, bool enable);
|
bool SetLightEnabled(int lightRank, bool enabled);
|
||||||
//! Changes the light priority
|
//! Changes the light priority
|
||||||
bool SetLightPriority(int lightRank, LightPriority priority);
|
bool SetLightPriority(int lightRank, LightPriority priority);
|
||||||
|
|
||||||
|
@ -212,10 +212,10 @@ public:
|
||||||
void UpdateDeviceLights(EngineObjectType type);
|
void UpdateDeviceLights(EngineObjectType type);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class LightsComparator
|
class CLightsComparator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LightsComparator(Math::Vector eyePos, EngineObjectType objectType);
|
CLightsComparator(Math::Vector eyePos, EngineObjectType objectType);
|
||||||
|
|
||||||
bool operator()(const DynamicLight& left, const DynamicLight& right);
|
bool operator()(const DynamicLight& left, const DynamicLight& right);
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ protected:
|
||||||
void DeleteObject(bool primary, bool secondary);
|
void DeleteObject(bool primary, bool secondary);
|
||||||
|
|
||||||
//! Creates an explosion with triangular form of particles
|
//! Creates an explosion with triangular form of particles
|
||||||
void CreateTriangle(CObject* obj, ObjectType type, int part);
|
void CreateTriangle(CObject* obj, ObjectType oType, int part);
|
||||||
|
|
||||||
//! Starts the explosion of a vehicle
|
//! Starts the explosion of a vehicle
|
||||||
void ExploStart();
|
void ExploStart();
|
||||||
|
|
|
@ -247,13 +247,13 @@ bool CTerrain::LoadResources(const std::string& fileName)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrainRes CTerrain::GetResource(const Math::Vector &p)
|
TerrainRes CTerrain::GetResource(const Math::Vector &pos)
|
||||||
{
|
{
|
||||||
if (m_resources.empty())
|
if (m_resources.empty())
|
||||||
return TR_NULL;
|
return TR_NULL;
|
||||||
|
|
||||||
int x = static_cast<int>((p.x + (m_mosaicCount*m_brickCount*m_brickSize)/2.0f)/m_brickSize);
|
int x = static_cast<int>((pos.x + (m_mosaicCount*m_brickCount*m_brickSize)/2.0f)/m_brickSize);
|
||||||
int y = static_cast<int>((p.z + (m_mosaicCount*m_brickCount*m_brickSize)/2.0f)/m_brickSize);
|
int y = static_cast<int>((pos.z + (m_mosaicCount*m_brickCount*m_brickSize)/2.0f)/m_brickSize);
|
||||||
|
|
||||||
if ( x < 0 || x > m_mosaicCount*m_brickCount ||
|
if ( x < 0 || x > m_mosaicCount*m_brickCount ||
|
||||||
y < 0 || y > m_mosaicCount*m_brickCount )
|
y < 0 || y > m_mosaicCount*m_brickCount )
|
||||||
|
@ -1677,16 +1677,16 @@ bool CTerrain::DeleteBuildingLevel(Math::Vector center)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CTerrain::GetBuildingFactor(const Math::Vector &p)
|
float CTerrain::GetBuildingFactor(const Math::Vector &pos)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < static_cast<int>( m_buildingLevels.size() ); i++)
|
for (int i = 0; i < static_cast<int>( m_buildingLevels.size() ); i++)
|
||||||
{
|
{
|
||||||
if ( p.x < m_buildingLevels[i].bboxMinX ||
|
if ( pos.x < m_buildingLevels[i].bboxMinX ||
|
||||||
p.x > m_buildingLevels[i].bboxMaxX ||
|
pos.x > m_buildingLevels[i].bboxMaxX ||
|
||||||
p.z < m_buildingLevels[i].bboxMinZ ||
|
pos.z < m_buildingLevels[i].bboxMinZ ||
|
||||||
p.z > m_buildingLevels[i].bboxMaxZ ) continue;
|
pos.z > m_buildingLevels[i].bboxMaxZ ) continue;
|
||||||
|
|
||||||
float dist = Math::DistanceProjected(p, m_buildingLevels[i].center);
|
float dist = Math::DistanceProjected(pos, m_buildingLevels[i].center);
|
||||||
|
|
||||||
if (dist <= m_buildingLevels[i].max)
|
if (dist <= m_buildingLevels[i].max)
|
||||||
return m_buildingLevels[i].factor;
|
return m_buildingLevels[i].factor;
|
||||||
|
@ -1730,9 +1730,9 @@ void CTerrain::AdjustBuildingLevel(Math::Vector &p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float CTerrain::GetHardness(const Math::Vector &p)
|
float CTerrain::GetHardness(const Math::Vector &pos)
|
||||||
{
|
{
|
||||||
float factor = GetBuildingFactor(p);
|
float factor = GetBuildingFactor(pos);
|
||||||
if (factor != 1.0f) return 1.0f; // on building level
|
if (factor != 1.0f) return 1.0f; // on building level
|
||||||
|
|
||||||
if (m_materialPoints.empty()) return m_defaultHardness;
|
if (m_materialPoints.empty()) return m_defaultHardness;
|
||||||
|
@ -1741,8 +1741,8 @@ float CTerrain::GetHardness(const Math::Vector &p)
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
x = static_cast<int>((p.x+dim)/m_brickSize);
|
x = static_cast<int>((pos.x+dim)/m_brickSize);
|
||||||
y = static_cast<int>((p.z+dim)/m_brickSize);
|
y = static_cast<int>((pos.z+dim)/m_brickSize);
|
||||||
|
|
||||||
if ( x < 0 || x > m_mosaicCount*m_brickCount ||
|
if ( x < 0 || x > m_mosaicCount*m_brickCount ||
|
||||||
y < 0 || y > m_mosaicCount*m_brickCount ) return m_defaultHardness;
|
y < 0 || y > m_mosaicCount*m_brickCount ) return m_defaultHardness;
|
||||||
|
|
|
@ -157,7 +157,7 @@ public:
|
||||||
//! Clears all terrain materials
|
//! Clears all terrain materials
|
||||||
void FlushMaterials();
|
void FlushMaterials();
|
||||||
//! Adds a terrain material the names of textures to use for the land
|
//! Adds a terrain material the names of textures to use for the land
|
||||||
void AddMaterial(int id, const std::string& baseName, const Math::Point& uv,
|
void AddMaterial(int id, const std::string& texName, const Math::Point& uv,
|
||||||
int up, int right, int down, int left, float hardness);
|
int up, int right, int down, int left, float hardness);
|
||||||
//! Initializes all the ground with one material
|
//! Initializes all the ground with one material
|
||||||
bool InitMaterials(int id);
|
bool InitMaterials(int id);
|
||||||
|
|
|
@ -22,14 +22,14 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "graphics/engine/engine.h"
|
|
||||||
|
|
||||||
#include "common/image.h"
|
#include "common/image.h"
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "common/stringutils.h"
|
#include "common/stringutils.h"
|
||||||
|
|
||||||
#include "common/resources/resourcemanager.h"
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
||||||
|
#include "graphics/engine/engine.h"
|
||||||
|
|
||||||
#include "math/func.h"
|
#include "math/func.h"
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
#include "graphics/core/color.h"
|
#include "graphics/core/color.h"
|
||||||
|
|
||||||
#include "math/point.h"
|
|
||||||
#include "math/intpoint.h"
|
#include "math/intpoint.h"
|
||||||
|
#include "math/point.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -309,7 +309,7 @@ public:
|
||||||
CharTexture GetCharTexture(UTF8Char ch, FontType font, float size);
|
CharTexture GetCharTexture(UTF8Char ch, FontType font, float size);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CachedFont* GetOrOpenFont(FontType type, float size);
|
CachedFont* GetOrOpenFont(FontType font, float size);
|
||||||
CharTexture CreateCharTexture(UTF8Char ch, CachedFont* font);
|
CharTexture CreateCharTexture(UTF8Char ch, CachedFont* font);
|
||||||
|
|
||||||
void DrawString(const std::string &text, std::vector<FontMetaChar>::iterator format,
|
void DrawString(const std::string &text, std::vector<FontMetaChar>::iterator format,
|
||||||
|
|
|
@ -59,8 +59,8 @@ namespace ModelInput
|
||||||
VertexTex2 ReadBinaryVertexTex2(std::istream& stream);
|
VertexTex2 ReadBinaryVertexTex2(std::istream& stream);
|
||||||
Material ReadBinaryMaterial(std::istream& stream);
|
Material ReadBinaryMaterial(std::istream& stream);
|
||||||
|
|
||||||
std::string ReadLineString(std::istream& stream, const std::string& prefix);
|
std::string ReadLineString(std::istream& stream, const std::string& expectedPrefix);
|
||||||
void ReadValuePrefix(std::istream& stream, const std::string& prefix);
|
void ReadValuePrefix(std::istream& stream, const std::string& expectedPrefix);
|
||||||
VertexTex2 ParseVertexTex2(const std::string& text);
|
VertexTex2 ParseVertexTex2(const std::string& text);
|
||||||
Material ParseMaterial(const std::string& text);
|
Material ParseMaterial(const std::string& text);
|
||||||
Math::Vector ParseVector(const std::string& text);
|
Math::Vector ParseVector(const std::string& text);
|
||||||
|
|
|
@ -24,10 +24,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "level/level_category.h"
|
|
||||||
|
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
|
#include "level/level_category.h"
|
||||||
#include "level/robotmain.h"
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
#include "level/parser/parserexceptions.h"
|
#include "level/parser/parserexceptions.h"
|
||||||
|
|
|
@ -502,15 +502,21 @@ void CRobotMain::ChangePhase(Phase phase)
|
||||||
if (CResourceManager::DirectoryExists("crashsave"))
|
if (CResourceManager::DirectoryExists("crashsave"))
|
||||||
{
|
{
|
||||||
GetLogger()->Info("Pre-crash save found!\n");
|
GetLogger()->Info("Pre-crash save found!\n");
|
||||||
m_ui->GetDialog()->StartQuestion("Your game seems to have crashed. Do you want to restore pre-crash state?", false, false, false, [&]() {
|
m_ui->GetDialog()->StartQuestion(
|
||||||
GetLogger()->Info("Trying to restore pre-crash state...\n");
|
"Your game seems to have crashed. Do you want to restore pre-crash state?", false, false, false,
|
||||||
assert(m_playerProfile != nullptr);
|
[&]()
|
||||||
m_playerProfile->LoadScene("../../crashsave");
|
{
|
||||||
CResourceManager::RemoveDirectory("crashsave");
|
GetLogger()->Info("Trying to restore pre-crash state...\n");
|
||||||
}, [&]() {
|
assert(m_playerProfile != nullptr);
|
||||||
GetLogger()->Info("Not restoring pre-crash state\n");
|
m_playerProfile->LoadScene("../../crashsave");
|
||||||
CResourceManager::RemoveDirectory("crashsave");
|
CResourceManager::RemoveDirectory("crashsave");
|
||||||
});
|
},
|
||||||
|
[&]()
|
||||||
|
{
|
||||||
|
GetLogger()->Info("Not restoring pre-crash state\n");
|
||||||
|
CResourceManager::RemoveDirectory("crashsave");
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,9 +1024,13 @@ bool CRobotMain::ProcessEvent(Event &event)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_OBJECT_DELETE:
|
case EVENT_OBJECT_DELETE:
|
||||||
m_ui->GetDialog()->StartQuestion(RT_DIALOG_DELOBJ, true, false, false, [&]() {
|
m_ui->GetDialog()->StartQuestion(
|
||||||
DestroySelectedObject();
|
RT_DIALOG_DELOBJ, true, false, false,
|
||||||
});
|
[&]()
|
||||||
|
{
|
||||||
|
DestroySelectedObject();
|
||||||
|
}
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_OBJECT_BHELP:
|
case EVENT_OBJECT_BHELP:
|
||||||
|
@ -2256,9 +2266,9 @@ void CRobotMain::ChangeCamera()
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Remote control the camera using the arrow keys
|
//! Remote control the camera using the arrow keys
|
||||||
void CRobotMain::KeyCamera(EventType type, InputSlot key)
|
void CRobotMain::KeyCamera(EventType event, InputSlot key)
|
||||||
{
|
{
|
||||||
if (type == EVENT_KEY_UP)
|
if (event == EVENT_KEY_UP)
|
||||||
{
|
{
|
||||||
if (key == INPUT_SLOT_LEFT)
|
if (key == INPUT_SLOT_LEFT)
|
||||||
{
|
{
|
||||||
|
@ -2290,7 +2300,7 @@ void CRobotMain::KeyCamera(EventType type, InputSlot key)
|
||||||
assert(obj->Implements(ObjectInterfaceType::Controllable));
|
assert(obj->Implements(ObjectInterfaceType::Controllable));
|
||||||
if (!dynamic_cast<CControllableObject*>(obj)->GetTrainer()) return;
|
if (!dynamic_cast<CControllableObject*>(obj)->GetTrainer()) return;
|
||||||
|
|
||||||
if (type == EVENT_KEY_DOWN)
|
if (event == EVENT_KEY_DOWN)
|
||||||
{
|
{
|
||||||
if (key == INPUT_SLOT_LEFT)
|
if (key == INPUT_SLOT_LEFT)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,14 +30,14 @@
|
||||||
#include "common/event.h"
|
#include "common/event.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
|
|
||||||
|
#include "graphics/engine/camera.h"
|
||||||
|
#include "graphics/engine/particle.h"
|
||||||
|
|
||||||
#include "level/build_type.h"
|
#include "level/build_type.h"
|
||||||
#include "level/level_category.h"
|
#include "level/level_category.h"
|
||||||
#include "level/mainmovie.h"
|
#include "level/mainmovie.h"
|
||||||
#include "level/research_type.h"
|
#include "level/research_type.h"
|
||||||
|
|
||||||
#include "graphics/engine/camera.h"
|
|
||||||
#include "graphics/engine/particle.h"
|
|
||||||
|
|
||||||
#include "object/drive_type.h"
|
#include "object/drive_type.h"
|
||||||
#include "object/mission_type.h"
|
#include "object/mission_type.h"
|
||||||
#include "object/object_type.h"
|
#include "object/object_type.h"
|
||||||
|
@ -193,8 +193,8 @@ public:
|
||||||
void SelectHuman();
|
void SelectHuman();
|
||||||
CObject* SearchHuman();
|
CObject* SearchHuman();
|
||||||
CObject* SearchToto();
|
CObject* SearchToto();
|
||||||
CObject* SearchNearest(Math::Vector pos, CObject* pExclu);
|
CObject* SearchNearest(Math::Vector pos, CObject* exclu);
|
||||||
bool SelectObject(CObject* pObj, bool displayError=true);
|
bool SelectObject(CObject* obj, bool displayError=true);
|
||||||
CObject* GetSelectObject();
|
CObject* GetSelectObject();
|
||||||
CObject* DeselectAll();
|
CObject* DeselectAll();
|
||||||
|
|
||||||
|
@ -259,15 +259,15 @@ public:
|
||||||
void HideDropZone(CObject* metal);
|
void HideDropZone(CObject* metal);
|
||||||
void ShowDropZone(CObject* metal, CObject* transporter);
|
void ShowDropZone(CObject* metal, CObject* transporter);
|
||||||
void FlushShowLimit(int i);
|
void FlushShowLimit(int i);
|
||||||
void SetShowLimit(int i, Gfx::ParticleType parti, CObject *pObj, Math::Vector pos,
|
void SetShowLimit(int i, Gfx::ParticleType parti, CObject *obj, Math::Vector pos,
|
||||||
float radius, float duration=SHOWLIMITTIME);
|
float radius, float duration=SHOWLIMITTIME);
|
||||||
void StartShowLimit();
|
void StartShowLimit();
|
||||||
void FrameShowLimit(float rTime);
|
void FrameShowLimit(float rTime);
|
||||||
|
|
||||||
void SaveAllScript();
|
void SaveAllScript();
|
||||||
void SaveOneScript(CObject *pObj);
|
void SaveOneScript(CObject *obj);
|
||||||
bool SaveFileStack(CObject *pObj, FILE *file, int objRank);
|
bool SaveFileStack(CObject *obj, FILE *file, int objRank);
|
||||||
bool ReadFileStack(CObject *pObj, FILE *file, int objRank);
|
bool ReadFileStack(CObject *obj, FILE *file, int objRank);
|
||||||
|
|
||||||
void FlushNewScriptName();
|
void FlushNewScriptName();
|
||||||
void AddNewScriptName(ObjectType type, const std::string& name);
|
void AddNewScriptName(ObjectType type, const std::string& name);
|
||||||
|
@ -365,7 +365,7 @@ public:
|
||||||
|
|
||||||
void StartDetectEffect(COldObject* object, CObject* target);
|
void StartDetectEffect(COldObject* object, CObject* target);
|
||||||
|
|
||||||
bool IsSelectable(CObject* pObj);
|
bool IsSelectable(CObject* obj);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool EventFrame(const Event &event);
|
bool EventFrame(const Event &event);
|
||||||
|
@ -390,7 +390,7 @@ protected:
|
||||||
void RemoteCamera(float pan, float zoom, float rTime);
|
void RemoteCamera(float pan, float zoom, float rTime);
|
||||||
void KeyCamera(EventType event, InputSlot key);
|
void KeyCamera(EventType event, InputSlot key);
|
||||||
void AbortMovie();
|
void AbortMovie();
|
||||||
void SelectOneObject(CObject* pObj, bool displayError=true);
|
void SelectOneObject(CObject* obj, bool displayError=true);
|
||||||
void HelpObject();
|
void HelpObject();
|
||||||
bool DeselectObject();
|
bool DeselectObject();
|
||||||
void DeleteAllObjects();
|
void DeleteAllObjects();
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
|
|
||||||
#include "level/scene_conditions.h"
|
#include "level/scene_conditions.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
|
||||||
|
|
||||||
#include "level/parser/parserline.h"
|
#include "level/parser/parserline.h"
|
||||||
|
|
||||||
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
#include "object/object_manager.h"
|
#include "object/object_manager.h"
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,12 @@
|
||||||
|
|
||||||
#include "object/old_object.h"
|
#include "object/old_object.h"
|
||||||
|
|
||||||
|
#include "sound/sound.h"
|
||||||
|
|
||||||
#include "ui/controls/gauge.h"
|
#include "ui/controls/gauge.h"
|
||||||
#include "ui/controls/interface.h"
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
#include "sound/sound.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Object's constructor.
|
// Object's constructor.
|
||||||
|
|
||||||
|
@ -372,9 +372,9 @@ bool CAuto::GetBusy()
|
||||||
return m_bBusy;
|
return m_bBusy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAuto::SetBusy(bool bBusy)
|
void CAuto::SetBusy(bool busy)
|
||||||
{
|
{
|
||||||
m_bBusy = bBusy;
|
m_bBusy = busy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAuto::InitProgressTotal(float total)
|
void CAuto::InitProgressTotal(float total)
|
||||||
|
|
|
@ -19,9 +19,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include "common/event.h"
|
|
||||||
#include "common/error.h"
|
#include "common/error.h"
|
||||||
|
#include "common/event.h"
|
||||||
|
|
||||||
#include "object/object_type.h"
|
#include "object/object_type.h"
|
||||||
|
|
||||||
|
@ -75,7 +74,7 @@ public:
|
||||||
virtual Error GetError();
|
virtual Error GetError();
|
||||||
|
|
||||||
virtual bool GetBusy();
|
virtual bool GetBusy();
|
||||||
virtual void SetBusy(bool bBuse);
|
virtual void SetBusy(bool busy);
|
||||||
virtual void InitProgressTotal(float total);
|
virtual void InitProgressTotal(float total);
|
||||||
virtual void EventProgress(float rTime);
|
virtual void EventProgress(float rTime);
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,6 @@
|
||||||
#include "ui/controls/interface.h"
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
#include "sound/sound.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const float BASE_LAND_TIME = 7.5f; // hard landing
|
const float BASE_LAND_TIME = 7.5f; // hard landing
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void UpdateInterface();
|
void UpdateInterface();
|
||||||
void FreezeCargo(bool bFreeze);
|
void FreezeCargo(bool freeze);
|
||||||
void MoveCargo();
|
void MoveCargo();
|
||||||
Error CheckCloseDoor();
|
Error CheckCloseDoor();
|
||||||
void BeginTransit();
|
void BeginTransit();
|
||||||
|
|
|
@ -22,11 +22,11 @@
|
||||||
|
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
#include "level/parser/parserline.h"
|
#include "level/parser/parserline.h"
|
||||||
#include "level/parser/parserparam.h"
|
#include "level/parser/parserparam.h"
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
|
||||||
|
|
||||||
#include "math/geometry.h"
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/object_manager.h"
|
#include "object/object_manager.h"
|
||||||
|
@ -34,11 +34,11 @@
|
||||||
|
|
||||||
#include "object/interface/transportable_object.h"
|
#include "object/interface/transportable_object.h"
|
||||||
|
|
||||||
|
#include "sound/sound.h"
|
||||||
|
|
||||||
#include "ui/controls/interface.h"
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
#include "sound/sound.h"
|
|
||||||
|
|
||||||
|
|
||||||
// Object's constructor.
|
// Object's constructor.
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
CAutoConvert(COldObject* object);
|
CAutoConvert(COldObject* object);
|
||||||
~CAutoConvert();
|
~CAutoConvert();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false) override;
|
void DeleteObject(bool all=false) override;
|
||||||
|
|
||||||
void Init() override;
|
void Init() override;
|
||||||
bool EventProcess(const Event &event) override;
|
bool EventProcess(const Event &event) override;
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
#include "ui/controls/interface.h"
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
#include "sound/sound.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const float DERRICK_DELAY = 10.0f; // duration of the extraction
|
const float DERRICK_DELAY = 10.0f; // duration of the extraction
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
CAutoDerrick(COldObject* object);
|
CAutoDerrick(COldObject* object);
|
||||||
~CAutoDerrick();
|
~CAutoDerrick();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false) override;
|
void DeleteObject(bool all=false) override;
|
||||||
|
|
||||||
void Init() override;
|
void Init() override;
|
||||||
bool EventProcess(const Event &event) override;
|
bool EventProcess(const Event &event) override;
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
#include "ui/controls/interface.h"
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
#include "sound/sound.h"
|
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
#include "object/object_manager.h"
|
#include "object/object_manager.h"
|
||||||
#include "object/old_object.h"
|
#include "object/old_object.h"
|
||||||
|
|
||||||
#include "object/interface/programmable_object.h"
|
|
||||||
#include "object/interface/program_storage_object.h"
|
#include "object/interface/program_storage_object.h"
|
||||||
|
#include "object/interface/programmable_object.h"
|
||||||
#include "object/interface/transportable_object.h"
|
#include "object/interface/transportable_object.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
CAutoEgg(COldObject* object);
|
CAutoEgg(COldObject* object);
|
||||||
~CAutoEgg();
|
~CAutoEgg();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false) override;
|
void DeleteObject(bool all=false) override;
|
||||||
|
|
||||||
void Init() override;
|
void Init() override;
|
||||||
void Start(int param) override;
|
void Start(int param) override;
|
||||||
|
|
|
@ -22,20 +22,20 @@
|
||||||
|
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
#include "level/parser/parser.h"
|
#include "level/parser/parser.h"
|
||||||
#include "level/parser/parserline.h"
|
#include "level/parser/parserline.h"
|
||||||
#include "level/parser/parserparam.h"
|
#include "level/parser/parserparam.h"
|
||||||
|
|
||||||
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/object_create_params.h"
|
#include "object/object_create_params.h"
|
||||||
#include "object/object_manager.h"
|
#include "object/object_manager.h"
|
||||||
#include "object/old_object.h"
|
#include "object/old_object.h"
|
||||||
|
|
||||||
#include "object/interface/programmable_object.h"
|
|
||||||
#include "object/interface/program_storage_object.h"
|
#include "object/interface/program_storage_object.h"
|
||||||
|
#include "object/interface/programmable_object.h"
|
||||||
#include "object/interface/transportable_object.h"
|
#include "object/interface/transportable_object.h"
|
||||||
|
|
||||||
#include "physics/physics.h"
|
#include "physics/physics.h"
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
CAutoFactory(COldObject* object);
|
CAutoFactory(COldObject* object);
|
||||||
~CAutoFactory();
|
~CAutoFactory();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false) override;
|
void DeleteObject(bool all=false) override;
|
||||||
|
|
||||||
void Init() override;
|
void Init() override;
|
||||||
bool EventProcess(const Event &event) override;
|
bool EventProcess(const Event &event) override;
|
||||||
|
|
|
@ -35,11 +35,11 @@
|
||||||
|
|
||||||
#include "object/interface/powered_object.h"
|
#include "object/interface/powered_object.h"
|
||||||
|
|
||||||
|
#include "sound/sound.h"
|
||||||
|
|
||||||
#include "ui/controls/interface.h"
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
#include "sound/sound.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const float LABO_DELAY = 20.0f; // duration of the analysis
|
const float LABO_DELAY = 20.0f; // duration of the analysis
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
CAutoNest(COldObject* object);
|
CAutoNest(COldObject* object);
|
||||||
~CAutoNest();
|
~CAutoNest();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false) override;
|
void DeleteObject(bool all=false) override;
|
||||||
|
|
||||||
void Init() override;
|
void Init() override;
|
||||||
bool EventProcess(const Event &event) override;
|
bool EventProcess(const Event &event) override;
|
||||||
|
|
|
@ -22,13 +22,13 @@
|
||||||
|
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
#include "level/parser/parserline.h"
|
#include "level/parser/parserline.h"
|
||||||
#include "level/parser/parserparam.h"
|
#include "level/parser/parserparam.h"
|
||||||
|
|
||||||
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/object_manager.h"
|
#include "object/object_manager.h"
|
||||||
#include "object/old_object.h"
|
#include "object/old_object.h"
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
CAutoNuclearPlant(COldObject* object);
|
CAutoNuclearPlant(COldObject* object);
|
||||||
~CAutoNuclearPlant();
|
~CAutoNuclearPlant();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false) override;
|
void DeleteObject(bool all=false) override;
|
||||||
|
|
||||||
void Init() override;
|
void Init() override;
|
||||||
bool EventProcess(const Event &event) override;
|
bool EventProcess(const Event &event) override;
|
||||||
|
|
|
@ -22,11 +22,11 @@
|
||||||
|
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
|
||||||
|
|
||||||
#include "level/parser/parserline.h"
|
#include "level/parser/parserline.h"
|
||||||
#include "level/parser/parserparam.h"
|
#include "level/parser/parserparam.h"
|
||||||
|
|
||||||
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/object_manager.h"
|
#include "object/object_manager.h"
|
||||||
#include "object/old_object.h"
|
#include "object/old_object.h"
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
CAutoPowerPlant(COldObject* object);
|
CAutoPowerPlant(COldObject* object);
|
||||||
~CAutoPowerPlant();
|
~CAutoPowerPlant();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false) override;
|
void DeleteObject(bool all=false) override;
|
||||||
|
|
||||||
void Init() override;
|
void Init() override;
|
||||||
bool EventProcess(const Event &event) override;
|
bool EventProcess(const Event &event) override;
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
void DeleteObject(bool bAll=false) override;
|
void DeleteObject(bool bAll=false) override;
|
||||||
|
|
||||||
void Init() override;
|
void Init() override;
|
||||||
Error StartAction(int result) override;
|
Error StartAction(int param) override;
|
||||||
bool EventProcess(const Event &event) override;
|
bool EventProcess(const Event &event) override;
|
||||||
Error GetError() override;
|
Error GetError() override;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* along with this program. If not, see http://gnu.org/licenses
|
* along with this program. If not, see http://gnu.org/licenses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "object/implementation/programmable_impl.h"
|
#include "object/implementation/program_storage_impl.h"
|
||||||
|
|
||||||
#include "common/global.h"
|
#include "common/global.h"
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
|
|
|
@ -19,12 +19,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "object/interface/interactive_object.h"
|
|
||||||
#include "object/interface/programmable_object.h"
|
#include "object/interface/programmable_object.h"
|
||||||
#include "object/interface/trace_drawing_object.h"
|
|
||||||
|
|
||||||
#include "math/vector.h"
|
#include "math/vector.h"
|
||||||
|
|
||||||
|
#include "object/interface/interactive_object.h"
|
||||||
|
#include "object/interface/trace_drawing_object.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
class CObject;
|
class CObject;
|
||||||
|
@ -64,7 +65,7 @@ public:
|
||||||
void TraceRecordStop() override;
|
void TraceRecordStop() override;
|
||||||
bool IsTraceRecord() override;
|
bool IsTraceRecord() override;
|
||||||
|
|
||||||
void SetActivity(bool bMode) override;
|
void SetActivity(bool activity) override;
|
||||||
bool GetActivity() override;
|
bool GetActivity() override;
|
||||||
|
|
||||||
void SetCmdLine(unsigned int rank, float value);
|
void SetCmdLine(unsigned int rank, float value);
|
||||||
|
|
|
@ -53,9 +53,9 @@ enum class TraceColor
|
||||||
Max,
|
Max,
|
||||||
};
|
};
|
||||||
//! Convert TraceColor to a std::string
|
//! Convert TraceColor to a std::string
|
||||||
std::string TraceColorName(TraceColor c);
|
std::string TraceColorName(TraceColor color);
|
||||||
//! Return Gfx::Color for this TraceColor constants
|
//! Return Gfx::Color for this TraceColor constants
|
||||||
Gfx::Color TraceColorColor(TraceColor c);
|
Gfx::Color TraceColorColor(TraceColor color);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class CTraceDrawingObject
|
* \class CTraceDrawingObject
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
#include "common/restext.h"
|
#include "common/restext.h"
|
||||||
#include "common/stringutils.h"
|
#include "common/stringutils.h"
|
||||||
|
|
||||||
|
#include "graphics/model/model_crash_sphere.h"
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
#include "level/parser/parserline.h"
|
#include "level/parser/parserline.h"
|
||||||
#include "level/parser/parserparam.h"
|
#include "level/parser/parserparam.h"
|
||||||
|
|
||||||
#include "graphics/model/model_crash_sphere.h"
|
|
||||||
|
|
||||||
#include "script/scriptfunc.h"
|
#include "script/scriptfunc.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
|
@ -28,6 +28,11 @@
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
|
||||||
|
#include "object/implementation/power_container_impl.h"
|
||||||
|
#include "object/implementation/program_storage_impl.h"
|
||||||
|
#include "object/implementation/programmable_impl.h"
|
||||||
|
#include "object/implementation/task_executor_impl.h"
|
||||||
|
|
||||||
#include "object/interface/carrier_object.h"
|
#include "object/interface/carrier_object.h"
|
||||||
#include "object/interface/controllable_object.h"
|
#include "object/interface/controllable_object.h"
|
||||||
#include "object/interface/flying_object.h"
|
#include "object/interface/flying_object.h"
|
||||||
|
@ -44,11 +49,6 @@
|
||||||
#include "object/interface/trace_drawing_object.h"
|
#include "object/interface/trace_drawing_object.h"
|
||||||
#include "object/interface/transportable_object.h"
|
#include "object/interface/transportable_object.h"
|
||||||
|
|
||||||
#include "object/implementation/power_container_impl.h"
|
|
||||||
#include "object/implementation/program_storage_impl.h"
|
|
||||||
#include "object/implementation/programmable_impl.h"
|
|
||||||
#include "object/implementation/task_executor_impl.h"
|
|
||||||
|
|
||||||
// The father of all parts must always be the part number zero!
|
// The father of all parts must always be the part number zero!
|
||||||
const int OBJECTMAXPART = 40;
|
const int OBJECTMAXPART = 40;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ protected:
|
||||||
void SetMovable(std::unique_ptr<CMotion> motion, std::unique_ptr<CPhysics> physics);
|
void SetMovable(std::unique_ptr<CMotion> motion, std::unique_ptr<CPhysics> physics);
|
||||||
void SetAuto(std::unique_ptr<CAuto> automat);
|
void SetAuto(std::unique_ptr<CAuto> automat);
|
||||||
void SetOption(int option);
|
void SetOption(int option);
|
||||||
void SetJostlingSphere(const Math::Sphere& sphere);
|
void SetJostlingSphere(const Math::Sphere& jostlingSphere);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -360,7 +360,6 @@ protected:
|
||||||
float m_cameraDist;
|
float m_cameraDist;
|
||||||
bool m_bCameraLock;
|
bool m_bCameraLock;
|
||||||
float m_magnifyDamage;
|
float m_magnifyDamage;
|
||||||
float m_param;
|
|
||||||
|
|
||||||
Math::Sphere m_jostlingSphere;
|
Math::Sphere m_jostlingSphere;
|
||||||
float m_shieldRadius;
|
float m_shieldRadius;
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
#include "level/parser/parserline.h"
|
#include "level/parser/parserline.h"
|
||||||
#include "level/parser/parserparam.h"
|
#include "level/parser/parserparam.h"
|
||||||
|
|
||||||
#include "graphics/engine/oldmodelmanager.h"
|
|
||||||
|
|
||||||
#include "object/object_create_params.h"
|
#include "object/object_create_params.h"
|
||||||
|
|
||||||
#include "object/motion/motionant.h"
|
#include "object/motion/motionant.h"
|
||||||
|
@ -87,7 +85,7 @@ std::unique_ptr<CBaseAlien> CBaseAlien::Create(
|
||||||
obj->SetProgrammable();
|
obj->SetProgrammable();
|
||||||
obj->SetMovable(std::move(motion), std::move(physics));
|
obj->SetMovable(std::move(motion), std::move(physics));
|
||||||
|
|
||||||
return std::move(obj);
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBaseAlien::SetFixed(bool fixed)
|
void CBaseAlien::SetFixed(bool fixed)
|
||||||
|
|
|
@ -889,5 +889,5 @@ std::unique_ptr<CBaseBuilding> CBaseBuilding::Create(
|
||||||
|
|
||||||
obj->UpdateMapping();
|
obj->UpdateMapping();
|
||||||
|
|
||||||
return std::move(obj);
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ std::unique_ptr<CBaseRobot> CBaseRobot::Create(
|
||||||
auto motion = MakeUnique<CMotionToto>(obj.get());
|
auto motion = MakeUnique<CMotionToto>(obj.get());
|
||||||
motion->Create(params.pos, params.angle, params.type, 1.0f, modelManager);
|
motion->Create(params.pos, params.angle, params.type, 1.0f, modelManager);
|
||||||
obj->SetMovable(std::move(motion), nullptr);
|
obj->SetMovable(std::move(motion), nullptr);
|
||||||
return std::move(obj);
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( params.type == OBJECT_HUMAN ||
|
if ( params.type == OBJECT_HUMAN ||
|
||||||
|
@ -95,5 +95,5 @@ std::unique_ptr<CBaseRobot> CBaseRobot::Create(
|
||||||
obj->SetProgrammable();
|
obj->SetProgrammable();
|
||||||
obj->SetMovable(std::move(motion), std::move(physics));
|
obj->SetMovable(std::move(motion), std::move(physics));
|
||||||
|
|
||||||
return std::move(obj);
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ std::unique_ptr<CShielder> CShielder::Create(
|
||||||
obj->SetProgrammable();
|
obj->SetProgrammable();
|
||||||
obj->SetMovable(std::move(motion), std::move(physics));
|
obj->SetMovable(std::move(motion), std::move(physics));
|
||||||
|
|
||||||
return std::move(obj);
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CShielder::SetShieldRadius(float shieldRadius)
|
void CShielder::SetShieldRadius(float shieldRadius)
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
|
|
||||||
#include "object/task/taskgoto.h"
|
#include "object/task/taskgoto.h"
|
||||||
|
|
||||||
#include "common/global.h"
|
|
||||||
#include "common/event.h"
|
#include "common/event.h"
|
||||||
|
#include "common/global.h"
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
|
@ -19,13 +19,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include "object/task/task.h"
|
#include "object/task/task.h"
|
||||||
|
|
||||||
#include "object/interface/trace_drawing_object.h"
|
|
||||||
|
|
||||||
#include "math/vector.h"
|
#include "math/vector.h"
|
||||||
|
|
||||||
|
#include "object/interface/trace_drawing_object.h"
|
||||||
|
|
||||||
|
|
||||||
enum TaskPenPhase
|
enum TaskPenPhase
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,10 +23,10 @@
|
||||||
#include "graphics/engine/pyro_manager.h"
|
#include "graphics/engine/pyro_manager.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
|
||||||
#include "math/geometry.h"
|
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
|
#include "math/geometry.h"
|
||||||
|
|
||||||
#include "object/object_manager.h"
|
#include "object/object_manager.h"
|
||||||
#include "object/old_object.h"
|
#include "object/old_object.h"
|
||||||
|
|
||||||
|
|
|
@ -3680,14 +3680,14 @@ void CScriptFunctions::Init()
|
||||||
CBotClass* bc;
|
CBotClass* bc;
|
||||||
|
|
||||||
// Add the class Point.
|
// Add the class Point.
|
||||||
bc = new CBotClass("point", nullptr, true); // intrinsic class
|
bc = CBotClass::Create("point", nullptr, true); // intrinsic class
|
||||||
bc->AddItem("x", CBotTypFloat);
|
bc->AddItem("x", CBotTypFloat);
|
||||||
bc->AddItem("y", CBotTypFloat);
|
bc->AddItem("y", CBotTypFloat);
|
||||||
bc->AddItem("z", CBotTypFloat);
|
bc->AddItem("z", CBotTypFloat);
|
||||||
bc->AddFunction("point", CScriptFunctions::rPointConstructor, CScriptFunctions::cPointConstructor);
|
bc->AddFunction("point", CScriptFunctions::rPointConstructor, CScriptFunctions::cPointConstructor);
|
||||||
|
|
||||||
// Adds the class Object.
|
// Adds the class Object.
|
||||||
bc = new CBotClass("object", nullptr);
|
bc = CBotClass::Create("object", nullptr);
|
||||||
bc->AddItem("category", CBotTypResult(CBotTypInt), PR_READ);
|
bc->AddItem("category", CBotTypResult(CBotTypInt), PR_READ);
|
||||||
bc->AddItem("position", CBotTypResult(CBotTypClass, "point"), PR_READ);
|
bc->AddItem("position", CBotTypResult(CBotTypClass, "point"), PR_READ);
|
||||||
bc->AddItem("orientation", CBotTypResult(CBotTypFloat), PR_READ);
|
bc->AddItem("orientation", CBotTypResult(CBotTypFloat), PR_READ);
|
||||||
|
@ -3718,7 +3718,7 @@ void CScriptFunctions::Init()
|
||||||
// canal.close(); // close the file
|
// canal.close(); // close the file
|
||||||
|
|
||||||
// create the class FILE
|
// create the class FILE
|
||||||
bc = new CBotClass("file", nullptr);
|
bc = CBotClass::Create("file", nullptr);
|
||||||
// adds the component ".filename"
|
// adds the component ".filename"
|
||||||
bc->AddItem("filename", CBotTypString);
|
bc->AddItem("filename", CBotTypString);
|
||||||
// adds the component ".handle"
|
// adds the component ".handle"
|
||||||
|
@ -3991,6 +3991,6 @@ void CScriptFunctions::DestroyObjectVar(CBotVar* botVar, bool permanent)
|
||||||
if ( botVar == nullptr ) return;
|
if ( botVar == nullptr ) return;
|
||||||
|
|
||||||
botVar->SetUserPtr(OBJECTDELETED);
|
botVar->SetUserPtr(OBJECTDELETED);
|
||||||
if(permanent)
|
if (permanent)
|
||||||
delete botVar;
|
CBotVar::Destroy(botVar);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
ALSound::ALSound()
|
CALSound::CALSound()
|
||||||
: m_enabled(false),
|
: m_enabled(false),
|
||||||
m_audioVolume(1.0f),
|
m_audioVolume(1.0f),
|
||||||
m_musicVolume(1.0f),
|
m_musicVolume(1.0f),
|
||||||
|
@ -37,14 +37,12 @@ ALSound::ALSound()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CALSound::~CALSound()
|
||||||
ALSound::~ALSound()
|
|
||||||
{
|
{
|
||||||
CleanUp();
|
CleanUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CALSound::CleanUp()
|
||||||
void ALSound::CleanUp()
|
|
||||||
{
|
{
|
||||||
if (m_enabled)
|
if (m_enabled)
|
||||||
{
|
{
|
||||||
|
@ -71,8 +69,7 @@ void ALSound::CleanUp()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::Create()
|
||||||
bool ALSound::Create()
|
|
||||||
{
|
{
|
||||||
CleanUp();
|
CleanUp();
|
||||||
|
|
||||||
|
@ -102,20 +99,17 @@ bool ALSound::Create()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::GetEnable()
|
||||||
bool ALSound::GetEnable()
|
|
||||||
{
|
{
|
||||||
return m_enabled;
|
return m_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CALSound::SetAudioVolume(int volume)
|
||||||
void ALSound::SetAudioVolume(int volume)
|
|
||||||
{
|
{
|
||||||
m_audioVolume = static_cast<float>(volume) / MAXVOLUME;
|
m_audioVolume = static_cast<float>(volume) / MAXVOLUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CALSound::GetAudioVolume()
|
||||||
int ALSound::GetAudioVolume()
|
|
||||||
{
|
{
|
||||||
if ( !m_enabled )
|
if ( !m_enabled )
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -123,8 +117,7 @@ int ALSound::GetAudioVolume()
|
||||||
return m_audioVolume * MAXVOLUME;
|
return m_audioVolume * MAXVOLUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CALSound::SetMusicVolume(int volume)
|
||||||
void ALSound::SetMusicVolume(int volume)
|
|
||||||
{
|
{
|
||||||
m_musicVolume = static_cast<float>(volume) / MAXVOLUME;
|
m_musicVolume = static_cast<float>(volume) / MAXVOLUME;
|
||||||
if (m_currentMusic)
|
if (m_currentMusic)
|
||||||
|
@ -133,8 +126,7 @@ void ALSound::SetMusicVolume(int volume)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CALSound::GetMusicVolume()
|
||||||
int ALSound::GetMusicVolume()
|
|
||||||
{
|
{
|
||||||
if ( !m_enabled )
|
if ( !m_enabled )
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
@ -142,10 +134,9 @@ int ALSound::GetMusicVolume()
|
||||||
return m_musicVolume * MAXVOLUME;
|
return m_musicVolume * MAXVOLUME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::Cache(SoundType sound, const std::string &filename)
|
||||||
bool ALSound::Cache(SoundType sound, const std::string &filename)
|
|
||||||
{
|
{
|
||||||
auto buffer = MakeUnique<Buffer>();
|
auto buffer = MakeUnique<CBuffer>();
|
||||||
if (buffer->LoadFromFile(filename, sound))
|
if (buffer->LoadFromFile(filename, sound))
|
||||||
{
|
{
|
||||||
m_sounds[sound] = std::move(buffer);
|
m_sounds[sound] = std::move(buffer);
|
||||||
|
@ -154,11 +145,11 @@ bool ALSound::Cache(SoundType sound, const std::string &filename)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ALSound::CacheMusic(const std::string &filename)
|
bool CALSound::CacheMusic(const std::string &filename)
|
||||||
{
|
{
|
||||||
if (m_music.find(filename) == m_music.end())
|
if (m_music.find(filename) == m_music.end())
|
||||||
{
|
{
|
||||||
auto buffer = MakeUnique<Buffer>();
|
auto buffer = MakeUnique<CBuffer>();
|
||||||
if (buffer->LoadFromFile(filename, static_cast<SoundType>(-1)))
|
if (buffer->LoadFromFile(filename, static_cast<SoundType>(-1)))
|
||||||
{
|
{
|
||||||
m_music[filename] = std::move(buffer);
|
m_music[filename] = std::move(buffer);
|
||||||
|
@ -168,17 +159,17 @@ bool ALSound::CacheMusic(const std::string &filename)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ALSound::IsCached(SoundType sound)
|
bool CALSound::IsCached(SoundType sound)
|
||||||
{
|
{
|
||||||
return m_sounds.find(sound) != m_sounds.end();
|
return m_sounds.find(sound) != m_sounds.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ALSound::IsCachedMusic(const std::string &filename)
|
bool CALSound::IsCachedMusic(const std::string &filename)
|
||||||
{
|
{
|
||||||
return m_music.find(filename) != m_music.end();
|
return m_music.find(filename) != m_music.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ALSound::GetPriority(SoundType sound)
|
int CALSound::GetPriority(SoundType sound)
|
||||||
{
|
{
|
||||||
if ( sound == SOUND_FLYh ||
|
if ( sound == SOUND_FLYh ||
|
||||||
sound == SOUND_FLY ||
|
sound == SOUND_FLY ||
|
||||||
|
@ -226,8 +217,7 @@ int ALSound::GetPriority(SoundType sound)
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoaded)
|
||||||
bool ALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoaded)
|
|
||||||
{
|
{
|
||||||
int priority = GetPriority(sound);
|
int priority = GetPriority(sound);
|
||||||
|
|
||||||
|
@ -253,7 +243,7 @@ bool ALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoade
|
||||||
// just add a new channel if we dont have any
|
// just add a new channel if we dont have any
|
||||||
if (m_channels.size() == 0)
|
if (m_channels.size() == 0)
|
||||||
{
|
{
|
||||||
auto chn = MakeUnique<Channel>();
|
auto chn = MakeUnique<CChannel>();
|
||||||
// check if we channel ready to play music, if not report error
|
// check if we channel ready to play music, if not report error
|
||||||
if (chn->IsReady())
|
if (chn->IsReady())
|
||||||
{
|
{
|
||||||
|
@ -278,7 +268,7 @@ bool ALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoade
|
||||||
{
|
{
|
||||||
if (m_channels.find(i) == m_channels.end())
|
if (m_channels.find(i) == m_channels.end())
|
||||||
{
|
{
|
||||||
auto chn = MakeUnique<Channel>();
|
auto chn = MakeUnique<CChannel>();
|
||||||
// check if channel is ready to play music, if not destroy it and seek free one
|
// check if channel is ready to play music, if not destroy it and seek free one
|
||||||
if (chn->IsReady())
|
if (chn->IsReady())
|
||||||
{
|
{
|
||||||
|
@ -321,14 +311,12 @@ bool ALSound::SearchFreeBuffer(SoundType sound, int &channel, bool &alreadyLoade
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CALSound::Play(SoundType sound, float amplitude, float frequency, bool loop)
|
||||||
int ALSound::Play(SoundType sound, float amplitude, float frequency, bool loop)
|
|
||||||
{
|
{
|
||||||
return Play(sound, m_eye, amplitude, frequency, loop);
|
return Play(sound, m_eye, amplitude, frequency, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop)
|
||||||
int ALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, float frequency, bool loop)
|
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
{
|
{
|
||||||
|
@ -356,7 +344,7 @@ int ALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, flo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel* chn = m_channels[channel].get();
|
CChannel* chn = m_channels[channel].get();
|
||||||
|
|
||||||
chn->SetPosition(pos);
|
chn->SetPosition(pos);
|
||||||
chn->SetVolumeAtrib(1.0f);
|
chn->SetVolumeAtrib(1.0f);
|
||||||
|
@ -382,8 +370,7 @@ int ALSound::Play(SoundType sound, const Math::Vector &pos, float amplitude, flo
|
||||||
return channel | ((chn->GetId() & 0xffff) << 16);
|
return channel | ((chn->GetId() & 0xffff) << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::FlushEnvelope(int channel)
|
||||||
bool ALSound::FlushEnvelope(int channel)
|
|
||||||
{
|
{
|
||||||
if (!CheckChannel(channel))
|
if (!CheckChannel(channel))
|
||||||
{
|
{
|
||||||
|
@ -394,8 +381,7 @@ bool ALSound::FlushEnvelope(int channel)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper)
|
||||||
bool ALSound::AddEnvelope(int channel, float amplitude, float frequency, float time, SoundNext oper)
|
|
||||||
{
|
{
|
||||||
if (!CheckChannel(channel))
|
if (!CheckChannel(channel))
|
||||||
{
|
{
|
||||||
|
@ -413,8 +399,7 @@ bool ALSound::AddEnvelope(int channel, float amplitude, float frequency, float t
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::Position(int channel, const Math::Vector &pos)
|
||||||
bool ALSound::Position(int channel, const Math::Vector &pos)
|
|
||||||
{
|
{
|
||||||
if (!CheckChannel(channel))
|
if (!CheckChannel(channel))
|
||||||
{
|
{
|
||||||
|
@ -425,8 +410,7 @@ bool ALSound::Position(int channel, const Math::Vector &pos)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::Frequency(int channel, float frequency)
|
||||||
bool ALSound::Frequency(int channel, float frequency)
|
|
||||||
{
|
{
|
||||||
if (!CheckChannel(channel))
|
if (!CheckChannel(channel))
|
||||||
{
|
{
|
||||||
|
@ -438,7 +422,7 @@ bool ALSound::Frequency(int channel, float frequency)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ALSound::Stop(int channel)
|
bool CALSound::Stop(int channel)
|
||||||
{
|
{
|
||||||
if (!CheckChannel(channel))
|
if (!CheckChannel(channel))
|
||||||
{
|
{
|
||||||
|
@ -451,8 +435,7 @@ bool ALSound::Stop(int channel)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::StopAll()
|
||||||
bool ALSound::StopAll()
|
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
{
|
{
|
||||||
|
@ -468,8 +451,7 @@ bool ALSound::StopAll()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::MuteAll(bool mute)
|
||||||
bool ALSound::MuteAll(bool mute)
|
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
{
|
{
|
||||||
|
@ -487,8 +469,7 @@ bool ALSound::MuteAll(bool mute)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CALSound::FrameMove(float rTime)
|
||||||
void ALSound::FrameMove(float delta)
|
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
{
|
{
|
||||||
|
@ -513,7 +494,7 @@ void ALSound::FrameMove(float delta)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
SoundOper &oper = it.second->GetEnvelope();
|
SoundOper &oper = it.second->GetEnvelope();
|
||||||
oper.currentTime += delta;
|
oper.currentTime += rTime;
|
||||||
progress = oper.currentTime / oper.totalTime;
|
progress = oper.currentTime / oper.totalTime;
|
||||||
progress = std::min(progress, 1.0f);
|
progress = std::min(progress, 1.0f);
|
||||||
|
|
||||||
|
@ -560,7 +541,7 @@ void ALSound::FrameMove(float delta)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
it->currentTime += delta;
|
it->currentTime += rTime;
|
||||||
it->music->SetVolume(((it->fadeTime-it->currentTime) / it->fadeTime) * m_musicVolume);
|
it->music->SetVolume(((it->fadeTime-it->currentTime) / it->fadeTime) * m_musicVolume);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
@ -574,14 +555,13 @@ void ALSound::FrameMove(float delta)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_previousMusic.currentTime += delta;
|
m_previousMusic.currentTime += rTime;
|
||||||
m_previousMusic.music->SetVolume(((m_previousMusic.fadeTime-m_previousMusic.currentTime) / m_previousMusic.fadeTime) * m_musicVolume);
|
m_previousMusic.music->SetVolume(((m_previousMusic.fadeTime-m_previousMusic.currentTime) / m_previousMusic.fadeTime) * m_musicVolume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat)
|
||||||
void ALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat)
|
|
||||||
{
|
{
|
||||||
m_eye = eye;
|
m_eye = eye;
|
||||||
m_lookat = lookat;
|
m_lookat = lookat;
|
||||||
|
@ -593,15 +573,14 @@ void ALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat)
|
||||||
alListenerfv(AL_ORIENTATION, orientation);
|
alListenerfv(AL_ORIENTATION, orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::PlayMusic(const std::string &filename, bool repeat, float fadeTime)
|
||||||
bool ALSound::PlayMusic(const std::string &filename, bool repeat, float fadeTime)
|
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer *buffer = nullptr;
|
CBuffer *buffer = nullptr;
|
||||||
|
|
||||||
// check if we have music in cache
|
// check if we have music in cache
|
||||||
if (m_music.find(filename) == m_music.end())
|
if (m_music.find(filename) == m_music.end())
|
||||||
|
@ -613,7 +592,7 @@ bool ALSound::PlayMusic(const std::string &filename, bool repeat, float fadeTime
|
||||||
return false;
|
return false;
|
||||||
} */
|
} */
|
||||||
|
|
||||||
auto newBuffer = MakeUnique<Buffer>();
|
auto newBuffer = MakeUnique<CBuffer>();
|
||||||
buffer = newBuffer.get();
|
buffer = newBuffer.get();
|
||||||
if (!newBuffer->LoadFromFile(filename, static_cast<SoundType>(-1)))
|
if (!newBuffer->LoadFromFile(filename, static_cast<SoundType>(-1)))
|
||||||
{
|
{
|
||||||
|
@ -636,7 +615,7 @@ bool ALSound::PlayMusic(const std::string &filename, bool repeat, float fadeTime
|
||||||
m_oldMusic.push_back(std::move(old));
|
m_oldMusic.push_back(std::move(old));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentMusic = MakeUnique<Channel>();
|
m_currentMusic = MakeUnique<CChannel>();
|
||||||
m_currentMusic->SetBuffer(buffer);
|
m_currentMusic->SetBuffer(buffer);
|
||||||
m_currentMusic->SetVolume(m_musicVolume);
|
m_currentMusic->SetVolume(m_musicVolume);
|
||||||
m_currentMusic->SetLoop(repeat);
|
m_currentMusic->SetLoop(repeat);
|
||||||
|
@ -645,8 +624,7 @@ bool ALSound::PlayMusic(const std::string &filename, bool repeat, float fadeTime
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::PlayPauseMusic(const std::string &filename, bool repeat)
|
||||||
bool ALSound::PlayPauseMusic(const std::string &filename, bool repeat)
|
|
||||||
{
|
{
|
||||||
if (m_previousMusic.fadeTime > 0.0f)
|
if (m_previousMusic.fadeTime > 0.0f)
|
||||||
{
|
{
|
||||||
|
@ -671,8 +649,7 @@ bool ALSound::PlayPauseMusic(const std::string &filename, bool repeat)
|
||||||
return PlayMusic(filename, repeat);
|
return PlayMusic(filename, repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CALSound::StopPauseMusic()
|
||||||
void ALSound::StopPauseMusic()
|
|
||||||
{
|
{
|
||||||
if (m_previousMusic.fadeTime > 0.0f)
|
if (m_previousMusic.fadeTime > 0.0f)
|
||||||
{
|
{
|
||||||
|
@ -691,8 +668,7 @@ void ALSound::StopPauseMusic()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::RestartMusic()
|
||||||
bool ALSound::RestartMusic()
|
|
||||||
{
|
{
|
||||||
if (!m_enabled || m_currentMusic == nullptr)
|
if (!m_enabled || m_currentMusic == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -704,8 +680,7 @@ bool ALSound::RestartMusic()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CALSound::StopMusic(float fadeTime)
|
||||||
void ALSound::StopMusic(float fadeTime)
|
|
||||||
{
|
{
|
||||||
if (!m_enabled || m_currentMusic == nullptr)
|
if (!m_enabled || m_currentMusic == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -719,8 +694,7 @@ void ALSound::StopMusic(float fadeTime)
|
||||||
m_oldMusic.push_back(std::move(old));
|
m_oldMusic.push_back(std::move(old));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::IsPlayingMusic()
|
||||||
bool ALSound::IsPlayingMusic()
|
|
||||||
{
|
{
|
||||||
if (!m_enabled || m_currentMusic == nullptr)
|
if (!m_enabled || m_currentMusic == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -730,8 +704,7 @@ bool ALSound::IsPlayingMusic()
|
||||||
return m_currentMusic->IsPlaying();
|
return m_currentMusic->IsPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CALSound::SuspendMusic()
|
||||||
void ALSound::SuspendMusic()
|
|
||||||
{
|
{
|
||||||
if (!m_enabled || m_currentMusic == nullptr)
|
if (!m_enabled || m_currentMusic == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -741,8 +714,7 @@ void ALSound::SuspendMusic()
|
||||||
m_currentMusic->Stop();
|
m_currentMusic->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CALSound::CheckChannel(int &channel)
|
||||||
bool ALSound::CheckChannel(int &channel)
|
|
||||||
{
|
{
|
||||||
int id = (channel >> 16) & 0xffff;
|
int id = (channel >> 16) & 0xffff;
|
||||||
channel &= 0xffff;
|
channel &= 0xffff;
|
||||||
|
|
|
@ -60,7 +60,7 @@ struct OldMusic
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Channel> music;
|
std::unique_ptr<CChannel> music;
|
||||||
float fadeTime = 0.0f;
|
float fadeTime = 0.0f;
|
||||||
float currentTime = 0.0f;
|
float currentTime = 0.0f;
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ struct OldMusic
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ALSound : public CSoundInterface
|
class CALSound : public CSoundInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ALSound();
|
CALSound();
|
||||||
~ALSound();
|
~CALSound();
|
||||||
|
|
||||||
bool Create() override;
|
bool Create() override;
|
||||||
bool Cache(SoundType, const std::string &) override;
|
bool Cache(SoundType, const std::string &) override;
|
||||||
|
@ -126,10 +126,10 @@ private:
|
||||||
unsigned int m_channelsLimit;
|
unsigned int m_channelsLimit;
|
||||||
ALCdevice* m_device;
|
ALCdevice* m_device;
|
||||||
ALCcontext* m_context;
|
ALCcontext* m_context;
|
||||||
std::map<SoundType, std::unique_ptr<Buffer>> m_sounds;
|
std::map<SoundType, std::unique_ptr<CBuffer>> m_sounds;
|
||||||
std::map<std::string, std::unique_ptr<Buffer>> m_music;
|
std::map<std::string, std::unique_ptr<CBuffer>> m_music;
|
||||||
std::map<int, std::unique_ptr<Channel>> m_channels;
|
std::map<int, std::unique_ptr<CChannel>> m_channels;
|
||||||
std::unique_ptr<Channel> m_currentMusic;
|
std::unique_ptr<CChannel> m_currentMusic;
|
||||||
std::list<OldMusic> m_oldMusic;
|
std::list<OldMusic> m_oldMusic;
|
||||||
OldMusic m_previousMusic;
|
OldMusic m_previousMusic;
|
||||||
Math::Vector m_eye;
|
Math::Vector m_eye;
|
||||||
|
|
|
@ -28,15 +28,14 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
Buffer::Buffer()
|
CBuffer::CBuffer()
|
||||||
: m_buffer(),
|
: m_buffer(),
|
||||||
m_sound(),
|
m_sound(),
|
||||||
m_loaded(false),
|
m_loaded(false),
|
||||||
m_duration(0.0f)
|
m_duration(0.0f)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
CBuffer::~CBuffer()
|
||||||
Buffer::~Buffer()
|
|
||||||
{
|
{
|
||||||
if (m_loaded)
|
if (m_loaded)
|
||||||
{
|
{
|
||||||
|
@ -46,8 +45,7 @@ Buffer::~Buffer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CBuffer::LoadFromFile(std::string filename, SoundType sound)
|
||||||
bool Buffer::LoadFromFile(std::string filename, SoundType sound)
|
|
||||||
{
|
{
|
||||||
m_sound = sound;
|
m_sound = sound;
|
||||||
GetLogger()->Debug("Loading audio file: %s\n", filename.c_str());
|
GetLogger()->Debug("Loading audio file: %s\n", filename.c_str());
|
||||||
|
@ -92,27 +90,22 @@ bool Buffer::LoadFromFile(std::string filename, SoundType sound)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoundType CBuffer::GetSoundType()
|
||||||
SoundType Buffer::GetSoundType()
|
|
||||||
{
|
{
|
||||||
return m_sound;
|
return m_sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALuint CBuffer::GetBuffer()
|
||||||
ALuint Buffer::GetBuffer()
|
|
||||||
{
|
{
|
||||||
return m_buffer;
|
return m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CBuffer::IsLoaded()
|
||||||
bool Buffer::IsLoaded()
|
|
||||||
{
|
{
|
||||||
return m_loaded;
|
return m_loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CBuffer::GetDuration()
|
||||||
float Buffer::GetDuration()
|
|
||||||
{
|
{
|
||||||
return m_duration;
|
return m_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,11 @@
|
||||||
|
|
||||||
#include <al.h>
|
#include <al.h>
|
||||||
|
|
||||||
class Buffer
|
class CBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Buffer();
|
CBuffer();
|
||||||
~Buffer();
|
~CBuffer();
|
||||||
|
|
||||||
bool LoadFromFile(std::string, SoundType);
|
bool LoadFromFile(std::string, SoundType);
|
||||||
bool IsLoaded();
|
bool IsLoaded();
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "sound/oalsound/buffer.h"
|
#include "sound/oalsound/buffer.h"
|
||||||
|
|
||||||
Channel::Channel()
|
CChannel::CChannel()
|
||||||
: m_buffer(nullptr),
|
: m_buffer(nullptr),
|
||||||
m_source(0),
|
m_source(0),
|
||||||
m_priority(0),
|
m_priority(0),
|
||||||
|
@ -49,8 +49,7 @@ Channel::Channel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CChannel::~CChannel()
|
||||||
Channel::~Channel()
|
|
||||||
{
|
{
|
||||||
if (m_ready)
|
if (m_ready)
|
||||||
{
|
{
|
||||||
|
@ -62,8 +61,7 @@ Channel::~Channel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CChannel::Play()
|
||||||
bool Channel::Play()
|
|
||||||
{
|
{
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -81,7 +79,7 @@ bool Channel::Play()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Channel::Pause()
|
bool CChannel::Pause()
|
||||||
{
|
{
|
||||||
if (!m_ready || !IsPlaying())
|
if (!m_ready || !IsPlaying())
|
||||||
{
|
{
|
||||||
|
@ -96,8 +94,7 @@ bool Channel::Pause()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CChannel::SetPosition(const Math::Vector &pos)
|
||||||
bool Channel::SetPosition(const Math::Vector &pos)
|
|
||||||
{
|
{
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -113,8 +110,7 @@ bool Channel::SetPosition(const Math::Vector &pos)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CChannel::SetFrequency(float freq)
|
||||||
bool Channel::SetFrequency(float freq)
|
|
||||||
{
|
{
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -130,8 +126,7 @@ bool Channel::SetFrequency(float freq)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CChannel::GetFrequency()
|
||||||
float Channel::GetFrequency()
|
|
||||||
{
|
{
|
||||||
ALfloat freq;
|
ALfloat freq;
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
|
@ -149,8 +144,7 @@ float Channel::GetFrequency()
|
||||||
return freq;
|
return freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CChannel::SetVolume(float vol)
|
||||||
bool Channel::SetVolume(float vol)
|
|
||||||
{
|
{
|
||||||
if (!m_ready || vol < 0 || m_buffer == nullptr)
|
if (!m_ready || vol < 0 || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -166,8 +160,7 @@ bool Channel::SetVolume(float vol)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CChannel::GetVolume()
|
||||||
float Channel::GetVolume()
|
|
||||||
{
|
{
|
||||||
ALfloat vol;
|
ALfloat vol;
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
|
@ -185,87 +178,72 @@ float Channel::GetVolume()
|
||||||
return vol;
|
return vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::SetVolumeAtrib(float volume)
|
||||||
void Channel::SetVolumeAtrib(float volume)
|
|
||||||
{
|
{
|
||||||
m_volume = volume;
|
m_volume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CChannel::GetVolumeAtrib()
|
||||||
float Channel::GetVolumeAtrib()
|
|
||||||
{
|
{
|
||||||
return m_volume;
|
return m_volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CChannel::GetPriority()
|
||||||
|
|
||||||
int Channel::GetPriority()
|
|
||||||
{
|
{
|
||||||
return m_priority;
|
return m_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::SetPriority(int pri)
|
||||||
void Channel::SetPriority(int pri)
|
|
||||||
{
|
{
|
||||||
m_priority = pri;
|
m_priority = pri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::SetStartAmplitude(float gain)
|
||||||
void Channel::SetStartAmplitude(float gain)
|
|
||||||
{
|
{
|
||||||
m_startAmplitude = gain;
|
m_startAmplitude = gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::SetStartFrequency(float freq)
|
||||||
void Channel::SetStartFrequency(float freq)
|
|
||||||
{
|
{
|
||||||
m_startFrequency = freq;
|
m_startFrequency = freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::SetChangeFrequency(float freq)
|
||||||
void Channel::SetChangeFrequency(float freq)
|
|
||||||
{
|
{
|
||||||
m_changeFrequency = freq;
|
m_changeFrequency = freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CChannel::GetStartAmplitude()
|
||||||
float Channel::GetStartAmplitude()
|
|
||||||
{
|
{
|
||||||
return m_startAmplitude;
|
return m_startAmplitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CChannel::GetStartFrequency()
|
||||||
float Channel::GetStartFrequency()
|
|
||||||
{
|
{
|
||||||
return m_startFrequency;
|
return m_startFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CChannel::GetChangeFrequency()
|
||||||
float Channel::GetChangeFrequency()
|
|
||||||
{
|
{
|
||||||
return m_changeFrequency;
|
return m_changeFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CChannel::GetInitFrequency()
|
||||||
float Channel::GetInitFrequency()
|
|
||||||
{
|
{
|
||||||
return m_initFrequency;
|
return m_initFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::AddOper(SoundOper oper)
|
||||||
void Channel::AddOper(SoundOper oper)
|
|
||||||
{
|
{
|
||||||
m_oper.push_back(oper);
|
m_oper.push_back(oper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::ResetOper()
|
||||||
void Channel::ResetOper()
|
|
||||||
{
|
{
|
||||||
m_oper.clear();
|
m_oper.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoundType CChannel::GetSoundType()
|
||||||
SoundType Channel::GetSoundType()
|
|
||||||
{
|
{
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -275,8 +253,7 @@ SoundType Channel::GetSoundType()
|
||||||
return m_buffer->GetSoundType();
|
return m_buffer->GetSoundType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CChannel::SetBuffer(CBuffer *buffer)
|
||||||
bool Channel::SetBuffer(Buffer *buffer)
|
|
||||||
{
|
{
|
||||||
if (!m_ready)
|
if (!m_ready)
|
||||||
return false;
|
return false;
|
||||||
|
@ -299,7 +276,7 @@ bool Channel::SetBuffer(Buffer *buffer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Channel::IsPlaying()
|
bool CChannel::IsPlaying()
|
||||||
{
|
{
|
||||||
ALint status;
|
ALint status;
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
|
@ -317,19 +294,17 @@ bool Channel::IsPlaying()
|
||||||
return status == AL_PLAYING;
|
return status == AL_PLAYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CChannel::IsReady()
|
||||||
bool Channel::IsReady()
|
|
||||||
{
|
{
|
||||||
return m_ready;
|
return m_ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Channel::IsLoaded()
|
bool CChannel::IsLoaded()
|
||||||
{
|
{
|
||||||
return m_buffer != nullptr;
|
return m_buffer != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CChannel::Stop()
|
||||||
bool Channel::Stop()
|
|
||||||
{
|
{
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -345,8 +320,7 @@ bool Channel::Stop()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CChannel::GetCurrentTime()
|
||||||
float Channel::GetCurrentTime()
|
|
||||||
{
|
{
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -363,8 +337,7 @@ float Channel::GetCurrentTime()
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::SetCurrentTime(float current)
|
||||||
void Channel::SetCurrentTime(float current)
|
|
||||||
{
|
{
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -378,8 +351,7 @@ void Channel::SetCurrentTime(float current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CChannel::GetDuration()
|
||||||
float Channel::GetDuration()
|
|
||||||
{
|
{
|
||||||
if (!m_ready || m_buffer == nullptr)
|
if (!m_ready || m_buffer == nullptr)
|
||||||
{
|
{
|
||||||
|
@ -389,50 +361,42 @@ float Channel::GetDuration()
|
||||||
return m_buffer->GetDuration();
|
return m_buffer->GetDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CChannel::HasEnvelope()
|
||||||
bool Channel::HasEnvelope()
|
|
||||||
{
|
{
|
||||||
return m_oper.size() > 0;
|
return m_oper.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoundOper& CChannel::GetEnvelope()
|
||||||
SoundOper& Channel::GetEnvelope()
|
|
||||||
{
|
{
|
||||||
return m_oper.front();
|
return m_oper.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::PopEnvelope()
|
||||||
void Channel::PopEnvelope()
|
|
||||||
{
|
{
|
||||||
m_oper.pop_front();
|
m_oper.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::SetLoop(bool loop)
|
||||||
void Channel::SetLoop(bool loop)
|
|
||||||
{
|
{
|
||||||
m_loop = loop;
|
m_loop = loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::Mute(bool mute)
|
||||||
void Channel::Mute(bool mute)
|
|
||||||
{
|
{
|
||||||
m_mute = mute;
|
m_mute = mute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CChannel::IsMuted()
|
||||||
bool Channel::IsMuted()
|
|
||||||
{
|
{
|
||||||
return m_mute;
|
return m_mute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::Reset()
|
||||||
void Channel::Reset()
|
|
||||||
{
|
{
|
||||||
m_id++;
|
m_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CChannel::GetId()
|
||||||
int Channel::GetId()
|
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <al.h>
|
#include <al.h>
|
||||||
#include <alc.h>
|
#include <alc.h>
|
||||||
|
|
||||||
class Buffer;
|
class CBuffer;
|
||||||
|
|
||||||
struct SoundOper
|
struct SoundOper
|
||||||
{
|
{
|
||||||
|
@ -49,11 +49,11 @@ struct SoundOper
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Channel
|
class CChannel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Channel();
|
CChannel();
|
||||||
~Channel();
|
~CChannel();
|
||||||
|
|
||||||
bool Play();
|
bool Play();
|
||||||
bool Pause();
|
bool Pause();
|
||||||
|
@ -77,7 +77,7 @@ public:
|
||||||
bool IsReady();
|
bool IsReady();
|
||||||
bool IsLoaded();
|
bool IsLoaded();
|
||||||
|
|
||||||
bool SetBuffer(Buffer *buffer);
|
bool SetBuffer(CBuffer *buffer);
|
||||||
|
|
||||||
bool HasEnvelope();
|
bool HasEnvelope();
|
||||||
SoundOper& GetEnvelope();
|
SoundOper& GetEnvelope();
|
||||||
|
@ -106,7 +106,7 @@ public:
|
||||||
int GetId();
|
int GetId();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Buffer *m_buffer;
|
CBuffer *m_buffer;
|
||||||
ALuint m_source;
|
ALuint m_source;
|
||||||
|
|
||||||
int m_priority;
|
int m_priority;
|
||||||
|
|
|
@ -153,7 +153,7 @@ bool CSoundInterface::StopAll()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSoundInterface::MuteAll(bool bMute)
|
bool CSoundInterface::MuteAll(bool mute)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,9 +208,9 @@ void CButton::Draw()
|
||||||
// Management of immediate mode, which sends the event "press"
|
// Management of immediate mode, which sends the event "press"
|
||||||
// before the mouse button is released.
|
// before the mouse button is released.
|
||||||
|
|
||||||
void CButton::SetImmediat(bool bImmediat)
|
void CButton::SetImmediat(bool immediat)
|
||||||
{
|
{
|
||||||
m_bImmediat = bImmediat;
|
m_bImmediat = immediat;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CButton::GetImmediat()
|
bool CButton::GetImmediat()
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
|
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
|
|
||||||
void SetImmediat(bool bRepeat);
|
void SetImmediat(bool immediat);
|
||||||
bool GetImmediat();
|
bool GetImmediat();
|
||||||
|
|
||||||
void SetRepeat(bool bRepeat);
|
void SetRepeat(bool bRepeat);
|
||||||
|
|
|
@ -699,12 +699,12 @@ bool CList::GetCheck(int i)
|
||||||
|
|
||||||
// Specifies the bit "enable" for a box.
|
// Specifies the bit "enable" for a box.
|
||||||
|
|
||||||
void CList::SetEnable(int i, bool bMode)
|
void CList::SetEnable(int i, bool enable)
|
||||||
{
|
{
|
||||||
if ( i < 0 || i >= m_totalLine )
|
if ( i < 0 || i >= m_totalLine )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_items[i].enable = bMode;
|
m_items[i].enable = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the bit "enable" for a box.
|
// Returns the bit "enable" for a box.
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
void SetCheck(int i, bool bMode);
|
void SetCheck(int i, bool bMode);
|
||||||
bool GetCheck(int i);
|
bool GetCheck(int i);
|
||||||
|
|
||||||
void SetEnable(int i, bool bEnable);
|
void SetEnable(int i, bool enable);
|
||||||
bool GetEnable(int i);
|
bool GetEnable(int i);
|
||||||
|
|
||||||
void SetTabs(int i, float pos, Gfx::TextAlign justif=Gfx::TEXT_ALIGN_LEFT);
|
void SetTabs(int i, float pos, Gfx::TextAlign justif=Gfx::TEXT_ALIGN_LEFT);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
CSlider();
|
CSlider();
|
||||||
~CSlider();
|
~CSlider();
|
||||||
|
|
||||||
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) override;
|
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) override;
|
||||||
|
|
||||||
void SetPos(Math::Point pos) override;
|
void SetPos(Math::Point pos) override;
|
||||||
void SetDim(Math::Point dim) override;
|
void SetDim(Math::Point dim) override;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
CTarget();
|
CTarget();
|
||||||
~CTarget();
|
~CTarget();
|
||||||
|
|
||||||
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg) override;
|
bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) override;
|
||||||
|
|
||||||
bool EventProcess(const Event &event) override;
|
bool EventProcess(const Event &event) override;
|
||||||
void Draw() override;
|
void Draw() override;
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/event.h"
|
|
||||||
#include "common/error.h"
|
#include "common/error.h"
|
||||||
|
#include "common/event.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
|
|
@ -29,14 +29,14 @@
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
#include "common/settings.h"
|
#include "common/settings.h"
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
|
||||||
#include "level/player_profile.h"
|
#include "level/player_profile.h"
|
||||||
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
#include "sound/sound.h"
|
#include "sound/sound.h"
|
||||||
|
|
||||||
#include "ui/controls/button.h"
|
#include "ui/controls/button.h"
|
||||||
#include "ui/controls/label.h"
|
|
||||||
#include "ui/controls/interface.h"
|
#include "ui/controls/interface.h"
|
||||||
|
#include "ui/controls/label.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
#include "ui/screen/screen_setup.h"
|
#include "ui/screen/screen_setup.h"
|
||||||
|
|
|
@ -35,6 +35,11 @@
|
||||||
|
|
||||||
#include "ui/maindialog.h"
|
#include "ui/maindialog.h"
|
||||||
|
|
||||||
|
#include "ui/controls/group.h"
|
||||||
|
#include "ui/controls/interface.h"
|
||||||
|
#include "ui/controls/label.h"
|
||||||
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
#include "ui/screen/screen.h"
|
#include "ui/screen/screen.h"
|
||||||
#include "ui/screen/screen_apperance.h"
|
#include "ui/screen/screen_apperance.h"
|
||||||
#include "ui/screen/screen_io_read.h"
|
#include "ui/screen/screen_io_read.h"
|
||||||
|
@ -43,19 +48,14 @@
|
||||||
#include "ui/screen/screen_loading.h"
|
#include "ui/screen/screen_loading.h"
|
||||||
#include "ui/screen/screen_main_menu.h"
|
#include "ui/screen/screen_main_menu.h"
|
||||||
#include "ui/screen/screen_player_select.h"
|
#include "ui/screen/screen_player_select.h"
|
||||||
|
#include "ui/screen/screen_quit.h"
|
||||||
#include "ui/screen/screen_setup_controls.h"
|
#include "ui/screen/screen_setup_controls.h"
|
||||||
#include "ui/screen/screen_setup_display.h"
|
#include "ui/screen/screen_setup_display.h"
|
||||||
#include "ui/screen/screen_setup_game.h"
|
#include "ui/screen/screen_setup_game.h"
|
||||||
#include "ui/screen/screen_setup_graphics.h"
|
#include "ui/screen/screen_setup_graphics.h"
|
||||||
#include "ui/screen/screen_setup_sound.h"
|
#include "ui/screen/screen_setup_sound.h"
|
||||||
#include "ui/screen/screen_quit.h"
|
|
||||||
#include "ui/screen/screen_welcome.h"
|
#include "ui/screen/screen_welcome.h"
|
||||||
|
|
||||||
#include "ui/controls/interface.h"
|
|
||||||
#include "ui/controls/group.h"
|
|
||||||
#include "ui/controls/label.h"
|
|
||||||
#include "ui/controls/window.h"
|
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
CObjectInterface(COldObject* object);
|
CObjectInterface(COldObject* object);
|
||||||
~CObjectInterface();
|
~CObjectInterface();
|
||||||
|
|
||||||
void DeleteObject(bool bAll=false);
|
void DeleteObject(bool all=false);
|
||||||
|
|
||||||
bool EventProcess(const Event &event);
|
bool EventProcess(const Event &event);
|
||||||
bool CreateInterface(bool bSelect);
|
bool CreateInterface(bool bSelect);
|
||||||
|
|
|
@ -19,10 +19,10 @@
|
||||||
|
|
||||||
#include "ui/screen/screen.h"
|
#include "ui/screen/screen.h"
|
||||||
|
|
||||||
#include "common/version.h"
|
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
|
#include "common/version.h"
|
||||||
|
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
#include "level/robotmain.h"
|
||||||
|
|
|
@ -31,15 +31,15 @@
|
||||||
|
|
||||||
#include "sound/sound.h"
|
#include "sound/sound.h"
|
||||||
|
|
||||||
#include "ui/screen/screen_level_list.h"
|
|
||||||
|
|
||||||
#include "ui/controls/button.h"
|
#include "ui/controls/button.h"
|
||||||
#include "ui/controls/edit.h"
|
#include "ui/controls/edit.h"
|
||||||
#include "ui/controls/interface.h"
|
|
||||||
#include "ui/controls/image.h"
|
#include "ui/controls/image.h"
|
||||||
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/list.h"
|
#include "ui/controls/list.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
|
#include "ui/screen/screen_level_list.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
#include "level/robotmain.h"
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
#include "ui/controls/button.h"
|
#include "ui/controls/button.h"
|
||||||
#include "ui/controls/interface.h"
|
|
||||||
#include "ui/controls/image.h"
|
#include "ui/controls/image.h"
|
||||||
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/list.h"
|
#include "ui/controls/list.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
#include "ui/controls/button.h"
|
#include "ui/controls/button.h"
|
||||||
#include "ui/controls/edit.h"
|
#include "ui/controls/edit.h"
|
||||||
#include "ui/controls/interface.h"
|
|
||||||
#include "ui/controls/image.h"
|
#include "ui/controls/image.h"
|
||||||
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/label.h"
|
#include "ui/controls/label.h"
|
||||||
#include "ui/controls/list.h"
|
#include "ui/controls/list.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
|
@ -21,13 +21,12 @@
|
||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
|
||||||
|
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "common/misc.h"
|
#include "common/misc.h"
|
||||||
#include "common/stringutils.h"
|
#include "common/stringutils.h"
|
||||||
|
|
||||||
#include "level/player_profile.h"
|
#include "level/player_profile.h"
|
||||||
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
#include "sound/sound.h"
|
#include "sound/sound.h"
|
||||||
|
|
||||||
|
@ -194,9 +193,13 @@ bool CScreenPlayerSelect::EventProcess(const Event &event)
|
||||||
|
|
||||||
GetResource(RES_TEXT, RT_DIALOG_DELGAME, name);
|
GetResource(RES_TEXT, RT_DIALOG_DELGAME, name);
|
||||||
gamer = pl->GetItemName(pl->GetSelect());
|
gamer = pl->GetItemName(pl->GetSelect());
|
||||||
m_dialog->StartQuestion(StrUtils::Format(name.c_str(), gamer), true, false, false, [&]() {
|
m_dialog->StartQuestion(
|
||||||
NameDelete();
|
StrUtils::Format(name.c_str(), gamer), true, false, false,
|
||||||
});
|
[&]()
|
||||||
|
{
|
||||||
|
NameDelete();
|
||||||
|
}
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -32,12 +32,12 @@
|
||||||
|
|
||||||
#include "common/resources/resourcemanager.h"
|
#include "common/resources/resourcemanager.h"
|
||||||
|
|
||||||
#include "level/robotmain.h"
|
|
||||||
#include "level/player_profile.h"
|
|
||||||
|
|
||||||
#include "graphics/engine/camera.h"
|
#include "graphics/engine/camera.h"
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
|
|
||||||
|
#include "level/player_profile.h"
|
||||||
|
#include "level/robotmain.h"
|
||||||
|
|
||||||
#include "object/object.h"
|
#include "object/object.h"
|
||||||
|
|
||||||
#include "object/interface/program_storage_object.h"
|
#include "object/interface/program_storage_object.h"
|
||||||
|
|
|
@ -61,16 +61,16 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ApplicationUT : public testing::Test
|
class CApplicationUT : public testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
ApplicationUT() :
|
CApplicationUT() :
|
||||||
m_systemUtils(nullptr),
|
m_systemUtils(nullptr),
|
||||||
m_stampUid(0),
|
m_stampUid(0),
|
||||||
m_currentTime(0)
|
m_currentTime(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~ApplicationUT() NOEXCEPT
|
~CApplicationUT() NOEXCEPT
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void SetUp() override;
|
void SetUp() override;
|
||||||
|
@ -99,7 +99,7 @@ private:
|
||||||
long long m_currentTime;
|
long long m_currentTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ApplicationUT::SetUp()
|
void CApplicationUT::SetUp()
|
||||||
{
|
{
|
||||||
m_systemUtils = m_mocks.Mock<CSystemUtils>();
|
m_systemUtils = m_mocks.Mock<CSystemUtils>();
|
||||||
|
|
||||||
|
@ -107,21 +107,21 @@ void ApplicationUT::SetUp()
|
||||||
m_mocks.OnCall(m_systemUtils, CSystemUtils::GetLangPath).Return("");
|
m_mocks.OnCall(m_systemUtils, CSystemUtils::GetLangPath).Return("");
|
||||||
m_mocks.OnCall(m_systemUtils, CSystemUtils::GetSaveDir).Return("");
|
m_mocks.OnCall(m_systemUtils, CSystemUtils::GetSaveDir).Return("");
|
||||||
|
|
||||||
m_mocks.OnCall(m_systemUtils, CSystemUtils::CreateTimeStamp).Do(std::bind(&ApplicationUT::CreateTimeStamp, this));
|
m_mocks.OnCall(m_systemUtils, CSystemUtils::CreateTimeStamp).Do(std::bind(&CApplicationUT::CreateTimeStamp, this));
|
||||||
m_mocks.OnCall(m_systemUtils, CSystemUtils::DestroyTimeStamp).Do(std::bind(&ApplicationUT::DestroyTimeStamp, this, ph::_1));
|
m_mocks.OnCall(m_systemUtils, CSystemUtils::DestroyTimeStamp).Do(std::bind(&CApplicationUT::DestroyTimeStamp, this, ph::_1));
|
||||||
m_mocks.OnCall(m_systemUtils, CSystemUtils::CopyTimeStamp).Do(std::bind(&ApplicationUT::CopyTimeStamp, this, ph::_1, ph::_2));
|
m_mocks.OnCall(m_systemUtils, CSystemUtils::CopyTimeStamp).Do(std::bind(&CApplicationUT::CopyTimeStamp, this, ph::_1, ph::_2));
|
||||||
m_mocks.OnCall(m_systemUtils, CSystemUtils::GetCurrentTimeStamp).Do(std::bind(&ApplicationUT::GetCurrentTimeStamp, this, ph::_1));
|
m_mocks.OnCall(m_systemUtils, CSystemUtils::GetCurrentTimeStamp).Do(std::bind(&CApplicationUT::GetCurrentTimeStamp, this, ph::_1));
|
||||||
m_mocks.OnCall(m_systemUtils, CSystemUtils::TimeStampExactDiff).Do(std::bind(&ApplicationUT::TimeStampExactDiff, this, ph::_1, ph::_2));
|
m_mocks.OnCall(m_systemUtils, CSystemUtils::TimeStampExactDiff).Do(std::bind(&CApplicationUT::TimeStampExactDiff, this, ph::_1, ph::_2));
|
||||||
|
|
||||||
m_app = MakeUnique<CApplicationWrapper>(m_systemUtils);
|
m_app = MakeUnique<CApplicationWrapper>(m_systemUtils);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationUT::TearDown()
|
void CApplicationUT::TearDown()
|
||||||
{
|
{
|
||||||
m_app.reset();
|
m_app.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemTimeStamp* ApplicationUT::CreateTimeStamp()
|
SystemTimeStamp* CApplicationUT::CreateTimeStamp()
|
||||||
{
|
{
|
||||||
auto stamp = MakeUnique<FakeSystemTimeStamp>(++m_stampUid);
|
auto stamp = MakeUnique<FakeSystemTimeStamp>(++m_stampUid);
|
||||||
auto stampPtr = stamp.get();
|
auto stampPtr = stamp.get();
|
||||||
|
@ -129,33 +129,33 @@ SystemTimeStamp* ApplicationUT::CreateTimeStamp()
|
||||||
return stampPtr;
|
return stampPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationUT::DestroyTimeStamp(SystemTimeStamp *stamp)
|
void CApplicationUT::DestroyTimeStamp(SystemTimeStamp *stamp)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationUT::CopyTimeStamp(SystemTimeStamp *dst, SystemTimeStamp *src)
|
void CApplicationUT::CopyTimeStamp(SystemTimeStamp *dst, SystemTimeStamp *src)
|
||||||
{
|
{
|
||||||
*static_cast<FakeSystemTimeStamp*>(dst) = *static_cast<FakeSystemTimeStamp*>(src);
|
*static_cast<FakeSystemTimeStamp*>(dst) = *static_cast<FakeSystemTimeStamp*>(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationUT::GetCurrentTimeStamp(SystemTimeStamp *stamp)
|
void CApplicationUT::GetCurrentTimeStamp(SystemTimeStamp *stamp)
|
||||||
{
|
{
|
||||||
static_cast<FakeSystemTimeStamp*>(stamp)->time = m_currentTime;
|
static_cast<FakeSystemTimeStamp*>(stamp)->time = m_currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long ApplicationUT::TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after)
|
long long CApplicationUT::TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after)
|
||||||
{
|
{
|
||||||
return static_cast<FakeSystemTimeStamp*>(after)->time - static_cast<FakeSystemTimeStamp*>(before)->time;
|
return static_cast<FakeSystemTimeStamp*>(after)->time - static_cast<FakeSystemTimeStamp*>(before)->time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationUT::NextInstant(long long diff)
|
void CApplicationUT::NextInstant(long long diff)
|
||||||
{
|
{
|
||||||
m_currentTime += diff;
|
m_currentTime += diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationUT::TestCreateUpdateEvent(long long relTimeExact, long long absTimeExact,
|
void CApplicationUT::TestCreateUpdateEvent(long long relTimeExact, long long absTimeExact,
|
||||||
float relTime, float absTime,
|
float relTime, float absTime,
|
||||||
long long relTimeReal, long long absTimeReal)
|
long long relTimeReal, long long absTimeReal)
|
||||||
{
|
{
|
||||||
Event event = m_app->CreateUpdateEvent();
|
Event event = m_app->CreateUpdateEvent();
|
||||||
EXPECT_EQ(EVENT_FRAME, event.type);
|
EXPECT_EQ(EVENT_FRAME, event.type);
|
||||||
|
@ -169,14 +169,14 @@ void ApplicationUT::TestCreateUpdateEvent(long long relTimeExact, long long absT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F(ApplicationUT, UpdateEventTimeCalculation_SimulationSuspended)
|
TEST_F(CApplicationUT, UpdateEventTimeCalculation_SimulationSuspended)
|
||||||
{
|
{
|
||||||
m_app->SuspendSimulation();
|
m_app->SuspendSimulation();
|
||||||
Event event = m_app->CreateUpdateEvent();
|
Event event = m_app->CreateUpdateEvent();
|
||||||
EXPECT_EQ(EVENT_NULL, event.type);
|
EXPECT_EQ(EVENT_NULL, event.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ApplicationUT, UpdateEventTimeCalculation_NormalOperation)
|
TEST_F(CApplicationUT, UpdateEventTimeCalculation_NormalOperation)
|
||||||
{
|
{
|
||||||
// 1st update
|
// 1st update
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ TEST_F(ApplicationUT, UpdateEventTimeCalculation_NormalOperation)
|
||||||
TestCreateUpdateEvent(relTimeExact, absTimeExact, relTime, absTime, relTimeReal, absTimeReal);
|
TestCreateUpdateEvent(relTimeExact, absTimeExact, relTime, absTime, relTimeReal, absTimeReal);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ApplicationUT, UpdateEventTimeCalculation_NegativeTimeOperation)
|
TEST_F(CApplicationUT, UpdateEventTimeCalculation_NegativeTimeOperation)
|
||||||
{
|
{
|
||||||
// 1st update
|
// 1st update
|
||||||
|
|
||||||
|
@ -228,7 +228,7 @@ TEST_F(ApplicationUT, UpdateEventTimeCalculation_NegativeTimeOperation)
|
||||||
EXPECT_EQ(EVENT_NULL, event.type);
|
EXPECT_EQ(EVENT_NULL, event.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ApplicationUT, UpdateEventTimeCalculation_ChangingSimulationSpeed)
|
TEST_F(CApplicationUT, UpdateEventTimeCalculation_ChangingSimulationSpeed)
|
||||||
{
|
{
|
||||||
m_app->SetSimulationSpeed(2.0f);
|
m_app->SetSimulationSpeed(2.0f);
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ TEST_F(ApplicationUT, UpdateEventTimeCalculation_ChangingSimulationSpeed)
|
||||||
TestCreateUpdateEvent(relTimeExact, absTimeExact, relTime, absTime, relTimeReal, absTimeReal);
|
TestCreateUpdateEvent(relTimeExact, absTimeExact, relTime, absTime, relTimeReal, absTimeReal);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ApplicationUT, UpdateEventTimeCalculation_SuspendingAndResumingSimulation)
|
TEST_F(CApplicationUT, UpdateEventTimeCalculation_SuspendingAndResumingSimulation)
|
||||||
{
|
{
|
||||||
// 1st update -- simulation enabled
|
// 1st update -- simulation enabled
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
class SystemUtilsLinuxUT : public testing::Test
|
class CSystemUtilsLinuxUT : public testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
static const long long SEC = 1000000000;
|
static const long long SEC = 1000000000;
|
||||||
|
@ -31,7 +31,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TEST_F(SystemUtilsLinuxUT, TimeStampDiff)
|
TEST_F(CSystemUtilsLinuxUT, TimeStampDiff)
|
||||||
{
|
{
|
||||||
SystemTimeStamp before, after;
|
SystemTimeStamp before, after;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class SystemUtilsWindowsUT : public testing::Test
|
class CSystemUtilsWindowsUT : public testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
static const long long SEC = 1000000000;
|
static const long long SEC = 1000000000;
|
||||||
|
@ -39,7 +39,7 @@ protected:
|
||||||
CSystemUtilsWindowsWrapper m_systemUtils;
|
CSystemUtilsWindowsWrapper m_systemUtils;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(SystemUtilsWindowsUT, TimeStampDiff)
|
TEST_F(CSystemUtilsWindowsUT, TimeStampDiff)
|
||||||
{
|
{
|
||||||
m_systemUtils.SetFrequency(SEC);
|
m_systemUtils.SetFrequency(SEC);
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,10 @@
|
||||||
* along with this program. If not, see http://gnu.org/licenses
|
* along with this program. If not, see http://gnu.org/licenses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "app/system.h"
|
||||||
|
|
||||||
#include "common/config_file.h"
|
#include "common/config_file.h"
|
||||||
#include "common/logger.h"
|
#include "common/logger.h"
|
||||||
#include "app/system.h"
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
* along with this program. If not, see http://gnu.org/licenses
|
* along with this program. If not, see http://gnu.org/licenses
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "graphics/engine/lightman.h"
|
|
||||||
|
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
|
|
||||||
#include "graphics/core/device.h"
|
#include "graphics/core/device.h"
|
||||||
|
|
||||||
|
#include "graphics/engine/lightman.h"
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <hippomocks.h>
|
#include <hippomocks.h>
|
||||||
|
|
||||||
|
@ -33,15 +33,15 @@ using namespace Gfx;
|
||||||
using namespace HippoMocks;
|
using namespace HippoMocks;
|
||||||
namespace ph = std::placeholders;
|
namespace ph = std::placeholders;
|
||||||
|
|
||||||
class LightManagerUT : public testing::Test
|
class CLightManagerUT : public testing::Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
LightManagerUT() :
|
CLightManagerUT() :
|
||||||
m_engine(nullptr),
|
m_engine(nullptr),
|
||||||
m_device(nullptr),
|
m_device(nullptr),
|
||||||
m_maxLightsCount(0)
|
m_maxLightsCount(0)
|
||||||
{}
|
{}
|
||||||
~LightManagerUT() NOEXCEPT
|
~CLightManagerUT() NOEXCEPT
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void SetUp() override;
|
void SetUp() override;
|
||||||
|
@ -64,7 +64,7 @@ private:
|
||||||
int m_maxLightsCount;
|
int m_maxLightsCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
void LightManagerUT::SetUp()
|
void CLightManagerUT::SetUp()
|
||||||
{
|
{
|
||||||
m_engine = m_mocks.Mock<CEngine>();
|
m_engine = m_mocks.Mock<CEngine>();
|
||||||
m_device = m_mocks.Mock<CDevice>();
|
m_device = m_mocks.Mock<CDevice>();
|
||||||
|
@ -72,7 +72,7 @@ void LightManagerUT::SetUp()
|
||||||
m_lightManager = MakeUnique<CLightManager>(m_engine);
|
m_lightManager = MakeUnique<CLightManager>(m_engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightManagerUT::PrepareLightTesting(int maxLights, Math::Vector eyePos)
|
void CLightManagerUT::PrepareLightTesting(int maxLights, Math::Vector eyePos)
|
||||||
{
|
{
|
||||||
m_maxLightsCount = maxLights;
|
m_maxLightsCount = maxLights;
|
||||||
|
|
||||||
|
@ -80,12 +80,12 @@ void LightManagerUT::PrepareLightTesting(int maxLights, Math::Vector eyePos)
|
||||||
|
|
||||||
m_lightManager->SetDevice(m_device);
|
m_lightManager->SetDevice(m_device);
|
||||||
|
|
||||||
m_mocks.OnCall(m_device, CDevice::SetLight).Do(std::bind(&LightManagerUT::CheckLight, this, ph::_1, ph::_2));
|
m_mocks.OnCall(m_device, CDevice::SetLight).Do(std::bind(&CLightManagerUT::CheckLight, this, ph::_1, ph::_2));
|
||||||
|
|
||||||
m_mocks.OnCall(m_engine, CEngine::GetEyePt).Return(eyePos);
|
m_mocks.OnCall(m_engine, CEngine::GetEyePt).Return(eyePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightManagerUT::CheckLightSorting(EngineObjectType objectType, const std::vector<int>& expectedLights)
|
void CLightManagerUT::CheckLightSorting(EngineObjectType objectType, const std::vector<int>& expectedLights)
|
||||||
{
|
{
|
||||||
m_expectedLightTypes = expectedLights;
|
m_expectedLightTypes = expectedLights;
|
||||||
|
|
||||||
|
@ -105,14 +105,14 @@ void LightManagerUT::CheckLightSorting(EngineObjectType objectType, const std::v
|
||||||
m_lightManager->UpdateDeviceLights(objectType);
|
m_lightManager->UpdateDeviceLights(objectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightManagerUT::CheckLight(int index, const Light& light)
|
void CLightManagerUT::CheckLight(int index, const Light& light)
|
||||||
{
|
{
|
||||||
ASSERT_TRUE(index >= 0 && index < static_cast<int>( m_expectedLightTypes.size() ));
|
ASSERT_TRUE(index >= 0 && index < static_cast<int>( m_expectedLightTypes.size() ));
|
||||||
ASSERT_EQ(m_expectedLightTypes[index], light.type);
|
ASSERT_EQ(m_expectedLightTypes[index], light.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightManagerUT::AddLight(int type, LightPriority priority, bool used, bool enabled,
|
void CLightManagerUT::AddLight(int type, LightPriority priority, bool used, bool enabled,
|
||||||
Math::Vector pos, EngineObjectType includeType, EngineObjectType excludeType)
|
Math::Vector pos, EngineObjectType includeType, EngineObjectType excludeType)
|
||||||
{
|
{
|
||||||
int rank = m_lightManager->CreateLight(priority);
|
int rank = m_lightManager->CreateLight(priority);
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ void LightManagerUT::AddLight(int type, LightPriority priority, bool used, bool
|
||||||
m_lightManager->DeleteLight(rank);
|
m_lightManager->DeleteLight(rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LightManagerUT, LightSorting_UnusedOrDisabledAreSkipped)
|
TEST_F(CLightManagerUT, LightSorting_UnusedOrDisabledAreSkipped)
|
||||||
{
|
{
|
||||||
const int lightCount = 10;
|
const int lightCount = 10;
|
||||||
const Math::Vector eyePos(0.0f, 0.0f, 0.0f);
|
const Math::Vector eyePos(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -143,7 +143,7 @@ TEST_F(LightManagerUT, LightSorting_UnusedOrDisabledAreSkipped)
|
||||||
CheckLightSorting(ENG_OBJTYPE_TERRAIN, expectedLights);
|
CheckLightSorting(ENG_OBJTYPE_TERRAIN, expectedLights);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LightManagerUT, LightSorting_IncludeTypesAreIncluded)
|
TEST_F(CLightManagerUT, LightSorting_IncludeTypesAreIncluded)
|
||||||
{
|
{
|
||||||
const int lightCount = 10;
|
const int lightCount = 10;
|
||||||
const Math::Vector eyePos(0.0f, 0.0f, 0.0f);
|
const Math::Vector eyePos(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -157,7 +157,7 @@ TEST_F(LightManagerUT, LightSorting_IncludeTypesAreIncluded)
|
||||||
CheckLightSorting(ENG_OBJTYPE_TERRAIN, expectedLights);
|
CheckLightSorting(ENG_OBJTYPE_TERRAIN, expectedLights);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LightManagerUT, LightSorting_ExcludeTypesAreExcluded)
|
TEST_F(CLightManagerUT, LightSorting_ExcludeTypesAreExcluded)
|
||||||
{
|
{
|
||||||
const int lightCount = 10;
|
const int lightCount = 10;
|
||||||
const Math::Vector eyePos(0.0f, 0.0f, 0.0f);
|
const Math::Vector eyePos(0.0f, 0.0f, 0.0f);
|
||||||
|
@ -171,7 +171,7 @@ TEST_F(LightManagerUT, LightSorting_ExcludeTypesAreExcluded)
|
||||||
CheckLightSorting(ENG_OBJTYPE_TERRAIN, expectedLights);
|
CheckLightSorting(ENG_OBJTYPE_TERRAIN, expectedLights);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(LightManagerUT, LightSorting_SortingAccordingToDistance)
|
TEST_F(CLightManagerUT, LightSorting_SortingAccordingToDistance)
|
||||||
{
|
{
|
||||||
const int lightCount = 3;
|
const int lightCount = 3;
|
||||||
const Math::Vector eyePos(0.0f, 0.0f, 0.0f);
|
const Math::Vector eyePos(0.0f, 0.0f, 0.0f);
|
||||||
|
|
Loading…
Reference in New Issue