Cosmetic changes only.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9937 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a37b77543c
commit
b856a0c514
@ -26,11 +26,9 @@
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <SMesh.h>
|
||||
|
||||
float SkidMarks::m_avoid_z_fighting = 0.005f;
|
||||
const int SkidMarks::m_start_alpha = 128;
|
||||
const int SkidMarks::m_start_grey = 32;
|
||||
//const int start_premul = SkidMarks::m_start_grey * SkidMarks::m_start_alpha / 256; compiler whines about private later
|
||||
const int start_premul = 32 * 128 / 256;
|
||||
float SkidMarks::m_avoid_z_fighting = 0.005f;
|
||||
const int SkidMarks::m_start_alpha = 128;
|
||||
const int SkidMarks::m_start_grey = 32;
|
||||
|
||||
/** Initialises empty skid marks. */
|
||||
SkidMarks::SkidMarks(const Kart& kart, float width) : m_kart(kart)
|
||||
@ -38,8 +36,7 @@ SkidMarks::SkidMarks(const Kart& kart, float width) : m_kart(kart)
|
||||
m_width = width;
|
||||
m_material = new video::SMaterial();
|
||||
m_material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||
m_material->AmbientColor = video::SColor(128, 0, 0, 0); // or should be start_premul?
|
||||
// m_material->DiffuseColor = video::SColor(SkidMarks::m_start_alpha, start_premul, start_premul, start_premul); compiler whines about private
|
||||
m_material->AmbientColor = video::SColor(128, 0, 0, 0);
|
||||
m_material->DiffuseColor = video::SColor(128, 16, 16, 16);
|
||||
m_material->Shininess = 0;
|
||||
m_skid_marking = false;
|
||||
@ -77,7 +74,8 @@ void SkidMarks::reset()
|
||||
* starts a new skid mark quad.
|
||||
* \param dt Time step.
|
||||
*/
|
||||
void SkidMarks::update(float dt, bool force_skid_marks, video::SColor* custom_color)
|
||||
void SkidMarks::update(float dt, bool force_skid_marks,
|
||||
video::SColor* custom_color)
|
||||
{
|
||||
//if the kart is gnu, then dont skid because he floats!
|
||||
if (m_kart.isWheeless() == false)
|
||||
@ -97,7 +95,8 @@ void SkidMarks::update(float dt, bool force_skid_marks, video::SColor* custom_co
|
||||
m_kart.getVehicle()->getWheelInfo(2).m_raycastInfo;
|
||||
const btWheelInfo::RaycastInfo raycast_left =
|
||||
m_kart.getVehicle()->getWheelInfo(3).m_raycastInfo;
|
||||
Vec3 delta = raycast_right.m_contactPointWS - raycast_left.m_contactPointWS;
|
||||
Vec3 delta = raycast_right.m_contactPointWS
|
||||
- raycast_left.m_contactPointWS;
|
||||
|
||||
// We were skid marking, but not anymore (either because the
|
||||
// wheels don't touch the ground, or the kart has stopped
|
||||
@ -107,19 +106,18 @@ void SkidMarks::update(float dt, bool force_skid_marks, video::SColor* custom_co
|
||||
// delta is 0, and the behaviour is undefined. In this case
|
||||
// just stop doing skid marks as well.
|
||||
// ---------------------------------------------------------
|
||||
if (!force_skid_marks)
|
||||
if (!force_skid_marks &&
|
||||
(!raycast_right.m_isInContact ||
|
||||
!m_kart.getControls().m_drift ||
|
||||
fabsf(m_kart.getControls().m_steer) < 0.001f ||
|
||||
delta.length2()<0.0001 ) )
|
||||
{
|
||||
if(!raycast_right.m_isInContact || !m_kart.getControls().m_drift ||
|
||||
fabsf(m_kart.getControls().m_steer) < 0.001f ||
|
||||
delta.length2()<0.0001)
|
||||
{
|
||||
m_skid_marking = false;
|
||||
// The vertices and indices will not change anymore (till these
|
||||
// skid mark quads are deleted)
|
||||
m_left[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
m_right[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
return;
|
||||
}
|
||||
m_skid_marking = false;
|
||||
// The vertices and indices will not change anymore
|
||||
// (till these skid mark quads are deleted)
|
||||
m_left[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
m_right[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
|
||||
return;
|
||||
}
|
||||
|
||||
// We are still skid marking, so add the latest quad
|
||||
@ -134,7 +132,8 @@ void SkidMarks::update(float dt, bool force_skid_marks, video::SColor* custom_co
|
||||
raycast_right.m_contactPointWS);
|
||||
// Adjust the boundary box of the mesh to include the
|
||||
// adjusted aabb of its buffers.
|
||||
core::aabbox3df aabb=m_nodes[m_current]->getMesh()->getBoundingBox();
|
||||
core::aabbox3df aabb=m_nodes[m_current]->getMesh()
|
||||
->getBoundingBox();
|
||||
aabb.addInternalBox(m_left[m_current]->getAABB());
|
||||
aabb.addInternalBox(m_right[m_current]->getAABB());
|
||||
m_nodes[m_current]->getMesh()->setBoundingBox(aabb);
|
||||
@ -146,11 +145,14 @@ void SkidMarks::update(float dt, bool force_skid_marks, video::SColor* custom_co
|
||||
if (!force_skid_marks)
|
||||
{
|
||||
if((!m_kart.getControls().m_drift) ||
|
||||
(fabsf(m_kart.getControls().m_steer) < 0.001f)) return; // not skidmarking
|
||||
(fabsf(m_kart.getControls().m_steer) < 0.001f))
|
||||
return; // not skidmarking
|
||||
|
||||
// not turning enough, don't draw skidmarks if kart is going straight ahead
|
||||
// this is even stricter for Ai karts, since they tend to use LOTS of skidding
|
||||
const float min_skid_angle = m_kart.getController()->isPlayerController() ? 0.55f : 0.95f;
|
||||
// not turning enough, don't draw skidmarks if kart is going
|
||||
// straight ahead this is even stricter for Ai karts, since they
|
||||
// tend to use LOTS of skidding
|
||||
const float min_skid_angle =
|
||||
m_kart.getController()->isPlayerController() ? 0.55f : 0.95f;
|
||||
if( fabsf(m_kart.getSteerPercent()) < min_skid_angle) return;
|
||||
}
|
||||
|
||||
@ -164,26 +166,29 @@ void SkidMarks::update(float dt, bool force_skid_marks, video::SColor* custom_co
|
||||
const btWheelInfo::RaycastInfo raycast_left =
|
||||
m_kart.getVehicle()->getWheelInfo(3).m_raycastInfo;
|
||||
|
||||
Vec3 delta = raycast_right.m_contactPointWS - raycast_left.m_contactPointWS;
|
||||
// Special case: only one wheel on one axis touches the ground --> physics
|
||||
// set both wheels to touch the same spot --> delta = 0. In this case,
|
||||
// don't start skidmarks.
|
||||
Vec3 delta = raycast_right.m_contactPointWS
|
||||
- raycast_left.m_contactPointWS;
|
||||
// Special case: only one wheel on one axis touches the ground
|
||||
// --> physics set both wheels to touch the same spot --> delta = 0.
|
||||
// In this case, don't start skidmarks.
|
||||
if(delta.length2()<0.0001) return;
|
||||
delta.normalize();
|
||||
delta *= m_width;
|
||||
|
||||
SkidMarkQuads *smq_left = new SkidMarkQuads(raycast_left.m_contactPointWS,
|
||||
raycast_left.m_contactPointWS + delta,
|
||||
m_material, m_avoid_z_fighting,
|
||||
custom_color);
|
||||
SkidMarkQuads *smq_left =
|
||||
new SkidMarkQuads(raycast_left.m_contactPointWS,
|
||||
raycast_left.m_contactPointWS + delta,
|
||||
m_material, m_avoid_z_fighting,
|
||||
custom_color);
|
||||
scene::SMesh *new_mesh = new scene::SMesh();
|
||||
new_mesh->addMeshBuffer(smq_left);
|
||||
|
||||
SkidMarkQuads *smq_right = new SkidMarkQuads(raycast_right.m_contactPointWS - delta,
|
||||
raycast_right.m_contactPointWS,
|
||||
m_material,
|
||||
m_avoid_z_fighting,
|
||||
custom_color);
|
||||
SkidMarkQuads *smq_right =
|
||||
new SkidMarkQuads(raycast_right.m_contactPointWS - delta,
|
||||
raycast_right.m_contactPointWS,
|
||||
m_material,
|
||||
m_avoid_z_fighting,
|
||||
custom_color);
|
||||
new_mesh->addMeshBuffer(smq_right);
|
||||
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh);
|
||||
#ifdef DEBUG
|
||||
@ -250,7 +255,9 @@ SkidMarks::SkidMarkQuads::SkidMarkQuads(const Vec3 &left,
|
||||
} // SkidMarkQuads
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** Adds the two points to this SkidMarkQuads.
|
||||
* \param left,right Left and right coordinates.
|
||||
*/
|
||||
void SkidMarks::SkidMarkQuads::add(const Vec3 &left,
|
||||
const Vec3 &right)
|
||||
{
|
||||
@ -313,7 +320,9 @@ void SkidMarks::SkidMarkQuads::fade(float f)
|
||||
} // fade
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** Sets the fog handling for the skid marks.
|
||||
* \param enabled True if fog should be enabled.
|
||||
*/
|
||||
void SkidMarks::adjustFog(bool enabled)
|
||||
{
|
||||
m_material->FogEnable = enabled;
|
||||
|
@ -44,29 +44,36 @@ class SkidMarks : public NoCopy
|
||||
private:
|
||||
/** Reference to the kart to which these skidmarks belong. */
|
||||
const Kart &m_kart;
|
||||
|
||||
/** True if the kart was skidding in the previous frame. */
|
||||
bool m_skid_marking;
|
||||
|
||||
/** Reduce effect of Z-fighting. */
|
||||
float m_width;
|
||||
|
||||
/** Index of current (last added) skid mark quad. */
|
||||
int m_current;
|
||||
|
||||
/** Initial alpha value. */
|
||||
static const int m_start_alpha;
|
||||
|
||||
/** Initial grey value, same for the 3 channels. */
|
||||
static const int m_start_grey;
|
||||
|
||||
/** Material to use for the skid marks. */
|
||||
video::SMaterial *m_material;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
class SkidMarkQuads : public scene::SMeshBuffer, public NoCopy
|
||||
{
|
||||
/** Used to move skid marks at the same location slightly on
|
||||
* top of each other to avoid a 'wobbling' effect when sometines
|
||||
* the first and sometimes the 2nd one is drawn on top
|
||||
*/
|
||||
* the first and sometimes the 2nd one is drawn on top. */
|
||||
float m_z_offset;
|
||||
|
||||
/** Fade out = alpha value. */
|
||||
float m_fade_out;
|
||||
|
||||
/** For culling, we need the overall radius of the skid marks. We
|
||||
* approximate this by maintaining an axis-aligned boundary box. */
|
||||
core::aabbox3df m_aabb;
|
||||
@ -84,6 +91,7 @@ private:
|
||||
const core::aabbox3df &getAABB() { return m_aabb; }
|
||||
}; // SkidMarkQuads
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Two skidmark objects for the left and right wheel. */
|
||||
std::vector<SkidMarkQuads *> m_left, m_right;
|
||||
|
||||
@ -93,10 +101,12 @@ private:
|
||||
/** Shared static so that consecutive skidmarks are at a slightly
|
||||
* different height. */
|
||||
static float m_avoid_z_fighting;
|
||||
|
||||
public:
|
||||
SkidMarks(const Kart& kart, float width=0.2f);
|
||||
~SkidMarks();
|
||||
void update (float dt, bool force_skid_marks=false, video::SColor* custom_color = NULL);
|
||||
void update (float dt, bool force_skid_marks=false,
|
||||
video::SColor* custom_color = NULL);
|
||||
void reset();
|
||||
|
||||
void adjustFog(bool enabled);
|
||||
|
@ -38,53 +38,49 @@ using namespace GUIEngine;
|
||||
const float TIME_SECTION_FADE = 0.8f;
|
||||
const float ENTRIES_FADE_TIME = 0.3f;
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class CreditsEntry
|
||||
{
|
||||
public:
|
||||
stringw m_name;
|
||||
stringw m_name;
|
||||
std::vector<stringw> m_subentries;
|
||||
|
||||
CreditsEntry(stringw& name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
};
|
||||
}; // CreditsEntry
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class CreditsSection
|
||||
{
|
||||
public:
|
||||
// read-only
|
||||
std::vector<CreditsEntry> m_entries;
|
||||
stringw m_name;
|
||||
stringw m_name;
|
||||
|
||||
CreditsSection(stringw name)
|
||||
{
|
||||
this->m_name = name;
|
||||
}
|
||||
void addEntry(CreditsEntry& entry)
|
||||
{
|
||||
m_entries.push_back(entry);
|
||||
}
|
||||
CreditsSection(stringw name) { m_name = name; }
|
||||
// ------------------------------------------------------------------------
|
||||
void addEntry(CreditsEntry& entry) {m_entries.push_back(entry); }
|
||||
// ------------------------------------------------------------------------
|
||||
void addSubEntry(stringw& subEntryString)
|
||||
{
|
||||
m_entries[m_entries.size()-1].m_subentries.push_back(subEntryString);
|
||||
}
|
||||
};
|
||||
}; // CreditdsSection
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
CreditsSection* CreditsScreen::getCurrentSection()
|
||||
{
|
||||
return m_sections.get(m_sections.size()-1);
|
||||
}
|
||||
} // getCurrentSection
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool getWideLine(std::ifstream& file, stringw* out)
|
||||
bool CreditsScreen::getWideLine(std::ifstream& file, core::stringw* out)
|
||||
{
|
||||
if (!file.good())
|
||||
{
|
||||
@ -102,37 +98,29 @@ bool getWideLine(std::ifstream& file, stringw* out)
|
||||
{
|
||||
file.read( buff, 2 );
|
||||
if (file.good())
|
||||
{
|
||||
//std::cout << buff[0] << ", " << buff[1]
|
||||
// << "(" << std::hex << (unsigned)buff[0] << ", " << std::hex << (unsigned)buff[1] << ")\n";
|
||||
|
||||
{
|
||||
// We got no complaints so I assume the endianness code here is OK
|
||||
wide_char = unsigned(buff[0] & 0xFF) | (unsigned(buff[1] & 0xFF) << 8);
|
||||
wide_char = unsigned(buff[0] & 0xFF)
|
||||
| (unsigned(buff[1] & 0xFF) << 8);
|
||||
line += wide_char;
|
||||
//std::cout << "Read char " << (char)(wide_char) << " (" << std::hex << wide_char << ")" << std::endl;
|
||||
if (wide_char == L'\n')
|
||||
{
|
||||
//std::cout << "EOL\n";
|
||||
found_eol = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//std::cout << "- file not good -\n";
|
||||
//file.get(); // if we stopped on EOL, try to skip it
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_eol) return false;
|
||||
*out = line;
|
||||
//std::cout << "Read line <" << stringc(line.c_str()).c_str() << ">\n";
|
||||
return true;
|
||||
}
|
||||
} // getWideLine
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
#pragma mark -
|
||||
@ -141,9 +129,9 @@ bool getWideLine(std::ifstream& file, stringw* out)
|
||||
|
||||
CreditsScreen::CreditsScreen() : Screen("credits.stkgui")
|
||||
{
|
||||
}
|
||||
} // CreditsScreen
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void CreditsScreen::loadedFromFile()
|
||||
{
|
||||
@ -157,7 +145,8 @@ void CreditsScreen::loadedFromFile()
|
||||
|
||||
if (file.fail() || !file.is_open() || file.eof())
|
||||
{
|
||||
fprintf(stderr, "\n/!\\ Failed to open file at '%s'\n\n", creditsfile.c_str());
|
||||
fprintf(stderr, "\n/!\\ Failed to open file at '%s'\n\n",
|
||||
creditsfile.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -169,7 +158,9 @@ void CreditsScreen::loadedFromFile()
|
||||
|
||||
if (file.fail() || !file.is_open() || file.eof())
|
||||
{
|
||||
fprintf(stderr, "\n/!\\ Failed to read file at '%s', unexpected EOF\n\n", creditsfile.c_str());
|
||||
fprintf(stderr,
|
||||
"\n/!\\ Failed to read file at '%s', unexpected EOF\n\n",
|
||||
creditsfile.c_str());
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
@ -193,25 +184,15 @@ void CreditsScreen::loadedFromFile()
|
||||
line = stringw( line.subString(1, line.size()-2).c_str() );
|
||||
line = line.trim();
|
||||
|
||||
//stringc cversion = line.c_str();
|
||||
//std::cout << "Section : " << (char*)(cversion.c_str()) << std::endl;
|
||||
m_sections.push_back( new CreditsSection(line) );
|
||||
}
|
||||
else if ((line[0] & 0xFF) == '-')
|
||||
{
|
||||
line = stringw( line.subString(1, line.size()-1).c_str() );
|
||||
//line = line.trim();
|
||||
|
||||
//stringc cversion = line.c_str();
|
||||
//std::cout << "---- Sub-Entry : " << (char*)(cversion.c_str()) << std::endl;
|
||||
|
||||
getCurrentSection()->addSubEntry( line );
|
||||
}
|
||||
else
|
||||
{
|
||||
//tringc cversion = line.c_str();
|
||||
//std::cout << "-- Entry : " << (char*)(cversion.c_str()) << std::endl;
|
||||
|
||||
CreditsEntry entry(line);
|
||||
getCurrentSection()->addEntry( entry );
|
||||
}
|
||||
@ -220,12 +201,14 @@ void CreditsScreen::loadedFromFile()
|
||||
|
||||
if (lineCount == 0)
|
||||
{
|
||||
fprintf(stderr, "\n/!\\ Could not read anything from CREDITS file!\n\n");
|
||||
fprintf(stderr,
|
||||
"\n/!\\ Could not read anything from CREDITS file!\n\n");
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<irr::core::stringw> translator = StringUtils::split(_("translator-credits"), '\n');
|
||||
std::vector<irr::core::stringw> translator =
|
||||
StringUtils::split(_("translator-credits"), '\n');
|
||||
m_sections.push_back( new CreditsSection("Launchpad translations"));
|
||||
for(unsigned int i = 1; i < translator.size(); i = i + 4)
|
||||
{
|
||||
@ -240,9 +223,9 @@ void CreditsScreen::loadedFromFile()
|
||||
}
|
||||
assert(m_sections.size() > 0);
|
||||
|
||||
}
|
||||
} // loadedFromFile
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void CreditsScreen::init()
|
||||
{
|
||||
@ -252,9 +235,9 @@ void CreditsScreen::init()
|
||||
|
||||
reset();
|
||||
setArea(w->m_x, w->m_y, w->m_w, w->m_h);
|
||||
}
|
||||
} // init
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void CreditsScreen::setArea(const int x, const int y, const int w, const int h)
|
||||
{
|
||||
@ -264,9 +247,9 @@ void CreditsScreen::setArea(const int x, const int y, const int w, const int h)
|
||||
m_h = h;
|
||||
|
||||
m_section_rect = core::rect< s32 >( x, y, x + w, y + h/6 );
|
||||
}
|
||||
} // setArea
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void CreditsScreen::reset()
|
||||
{
|
||||
@ -274,16 +257,18 @@ void CreditsScreen::reset()
|
||||
m_curr_element = -1;
|
||||
time_before_next_step = TIME_SECTION_FADE;
|
||||
m_time_element = 2.5f;
|
||||
}
|
||||
} // reset
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void CreditsScreen::onUpdate(float elapsed_time, irr::video::IVideoDriver*)
|
||||
{
|
||||
time_before_next_step -= elapsed_time*0.8f; // multiply by 0.8 to slow it down a bit as a whole
|
||||
// multiply by 0.8 to slow it down a bit as a whole
|
||||
time_before_next_step -= elapsed_time*0.8f;
|
||||
|
||||
const bool before_first_elem = (m_curr_element == -1);
|
||||
const bool after_last_elem = (m_curr_element >= (int)m_sections[m_curr_section].m_entries.size());
|
||||
const bool after_last_elem =
|
||||
(m_curr_element >= (int)m_sections[m_curr_section].m_entries.size());
|
||||
|
||||
|
||||
// ---- section name
|
||||
@ -303,13 +288,15 @@ void CreditsScreen::onUpdate(float elapsed_time, irr::video::IVideoDriver*)
|
||||
else if (after_last_elem)
|
||||
{
|
||||
// I use 425 instead of 255 so that there is a little pause after
|
||||
int alpha = (int)(time_before_next_step/TIME_SECTION_FADE * 425) - (425-255);
|
||||
int alpha =
|
||||
(int)(time_before_next_step/TIME_SECTION_FADE * 425) - (425-255);
|
||||
if (alpha < 0) alpha = 0;
|
||||
else if (alpha > 255) alpha = 255;
|
||||
white_color.setAlpha( alpha );
|
||||
}
|
||||
|
||||
GUIEngine::getTitleFont()->draw(m_sections[m_curr_section].m_name.c_str(), m_section_rect, white_color,
|
||||
GUIEngine::getTitleFont()->draw(m_sections[m_curr_section].m_name.c_str(),
|
||||
m_section_rect, white_color,
|
||||
true /* center h */, true /* center v */ );
|
||||
|
||||
// draw entries
|
||||
@ -334,7 +321,9 @@ void CreditsScreen::onUpdate(float elapsed_time, irr::video::IVideoDriver*)
|
||||
// fade out
|
||||
else if (time_before_next_step >= m_time_element - ENTRIES_FADE_TIME)
|
||||
{
|
||||
const float fade_out = (time_before_next_step - (m_time_element - ENTRIES_FADE_TIME)) / ENTRIES_FADE_TIME;
|
||||
const float fade_out =
|
||||
(time_before_next_step - (m_time_element - ENTRIES_FADE_TIME))
|
||||
/ ENTRIES_FADE_TIME;
|
||||
|
||||
int alpha = 255 - (int)(fade_out * 255);
|
||||
if(alpha < 0) alpha = 0;
|
||||
@ -345,18 +334,33 @@ void CreditsScreen::onUpdate(float elapsed_time, irr::video::IVideoDriver*)
|
||||
}
|
||||
|
||||
|
||||
GUIEngine::getFont()->draw(m_sections[m_curr_section].m_entries[m_curr_element].m_name.c_str(),
|
||||
core::rect< s32 >( m_x + text_offset, m_y + m_h/6, m_x + m_w + text_offset, m_y + m_h/3 ),
|
||||
color, false /* center h */, true /* center v */, NULL, true /* ignore RTL */ );
|
||||
GUIEngine::getFont()->draw(
|
||||
m_sections[m_curr_section].m_entries[m_curr_element]
|
||||
.m_name.c_str(),
|
||||
core::recti( m_x + text_offset, m_y + m_h/6,
|
||||
m_x + m_w + text_offset, m_y + m_h/3 ),
|
||||
color, false /* center h */, true /* center v */, NULL,
|
||||
true /* ignore RTL */ );
|
||||
|
||||
const int subamount = m_sections[m_curr_section].m_entries[m_curr_element].m_subentries.size();
|
||||
const int subamount = m_sections[m_curr_section]
|
||||
.m_entries[m_curr_element].m_subentries.size();
|
||||
int suby = m_y + m_h/3;
|
||||
const int inc = subamount == 0 ? m_h/8 : std::min(m_h/8, (m_h - m_h/3)/(subamount+1));
|
||||
const int inc = subamount == 0 ? m_h/8
|
||||
: std::min(m_h/8,
|
||||
(m_h - m_h/3)/(subamount+1));
|
||||
for(int i=0; i<subamount; i++)
|
||||
{
|
||||
GUIEngine::getFont()->draw(m_sections[m_curr_section].m_entries[m_curr_element].m_subentries[i].c_str(),
|
||||
core::rect< s32 >( m_x + 32, suby + text_offset/(1+1), m_x + m_w + 32, suby + m_h/8 + text_offset/(1+1) ),
|
||||
color, false/* center h */, true /* center v */, NULL, true /* ignore RTL */ );
|
||||
GUIEngine::getFont()->draw(m_sections[m_curr_section]
|
||||
.m_entries[m_curr_element]
|
||||
.m_subentries[i].c_str(),
|
||||
core::recti( m_x + 32,
|
||||
suby + text_offset/(1+1),
|
||||
m_x + m_w + 32,
|
||||
suby + m_h/8
|
||||
+ text_offset/(1+1) ),
|
||||
color, false/* center h */,
|
||||
true /* center v */, NULL,
|
||||
true /* ignore RTL */ );
|
||||
suby += inc;
|
||||
}
|
||||
|
||||
@ -379,29 +383,28 @@ void CreditsScreen::onUpdate(float elapsed_time, irr::video::IVideoDriver*)
|
||||
// move on
|
||||
m_curr_element++;
|
||||
|
||||
if (m_curr_element >= (int)m_sections[m_curr_section].m_entries.size())
|
||||
if (m_curr_element >=
|
||||
(int)m_sections[m_curr_section].m_entries.size())
|
||||
{
|
||||
time_before_next_step = TIME_SECTION_FADE;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int count = (int)m_sections[m_curr_section].m_entries[m_curr_element].m_subentries.size();
|
||||
const int count =
|
||||
(int)m_sections[m_curr_section].m_entries[m_curr_element]
|
||||
.m_subentries.size();
|
||||
m_time_element = 2.0f + count*0.6f;
|
||||
time_before_next_step = m_time_element;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
draw (const wchar_t *text, const core::rect< s32 > &position, video::SColor color,
|
||||
bool hcenter=false,
|
||||
bool vcenter=false, const core::rect< s32 > *clip=0)=0
|
||||
*/
|
||||
}
|
||||
} // onUpdate
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void CreditsScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID)
|
||||
void CreditsScreen::eventCallback(GUIEngine::Widget* widget,
|
||||
const std::string& name, const int playerID)
|
||||
{
|
||||
if (name == "back")
|
||||
{
|
||||
@ -409,5 +412,5 @@ void CreditsScreen::eventCallback(GUIEngine::Widget* widget, const std::string&
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
@ -37,7 +37,8 @@ class CreditsSection;
|
||||
* \brief Screen where STK credits are shown
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class CreditsScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<CreditsScreen>
|
||||
class CreditsScreen : public GUIEngine::Screen,
|
||||
public GUIEngine::ScreenSingleton<CreditsScreen>
|
||||
{
|
||||
float m_time_element;
|
||||
|
||||
@ -54,7 +55,8 @@ class CreditsScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleto
|
||||
|
||||
friend class GUIEngine::ScreenSingleton<CreditsScreen>;
|
||||
CreditsScreen();
|
||||
|
||||
bool getWideLine(std::ifstream& file, core::stringw* out);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -66,14 +68,16 @@ public:
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void loadedFromFile();
|
||||
|
||||
/** \brief implement optional callback from parent class GUIEngine::Screen */
|
||||
/** \brief implement optional callback from parent class
|
||||
* GUIEngine::Screen */
|
||||
void onUpdate(float dt, irr::video::IVideoDriver*);
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
void init();
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID);
|
||||
void eventCallback(GUIEngine::Widget* widget, const std::string& name,
|
||||
const int playerID);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user