Move GetTooltipText and Get/SetLock to CObject; remove Get/SetEnable
parent
f37d2a338e
commit
63d83185b5
|
@ -324,7 +324,7 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
if ( m_type == PT_WPCHECK )
|
||||
{
|
||||
m_speed = 1.0f/8.0f;
|
||||
m_object->SetEnable(false); // object more functional
|
||||
m_object->SetLock(true); // object more functional
|
||||
}
|
||||
if ( m_type == PT_FLCREATE )
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ bool CPyro::Create(PyroType type, CObject* obj, float force)
|
|||
if ( m_type == PT_FLDELETE )
|
||||
{
|
||||
m_speed = 1.0f/2.0f;
|
||||
m_object->SetEnable(false); // object more functional
|
||||
m_object->SetLock(true); // object more functional
|
||||
}
|
||||
if ( m_type == PT_RESET )
|
||||
{
|
||||
|
|
|
@ -192,13 +192,11 @@ bool CAuto::CreateInterface(bool bSelect)
|
|||
pw = static_cast<Ui::CWindow*>(m_interface->SearchControl(EVENT_WINDOW0));
|
||||
if ( pw == 0 ) return false;
|
||||
|
||||
std::string name;
|
||||
m_object->GetTooltipName(name);
|
||||
pos.x = 0.0f;
|
||||
pos.y = 64.0f/480.0f;
|
||||
ddim.x = 540.0f/640.0f;
|
||||
ddim.y = 16.0f/480.0f;
|
||||
pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, name);
|
||||
pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, m_object->GetTooltipText());
|
||||
|
||||
dim.x = 33.0f/640.0f;
|
||||
dim.y = 33.0f/480.0f;
|
||||
|
@ -442,4 +440,3 @@ bool CAuto::Read(CLevelParserLine* line)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "math/geometry.h"
|
||||
|
||||
#include "object/object_manager.h"
|
||||
#include "object/old_object.h"
|
||||
#include "object/robotmain.h"
|
||||
|
||||
|
@ -1382,7 +1383,8 @@ bool CMotionHuman::EventFrame(const Event &event)
|
|||
{
|
||||
if ( m_progress >= 1.0f )
|
||||
{
|
||||
m_object->SetEnable(false);
|
||||
CObjectManager::GetInstancePointer()->DeleteObject(m_object);
|
||||
return false;
|
||||
}
|
||||
|
||||
time = 100.0f;
|
||||
|
@ -1426,7 +1428,11 @@ bool CMotionHuman::EventFrame(const Event &event)
|
|||
if ( prog >= 1.0f )
|
||||
{
|
||||
prog = 1.0f;
|
||||
if ( pos.y >= level ) m_object->SetEnable(false);
|
||||
if ( pos.y >= level )
|
||||
{
|
||||
CObjectManager::GetInstancePointer()->DeleteObject(m_object);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
prog *= 2.0f;
|
||||
|
@ -1736,4 +1742,3 @@ void CMotionHuman::StopDisplayPerso()
|
|||
{
|
||||
m_bDisplayPerso = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
|
||||
#include "object/object.h"
|
||||
|
||||
#include "common/restext.h"
|
||||
#include "common/stringutils.h"
|
||||
|
||||
#include "object/robotmain.h"
|
||||
|
||||
#include "graphics/model/model_crash_sphere.h"
|
||||
|
||||
#include "script/scriptfunc.h"
|
||||
|
@ -35,6 +40,7 @@ CObject::CObject(int id, ObjectType type)
|
|||
, m_team(0)
|
||||
, m_proxyActivate(false)
|
||||
, m_proxyDistance(60.0f)
|
||||
, m_lock(false)
|
||||
{
|
||||
m_implementedInterfaces.fill(false);
|
||||
m_botVar = CScriptFunctions::CreateObjectVar(this);
|
||||
|
@ -269,3 +275,28 @@ CBotVar* CObject::GetBotVar()
|
|||
{
|
||||
return m_botVar;
|
||||
}
|
||||
|
||||
std::string CObject::GetTooltipText()
|
||||
{
|
||||
std::string name;
|
||||
GetResource(RES_OBJECT, m_type, name);
|
||||
if (GetTeam() != 0)
|
||||
{
|
||||
name += " ["+CRobotMain::GetInstancePointer()->GetTeamName(GetTeam())+" ("+StrUtils::ToString<int>(GetTeam())+")]";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
// Management of the mode "blocked" of an object.
|
||||
// For example, a cube of titanium is blocked while it is used to make something,
|
||||
// or a vehicle is blocked as its construction is not finished.
|
||||
|
||||
void CObject::SetLock(bool lock)
|
||||
{
|
||||
m_lock = lock;
|
||||
}
|
||||
|
||||
bool CObject::GetLock()
|
||||
{
|
||||
return m_lock;
|
||||
}
|
||||
|
|
|
@ -181,6 +181,12 @@ public:
|
|||
//! Returns CBot "object" variable associated with this object
|
||||
CBotVar* GetBotVar();
|
||||
|
||||
//! Returns tooltip text for an object
|
||||
std::string GetTooltipText();
|
||||
|
||||
void SetLock(bool lock);
|
||||
bool GetLock();
|
||||
|
||||
protected:
|
||||
//! Transform crash sphere by object's world matrix
|
||||
virtual void TransformCrashSphere(Math::Sphere& crashSphere) = 0;
|
||||
|
@ -202,4 +208,5 @@ protected:
|
|||
bool m_proxyActivate;
|
||||
float m_proxyDistance;
|
||||
CBotVar* m_botVar;
|
||||
bool m_lock;
|
||||
};
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "common/global.h"
|
||||
#include "common/make_unique.h"
|
||||
#include "common/restext.h"
|
||||
#include "common/stringutils.h"
|
||||
|
||||
#include "graphics/engine/lightman.h"
|
||||
|
@ -142,7 +141,6 @@ COldObject::COldObject(int id)
|
|||
m_bSelectable = true;
|
||||
m_bCheckToken = true;
|
||||
m_bVisible = true;
|
||||
m_bEnable = true;
|
||||
m_bTrainer = false;
|
||||
m_bToy = false;
|
||||
m_bManual = false;
|
||||
|
@ -153,7 +151,6 @@ COldObject::COldObject(int id)
|
|||
m_bVirusMode = false;
|
||||
m_virusTime = 0.0f;
|
||||
m_lastVirusParticle = 0.0f;
|
||||
m_bLock = false;
|
||||
m_bExplo = false;
|
||||
m_bCargo = false;
|
||||
m_bBurn = false;
|
||||
|
@ -767,9 +764,6 @@ void COldObject::Write(CLevelParserLine* line)
|
|||
if ( !GetSelectable() )
|
||||
line->AddParam("selectable", MakeUnique<CLevelParserParam>(GetSelectable()));
|
||||
|
||||
if ( !GetEnable() )
|
||||
line->AddParam("enable", MakeUnique<CLevelParserParam>(GetEnable()));
|
||||
|
||||
// TODO: doesn't seem to be used
|
||||
// But it is, this is used by aliens after Thumper ~krzys_h
|
||||
if ( GetFixed() )
|
||||
|
@ -864,7 +858,6 @@ void COldObject::Read(CLevelParserLine* line)
|
|||
SetShield(line->GetParam("shield")->AsFloat(1.0f));
|
||||
SetRange(line->GetParam("range")->AsFloat(1.0f));
|
||||
SetSelectable(line->GetParam("selectable")->AsBool(true));
|
||||
SetEnable(line->GetParam("enable")->AsBool(true));
|
||||
SetFixed(line->GetParam("fixed")->AsBool(false));
|
||||
SetCollisions(line->GetParam("clip")->AsBool(true));
|
||||
SetLock(line->GetParam("lock")->AsBool(false));
|
||||
|
@ -1994,7 +1987,7 @@ bool COldObject::EventProcess(const Event &event)
|
|||
|
||||
if ( m_motion != nullptr )
|
||||
{
|
||||
m_motion->EventProcess(event);
|
||||
if (!m_motion->EventProcess(event)) return false;
|
||||
}
|
||||
|
||||
if ( event.type == EVENT_FRAME )
|
||||
|
@ -2616,23 +2609,6 @@ void COldObject::SetVisible(bool bVisible)
|
|||
}
|
||||
|
||||
|
||||
// Management mode of operation of an object.
|
||||
// An inactive object is an object destroyed, nonexistent.
|
||||
// This mode is used for objects "resetables"
|
||||
// during training to simulate destruction.
|
||||
|
||||
void COldObject::SetEnable(bool bEnable)
|
||||
{
|
||||
m_bEnable = bEnable;
|
||||
}
|
||||
|
||||
bool COldObject::GetEnable()
|
||||
{
|
||||
return m_bEnable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Management of the method of increasing damage.
|
||||
|
||||
void COldObject::SetMagnifyDamage(float factor)
|
||||
|
@ -2657,19 +2633,7 @@ float COldObject::GetParam()
|
|||
{
|
||||
return m_param;
|
||||
}
|
||||
// Management of the mode "blocked" of an object.
|
||||
// For example, a cube of titanium is blocked while it is used to make something,
|
||||
// or a vehicle is blocked as its construction is not finished.
|
||||
|
||||
void COldObject::SetLock(bool bLock)
|
||||
{
|
||||
m_bLock = bLock;
|
||||
}
|
||||
|
||||
bool COldObject::GetLock()
|
||||
{
|
||||
return m_bLock;
|
||||
}
|
||||
|
||||
// Management of the mode "current explosion" of an object.
|
||||
// An object in this mode is not saving.
|
||||
|
@ -2719,7 +2683,7 @@ bool COldObject::GetRuin()
|
|||
|
||||
bool COldObject::GetActive()
|
||||
{
|
||||
return !m_bLock && !m_bBurn && !m_bFlat && m_bVisible && m_bEnable;
|
||||
return !GetLock() && !m_bBurn && !m_bFlat && m_bVisible;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3083,18 +3047,6 @@ int COldObject::GetDefRank()
|
|||
return m_defRank;
|
||||
}
|
||||
|
||||
// Getes the object name for the tooltip.
|
||||
|
||||
bool COldObject::GetTooltipName(std::string& name)
|
||||
{
|
||||
GetResource(RES_OBJECT, m_type, name);
|
||||
if (GetTeam() != 0)
|
||||
{
|
||||
name += " ["+CRobotMain::GetInstancePointer()->GetTeamName(GetTeam())+" ("+boost::lexical_cast<std::string>(GetTeam())+")]";
|
||||
}
|
||||
return !name.empty();
|
||||
}
|
||||
|
||||
Math::Vector COldObject::GetPosition() const
|
||||
{
|
||||
return GetPartPosition(0);
|
||||
|
|
|
@ -243,9 +243,6 @@ public:
|
|||
|
||||
void SetVisible(bool bVisible);
|
||||
|
||||
void SetEnable(bool bEnable) override;
|
||||
bool GetEnable() override;
|
||||
|
||||
void SetCheckToken(bool bMode);
|
||||
bool GetCheckToken();
|
||||
|
||||
|
@ -257,8 +254,6 @@ public:
|
|||
|
||||
void SetExploding(bool bExplo) override;
|
||||
bool IsExploding() override;
|
||||
void SetLock(bool bLock) override;
|
||||
bool GetLock() override;
|
||||
void SetBurn(bool bBurn) override;
|
||||
bool GetBurn() override;
|
||||
void SetDead(bool bDead) override;
|
||||
|
@ -282,8 +277,6 @@ public:
|
|||
void SetDefRank(int rank) override;
|
||||
int GetDefRank() override;
|
||||
|
||||
bool GetTooltipName(std::string& name) override;
|
||||
|
||||
bool CreateShadowCircle(float radius, float intensity, Gfx::EngineShadowType type = Gfx::ENG_SHADOW_NORM);
|
||||
bool CreateShadowLight(float height, Gfx::Color color);
|
||||
bool CreateEffectLight(float height, Gfx::Color color);
|
||||
|
@ -438,8 +431,6 @@ protected:
|
|||
bool m_bSelectable; // selectable object
|
||||
bool m_bCheckToken; // object with audited tokens
|
||||
bool m_bVisible; // object active but undetectable
|
||||
bool m_bEnable; // dead object
|
||||
bool m_bLock;
|
||||
bool m_bExplo;
|
||||
bool m_bCargo;
|
||||
bool m_bBurn;
|
||||
|
|
|
@ -147,19 +147,6 @@ bool COldObjectInterface::GetVirusMode()
|
|||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetEnable(bool bEnable)
|
||||
{
|
||||
throw std::logic_error("SetEnable: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetEnable()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return true;
|
||||
//throw std::logic_error("GetEnable: not implemented!");
|
||||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetMagnifyDamage(float factor)
|
||||
{
|
||||
throw std::logic_error("SetMagnifyDamage: not implemented!");
|
||||
|
@ -194,17 +181,6 @@ bool COldObjectInterface::IsExploding()
|
|||
//throw std::logic_error("IsExploding: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetLock(bool bLock)
|
||||
{
|
||||
throw std::logic_error("SetLock: not implemented!");
|
||||
}
|
||||
|
||||
bool COldObjectInterface::GetLock()
|
||||
{
|
||||
// TODO: temporary hack
|
||||
return false;
|
||||
//throw std::logic_error("GetLock: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetBurn(bool bBurn)
|
||||
{
|
||||
|
@ -277,11 +253,6 @@ int COldObjectInterface::GetDefRank()
|
|||
}
|
||||
|
||||
|
||||
bool COldObjectInterface::GetTooltipName(std::string& name)
|
||||
{
|
||||
throw std::logic_error("GetTooltipName: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::FlatParent()
|
||||
{
|
||||
throw std::logic_error("FlatParent: not implemented!");
|
||||
|
|
|
@ -111,10 +111,6 @@ public:
|
|||
virtual void SetVirusMode(bool bEnable);
|
||||
virtual bool GetVirusMode();
|
||||
|
||||
// Main CObject class?
|
||||
virtual void SetEnable(bool bEnable);
|
||||
virtual bool GetEnable();
|
||||
|
||||
// These go to Shielder subclass
|
||||
//! Shielder radius (only while active) [0 or RADIUS_SHIELD_MIN..RADIUS_SHIELD_MAX]
|
||||
virtual float GetShieldRadius();
|
||||
|
@ -134,10 +130,6 @@ public:
|
|||
virtual bool GetRuin();
|
||||
virtual bool GetActive();
|
||||
|
||||
// probably main CObject?
|
||||
virtual void SetLock(bool bLock);
|
||||
virtual bool GetLock();
|
||||
|
||||
// Not sure. CRangedObject?
|
||||
virtual float GetShowLimitRadius();
|
||||
|
||||
|
@ -151,9 +143,6 @@ public:
|
|||
virtual void SetDefRank(int rank);
|
||||
virtual int GetDefRank();
|
||||
|
||||
// main CObject? not sure
|
||||
virtual bool GetTooltipName(std::string& name);
|
||||
|
||||
// CProgrammableObject or refactor
|
||||
virtual float GetInfoReturn();
|
||||
};
|
||||
|
|
|
@ -2204,12 +2204,15 @@ void CRobotMain::HiliteObject(Math::Point pos)
|
|||
|
||||
if (obj != nullptr)
|
||||
{
|
||||
std::string objectTooltipName;
|
||||
if (m_settings->GetTooltips() && obj->GetTooltipName(objectTooltipName))
|
||||
if (m_settings->GetTooltips())
|
||||
{
|
||||
m_tooltipPos = pos;
|
||||
m_tooltipName = objectTooltipName;
|
||||
m_tooltipTime = 0.0f;
|
||||
std::string objectTooltipName = obj->GetTooltipText();
|
||||
if (!objectTooltipName.empty())
|
||||
{
|
||||
m_tooltipPos = pos;
|
||||
m_tooltipName = objectTooltipName;
|
||||
m_tooltipTime = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsSelectable(obj))
|
||||
|
@ -3620,7 +3623,6 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
|
||||
bool selectable = line->GetParam("selectable")->AsBool(true);
|
||||
oldObj->SetSelectable(selectable);
|
||||
oldObj->SetEnable(line->GetParam("enable")->AsBool(true));
|
||||
oldObj->SetProxyActivate(line->GetParam("proxyActivate")->AsBool(false));
|
||||
oldObj->SetProxyDistance(line->GetParam("proxyDistance")->AsFloat(15.0f)*g_unit);
|
||||
oldObj->SetRange(line->GetParam("range")->AsFloat(30.0f));
|
||||
|
|
|
@ -60,7 +60,6 @@ int CSceneCondition::CountObjects()
|
|||
// should be regarded as existing here!
|
||||
if (obj->GetLock()) continue;
|
||||
if (obj->GetRuin()) continue;
|
||||
if (!obj->GetEnable()) continue;
|
||||
|
||||
if (!this->countTransported)
|
||||
{
|
||||
|
|
|
@ -157,8 +157,6 @@ int CTaskFlag::CountObject(ObjectType type)
|
|||
int count = 0;
|
||||
for (CObject* obj : CObjectManager::GetInstancePointer()->GetAllObjects())
|
||||
{
|
||||
if ( !obj->GetEnable() ) continue;
|
||||
|
||||
ObjectType oType = obj->GetType();
|
||||
if ( type == OBJECT_NULL )
|
||||
{
|
||||
|
@ -257,4 +255,3 @@ Error CTaskFlag::DeleteFlag()
|
|||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -759,8 +759,6 @@ float CPhysics::GetLinLength(float dist)
|
|||
|
||||
bool CPhysics::EventProcess(const Event &event)
|
||||
{
|
||||
if ( !m_object->GetEnable() ) return true;
|
||||
|
||||
if ( event.type == EVENT_FRAME )
|
||||
{
|
||||
return EventFrame(event);
|
||||
|
@ -2511,7 +2509,6 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
|||
{
|
||||
if ( pObj == m_object ) continue; // yourself?
|
||||
if (IsObjectBeingTransported(pObj)) continue;
|
||||
if ( !pObj->GetEnable() ) continue; // inactive?
|
||||
if ( pObj->GetRuin() ) continue; // is burning or exploding?
|
||||
if ( pObj->GetDead() ) continue; // dead man?
|
||||
|
||||
|
@ -2556,7 +2553,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
|||
}
|
||||
|
||||
if ( oType == OBJECT_WAYPOINT &&
|
||||
pObj->GetEnable() &&
|
||||
!pObj->GetLock() &&
|
||||
m_object->GetTrainer() ) // driving vehicle?
|
||||
{
|
||||
Math::Vector oPos = pObj->GetPosition();
|
||||
|
@ -2724,8 +2721,6 @@ bool CPhysics::JostleObject(CObject* pObj, float force)
|
|||
bool CPhysics::ExploOther(ObjectType iType,
|
||||
CObject *pObj, ObjectType oType, float force)
|
||||
{
|
||||
if ( !pObj->GetEnable() ) return true;
|
||||
|
||||
JostleObject(pObj, 1.0f); // shakes the object
|
||||
|
||||
if ( force > 50.0f &&
|
||||
|
|
|
@ -153,9 +153,7 @@ bool CMainShort::CreateShortcuts()
|
|||
positions[teamIndex].x += dim.x;
|
||||
m_shortcuts.push_back(pObj);
|
||||
|
||||
std::string tooltipName;
|
||||
pObj->GetTooltipName(tooltipName);
|
||||
shortcut->SetTooltip(tooltipName);
|
||||
shortcut->SetTooltip(pObj->GetTooltipText());
|
||||
|
||||
rank ++;
|
||||
|
||||
|
|
|
@ -833,14 +833,12 @@ bool CObjectInterface::CreateInterface(bool bSelect)
|
|||
pw = static_cast< CWindow* >(m_interface->SearchControl(EVENT_WINDOW0));
|
||||
if ( pw == 0 ) return false;
|
||||
|
||||
std::string tooltipLabel;
|
||||
m_object->GetTooltipName(tooltipLabel);
|
||||
pos.x = 0.0f;
|
||||
pos.y = 64.0f/480.0f;
|
||||
ddim.x = 540.0f/640.0f;
|
||||
if ( !m_main->GetShowMap() ) ddim.x = 640.0f/640.0f;
|
||||
ddim.y = 16.0f/480.0f;
|
||||
pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, tooltipLabel);
|
||||
pw->CreateLabel(pos, ddim, 0, EVENT_LABEL0, m_object->GetTooltipText());
|
||||
|
||||
dim.x = 33.0f/640.0f;
|
||||
dim.y = 33.0f/480.0f;
|
||||
|
|
Loading…
Reference in New Issue