Merge branch 'upstream/master' into fixes

Conflicts:
	src/input/input_manager.cpp
	src/states_screens/kart_selection.cpp
This commit is contained in:
Flakebi 2014-11-26 07:34:26 +01:00
commit c4cdfc4a0e
49 changed files with 2136 additions and 1095 deletions

View File

@ -16,12 +16,12 @@
max="1000" />
<!-- Minimal and maximal lifetime of a particle, in milliseconds. -->
<lifetime min="10000"
max="10000" />
<lifetime min="8500"
max="9500" />
<!-- Size of the particles -->
<size min="0.40"
max="0.60" />
<size min="0.10"
max="0.30" />
<color min="40 40 255"
max="255 255 255" />

View File

@ -11,9 +11,8 @@
<box width="95%" height="40%" padding="10" layout="horizontal-row">
<spacer width="10" height="100%"/>
<!-- Left pane -->
<div width="45%" height="95%" align="center" layout="vertical-row">
<placeholder proportion="1" width="100%" height="100%" id="screenshot_div">
</placeholder>
<div width="45%" height="100%" align="center" layout="vertical-row">
<icon-button proportion="1" width="100%" height="100%" id="screenshot" custom_ratio="1.33333"/>
</div>
<spacer width="5%" height="100%"/>

View File

@ -45,14 +45,20 @@
text="TEST: GPLose" label_location="hover"/>
<icon-button id="test_unlocked" width="64" height="64" icon="gui/main_options.png" extend_label="50"
text="TEST: Unlocked" label_location="hover"/>
<icon-button id="test_unlocked2" width="64" height="64" icon="gui/main_options.png" extend_label="50"
text="TEST: Unlocked 2" label_location="hover"/>
<icon-button id="test_unlocked2" width="64" height="64" icon="gui/main_options.png" extend_label="50"
text="TEST: Unlocked 2" label_location="hover"/>
<icon-button id="test_intro" width="64" height="64" icon="gui/main_options.png" extend_label="50"
text="TEST: Intro" label_location="hover"/>
<icon-button id="test_outro" width="64" height="64" icon="gui/main_options.png" extend_label="50"
text="TEST: Outro" label_location="hover"/>
<icon-button id="options" width="64" height="64" icon="gui/main_options.png" extend_label="50"
I18N="In the main screen" text="Options" label_location="hover"/>
<icon-button id="help" width="64" height="64" icon="gui/main_help.png" extend_label="50"
I18N="In the main screen" text="Help" label_location="hover"/>
<icon-button id="startTutorial" width="64" height="64" icon="gui/tutorial.png" extend_label="150"
I18N="In the main screen" text="Tutorial" label_location="hover"/>
<icon-button id="achievements" width="64" height="64" icon="gui/gp_copy.png" extend_label="150"
I18N="In the main screen" text="Achievements" label_location="hover"/>
<icon-button id="gpEditor" width="64" height="64" icon="gui/gpeditor.png" extend_label="150"
I18N="In the main screen" text="Grand Prix Editor" label_location="hover"/>
<icon-button id="about" width="64" height="64" icon="gui/main_about.png" extend_label="50"

View File

@ -8,13 +8,6 @@
<spacer height="25" width="10"/>
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_achievements" width="128" height="128" icon="gui/options_players.png"
I18N="Section in the profile screen" text="Achievements"/>
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png"/>
<icon-button id="tab_settings" width="128" height="128" icon="gui/main_options.png"/>
</tabs>
<box proportion="1" width="100%" layout="vertical-row" padding="6">
<list id="achievements_list" x="0" y="0" width="100%" height="100%"/>
</box>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<icon-button id="back" x="0" y="0" height="8%" icon="gui/back.png"/>
<div x="1%" y="1%" width="98%" height="98%" layout="vertical-row" >
<header id="title" text_align="center" width="80%" align="center" text="..."/>
<spacer height="25" width="10"/>
<tabs id="profile_tabs" height="10%" max_height="110" x="2%" width="98%" align="center">
<icon-button id="tab_achievements" width="128" height="128" icon="gui/options_players.png"
I18N="Section in the profile screen" text="Achievements"/>
<icon-button id="tab_friends" width="128" height="128" icon="gui/options_players.png"/>
<icon-button id="tab_settings" width="128" height="128" icon="gui/main_options.png"/>
</tabs>
<box proportion="1" width="100%" layout="vertical-row" padding="6">
<list id="achievements_list" x="0" y="0" width="100%" height="100%"/>
</box>
</div>
</stkgui>

View File

@ -10,8 +10,7 @@
<box width="95%" height="40%" padding="10" layout="horizontal-row">
<!-- Left pane -->
<div proportion="1" height="100%" layout="vertical-row">
<placeholder proportion="1" width="100%" height="100%" id="screenshot_div">
</placeholder>
<icon-button proportion="1" width="100%" height="100%" id="screenshot" custom_ratio="1.33333"/>
</div>
<!-- Right pane -->
<div proportion="1" height="100%" layout="vertical-row">

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ varying vec2 uv_bis;
#define FragColor gl_FragColor
#endif
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main(void)
{
@ -31,5 +31,5 @@ void main(void)
vec4 detail = texture(Detail, uv_bis);
color *= detail;
float specmap = texture(SpecMap, uv).g;
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.);
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap, 0.), 1.);
}

View File

@ -14,7 +14,7 @@ in vec3 nor;
in vec2 uv;
out vec4 FragColor;
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main(void)
{
@ -42,6 +42,6 @@ void main(void)
float scattering = mix(fPowEdotL, fLdotNBack, .5);
float specmap = texture(SpecMap, uv).g;
vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap);
vec3 LightFactor = color.xyz * (scattering * 0.3) + getLightFactor(color.xyz, vec3(1.), specmap, 0.);
FragColor = vec4(color.xyz * LightFactor, 1.);
}

View File

@ -13,7 +13,7 @@ in vec2 uv;
in vec2 uv_bis;
out vec4 FragColor;
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main(void)
{
@ -30,5 +30,5 @@ void main(void)
float specmap = texture(SpecMap, uv).g;
#endif
color *= detail;
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap), 1.);
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap, 0.), 1.);
}

View File

@ -16,7 +16,7 @@ in vec3 nor;
in vec2 uv;
out vec4 FragColor;
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main(void)
{
@ -48,6 +48,6 @@ void main(void)
float scattering = mix(fPowEdotL, fLdotNBack, .5);
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap);
vec3 LightFactor = color.xyz * (scattering * 0.1) + getLightFactor(color.xyz, vec3(1.), specmap, 0.);
FragColor = vec4(LightFactor, 1.);
}

View File

@ -11,20 +11,23 @@ in vec2 uv;
in vec4 color;
out vec4 FragColor;
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main(void)
{
#ifdef GL_ARB_bindless_texture
vec4 col = texture(handle, uv);
float specmap = texture(secondhandle, uv).g;
float emitmap = texture(secondhandle, uv).b;
#ifdef SRGBBindlessFix
col.xyz = pow(col.xyz, vec3(2.2));
#endif
#else
vec4 col = texture(Albedo, uv);
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap) , 1.);
}

View File

@ -12,7 +12,7 @@ out vec4 FragColor;
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main() {
vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
@ -30,5 +30,5 @@ void main() {
vec4 detail0 = texture(tex, r.xy / m + .5);
#endif
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.);
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
}

View File

@ -11,7 +11,7 @@ in vec2 uv;
in vec4 color;
out vec4 FragColor;
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main(void)
{
@ -27,5 +27,5 @@ void main(void)
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a * color.a < 0.5) discard;
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, 0.), 1.);
}

View File

@ -10,7 +10,7 @@ in vec2 uv;
in vec4 color;
out vec4 FragColor;
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main(void)
{
@ -24,5 +24,5 @@ void main(void)
#endif
col.xyz *= pow(color.xyz, vec3(2.2));
float specmap = texture(SpecMap, uv).g;
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, 0.), 1.);
}

View File

@ -15,7 +15,7 @@ varying vec3 nor;
#endif
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main() {
vec3 texc = gl_FragCoord.xyz / vec3(screen, 1.);
@ -31,5 +31,5 @@ void main() {
#endif
#endif
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0.), 1.);
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
}

View File

@ -10,7 +10,7 @@ in vec2 uv;
in vec4 color;
out vec4 FragColor;
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main(void)
{
@ -23,5 +23,5 @@ void main(void)
col.xyz *= pow(color.xyz, vec3(2.2));
if (col.a * color.a < 0.5) discard;
float specmap = texture(SpecMap, uv).g;
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap), 1.);
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, 0.), 1.);
}

View File

@ -22,7 +22,7 @@ varying vec2 uv_bis;
#define FragColor gl_FragColor
#endif
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue);
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
void main() {
// Splatting part
@ -46,5 +46,5 @@ void main() {
splatting.b * detail2 +
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 0.), 1.);
FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 0., 0.), 1.);
}

View File

@ -8,12 +8,13 @@ uniform sampler2D SpecularMap;
uniform sampler2D SSAO;
#endif
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue)
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue)
{
vec2 tc = gl_FragCoord.xy / screen;
vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz;
vec3 SpecularComponent = texture(SpecularMap, tc).xyz;
float ao = texture(SSAO, tc).x;
vec3 tmp = diffuseMatColor * DiffuseComponent * (1. - specMapValue) + specularMatColor * SpecularComponent * specMapValue;
return tmp * ao;
}
vec3 emitCol = diffuseMatColor.xyz * diffuseMatColor.xyz * diffuseMatColor.xyz * 15.;
return tmp * ao + (emitMapValue * emitCol);
}

View File

@ -209,7 +209,8 @@ void SFXManager::queue(SFXCommands command, SFXBase *sfx, const Vec3 &p)
void SFXManager::queueCommand(SFXCommand *command)
{
m_sfx_commands.lock();
if(m_sfx_commands.getData().size() > 20*race_manager->getNumberOfKarts()+20)
if(m_sfx_commands.getData().size() > 20*race_manager->getNumberOfKarts()+20 &&
race_manager->getMinorMode() != RaceManager::MINOR_MODE_CUTSCENE)
{
if(command->m_command==SFX_POSITION || command->m_command==SFX_LOOP ||
command->m_command==SFX_PLAY || command->m_command==SFX_SPEED )

View File

@ -736,13 +736,15 @@ void Camera::handleEndCamera(float dt)
/** Sets viewport etc. for this camera. Called from irr_driver just before
* rendering the view for this kart.
*/
void Camera::activate()
void Camera::activate(bool alsoActivateInIrrlicht)
{
s_active_camera = this;
irr::scene::ISceneManager *sm = irr_driver->getSceneManager();
sm->setActiveCamera(m_camera);
irr_driver->getVideoDriver()->setViewPort(m_viewport);
if (alsoActivateInIrrlicht)
{
irr::scene::ISceneManager *sm = irr_driver->getSceneManager();
sm->setActiveCamera(m_camera);
irr_driver->getVideoDriver()->setViewPort(m_viewport);
}
} // activate
// ----------------------------------------------------------------------------

View File

@ -257,7 +257,7 @@ public:
int getIndex() const {return m_index;}
void reset ();
void setInitialTransform();
void activate();
void activate(bool alsoActivateInIrrlicht=true);
void update (float dt);
void setKart (AbstractKart *new_kart);

View File

@ -128,10 +128,29 @@ void generateLifetimeSizeDirection(scene::IParticleEmitter *emitter, float &life
void ParticleSystemProxy::generateParticlesFromPointEmitter(scene::IParticlePointEmitter *emitter)
{
ParticleParams = (ParticleData *) realloc(ParticleParams, sizeof(ParticleData) * count);
InitialValues = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
ParticleData* ParticleParamsTmp = (ParticleData *) realloc(ParticleParams, sizeof(ParticleData) * m_count);
ParticleData* InitialValuesTmp = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* m_count);
for (unsigned i = 0; i < count; i++)
if (ParticleParamsTmp != NULL) // In case memory allocation succeeded
{
ParticleParams = ParticleParamsTmp;
}
else
{
Log::error("GPUParticles", "Not enough memory for %d from point particles.", m_count);
m_count = m_previous_count;
}
if (InitialValuesTmp != NULL)
{
InitialValues = InitialValuesTmp;
}
else
{
Log::fatal("GPUParticles", "Not enough memory for %d from point particles.", m_count);
m_count = m_previous_count;
}
for (unsigned i = 0; i < m_count; i++)
{
ParticleParams[i].PositionX = 0;
ParticleParams[i].PositionY = 0;
@ -150,12 +169,31 @@ void ParticleSystemProxy::generateParticlesFromPointEmitter(scene::IParticlePoin
void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *emitter)
{
ParticleParams = (ParticleData *)realloc(ParticleParams, sizeof(ParticleData)* count);
InitialValues = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
ParticleData* ParticleParamsTmp = (ParticleData *) realloc(ParticleParams, sizeof(ParticleData) * m_count);
ParticleData* InitialValuesTmp = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* m_count);
if (ParticleParamsTmp != NULL) // In case memory allocation succeeded
{
ParticleParams = ParticleParamsTmp;
}
else
{
Log::error("GPUParticles", "Not enough memory for %d from box particles.", m_count);
m_count = m_previous_count;
}
if (InitialValuesTmp != NULL)
{
InitialValues = InitialValuesTmp;
}
else
{
Log::error("GPUParticles", "Not enough memory for %d from box particles.", m_count);
m_count = m_previous_count;
}
const core::vector3df& extent = emitter->getBox().getExtent();
for (unsigned i = 0; i < count; i++)
for (unsigned i = 0; i < m_count; i++)
{
ParticleParams[i].PositionX = emitter->getBox().MinEdge.X + os::Randomizer::frand() * extent.X;
ParticleParams[i].PositionY = emitter->getBox().MinEdge.Y + os::Randomizer::frand() * extent.Y;
@ -177,10 +215,15 @@ void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmi
void ParticleSystemProxy::generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *emitter)
{
ParticleParams = (ParticleData *)realloc(ParticleParams, sizeof(ParticleData)* count);
InitialValues = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
ParticleData* ParticleParamsTmp = (ParticleData *) realloc(ParticleParams, sizeof(ParticleData) * m_count);
ParticleData* InitialValuesTmp = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* m_count);
for (unsigned i = 0; i < count; i++) {
if(ParticleParamsTmp != NULL) // In case memory allocation succeeded
ParticleParams = ParticleParamsTmp;
if(InitialValuesTmp != NULL)
InitialValues = InitialValuesTmp;
for (unsigned i = 0; i < m_count; i++) {
// Random distance from center
const f32 distance = os::Randomizer::frand() * emitter->getRadius();
@ -227,7 +270,8 @@ void ParticleSystemProxy::setEmitter(scene::IParticleEmitter* emitter)
flip = false;
m_first_execution = true;
count = emitter->getMaxParticlesPerSecond() * emitter->getMaxLifeTime() / 1000;
m_previous_count = m_count; // save to handle out of memory errors
m_count = emitter->getMaxParticlesPerSecond() * emitter->getMaxLifeTime() / 1000;
switch (emitter->getType())
{
case scene::EPET_POINT:
@ -340,7 +384,7 @@ void ParticleSystemProxy::simulate()
glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, tfb_buffers[1]);
glBeginTransformFeedback(GL_POINTS);
glDrawArrays(GL_POINTS, 0, count);
glDrawArrays(GL_POINTS, 0, m_count);
glEndTransformFeedback();
glBindVertexArray(0);
@ -359,7 +403,7 @@ void ParticleSystemProxy::drawFlip()
ParticleShader::FlipParticleRender::getInstance()->setUniforms();
glBindVertexArray(current_rendering_vao);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, m_count);
}
void ParticleSystemProxy::drawNotFlip()
@ -377,7 +421,7 @@ void ParticleSystemProxy::drawNotFlip()
ParticleShader::SimpleParticleRender::getInstance()->setUniforms(ColorFrom, ColorTo);
glBindVertexArray(current_rendering_vao);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, m_count);
}
void ParticleSystemProxy::draw()
@ -393,12 +437,12 @@ void ParticleSystemProxy::generateVAOs()
glBindVertexArray(0);
glGenBuffers(1, &initial_values_buffer);
glBindBuffer(GL_ARRAY_BUFFER, initial_values_buffer);
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), ParticleParams, GL_STREAM_COPY);
glBufferData(GL_ARRAY_BUFFER, m_count * sizeof(ParticleData), ParticleParams, GL_STREAM_COPY);
glGenBuffers(2, tfb_buffers);
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[0]);
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), InitialValues, GL_STREAM_COPY);
glBufferData(GL_ARRAY_BUFFER, m_count * sizeof(ParticleData), InitialValues, GL_STREAM_COPY);
glBindBuffer(GL_ARRAY_BUFFER, tfb_buffers[1]);
glBufferData(GL_ARRAY_BUFFER, count * sizeof(ParticleData), 0, GL_STREAM_COPY);
glBufferData(GL_ARRAY_BUFFER, m_count * sizeof(ParticleData), 0, GL_STREAM_COPY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenVertexArrays(1, &current_rendering_vao);
@ -415,8 +459,8 @@ void ParticleSystemProxy::generateVAOs()
glBindVertexArray(0);
if (flip)
{
float *quaternions = new float[4 * count];
for (unsigned i = 0; i < count; i++)
float *quaternions = new float[4 * m_count];
for (unsigned i = 0; i < m_count; i++)
{
core::vector3df rotationdir(0., 1., 0.);
@ -427,7 +471,7 @@ void ParticleSystemProxy::generateVAOs()
}
glGenBuffers(1, &quaternionsbuffer);
glBindBuffer(GL_ARRAY_BUFFER, quaternionsbuffer);
glBufferData(GL_ARRAY_BUFFER, 4 * count * sizeof(float), quaternions, GL_STREAM_COPY);
glBufferData(GL_ARRAY_BUFFER, 4 * m_count * sizeof(float), quaternions, GL_STREAM_COPY);
delete[] quaternions;
}
@ -454,4 +498,4 @@ void ParticleSystemProxy::render() {
m_first_execution = false;
simulate();
draw();
}
}

View File

@ -21,7 +21,12 @@ protected:
bool m_randomize_initial_y;
GLuint texture;
unsigned count;
/** Current count of particles. */
unsigned m_count;
/** Previous count - for error handling only. */
unsigned m_previous_count;
static void CommonRenderingVAO(GLuint PositionBuffer);
static void AppendQuaternionRenderingVAO(GLuint QuaternionBuffer);
static void CommonSimulationVAO(GLuint position_vbo, GLuint initialValues_vbo);

View File

@ -75,7 +75,6 @@ int LODNode::getLevel()
if(m_forced_lod>-1)
return m_forced_lod;
scene::ICameraSceneNode* curr_cam = irr_driver->getSceneManager()->getActiveCamera();
Camera* camera = Camera::getActiveCamera();
if (camera == NULL)
return (int)m_detail.size() - 1;

View File

@ -408,7 +408,7 @@ void PostProcessing::renderHorizontalBlur(FrameBuffer &in_fbo, FrameBuffer &auxi
in_fbo.Bind();
FullScreenShader::Gaussian6HBlurShader::getInstance()->SetTextureUnits(auxiliary.getRTT()[0]);
DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(inv_width, inv_height), 2.0);
DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(inv_width, inv_height), 2.0f);
}
}
@ -519,11 +519,7 @@ void PostProcessing::renderFog()
const Track * const track = World::getWorld()->getTrack();
// This function is only called once per frame - thus no need for setters.
const float fogmax = track->getFogMax();
const float startH = track->getFogStartHeight();
const float endH = track->getFogEndHeight();
const float start = track->getFogStart();
const float end = track->getFogEnd();
const SColor tmpcol = track->getFogColor();
core::vector3df col( tmpcol.getRed() / 255.0f,

View File

@ -166,8 +166,7 @@ void IrrDriver::renderGLSL(float dt)
oss << "drawAll() for kart " << cam;
PROFILER_PUSH_CPU_MARKER(oss.str().c_str(), (cam+1)*60,
0x00, 0x00);
if (!UserConfigParams::m_dynamic_lights)
camera->activate();
camera->activate(!UserConfigParams::m_dynamic_lights);
rg->preRenderCallback(camera); // adjusts start referee
m_scene_manager->setActiveCamera(camnode);

View File

@ -692,7 +692,6 @@ static void renderInstancedMeshNormals()
glBindVertexArray(VAOManager::getInstance()->getInstanceVAO(T::VertexType, T::Instance));
for (unsigned i = 0; i < meshes.size(); i++)
{
GLMesh *mesh = meshes[i];
MeshShader::NormalVisualizer::getInstance()->setUniforms(video::SColor(255, 0, 255, 0));
glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)((SolidPassCmd::getInstance()->Offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
}

View File

@ -201,7 +201,6 @@ void IrrDriver::renderLightsScatter(unsigned pointlightcount)
const Track * const track = World::getWorld()->getTrack();
const float start = track->getFogStart();
const video::SColor tmpcol = track->getFogColor();
core::vector3df col(1., 1., 1.);
glUseProgram(LightShader::PointLightScatterShader::getInstance()->Program);
@ -223,4 +222,4 @@ void IrrDriver::renderLightsScatter(unsigned pointlightcount)
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
getFBO(FBO_COLORS).Bind();
m_post_processing->renderPassThrough(getRenderTargetTexture(RTT_HALF1));
}
}

View File

@ -19,9 +19,10 @@
#include "graphics/slip_stream.hpp"
#include "config/user_config.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/material.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "io/file_manager.hpp"
#include "karts/controller/controller.hpp"
#include "karts/abstract_kart.hpp"
@ -100,7 +101,13 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
{
vertices[i].Pos = p[i].toIrrVector();
vertices[i].Color = red;
vertices[i].TCoords = core::vector2df(0, 0);
}
video::SMaterial &mat = buffer->getMaterial();
// Meshes need a texture, otherwise stk crashes.
video::ITexture *red_texture = getUnicolorTexture(red);
mat.setTexture(0, red_texture);
buffer->recalculateBoundingBox();
m_mesh->setBoundingBox(buffer->getBoundingBox());
m_debug_node = irr_driver->addMesh(m_debug_mesh, "splistream_debug", m_kart->getNode());
@ -340,6 +347,8 @@ void SlipStream::updateSlipstreamPower()
void SlipStream::setDebugColor(const video::SColor &color)
{
if(!UserConfigParams::m_slipstream_debug) return;
// FIXME: Does not work anymore - the colour is changed, but
// visually there is no change.
scene::IMeshBuffer *buffer = m_debug_mesh->getMeshBuffer(0);
irr::video::S3DVertex* vertices =
(video::S3DVertex*)buffer->getVertices();

View File

@ -208,9 +208,6 @@ void STKAnimatedMesh::updateGL()
void STKAnimatedMesh::render()
{
bool isTransparentPass =
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
++PassCount;
updateNoGL();

View File

@ -205,6 +205,7 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = core::stringc(prop_name).
READ_PROPERTY(y, PROP_Y);
READ_PROPERTY(layout, PROP_LAYOUT);
READ_PROPERTY(align, PROP_ALIGN);
READ_PROPERTY(custom_ratio, PROP_CUSTOM_RATIO);
READ_PROPERTY(icon, PROP_ICON);
READ_PROPERTY(focus_icon, PROP_FOCUS_ICON);

View File

@ -109,6 +109,7 @@ namespace GUIEngine
PROP_WRAP_AROUND,
PROP_DIV_PADDING,
PROP_KEEP_SELECTION,
PROP_CUSTOM_RATIO,
};
bool isWithinATextBox();

View File

@ -44,6 +44,7 @@ IconButtonWidget::IconButtonWidget(ScaleMode scale_mode, const bool tab_stop,
m_texture = NULL;
m_deactivated_texture = NULL;
m_highlight_texture = NULL;
m_custom_aspect_ratio = 1.0f;
m_texture_w = 0;
@ -103,6 +104,12 @@ void IconButtonWidget::add()
// irrlicht widgets don't support scaling while keeping aspect ratio
// so, happily, let's implement it ourselves
float useAspectRatio = -1.0f;
if (m_properties[PROP_CUSTOM_RATIO] != "")
{
m_custom_aspect_ratio = atof(m_properties[PROP_CUSTOM_RATIO].c_str());
m_scale_mode = SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO;
}
if (m_scale_mode == SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO)
{

View File

@ -215,7 +215,7 @@ void InputManager::handleStaticAction(int key, int value)
Camera *active_cam = Camera::getActiveCamera();
active_cam->setAngularVelocity(value ?
UserConfigParams::m_fpscam_max_angular_velocity : 0);
UserConfigParams::m_fpscam_max_angular_velocity : 0.0f);
break;
}
case KEY_KEY_E:

View File

@ -164,7 +164,7 @@ void WiimoteManager::launchDetection(int timeout)
device_manager->getConfigForGamepad(WIIMOTE_START_IRR_ID, "Wiimote",
&gamepad_config);
int num_buttons = (int)( log((float)WIIMOTE_BUTTON_ALL) / log(2.0f))+1;
int num_buttons = (int)( log((float)WIIMOTE_BUTTON_ALL) / log((float)2.0f))+1;
gamepad_config->setNumberOfButtons(num_buttons);
gamepad_config->setNumberOfAxis(1);
@ -213,7 +213,7 @@ void WiimoteManager::launchDetection(int timeout)
*/
int getButton(int n)
{
return (int)(log((float)n)/log(2.0f));
return (int)(log((float)n)/log((float)2.0f));
} // getButton
// ----------------------------------------------------------------------------

View File

@ -1284,7 +1284,12 @@ bool FileManager::copyFile(const std::string &source, const std::string &dest)
const int BUFFER_SIZE=32768;
char *buffer = new char[BUFFER_SIZE];
if(!buffer) return false;
if(!buffer)
{
fclose(f_source);
fclose(f_dest);
return false;
}
size_t n;
while((n=fread(buffer, 1, BUFFER_SIZE, f_source))>0)
{

View File

@ -253,7 +253,7 @@ void History::Load()
Log::fatal("History", "Could not read history.dat.");
unsigned int num_karts;
if(sscanf(s, "numkarts: %d",&num_karts)!=1)
if(sscanf(s, "numkarts: %u", &num_karts)!=1)
Log::fatal("History", "No number of karts found in history file.");
race_manager->setNumKarts(num_karts);

View File

@ -100,7 +100,7 @@ void ReplayPlay::Load()
Log::fatal("Replay", "Could not read '%s'.", getReplayFilename().c_str());
unsigned int version;
if (sscanf(s,"Version: %d", &version) != 1)
if (sscanf(s,"Version: %u", &version) != 1)
Log::fatal("Replay", "No Version information found in replay file (bogus replay file).");
if (version != getReplayVersion())
@ -130,7 +130,7 @@ void ReplayPlay::Load()
unsigned int num_laps;
fgets(s, 1023, fd);
if(sscanf(s, "Laps: %d", &num_laps) != 1)
if(sscanf(s, "Laps: %u", &num_laps) != 1)
Log::fatal("Replay", "No number of laps found in replay file.");
race_manager->setNumLaps(num_laps);
@ -164,7 +164,7 @@ void ReplayPlay::readKartData(FILE *fd, char *next_line)
fgets(s, 1023, fd);
unsigned int size;
if(sscanf(s,"size: %d",&size)!=1)
if(sscanf(s,"size: %u",&size)!=1)
Log::fatal("Replay", "Number of records not found in replay file "
"for kart %d.",
m_ghost_karts.size()-1);
@ -198,7 +198,7 @@ void ReplayPlay::readKartData(FILE *fd, char *next_line)
} // for i
fgets(s, 1023, fd);
unsigned int num_events;
if(sscanf(s,"events: %d",&num_events)!=1)
if(sscanf(s,"events: %u",&num_events)!=1)
Log::warn("Replay", "Number of events not found in replay file "
"for kart %d.", m_ghost_karts.size()-1);

View File

@ -58,7 +58,6 @@ GPInfoScreen::GPInfoScreen() : Screen("gp_info.stkgui")
m_curr_time = 0.0f;
// Necessary to test if loadedFroMFile() was executed (in setGP)
m_reverse_spinner = NULL;
m_screenshot_widget = NULL;
m_max_num_tracks = 0;
} // GPInfoScreen
@ -84,6 +83,10 @@ void GPInfoScreen::loadedFromFile()
m_num_tracks_spinner->setValue(1);
m_ai_kart_spinner = getWidget<SpinnerWidget>("ai-spinner");
GUIEngine::IconButtonWidget* screenshot = getWidget<IconButtonWidget>("screenshot");
screenshot->setFocusable(false);
screenshot->m_tab_stop = false;
} // loadedFromFile
// ----------------------------------------------------------------------------
@ -266,34 +269,18 @@ void GPInfoScreen::addTracks()
*/
void GPInfoScreen::addScreenshot()
{
Widget* screenshot_div = getWidget("screenshot_div");
if(!m_screenshot_widget || !m_widgets.contains(m_screenshot_widget))
{
m_screenshot_widget = new IconButtonWidget(
IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
false, false, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
m_widgets.push_back(m_screenshot_widget);
}
// images are saved squared, but must be stretched to 4:3
m_screenshot_widget->setCustomAspectRatio(4.0f / 3.0f);
m_screenshot_widget->m_x = screenshot_div->m_x;
m_screenshot_widget->m_y = screenshot_div->m_y;
m_screenshot_widget->m_w = screenshot_div->m_w;
m_screenshot_widget->m_h = screenshot_div->m_h;
GUIEngine::IconButtonWidget* screenshot = getWidget<IconButtonWidget>("screenshot");
// Temporary icon, will replace it just after
// (but it will be shown if the given icon is not found)
m_screenshot_widget->m_properties[PROP_ICON] = "gui/main_help.png";
m_screenshot_widget->add();
screenshot->m_properties[PROP_ICON] = "gui/main_help.png";
const Track *track = track_manager->getTrack(m_gp.getTrackId(0));
video::ITexture* screenshot = irr_driver->getTexture(track->getScreenshotFile(),
video::ITexture* image = irr_driver->getTexture(track->getScreenshotFile(),
"While loading screenshot for track '%s':",
track->getFilename() );
if (screenshot != NULL)
m_screenshot_widget->setImage(screenshot);
if (image != NULL)
screenshot->setImage(image);
} // addScreenShot
// ----------------------------------------------------------------------------
@ -378,8 +365,9 @@ void GPInfoScreen::onUpdate(float dt)
Track* track = track_manager->getTrack(tracks[frame_after]);
std::string file = track->getScreenshotFile();
m_screenshot_widget->setImage(file, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
m_screenshot_widget->m_properties[PROP_ICON] = file;
GUIEngine::IconButtonWidget* screenshot = getWidget<IconButtonWidget>("screenshot");
screenshot->setImage(file, IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
screenshot->m_properties[PROP_ICON] = file;
} // onUpdate
/** Get number of available tracks for random GPs

View File

@ -61,7 +61,6 @@ private:
int getMaxNumTracks(std::string group);
protected: // Necessary for RandomGPInfoScreen
GUIEngine::IconButtonWidget* m_screenshot_widget;
float m_curr_time;
/** The grand prix data. */

View File

@ -108,25 +108,25 @@ void FocusDispatcher::add()
m_element->setTabOrder(m_id);
}
EventPropagation FocusDispatcher::focused(const int playerID)
EventPropagation FocusDispatcher::focused(const int player_id)
{
if (!m_is_initialised) return EVENT_LET;
if(UserConfigParams::logGUI())
Log::info("[KartSelectionScreen]", "FocusDispatcher focused by player %u",
playerID);
player_id);
// since this screen is multiplayer, redirect focus to the right widget
const int amount = m_parent->m_kart_widgets.size();
for (int n=0; n<amount; n++)
{
if (m_parent->m_kart_widgets[n].getPlayerID() == playerID)
if (m_parent->m_kart_widgets[n].getPlayerID() == player_id)
{
// If player is done, don't do anything with focus
if (m_parent->m_kart_widgets[n].isReady())
return GUIEngine::EVENT_BLOCK;
//std::cout << "--> Redirecting focus for player " << playerID
//std::cout << "--> Redirecting focus for player " << player_id
// << " from FocusDispatcher " <<
// " (ID " << m_element->getID() <<
// ") to spinner " << n << " (ID " <<
@ -135,7 +135,7 @@ EventPropagation FocusDispatcher::focused(const int playerID)
// ")" << std::endl;
m_parent->m_kart_widgets[n].m_player_ident_spinner
->setFocusForPlayer(playerID);
->setFocusForPlayer(player_id);
return GUIEngine::EVENT_BLOCK;
@ -143,7 +143,7 @@ EventPropagation FocusDispatcher::focused(const int playerID)
}
//Log::fatal("KartSelectionScreen", "The focus dispatcher can't"
// "find the widget for player %d!", playerID);
// "find the widget for player %d!", player_id);
return GUIEngine::EVENT_LET;
} // focused
@ -172,39 +172,39 @@ KartHoverListener::~KartHoverListener()
void KartHoverListener::onSelectionChanged(DynamicRibbonWidget* theWidget,
const std::string& selectionID,
const irr::core::stringw& selectionText,
const int playerID)
const int player_id)
{
assert(m_magic_number == 0xCAFEC001);
// Check if this player has a kart
if (m_parent->m_kart_widgets.size() <= ((unsigned int) playerID))
if (m_parent->m_kart_widgets.size() <= unsigned(player_id))
{
GUIEngine::focusNothingForPlayer(playerID);
GUIEngine::focusNothingForPlayer(player_id);
return;
}
// Don't allow changing the selection after confirming it
if (m_parent->m_kart_widgets[playerID].isReady())
if (m_parent->m_kart_widgets[player_id].isReady())
{
// discard events sent when putting back to the right kart
if (selectionID ==
m_parent->m_kart_widgets[playerID].m_kartInternalName) return;
m_parent->m_kart_widgets[player_id].m_kartInternalName) return;
DynamicRibbonWidget* w =
m_parent->getWidget<DynamicRibbonWidget>("karts");
assert(w != NULL);
w->setSelection(m_parent->m_kart_widgets[playerID]
.m_kartInternalName, playerID, true);
w->setSelection(m_parent->m_kart_widgets[player_id]
.m_kartInternalName, player_id, true);
return;
}
if (m_parent->m_kart_widgets[playerID].getKartInternalName() == selectionID)
if (m_parent->m_kart_widgets[player_id].getKartInternalName() == selectionID)
return; // already selected
m_parent->updateKartWidgetModel(playerID, selectionID, selectionText);
m_parent->m_kart_widgets[playerID].setKartInternalName(selectionID);
m_parent->updateKartStats(playerID, selectionID);
m_parent->updateKartWidgetModel(player_id, selectionID, selectionText);
m_parent->m_kart_widgets[player_id].setKartInternalName(selectionID);
m_parent->updateKartStats(player_id, selectionID);
m_parent->validateKartChoices();
} // onSelectionChanged
@ -554,7 +554,7 @@ bool KartSelectionScreen::joinPlayer(InputDevice* device)
bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
{
int playerID = -1;
int player_id = -1;
DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts");
if (w == NULL)
@ -588,7 +588,7 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
return true;
}
playerID = n;
player_id = n;
}
else
{
@ -596,21 +596,21 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
m_kart_widgets[n].getKartInternalName();
}
}
if (playerID == -1)
if (player_id == -1)
{
Log::warn("KartSelectionScreen", "playerQuit cannot find "
"passed player");
return false;
}
if(UserConfigParams::logGUI())
Log::info("KartSelectionScreen", "playerQuit(%d)", playerID);
Log::info("KartSelectionScreen", "playerQuit(%d)", player_id);
// Just a cheap way to check if there is any discrepancy
// between m_kart_widgets and the active player array
assert( m_kart_widgets.size() == StateManager::get()->activePlayerCount());
// unset selection of this player
GUIEngine::focusNothingForPlayer(playerID);
GUIEngine::focusNothingForPlayer(player_id);
// delete a previous removed widget that didn't have time to fully shrink
// yet.
@ -624,10 +624,10 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
// keep the removed kart a while, for the 'disappear' animation
// to take place
m_removed_widget = m_kart_widgets.remove(playerID);
m_removed_widget = m_kart_widgets.remove(player_id);
// Tell the StateManager to remove this player
StateManager::get()->removeActivePlayer(playerID);
StateManager::get()->removeActivePlayer(player_id);
addMultiplayerMessage();
@ -706,23 +706,23 @@ void KartSelectionScreen::onUpdate(float delta)
// ----------------------------------------------------------------------------
void KartSelectionScreen::playerConfirm(const int playerID)
void KartSelectionScreen::playerConfirm(const int player_id)
{
DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts");
assert(w != NULL);
const std::string selection = w->getSelectionIDString(playerID);
const std::string selection = w->getSelectionIDString(player_id);
if (StringUtils::startsWith(selection, ID_LOCKED))
{
unlock_manager->playLockSound();
return;
}
if (playerID == PLAYER_ID_GAME_MASTER)
if (player_id == PLAYER_ID_GAME_MASTER)
{
UserConfigParams::m_default_kart = selection;
}
if (m_kart_widgets[playerID].getKartInternalName().size() == 0)
if (m_kart_widgets[player_id].getKartInternalName().size() == 0)
{
SFXManager::get()->quickSound( "anvil" );
return;
@ -738,16 +738,16 @@ void KartSelectionScreen::playerConfirm(const int playerID)
// make sure no other player selected the same identity or kart
for (int n=0; n<amount; n++)
{
if (n == playerID) continue; // don't check a kart against itself
if (n == player_id) continue; // don't check a kart against itself
const bool player_ready = m_kart_widgets[n].isReady();
const bool ident_conflict =
!m_kart_widgets[n].getAssociatedPlayer()->getProfile()
->isGuestAccount() &&
m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
m_kart_widgets[playerID].getAssociatedPlayer()->getProfile();
m_kart_widgets[player_id].getAssociatedPlayer()->getProfile();
const bool kart_conflict = sameKart(m_kart_widgets[n],
m_kart_widgets[playerID]);
m_kart_widgets[player_id]);
if (player_ready && (ident_conflict || kart_conflict) &&
!will_need_duplicates)
@ -763,13 +763,13 @@ void KartSelectionScreen::playerConfirm(const int playerID)
// If two PlayerKart entries are associated to the same ActivePlayer,
// something went wrong
assert(m_kart_widgets[n].getAssociatedPlayer() !=
m_kart_widgets[playerID].getAssociatedPlayer());
m_kart_widgets[player_id].getAssociatedPlayer());
}
// Mark this player as ready to start
m_kart_widgets[playerID].markAsReady();
m_kart_widgets[player_id].markAsReady();
if (playerID == PLAYER_ID_GAME_MASTER)
if (player_id == PLAYER_ID_GAME_MASTER)
{
m_game_master_confirmed = true;
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
@ -959,7 +959,7 @@ void KartSelectionScreen::removeMultiplayerMessage()
*/
void KartSelectionScreen::eventCallback(Widget* widget,
const std::string& name,
const int playerID)
const int player_id)
{
// don't allow changing group after someone confirmed
if (name == "kartgroups" && !m_game_master_confirmed)
@ -1032,8 +1032,8 @@ void KartSelectionScreen::eventCallback(Widget* widget,
}
else if (name == "karts")
{
if (m_kart_widgets.size() > ((unsigned int) playerID))
playerConfirm(playerID);
if (m_kart_widgets.size() > unsigned(player_id))
playerConfirm(player_id);
}
else if (name == "back")
{
@ -1045,7 +1045,7 @@ void KartSelectionScreen::eventCallback(Widget* widget,
const int amount = m_kart_widgets.size();
for (int n=0; n<amount; n++)
{
m_kart_widgets[n].transmitEvent(widget, name, playerID);
m_kart_widgets[n].transmitEvent(widget, name, player_id);
}
// those events may mean that a player selection changed, so

View File

@ -89,6 +89,8 @@ void MainMenuScreen::loadedFromFile()
rw->removeChildNamed("test_gplose");
rw->removeChildNamed("test_unlocked");
rw->removeChildNamed("test_unlocked2");
rw->removeChildNamed("test_intro");
rw->removeChildNamed("test_outro");
#endif
} // loadedFromFile
@ -346,6 +348,37 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
scene->push();
}
}
else if (selection == "test_intro")
{
CutsceneWorld::setUseDuration(true);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("introcutscene", 999, false);
std::vector<std::string> parts;
parts.push_back("introcutscene");
parts.push_back("introcutscene2");
((CutsceneWorld*)World::getWorld())->setParts(parts);
//race_manager->startSingleRace("introcutscene2", 999, false);
return;
}
else if (selection == "test_outro")
{
CutsceneWorld::setUseDuration(true);
StateManager::get()->enterGameState();
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("endcutscene", 999, false);
std::vector<std::string> parts;
parts.push_back("endcutscene");
((CutsceneWorld*)World::getWorld())->setParts(parts);
}
else
#endif
if (selection == "new")
@ -463,7 +496,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
// For 0.8.2 disable the server menu, instead go to online profile
//OnlineScreen::getInstance()->push();
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
OnlineProfileAchievements::getInstance()->push();
TabOnlineProfileAchievements::getInstance()->push();
}
else
{
@ -489,6 +522,10 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
{
GrandPrixEditorScreen::getInstance()->push();
}
else if (selection == "achievements")
{
OnlineProfileAchievements::getInstance()->push();
}
} // eventCallback
// ----------------------------------------------------------------------------

View File

@ -40,21 +40,22 @@ using namespace irr::core;
using namespace irr::gui;
using namespace Online;
DEFINE_SCREEN_SINGLETON( OnlineProfileAchievements );
DEFINE_SCREEN_SINGLETON( OnlineProfileAchievements );
DEFINE_SCREEN_SINGLETON( TabOnlineProfileAchievements );
// -----------------------------------------------------------------------------
/** Constructor.
*/
OnlineProfileAchievements::OnlineProfileAchievements()
: OnlineProfileBase("online/profile_achievements.stkgui")
BaseOnlineProfileAchievements::BaseOnlineProfileAchievements(const std::string &name)
: OnlineProfileBase(name)
{
m_selected_achievement_index = -1;
} // OnlineProfileAchievements
} // BaseOnlineProfileAchievements
// -----------------------------------------------------------------------------
/** Callback when the xml file was loaded.
*/
void OnlineProfileAchievements::loadedFromFile()
void BaseOnlineProfileAchievements::loadedFromFile()
{
OnlineProfileBase::loadedFromFile();
m_achievements_list_widget = getWidget<ListWidget>("achievements_list");
@ -65,7 +66,7 @@ void OnlineProfileAchievements::loadedFromFile()
// ----------------------------------------------------------------------------
/** Callback before widgets are added. Clears all widgets.
*/
void OnlineProfileAchievements::beforeAddingWidget()
void BaseOnlineProfileAchievements::beforeAddingWidget()
{
OnlineProfileBase::beforeAddingWidget();
m_achievements_list_widget->clearColumns();
@ -82,11 +83,12 @@ void OnlineProfileAchievements::beforeAddingWidget()
// -----------------------------------------------------------------------------
/** Called when entering this menu (after widgets have been added).
*/
void OnlineProfileAchievements::init()
void BaseOnlineProfileAchievements::init()
{
OnlineProfileBase::init();
m_profile_tabs->select( m_achievements_tab->m_properties[PROP_ID],
PLAYER_ID_GAME_MASTER );
if (m_profile_tabs)
m_profile_tabs->select(m_achievements_tab->m_properties[PROP_ID],
PLAYER_ID_GAME_MASTER);
// For current user add the progrss information.
// m_visiting_profile is NULL if the user is not logged in.
@ -129,7 +131,7 @@ void OnlineProfileAchievements::init()
// -----------------------------------------------------------------------------
void OnlineProfileAchievements::eventCallback(Widget* widget,
void BaseOnlineProfileAchievements::eventCallback(Widget* widget,
const std::string& name,
const int playerID)
{
@ -155,7 +157,7 @@ void OnlineProfileAchievements::eventCallback(Widget* widget,
/** Called every frame. It will check if results from an achievement request
* have been received, and if so, display them.
*/
void OnlineProfileAchievements::onUpdate(float delta)
void BaseOnlineProfileAchievements::onUpdate(float delta)
{
if (!m_waiting_for_achievements) return;

View File

@ -35,18 +35,20 @@ namespace GUIEngine { class Widget; }
* \brief Online profiel overview screen
* \ingroup states_screens
*/
class OnlineProfileAchievements : public OnlineProfileBase, public GUIEngine::ScreenSingleton<OnlineProfileAchievements>
class BaseOnlineProfileAchievements : public OnlineProfileBase
{
private:
OnlineProfileAchievements();
GUIEngine::ListWidget * m_achievements_list_widget;
int m_selected_achievement_index;
bool m_waiting_for_achievements;
protected:
BaseOnlineProfileAchievements(const std::string &filename);
public:
friend class GUIEngine::ScreenSingleton<OnlineProfileAchievements>;
friend class GUIEngine::ScreenSingleton<BaseOnlineProfileAchievements>;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void loadedFromFile() OVERRIDE;
@ -61,7 +63,46 @@ public:
virtual void beforeAddingWidget() OVERRIDE;
virtual void refreshAchievementsList() { m_waiting_for_achievements = true; }
// ------------------------------------------------------------------------
virtual void refreshAchievementsList()
{
m_waiting_for_achievements = true;
} // refreshAchievementsList
};
// ============================================================================
/**
* \brief Online profiel overview screen
* \ingroup states_screens
*/
class TabOnlineProfileAchievements : public BaseOnlineProfileAchievements,
public GUIEngine::ScreenSingleton<TabOnlineProfileAchievements>
{
protected:
friend class GUIEngine::ScreenSingleton<TabOnlineProfileAchievements>;
TabOnlineProfileAchievements()
: BaseOnlineProfileAchievements("online/profile_achievements_tab.stkgui")
{}
}; // TabOnlineProfileAchievements
// ============================================================================
/**
* \brief Online profiel overview screen
* \ingroup states_screens
*/
class OnlineProfileAchievements : public BaseOnlineProfileAchievements,
public GUIEngine::ScreenSingleton < OnlineProfileAchievements >
{
protected:
friend class GUIEngine::ScreenSingleton<OnlineProfileAchievements>;
OnlineProfileAchievements()
: BaseOnlineProfileAchievements("online/profile_achievements.stkgui")
{}
}; // class
#endif

View File

@ -38,7 +38,8 @@ using namespace irr::gui;
using namespace Online;
OnlineProfileBase::OnlineProfileBase(const char* filename) : Screen(filename)
OnlineProfileBase::OnlineProfileBase(const std::string &filename)
: Screen(filename.c_str())
{
} // OnlineProfileBase
@ -48,19 +49,19 @@ OnlineProfileBase::OnlineProfileBase(const char* filename) : Screen(filename)
void OnlineProfileBase::loadedFromFile()
{
m_profile_tabs = getWidget<RibbonWidget>("profile_tabs");
assert(m_profile_tabs != NULL);
m_header = getWidget<LabelWidget>("title");
assert(m_header != NULL);
m_friends_tab =
m_friends_tab = !m_profile_tabs ? NULL :
(IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_friends");
assert(m_friends_tab != NULL);
m_achievements_tab =
assert(m_profile_tabs == NULL || m_friends_tab != NULL);
m_achievements_tab = !m_profile_tabs ? NULL :
(IconButtonWidget*)m_profile_tabs->findWidgetNamed("tab_achievements");
assert(m_achievements_tab != NULL);
m_settings_tab =
assert(m_profile_tabs == NULL || m_achievements_tab != NULL);
m_settings_tab = !m_profile_tabs ? NULL :
(IconButtonWidget *) m_profile_tabs->findWidgetNamed("tab_settings");
assert(m_settings_tab != NULL);
assert(m_profile_tabs == NULL || m_settings_tab != NULL);
} // loadedFromFile
// -----------------------------------------------------------------------------
@ -70,17 +71,20 @@ void OnlineProfileBase::loadedFromFile()
void OnlineProfileBase::beforeAddingWidget()
{
m_visiting_profile = ProfileManager::get()->getVisitingProfile();
if (!m_visiting_profile || !m_visiting_profile->isCurrentUser())
m_settings_tab->setVisible(false);
else
m_settings_tab->setVisible(true);
// If not logged in, don't show profile or friends
if (!m_visiting_profile)
if (m_profile_tabs)
{
m_friends_tab->setVisible(false);
m_profile_tabs->setVisible(false);
}
if (!m_visiting_profile || !m_visiting_profile->isCurrentUser())
m_settings_tab->setVisible(false);
else
m_settings_tab->setVisible(true);
// If not logged in, don't show profile or friends
if (!m_visiting_profile)
{
m_friends_tab->setVisible(false);
m_profile_tabs->setVisible(false);
}
} // if m_profile_tabhs
} // beforeAddingWidget
// -----------------------------------------------------------------------------
@ -90,20 +94,26 @@ void OnlineProfileBase::init()
{
Screen::init();
m_friends_tab->setTooltip( _("Friends") );
m_achievements_tab->setTooltip( _("Achievements") );
m_settings_tab->setTooltip( _("Account Settings") );
// If no visiting_profile is defined, use the data of the current player.
if (!m_visiting_profile || m_visiting_profile->isCurrentUser())
m_header->setText(_("Your profile"), false);
else if (m_visiting_profile)
if (m_profile_tabs)
{
m_header->setText(m_visiting_profile->getUserName() + _("'s profile"), false);
}
else
Log::error("OnlineProfileBase", "No visting profile");
m_friends_tab->setTooltip(_("Friends"));
m_achievements_tab->setTooltip(_("Achievements"));
m_settings_tab->setTooltip(_("Account Settings"));
// If no visiting_profile is defined, use the data of the current player.
if (!m_visiting_profile || m_visiting_profile->isCurrentUser())
m_header->setText(_("Your profile"), false);
else if (m_visiting_profile)
{
m_header->setText(m_visiting_profile->getUserName() + _("'s profile"), false);
}
else
Log::error("OnlineProfileBase", "No visting profile");
}
else // no tabs, so must be local player achievements:
{
m_header->setText(_("Your profile"), false);
}
} // init
// -----------------------------------------------------------------------------
@ -115,7 +125,8 @@ bool OnlineProfileBase::onEscapePressed()
//return to your profile if it's another profile
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
StateManager::get()->replaceTopMostScreen(OnlineProfileAchievements::getInstance());
StateManager::get()->replaceTopMostScreen(
TabOnlineProfileAchievements::getInstance());
return false;
} // onEscapePressed
@ -125,7 +136,7 @@ bool OnlineProfileBase::onEscapePressed()
void OnlineProfileBase::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == m_profile_tabs->m_properties[PROP_ID])
if (m_profile_tabs && name == m_profile_tabs->m_properties[PROP_ID])
{
std::string selection =
((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);

View File

@ -37,7 +37,7 @@ namespace GUIEngine { class Widget; }
class OnlineProfileBase : public GUIEngine::Screen
{
protected:
OnlineProfileBase(const char* filename);
OnlineProfileBase(const std::string &filename);
/** Pointer to the various widgets on the screen. */
GUIEngine::LabelWidget * m_header;

View File

@ -59,7 +59,6 @@ DEFINE_SCREEN_SINGLETON( TrackInfoScreen );
TrackInfoScreen::TrackInfoScreen()
: Screen("track_info.stkgui")
{
m_screenshot = NULL;
} // TrackInfoScreen
// ----------------------------------------------------------------------------
@ -80,6 +79,10 @@ void TrackInfoScreen::loadedFromFile()
m_highscore_entries[0] = getWidget<LabelWidget>("highscore1");
m_highscore_entries[1] = getWidget<LabelWidget>("highscore2");
m_highscore_entries[2] = getWidget<LabelWidget>("highscore3");
GUIEngine::IconButtonWidget* screenshot = getWidget<IconButtonWidget>("screenshot");
screenshot->setFocusable(false);
screenshot->m_tab_stop = false;
} // loadedFromFile
// ----------------------------------------------------------------------------
@ -105,37 +108,24 @@ void TrackInfoScreen::init()
false );
// ---- Track screenshot
Widget* screenshot_div = getWidget("screenshot_div");
if(!m_screenshot || !m_widgets.contains(m_screenshot))
{
m_screenshot =
new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO,
false /* tab stop */, false /* focusable */);
m_screenshot->setCustomAspectRatio(4.0f / 3.0f);
GUIEngine::IconButtonWidget* screenshot = getWidget<IconButtonWidget>("screenshot");
m_screenshot->m_x = screenshot_div->m_x;
m_screenshot->m_y = screenshot_div->m_y;
m_screenshot->m_w = screenshot_div->m_w;
m_screenshot->m_h = screenshot_div->m_h;
m_screenshot->add();
m_widgets.push_back(m_screenshot);
}
// images are saved squared, but must be stretched to 4:
// temporary icon, will replace it just after (but it will be shown if the given icon is not found)
m_screenshot->m_properties[PROP_ICON] = "gui/main_help.png";
screenshot->m_properties[PROP_ICON] = "gui/main_help.png";
ITexture* screenshot = irr_driver->getTexture(m_track->getScreenshotFile(),
ITexture* image = irr_driver->getTexture(m_track->getScreenshotFile(),
"While loading screenshot for track '%s':",
m_track->getFilename() );
if(!screenshot)
if(!image)
{
screenshot = irr_driver->getTexture("main_help.png",
image = irr_driver->getTexture("main_help.png",
"While loading screenshot for track '%s':",
m_track->getFilename());
}
if (screenshot != NULL)
m_screenshot->setImage(screenshot);
if (image != NULL)
screenshot->setImage(image);
// Lap count m_lap_spinner
// -----------------------

View File

@ -52,9 +52,6 @@ class TrackInfoScreen : public GUIEngine::Screen,
/** Spinner for number of AI karts. */
GUIEngine::SpinnerWidget* m_ai_kart_spinner;
/** Screenshot widget. */
GUIEngine::IconButtonWidget *m_screenshot;
/** Check box for reverse mode. */
GUIEngine::CheckBoxWidget* m_reverse;