Adjust color of check lines according to state: active ones are
light red, inactive ones white-grey. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6765 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "irrlicht.h"
|
||||
|
||||
#include "io/xml_node.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
@@ -46,6 +48,7 @@ CheckLine::CheckLine(CheckManager *check_manager, const XMLNode &node,
|
||||
{
|
||||
video::SMaterial material;
|
||||
material.setFlag(video::EMF_BACK_FACE_CULLING, false);
|
||||
material.setFlag(video::EMF_LIGHTING, false);
|
||||
material.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
|
||||
scene::IMesh *mesh = irr_driver->createQuadMesh(&material,
|
||||
/*create mesh*/true);
|
||||
@@ -101,6 +104,22 @@ void CheckLine::reset(const Track &track)
|
||||
}
|
||||
} // reset
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CheckLine::changeDebugColor(bool is_active)
|
||||
{
|
||||
assert(m_debug_node);
|
||||
|
||||
scene::IMesh *mesh = m_debug_node->getMesh();
|
||||
scene::IMeshBuffer *buffer = mesh->getMeshBuffer(0);
|
||||
irr::video::S3DVertex* vertices
|
||||
= (video::S3DVertex*)buffer->getVertices();
|
||||
for(unsigned int i=0; i<4; i++)
|
||||
{
|
||||
vertices[i].Color = is_active ? video::SColor(0, 255, 0, 0)
|
||||
: video::SColor(0, 128, 128, 128);
|
||||
}
|
||||
} // changeDebugColor
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** True if going from old_pos to new_pos crosses this checkline. This function
|
||||
* is called from update (of the checkline structure).
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
virtual ~CheckLine();
|
||||
virtual bool isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx);
|
||||
virtual void reset(const Track &track);
|
||||
virtual void changeDebugColor(bool is_active);
|
||||
/** Returns the actual line data for this checkpoint. */
|
||||
const core::line2df &getLine2D() const {return m_line;}
|
||||
}; // CheckLine
|
||||
|
||||
@@ -121,6 +121,10 @@ void CheckStructure::changeStatus(const std::vector<int> indices,
|
||||
int kart_index,
|
||||
ChangeState change_state)
|
||||
{
|
||||
bool update_debug_colors =
|
||||
UserConfigParams::m_check_debug &&
|
||||
kart_index==World::getWorld()->getPlayerKart(0)->getWorldKartId();
|
||||
|
||||
for(unsigned int i=0; i<indices.size(); i++)
|
||||
{
|
||||
CheckStructure *cs =
|
||||
@@ -160,7 +164,10 @@ void CheckStructure::changeStatus(const std::vector<int> indices,
|
||||
}
|
||||
cs->m_is_active[kart_index] = !cs->m_is_active[kart_index];
|
||||
} // switch
|
||||
|
||||
if(update_debug_colors)
|
||||
{
|
||||
cs->changeDebugColor(cs->m_is_active[kart_index]);
|
||||
}
|
||||
} // for i<indices.size()
|
||||
} //changeStatus
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@ public:
|
||||
unsigned int index);
|
||||
virtual ~CheckStructure() {};
|
||||
virtual void update(float dt);
|
||||
virtual void changeDebugColor(bool is_active) {}
|
||||
/** True if going from old_pos to new_pos crosses this checkline. This function
|
||||
* is called from update (of the checkline structure).
|
||||
* \param old_pos Position in previous frame.
|
||||
@@ -117,6 +118,7 @@ public:
|
||||
|
||||
/** Returns the type of this check structure. */
|
||||
CheckType getType() const { return m_check_type; }
|
||||
|
||||
}; // CheckStructure
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user