This commit is contained in:
Arthur-D 2014-10-26 14:10:31 +01:00
commit 4ed59d8a4d
46 changed files with 352 additions and 490 deletions

View File

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="0" y="0" width="100%" height="fit" layout="vertical-row">
<button id="user-id" width="20%" height="fit" align="right"/>
</div>
<div x="0" y="0" width="100%" height="100%" layout="vertical-row" >
<icon id="logo" align="center" proportion="5" width="100%" icon="gui/logo.png"/>

View File

@ -52,7 +52,7 @@ void main(void)
float specval = texture(ntex, uv).z;
// From http://graphics.cs.williams.edu/papers/EnvMipReport2013/
int texSize = textureSize(tex, 0).x;
float lodval = log2(texSize * sqrt(3)) - .5 * log2(specval + 1);
float lodval = clamp(log2(texSize * sqrt(3)) - .5 * log2(specval + 1), 0., 10.);
vec4 specular = textureLod(tex, sampleDirection, lodval);
Spec = max(specular, vec4(0.));
}

View File

@ -16,6 +16,8 @@
#include "COSOperator.h"
#include "dimension2d.h"
#include "IGUISpriteBank.h"
#include <mmsystem.h>
#include <regstr.h>
#include <winuser.h>
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
#ifdef _IRR_COMPILE_WITH_DIRECTINPUT_JOYSTICK_
@ -359,6 +361,63 @@ void pollJoysticks()
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
}
/** This function is ported from SDL and released under zlip:
* Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
*/
void setJoystickName(int index, const JOYCAPS &caps, SJoystickInfo *joystick)
{
// As a default use the name given in the joystick structure
// - though that is always the same name, independent of joystick :(
joystick->Name = caps.szPname;
core::stringc key = core::stringc(REGSTR_PATH_JOYCONFIG)+"\\"+caps.szRegKey
+ "\\"+REGSTR_KEY_JOYCURR;
HKEY hTopKey = HKEY_LOCAL_MACHINE;
HKEY hKey;
long regresult = RegOpenKeyExA(hTopKey, key.c_str(), 0, KEY_READ, &hKey);
if (regresult != ERROR_SUCCESS)
{
hTopKey = HKEY_CURRENT_USER;
regresult = RegOpenKeyExA(hTopKey, key.c_str(), 0, KEY_READ, &hKey);
}
if (regresult != ERROR_SUCCESS) return;
/* find the registry key name for the joystick's properties */
char regname[256];
DWORD regsize = sizeof(regname);
core::stringc regvalue = core::stringc("Joystick")+core::stringc(index+1)
+ REGSTR_VAL_JOYOEMNAME;
regresult = RegQueryValueExA(hKey, regvalue.c_str(), 0, 0,
(LPBYTE)regname, &regsize);
RegCloseKey(hKey);
if (regresult != ERROR_SUCCESS) return;
/* open that registry key */
core::stringc regkey = core::stringc(REGSTR_PATH_JOYOEM)+"\\"+regname;
regresult = RegOpenKeyExA(hTopKey, regkey.c_str(), 0, KEY_READ, &hKey);
if (regresult != ERROR_SUCCESS) return;
/* find the size for the OEM name text */
regsize = sizeof(regvalue);
regresult = RegQueryValueExA(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0,
NULL, &regsize);
if (regresult == ERROR_SUCCESS)
{
char *name;
/* allocate enough memory for the OEM name text ... */
name = new char[regsize];
if (name)
{
/* ... and read it from the registry */
regresult = RegQueryValueExA(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0,
(LPBYTE)name, &regsize );
joystick->Name = name;
} // if name
} // if SUCCESS
RegCloseKey(hKey);
}
bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
{
#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
@ -407,11 +466,10 @@ bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
{
activeJoystick.Index = joystick;
ActiveJoysticks.push_back(activeJoystick);
returnInfo.Joystick = (u8)joystick;
returnInfo.Axes = activeJoystick.Caps.wNumAxes;
returnInfo.Buttons = activeJoystick.Caps.wNumButtons;
returnInfo.Name = activeJoystick.Caps.szPname;
setJoystickName(joystick, activeJoystick.Caps, &returnInfo);
returnInfo.PovHat = ((activeJoystick.Caps.wCaps & JOYCAPS_HASPOV) == JOYCAPS_HASPOV)
? SJoystickInfo::POV_HAT_PRESENT : SJoystickInfo::POV_HAT_ABSENT;

View File

@ -1,5 +1,5 @@
# Modify this file to change the last-modified date when you add/remove a file.
# This will then trigger a new cmake run automatically.
# This will then trigger a new cmake run automatically.
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")

View File

@ -24,7 +24,6 @@
#include "guiengine/message_queue.hpp"
#include "io/utf_writer.hpp"
#include "config/player_manager.hpp"
#include "states_screens/dialogs/notification_dialog.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"

View File

@ -16,11 +16,16 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <assert.h>
#include "config/device_config.hpp"
#include "io/xml_node.hpp"
#include "utils/log.hpp"
#include <SKeyMap.h>
#include <assert.h>
using namespace irr;
//==== D E V I C E C O N F I G =================================================
@ -223,39 +228,51 @@ void DeviceConfig::serialize (std::ofstream& stream)
} // serialize
//------------------------------------------------------------------------------
bool DeviceConfig::deserializeAction(irr::io::IrrXMLReader* xml)
/** Reads a device configuration from input.xml.
* \param config The XML Node of the configuration.
* \return False if an error occurred.
*/
bool DeviceConfig::load(const XMLNode *config)
{
int binding_id = -1;
// Never hurts to check ;)
if (xml == NULL)
bool error = false;
for(unsigned int i=0; i<config->getNumNodes(); i++)
{
Log::error("DeviceConfig", "Null pointer (DeviceConfig::deserializeAction)");
return false;
}
// Read tags from XML
const char *name_string = xml->getAttributeValue("name");
// Try to determine action # for verbose action name
for (int i = 0; i < PA_COUNT; i++)
{
if (strcmp(name_string, KartActionStrings[i].c_str()) == 0)
const XMLNode *action = config->getNode(i);
if(action->getName()!="action")
{
binding_id = i;
break;
Log::warn("DeviceConfig", "Invalid configuration '%s' - ignored.");
continue;
}
std::string name;
action->get("name", &name);
int binding_id = -1;
for (int i = 0; i < PA_COUNT; i++)
{
if (name==KartActionStrings[i])
{
binding_id = i;
break;
}
}
if (binding_id == -1)
{
Log::warn("DeviceConfig",
"DeviceConfig::deserializeAction : action '%s' is unknown.",
name.c_str());
error=true;
}
}
if(binding_id==-1)
{
Log::warn("DeviceConfig", "DeviceConfig::deserializeAction : action '%s' is unknown.",
name_string);
return false;
}
return m_bindings[binding_id].deserialize(xml);
} // deserializeAction
if(!m_bindings[binding_id].load(action))
{
Log::error("Device manager",
"Ignoring an ill-formed keyboard action in input config.");
error=true;
}
} // for i in nodes
return !error;
} // load
// ---------------------------------------------------------------------------
// KeyboardConfig & GamepadConfig classes really should be in a separate cpp
// file but they are so small that we'll just leave them here for now.
@ -350,19 +367,13 @@ GamepadConfig::GamepadConfig ( const std::string &name,
//------------------------------------------------------------------------------
GamepadConfig::GamepadConfig(irr::io::IrrXMLReader* xml) : DeviceConfig( DEVICE_CONFIG_TYPE_GAMEPAD )
GamepadConfig::GamepadConfig(const XMLNode *config)
: DeviceConfig( DEVICE_CONFIG_TYPE_GAMEPAD )
{
const char* name_string = xml->getAttributeValue("name");
if(name_string == NULL)
if(!config->get("name", &m_name))
Log::error("DeviceConfig", "Unnamed joystick in config file.");
else
m_name = name_string;
const char* enabled_string = xml->getAttributeValue("enabled");
if (enabled_string != NULL)
m_enabled = (strcmp(enabled_string, "true") == 0);
else
m_enabled = true;
config->get("enabled", &m_enabled);
m_plugged = 0;
setDefaultBinds();

View File

@ -86,7 +86,7 @@ public:
irr::core::stringw getMappingIdString (const PlayerAction action) const;
void serialize (std::ofstream& stream);
bool deserializeAction (irr::io::IrrXMLReader* xml);
bool load(const XMLNode *config);
void setBinding (const PlayerAction action,
const Input::InputType type,
@ -172,7 +172,7 @@ public:
void serialize (std::ofstream& stream);
void setDefaultBinds ();
GamepadConfig (irr::io::IrrXMLReader* xml);
GamepadConfig (const XMLNode *config);
GamepadConfig (const std::string &name,
const int axis_count=0,
const int button_ount=0);

View File

@ -578,7 +578,8 @@ void IrrDriver::initDevice()
mb->getMaterial().setTexture(0, getUnicolorTexture(video::SColor(255, 255, 255, 255)));
mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
}
m_sun_interposer = new STKMeshSceneNode(sphere, m_scene_manager->getRootSceneNode(), NULL, -1);
m_sun_interposer = new STKMeshSceneNode(sphere, m_scene_manager->getRootSceneNode(), NULL, -1, "sun_interposer");
m_sun_interposer->grab();
m_sun_interposer->setParent(NULL);
m_sun_interposer->setScale(core::vector3df(20));
@ -1077,6 +1078,7 @@ scene::IParticleSystemSceneNode *IrrDriver::addParticleNode(bool default_emitter
* \param mesh The mesh to add.
*/
scene::IMeshSceneNode *IrrDriver::addMesh(scene::IMesh *mesh,
const std::string& debug_name,
scene::ISceneNode *parent)
{
if (!isGLSL())
@ -1085,7 +1087,7 @@ scene::IMeshSceneNode *IrrDriver::addMesh(scene::IMesh *mesh,
if (!parent)
parent = m_scene_manager->getRootSceneNode();
scene::IMeshSceneNode* node = new STKMeshSceneNode(mesh, parent, m_scene_manager, -1);
scene::IMeshSceneNode* node = new STKMeshSceneNode(mesh, parent, m_scene_manager, -1, debug_name);
node->drop();
return node;
@ -1261,21 +1263,25 @@ void IrrDriver::removeTexture(video::ITexture *t)
/** Adds an animated mesh to the scene.
* \param mesh The animated mesh to add.
*/
scene::IAnimatedMeshSceneNode *IrrDriver::addAnimatedMesh(scene::IAnimatedMesh *mesh, scene::ISceneNode* parent)
scene::IAnimatedMeshSceneNode *IrrDriver::addAnimatedMesh(scene::IAnimatedMesh *mesh,
const std::string& debug_name, scene::ISceneNode* parent)
{
if (!isGLSL())
{
return m_scene_manager->addAnimatedMeshSceneNode(mesh, parent, -1,
core::vector3df(0,0,0),
core::vector3df(0,0,0),
core::vector3df(1,1,1),
/*addIfMeshIsZero*/true);
core::vector3df(0, 0, 0),
core::vector3df(0, 0, 0),
core::vector3df(1, 1, 1),
/*addIfMeshIsZero*/true);
}
if (!parent)
parent = m_scene_manager->getRootSceneNode();
scene::IAnimatedMeshSceneNode* node =
new STKAnimatedMesh(mesh, parent, m_scene_manager, -1, core::vector3df(0,0,0), core::vector3df(0,0,0), core::vector3df(1,1,1));
node->drop();
return node;
if (!parent)
parent = m_scene_manager->getRootSceneNode();
scene::IAnimatedMeshSceneNode* node =
new STKAnimatedMesh(mesh, parent, m_scene_manager, -1, debug_name,
core::vector3df(0, 0, 0), core::vector3df(0, 0, 0), core::vector3df(1, 1, 1));
node->drop();
return node;
} // addAnimatedMesh
// ----------------------------------------------------------------------------

View File

@ -453,6 +453,7 @@ public:
scene::IMeshSceneNode*addSphere(float radius,
const video::SColor &color=video::SColor(128, 255, 255, 255));
scene::IMeshSceneNode*addMesh(scene::IMesh *mesh,
const std::string& debug_name,
scene::ISceneNode *parent=NULL);
PerCameraNode *addPerCameraNode(scene::ISceneNode* node,
scene::ICameraSceneNode* cam,
@ -473,7 +474,7 @@ public:
void removeMeshFromCache(scene::IMesh *mesh);
void removeTexture(video::ITexture *t);
scene::IAnimatedMeshSceneNode
*addAnimatedMesh(scene::IAnimatedMesh *mesh, scene::ISceneNode* parent=NULL);
*addAnimatedMesh(scene::IAnimatedMesh *mesh, const std::string& debug_name, scene::ISceneNode* parent = NULL);
scene::ICameraSceneNode
*addCameraSceneNode();
Camera *addCamera(unsigned int index, AbstractKart *kart);

View File

@ -139,7 +139,7 @@ Referee::Referee()
// mesh. ATM it doesn't make any difference, but if we ever should
// decide to use more than one referee model at startup we only
// have to change the textures once, and all models will be in synch.
m_scene_node = irr_driver->addAnimatedMesh(NULL);
m_scene_node = irr_driver->addAnimatedMesh(NULL, "referee");
m_scene_node->setReadOnlyMaterials(true);
m_scene_node->setMesh(m_st_referee_mesh);
m_scene_node->grab();
@ -175,7 +175,7 @@ Referee::Referee(const AbstractKart &kart)
// mesh. ATM it doesn't make any difference, but if we ever should
// decide to use more than one referee model at startup we only
// have to change the textures once, and all models will be in synch.
m_scene_node = irr_driver->addAnimatedMesh(NULL);
m_scene_node = irr_driver->addAnimatedMesh(NULL, "referee");
m_scene_node->setReadOnlyMaterials(true);
m_scene_node->setMesh(m_st_referee_mesh);
m_scene_node->grab();

View File

@ -50,7 +50,7 @@ Shadow::Shadow(video::ITexture *texture, scene::ISceneNode *node,
v[3].Normal = normal;
buffer->recalculateBoundingBox();
m_node = irr_driver->addMesh(m_mesh);
m_node = irr_driver->addMesh(m_mesh, "shadow");
#ifdef DEBUG
m_node->setName("shadow");
#endif

View File

@ -33,7 +33,7 @@ ShowCurve::ShowCurve(float width, float height,
{
m_color = color;
addEmptyMesh();
m_scene_node = irr_driver->addMesh(m_mesh);
m_scene_node = irr_driver->addMesh(m_mesh, "showcurve");
// After addMesh ref count is 1 (for the attachment to the
// scene). We keep a copy here, so increase the ref count.
m_scene_node->grab();

View File

@ -190,7 +190,7 @@ void SkidMarks::update(float dt, bool force_skid_marks,
new SkidMarkQuads(raycast_right-delta, raycast_right+delta,
m_material, m_avoid_z_fighting, custom_color);
new_mesh->addMeshBuffer(smq_right);
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh);
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh, "skidmark");
if (STKMeshSceneNode* stkm = dynamic_cast<STKMeshSceneNode*>(new_node))
stkm->setReloadEachFrame(true);
#ifdef DEBUG

View File

@ -55,7 +55,7 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
m.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
createMesh(m);
m_node = irr_driver->addMesh(m_mesh);
m_node = irr_driver->addMesh(m_mesh, "splistream");
m_mesh->drop();
#ifdef DEBUG
@ -101,7 +101,7 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
}
buffer->recalculateBoundingBox();
m_mesh->setBoundingBox(buffer->getBoundingBox());
m_debug_node = irr_driver->addMesh(m_debug_mesh, m_kart->getNode());
m_debug_node = irr_driver->addMesh(m_debug_mesh, "splistream_debug", m_kart->getNode());
m_debug_node->grab();
}
else

View File

@ -20,7 +20,7 @@ STKTextBillboard::STKTextBillboard(core::stringw text, gui::ScalableFont* font,
irr::scene::ISceneManager* mgr, irr::s32 id,
const irr::core::vector3df& position, const irr::core::vector3df& size) :
STKMeshSceneNode(new scene::SMesh(),
parent, irr_driver->getSceneManager(), -1,
parent, irr_driver->getSceneManager(), -1, "text_billboard",
position, core::vector3df(0.0f, 0.0f, 0.0f), size, false)
{
m_color_top = color_top;

View File

@ -15,7 +15,7 @@
using namespace irr;
STKAnimatedMesh::STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
irr::scene::ISceneManager* mgr, s32 id,
irr::scene::ISceneManager* mgr, s32 id, const std::string& debug_name,
const core::vector3df& position,
const core::vector3df& rotation,
const core::vector3df& scale) :
@ -23,6 +23,9 @@ const core::vector3df& scale) :
{
isGLInitialized = false;
isMaterialInitialized = false;
#ifdef DEBUG
m_debug_name = debug_name;
#endif
}
STKAnimatedMesh::~STKAnimatedMesh()
@ -77,7 +80,7 @@ void STKAnimatedMesh::updateNoGL()
for (u32 i = 0; i < m->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
GLmeshes.push_back(allocateMeshBuffer(mb));
GLmeshes.push_back(allocateMeshBuffer(mb, m_debug_name));
}
for (u32 i = 0; i < m->getMeshBufferCount(); ++i)

View File

@ -19,7 +19,7 @@ public:
virtual void updateNoGL();
virtual void updateGL();
STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
irr::scene::ISceneManager* mgr, irr::s32 id,
irr::scene::ISceneManager* mgr, irr::s32 id, const std::string& debug_name,
const irr::core::vector3df& position = irr::core::vector3df(0,0,0),
const irr::core::vector3df& rotation = irr::core::vector3df(0,0,0),
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f));

View File

@ -121,13 +121,17 @@ GLuint createVAO(GLuint vbo, GLuint idx, video::E_VERTEX_TYPE type)
return vao;
}
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb)
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb, const std::string& debug_name)
{
GLMesh result = {};
if (!mb)
return result;
result.mb = mb;
#ifdef DEBUG
result.debug_name = debug_name;
#endif
result.IndexCount = mb->getIndexCount();
switch (mb->getIndexType())
{

View File

@ -36,9 +36,12 @@ struct GLMesh {
video::E_VERTEX_TYPE VAOType;
uint64_t TextureHandles[6];
scene::IMeshBuffer *mb;
#ifdef DEBUG
std::string debug_name;
#endif
};
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb);
GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb, const std::string& debug_name);
void fillLocalBuffer(GLMesh &, scene::IMeshBuffer* mb);
video::E_VERTEX_TYPE getVTXTYPEFromStride(size_t stride);
GLuint createVAO(GLuint vbo, GLuint idx, video::E_VERTEX_TYPE type);
@ -54,6 +57,8 @@ protected:
bool m_culledForPlayerCam;
bool m_culledForShadowCam[4];
bool m_culledForRSMCam;
std::string m_debug_name;
public:
PtrVector<GLMesh, REF> MeshSolidMaterial[Material::SHADERTYPE_COUNT];
PtrVector<GLMesh, REF> TransparentMesh[TM_COUNT];

View File

@ -14,7 +14,8 @@
#include "utils/tuple.hpp"
#include "utils/cpp2011.hpp"
STKMeshSceneNode::STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
STKMeshSceneNode::STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr,
irr::s32 id, const std::string& debug_name,
const irr::core::vector3df& position,
const irr::core::vector3df& rotation,
const irr::core::vector3df& scale, bool createGLMeshes) :
@ -25,6 +26,8 @@ STKMeshSceneNode::STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent,
update_each_frame = false;
isGlow = false;
m_debug_name = debug_name;
if (createGLMeshes)
this->createGLMeshes();
}
@ -41,7 +44,7 @@ void STKMeshSceneNode::createGLMeshes()
for (u32 i = 0; i<Mesh->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
GLmeshes.push_back(allocateMeshBuffer(mb));
GLmeshes.push_back(allocateMeshBuffer(mb, m_debug_name));
}
isMaterialInitialized = false;
isGLInitialized = false;

View File

@ -29,7 +29,8 @@ public:
virtual void updateNoGL();
virtual void updateGL();
void setReloadEachFrame(bool);
STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr,
irr::s32 id, const std::string& debug_name,
const irr::core::vector3df& position = irr::core::vector3df(0, 0, 0),
const irr::core::vector3df& rotation = irr::core::vector3df(0, 0, 0),
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f),

View File

@ -1034,6 +1034,7 @@ namespace GUIEngine
}
catch (std::runtime_error& err)
{
(void)err;
Log::fatal("Engine::init", "Canot load default GUI skin");
}
}

View File

@ -208,7 +208,7 @@ void ModelViewWidget::setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
else
{
scene::IAnimatedMeshSceneNode* node =
irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)mesh.get(0), NULL);
irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)mesh.get(0), "rtt_mesh", NULL);
node->setPosition(mesh_location[0].toIrrVector());
node->setFrameLoop(model_frames[0], model_frames[0]);
node->setAnimationSpeed(0);
@ -228,7 +228,7 @@ void ModelViewWidget::setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
if (model_frames[n] == -1)
{
scene::ISceneNode* node =
irr_driver->addMesh(mesh.get(n), m_rtt_main_node);
irr_driver->addMesh(mesh.get(n), "rtt_node", m_rtt_main_node);
node->setPosition(mesh_location[n].toIrrVector());
node->updateAbsolutePosition();
node->setScale(mesh_scale[n].toIrrVector());
@ -237,7 +237,7 @@ void ModelViewWidget::setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
{
scene::IAnimatedMeshSceneNode* node =
irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)mesh.get(n),
m_rtt_main_node);
"modelviewrtt", m_rtt_main_node);
node->setPosition(mesh_location[n].toIrrVector());
node->setFrameLoop(model_frames[n], model_frames[n]);
node->setAnimationSpeed(0);

View File

@ -16,12 +16,14 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <SKeyMap.h>
#include "input/binding.hpp"
#include "io/xml_node.hpp"
#include "utils/string_utils.hpp"
#include "utils/translation.hpp"
#include "utils/log.hpp"
#include <SKeyMap.h>
/** Convert thjis binding to XML attributes. The full XML node is actually
* written by device_config, so we only have to add the attributes here.
*/
@ -40,51 +42,37 @@ void Binding::serialize(std::ofstream& stream) const
} // serialize
// ----------------------------------------------------------------------------
bool Binding::deserialize(irr::io::IrrXMLReader* xml)
bool Binding::load(const XMLNode *action)
{
const char *id_string = xml->getAttributeValue("id");
const char *event_string = xml->getAttributeValue("event");
const char *dir_string = xml->getAttributeValue("direction");
const char *range_string = xml->getAttributeValue("range");
const char *character = xml->getAttributeValue("character");
// Proceed only if neccesary tags were found
if ((id_string == NULL) || (event_string == NULL))
int n;
if(!action->get("id", &m_id) || !action->get("event", &n) )
{
Log::warn("Binding", "No id-string or event-string given - ignored.");
return false;
}
// Convert strings to string tags to integer types
m_type = (Input::InputType)atoi(event_string);
m_id = atoi(id_string);
m_character = character ? atoi(character) : 0;
m_type = (Input::InputType)n;
core::stringw s;
m_character = 0;
action->get("character", &s);
if(s.size()>0)
m_character = s[0];
// If the action is not a stick motion (button or key)
if (m_type == Input::IT_STICKMOTION)
{
// If the action is a stick motion & a direction is defined
if (dir_string == NULL)
if(!action->get("direction", &n))
{
Log::warn("Binding", "IT_STICKMOTION without direction, ignoring.");
return false;
}
// If the action is a stick motion & a range is defined
if (range_string == NULL)
{
m_range = Input::AR_HALF;
}
else
{
m_range = (Input::AxisRange)atoi(range_string);
}
m_dir = (Input::AxisDirection)atoi(dir_string);
m_dir = (Input::AxisDirection)n;
if(!action->get("range", &n)) m_range = Input::AR_HALF;
else m_range = (Input::AxisRange)n;
} // if m_type!=stickmotion
return true;
} // deserialize
} // load
// ----------------------------------------------------------------------------
/** Returns a string representing this binding, which can be displayed on the

View File

@ -20,17 +20,20 @@
#ifndef BINDING_HPP
#define BINDING_HPP
#include <fstream>
#include <irrString.h>
#include "input/input.hpp"
#include "utils/no_copy.hpp"
#include <irrXML.h>
#include "irrString.h"
#include <fstream>
class XMLNode;
/**
* \ingroup config
*/
class Binding
class Binding : public NoCopy
{
private:
Input::InputType m_type;
@ -62,7 +65,7 @@ public:
// ------------------------------------------------------------------------
void serialize (std::ofstream& stream) const;
bool deserialize(irr::io::IrrXMLReader* xml);
bool load(const XMLNode *action);
irr::core::stringw getAsString() const;
};
#endif

View File

@ -61,7 +61,7 @@ bool DeviceManager::initialize()
Log::info("-","---------------------------");
}
deserialize();
load();
// Assign a configuration to the keyboard, or create one if we haven't yet
if(UserConfigParams::logMisc()) Log::info("Device manager","Initializing keyboard support.");
@ -437,123 +437,88 @@ void DeviceManager::clearLatestUsedDevice()
} // clearLatestUsedDevice
// -----------------------------------------------------------------------------
bool DeviceManager::deserialize()
/** Loads the configuration from the user's input.xml file.
*/
bool DeviceManager::load()
{
static std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME);
std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME);
if(UserConfigParams::logMisc())
Log::info("Device manager","Deserializing input.xml...");
Log::info("Device manager","Loading input.xml...");
if(!file_manager->fileExists(filepath))
const XMLNode *input = file_manager->createXMLTree(filepath);
if(!input)
{
if(UserConfigParams::logMisc())
Log::warn("Device manager","No configuration file exists.");
return false;
}
else
if(input->getName()!="input")
{
irr::io::IrrXMLReader* xml = irr::io::createIrrXMLReader( filepath.c_str() );
const int GAMEPAD = 1;
const int KEYBOARD = 2;
const int NOTHING = 3;
int reading_now = NOTHING;
KeyboardConfig* keyboard_config = NULL;
GamepadConfig* gamepad_config = NULL;
// parse XML file
while(xml && xml->read())
{
switch(xml->getNodeType())
{
case irr::io::EXN_TEXT:
break;
case irr::io::EXN_ELEMENT:
{
if (strcmp("input", xml->getNodeName()) == 0)
{
const char *version_string = xml->getAttributeValue("version");
if (version_string == NULL || atoi(version_string) != INPUT_FILE_VERSION)
{
//I18N: shown when config file is too old
GUIEngine::showMessage( _("Please re-configure your key bindings.") );
GUIEngine::showMessage( _("Your input config file is not compatible with this version of STK.") );
return false;
}
}
if (strcmp("keyboard", xml->getNodeName()) == 0)
{
keyboard_config = new KeyboardConfig();
reading_now = KEYBOARD;
}
else if (strcmp("gamepad", xml->getNodeName()) == 0)
{
gamepad_config = new GamepadConfig(xml);
reading_now = GAMEPAD;
}
else if (strcmp("action", xml->getNodeName()) == 0)
{
if(reading_now == KEYBOARD)
{
if(keyboard_config != NULL)
if(!keyboard_config->deserializeAction(xml))
Log::error("Device manager","Ignoring an ill-formed keyboard action in input config.");
}
else if(reading_now == GAMEPAD)
{
if(gamepad_config != NULL)
if(!gamepad_config->deserializeAction(xml))
Log::error("Device manager","Ignoring an ill-formed gamepad action in input config.");
}
else Log::warn("Device manager","An action is placed in an unexpected area in the input config file.");
}
}
break;
// ---- section ending
case irr::io::EXN_ELEMENT_END:
{
if (strcmp("keyboard", xml->getNodeName()) == 0)
{
m_keyboard_configs.push_back(keyboard_config);
reading_now = NOTHING;
}
else if (strcmp("gamepad", xml->getNodeName()) == 0)
{
m_gamepad_configs.push_back(gamepad_config);
reading_now = NOTHING;
}
}
break;
default: break;
} // end switch
} // end while
if(UserConfigParams::logMisc())
{
Log::info("Device manager","Found %d keyboard and %d gamepad configurations.",
m_keyboard_configs.size(), m_gamepad_configs.size());
}
// For Debugging....
/*
for (int n = 0; n < m_keyboard_configs.size(); n++)
printf("Config #%d\n%s", n + 1, m_keyboard_configs[n].toString().c_str());
for (int n = 0; n < m_gamepad_configs.size(); n++)
printf("%s", m_gamepad_configs[n].toString().c_str());
*/
delete xml;
Log::warn("DeviceManager", "Invalid input.xml file - no input node.");
return false;
}
int version=0;
if(!input->get("version", &version) || version != INPUT_FILE_VERSION )
{
//I18N: shown when config file is too old
GUIEngine::showMessage(_("Please re-configure your key bindings."));
GUIEngine::showMessage(_("Your input config file is not compatible "
"with this version of STK."));
return false;
}
for(unsigned int i=0; i<input->getNumNodes(); i++)
{
const XMLNode *config = input->getNode(i);
if(config->getName()=="keyboard")
{
KeyboardConfig* keyboard_config = new KeyboardConfig();
if(!keyboard_config->load(config))
{
Log::error("Device manager",
"Ignoring an ill-formed keyboard action in input config.");
}
m_keyboard_configs.push_back(keyboard_config);
}
else if (config->getName()=="gamepad")
{
GamepadConfig* gamepad_config = new GamepadConfig(config);
gamepad_config->load(config);
m_gamepad_configs.push_back(gamepad_config);
}
else
{
Log::warn("DeviceManager",
"Invalid node '%s' in input.xml - ignored.",
config->getName().c_str());
continue;
}
} // for i < getNumNodes
if (UserConfigParams::logMisc())
{
Log::info("Device manager",
"Found %d keyboard and %d gamepad configurations.",
m_keyboard_configs.size(), m_gamepad_configs.size());
}
// For Debugging....
/*
for (int n = 0; n < m_keyboard_configs.size(); n++)
printf("Config #%d\n%s", n + 1, m_keyboard_configs[n].toString().c_str());
for (int n = 0; n < m_gamepad_configs.size(); n++)
printf("%s", m_gamepad_configs[n].toString().c_str());
*/
delete input;
return true;
} // deserialize
} // load
// -----------------------------------------------------------------------------
void DeviceManager::serialize()

View File

@ -99,7 +99,7 @@ private:
* pressing fire. */
bool m_map_fire_to_select;
bool deserialize();
bool load();
void shutdown();
public:

View File

@ -59,7 +59,7 @@ Attachment::Attachment(AbstractKart* kart)
// If we attach a NULL mesh, we get a NULL scene node back. So we
// have to attach some kind of mesh, but make it invisible.
m_node = irr_driver->addAnimatedMesh(
attachment_manager->getMesh(Attachment::ATTACH_BOMB));
attachment_manager->getMesh(Attachment::ATTACH_BOMB), "bomb");
#ifdef DEBUG
std::string debug_name = kart->getIdent()+" (attachment)";
m_node->setName(debug_name.c_str());
@ -113,7 +113,7 @@ void Attachment::set(AttachmentType type, float time,
bomb_scene_node = m_node;
m_node = irr_driver->addAnimatedMesh(
attachment_manager->getMesh(Attachment::ATTACH_BOMB));
attachment_manager->getMesh(Attachment::ATTACH_BOMB), "bomb");
#ifdef DEBUG
std::string debug_name = m_kart->getIdent() + " (attachment)";
m_node->setName(debug_name.c_str());

View File

@ -74,7 +74,7 @@ Flyable::Flyable(AbstractKart *kart, PowerupManager::PowerupType type,
m_max_lifespan = -1;
// Add the graphical model
setNode(irr_driver->addMesh(m_st_model[type]));
setNode(irr_driver->addMesh(m_st_model[type], StringUtils::insertValues("flyable_%i", (int)type)));
irr_driver->applyObjectPassShader(getNode());
#ifdef DEBUG
std::string debug_name("flyable: ");

View File

@ -48,12 +48,12 @@ Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
LODNode* lodnode = new LODNode("item",
irr_driver->getSceneManager()->getRootSceneNode(),
irr_driver->getSceneManager());
scene::IMeshSceneNode* meshnode = irr_driver->addMesh(mesh);
scene::IMeshSceneNode* meshnode = irr_driver->addMesh(mesh, StringUtils::insertValues("item_%i", (int)type));
if (lowres_mesh != NULL)
{
lodnode->add(35, meshnode, true);
scene::IMeshSceneNode* meshnode = irr_driver->addMesh(lowres_mesh);
scene::IMeshSceneNode* meshnode = irr_driver->addMesh(lowres_mesh, StringUtils::insertValues("item_lo_%i", (int)type));
lodnode->add(100, meshnode, true);
}
else

View File

@ -75,7 +75,7 @@ RubberBand::RubberBand(Plunger *plunger, AbstractKart *kart)
// Gloss
mb->getMaterial().setTexture(1, getUnicolorTexture(video::SColor(0, 0, 0, 0)));
updatePosition();
m_node = irr_driver->addMesh(m_mesh);
m_node = irr_driver->addMesh(m_mesh, "rubberband");
irr_driver->applyObjectPassShader(m_node);
if (STKMeshSceneNode *stkm = dynamic_cast<STKMeshSceneNode *>(m_node))
stkm->setReloadEachFrame(true);

View File

@ -1720,7 +1720,7 @@ void Kart::crashed(AbstractKart *k, bool update_attachments)
getAttachment()->handleCollisionWithKart(k);
}
m_controller->crashed(k);
crashed(NULL, k);
playCrashSFX(NULL, k);
} // crashed(Kart, update_attachments
// -----------------------------------------------------------------------------
@ -1729,6 +1729,7 @@ void Kart::crashed(AbstractKart *k, bool update_attachments)
*/
void Kart::crashed(const Material *m, const Vec3 &normal)
{
playCrashSFX(m, NULL);
#ifdef DEBUG
// Simple debug output for people playing without sound.
// This makes it easier to see if a kart hit the track (esp.
@ -1834,26 +1835,33 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
}
else if (m->getCollisionReaction() == Material::PUSH_BACK)
{
if (m_bounce_back_time <= 0.2f) // this variable is sometimes set to 0.1 somewhere else
// This variable is set to 0.2 in case of a kart-terrain collision
if (m_bounce_back_time <= 0.2f)
{
btVector3 push = m_body->getLinearVelocity().normalized();
push[1] = 0.1f;
m_body->applyCentralImpulse( -4000.0f*push );
m_bounce_back_time = 2.0f;
core::stringw msg = _("You need more points\nto enter this challenge!\nCheck the minimap for\navailable challenges.");
std::vector<core::stringw> parts = StringUtils::split(msg, '\n', false);
core::stringw msg = _("You need more points\n"
"to enter this challenge!\n"
"Check the minimap for\n"
"available challenges.");
std::vector<core::stringw> parts =
StringUtils::split(msg, '\n', false);
// For now, until we have scripting, special-case the overworld... (TODO)
// For now, until we have scripting, special-case
// the overworld... (TODO)
if (dynamic_cast<OverWorld*>(World::getWorld()) != NULL)
{
SFXManager::get()->quickSound("forcefield");
for (unsigned int n = 0; n < parts.size(); n++)
{
World::getWorld()->getRaceGUI()->addMessage(parts[n], NULL, 4.0f,
video::SColor(255, 255,255,255),
true, true);
World::getWorld()->getRaceGUI()
->addMessage(parts[n], NULL, 4.0f,
video::SColor(255, 255,255,255),
true, true);
} // for n<parts.size()
} // if world exist
} // if m_bounce_back_time <= 0.2f
@ -1861,7 +1869,6 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
} // if(m && m->getCollisionReaction() != Material::NORMAL &&
// !getKartAnimation())
m_controller->crashed(m);
crashed(m, NULL);
} // crashed(Material)
// -----------------------------------------------------------------------------
@ -1869,7 +1876,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
* @param m The material collided into, or NULL if none
* @param k The kart collided into, or NULL if none
*/
void Kart::crashed(const Material* m, AbstractKart *k)
void Kart::playCrashSFX(const Material* m, AbstractKart *k)
{
if(World::getWorld()->getTime()-m_time_last_crash < 0.5f) return;
@ -1893,11 +1900,9 @@ void Kart::crashed(const Material* m, AbstractKart *k)
if(m_crash_sound->getStatus() != SFXBase::SFX_PLAYING)
m_crash_sound->play();
}
}
m_bounce_back_time = 0.1f;
}
} // crashed
} // if lin_vel > 0.555
} // if m_bounce_back_time <= 0
} // playCrashSFX
// -----------------------------------------------------------------------------
/** Plays a beep sfx.

View File

@ -231,7 +231,7 @@ private:
void updateEngineSFX();
void updateNitro(float dt);
float getActualWheelForce();
void crashed(const Material* m, AbstractKart *k);
void playCrashSFX(const Material* m, AbstractKart *k);
void loadData(RaceManager::KartType type, bool animatedModel);
public:

View File

@ -336,7 +336,7 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
irr_driver->getSceneManager() );
node = irr_driver->addAnimatedMesh(m_mesh);
node = irr_driver->addAnimatedMesh(m_mesh, "kartmesh");
// as animated mesh are not cheap to render use frustum box culling
if (irr_driver->isGLSL())
node->setAutomaticCulling(scene::EAC_OFF);
@ -407,17 +407,24 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
scene::IMesh* main_frame = m_mesh->getMesh(straight_frame);
main_frame->setHardwareMappingHint(scene::EHM_STATIC);
node = irr_driver->addMesh(main_frame);
std::string debug_name;
#ifdef DEBUG
debug_name = m_model_filename + " (kart-model)";
#endif
node = irr_driver->addMesh(main_frame, debug_name);
#ifdef DEBUG
std::string debug_name = m_model_filename+" (kart-model)";
node->setName(debug_name.c_str());
#endif
// Attach the wheels
for(unsigned int i=0; i<4; i++)
{
if(!m_wheel_model[i]) continue;
m_wheel_node[i] = irr_driver->addMesh(m_wheel_model[i], node);
m_wheel_node[i] = irr_driver->addMesh(m_wheel_model[i], "wheel", node);
Vec3 wheel_min, wheel_max;
MeshTools::minMax3D(m_wheel_model[i], &wheel_min, &wheel_max);
m_wheel_graphics_radius[i] = 0.5f*(wheel_max.getY() - wheel_min.getY());
@ -438,7 +445,7 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
obj.m_node = NULL;
if(obj.m_model)
{
obj.m_node = irr_driver->addAnimatedMesh(obj.m_model, node);
obj.m_node = irr_driver->addAnimatedMesh(obj.m_model, "speedweighted", node);
obj.m_node->grab();
obj.m_node->setFrameLoop(m_animation_frame[AF_SPEED_WEIGHTED_START], m_animation_frame[AF_SPEED_WEIGHTED_END]);
@ -892,7 +899,7 @@ void KartModel::attachHat(){
scene::IMesh *hat_mesh =
irr_driver->getAnimatedMesh(
file_manager->getAsset(FileManager::MODEL, m_hat_name));
m_hat_node = irr_driver->addMesh(hat_mesh);
m_hat_node = irr_driver->addMesh(hat_mesh, "hat");
bone->addChild(m_hat_node);
m_animated_node->setCurrentFrame((float)m_animation_frame[AF_STRAIGHT]);
m_animated_node->OnAnimate(0);

View File

@ -144,13 +144,13 @@ void ThreeStrikesBattle::kartAdded(AbstractKart* kart, scene::ISceneNode* node)
{
float coord = -kart->getKartLength()*0.5f;
scene::IMeshSceneNode* tire_node = irr_driver->addMesh(m_tire, node);
scene::IMeshSceneNode* tire_node = irr_driver->addMesh(m_tire, "3strikestire", node);
tire_node->setPosition(core::vector3df(-0.16f, 0.3f, coord - 0.25f));
tire_node->setScale(core::vector3df(0.4f, 0.4f, 0.4f));
tire_node->setRotation(core::vector3df(90.0f, 0.0f, 0.0f));
tire_node->setName("tire1");
tire_node = irr_driver->addMesh(m_tire, node);
tire_node = irr_driver->addMesh(m_tire, "3strikestire", node);
tire_node->setPosition(core::vector3df(0.16f, 0.3f, coord - 0.25f));
tire_node->setScale(core::vector3df(0.4f, 0.4f, 0.4f));
tire_node->setRotation(core::vector3df(90.0f, 0.0f, 0.0f));

View File

@ -29,7 +29,6 @@
#include "states_screens/online_profile_friends.hpp"
#include "states_screens/user_screen.hpp"
#include "states_screens/dialogs/change_password_dialog.hpp"
#include "states_screens/dialogs/notification_dialog.hpp"
#include "states_screens/dialogs/user_info_dialog.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"

View File

@ -1,152 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 Glenn De Jonghe
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "states_screens/dialogs/notification_dialog.hpp"
#include <IGUIEnvironment.h>
#include "config/player_manager.hpp"
#include "guiengine/engine.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/online_profile_achievements.hpp"
#include "states_screens/online_profile_friends.hpp"
#include "utils/translation.hpp"
using namespace GUIEngine;
using namespace irr;
using namespace irr::gui;
using namespace Online;
// -----------------------------------------------------------------------------
NotificationDialog::NotificationDialog(Type type, const core::stringw &info)
: ModalDialog(0.8f,0.5f)
{
m_info = info;
m_type = type;
}
void NotificationDialog::load()
{
loadFromFile("online/notification_dialog.stkgui");
}
void NotificationDialog::beforeAddingWidgets()
{
m_self_destroy = false;
m_view = false;
m_info_widget = getWidget<LabelWidget>("info");
assert(m_info_widget != NULL);
m_info_widget->setText(m_info, false);
m_options_widget = getWidget<RibbonWidget>("options");
assert(m_options_widget != NULL);
m_view_widget = getWidget<IconButtonWidget>("view");
assert(m_view_widget != NULL);
if(m_type == T_Friends)
{
m_view_widget->setText(_("View Friends"));
}
else if (m_type == T_Achievements)
{
m_view_widget->setText(_("View Achievements"));
}
m_cancel_widget = getWidget<IconButtonWidget>("cancel");
assert(m_cancel_widget != NULL);
m_options_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
// -----------------------------------------------------------------------------
NotificationDialog::~NotificationDialog()
{
}
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation NotificationDialog::processEvent(const std::string& eventSource)
{
if (eventSource == m_options_widget->m_properties[PROP_ID])
{
const std::string& selection = m_options_widget->getSelectionIDString(PLAYER_ID_GAME_MASTER);
if (selection == m_cancel_widget->m_properties[PROP_ID])
{
m_self_destroy = true;
return GUIEngine::EVENT_BLOCK;
}
else if(selection == m_view_widget->m_properties[PROP_ID])
{
m_view = true;
return GUIEngine::EVENT_BLOCK;
}
}
return GUIEngine::EVENT_LET;
}
// -----------------------------------------------------------------------------
void NotificationDialog::onEnterPressedInternal()
{
//If enter was pressed while none of the buttons was focused interpret as close
const int playerID = PLAYER_ID_GAME_MASTER;
if (GUIEngine::isFocusedForPlayer(m_options_widget, playerID))
return;
m_self_destroy = true;
}
// -----------------------------------------------------------------------------
bool NotificationDialog::onEscapePressed()
{
if (m_cancel_widget->isActivated())
m_self_destroy = true;
return false;
}
// -----------------------------------------------------------------------------
void NotificationDialog::onUpdate(float dt)
{
//If we want to open the registration dialog, we need to close this one first
if (m_view) m_self_destroy = true;
// It's unsafe to delete from inside the event handler so we do it here
if (m_self_destroy)
{
// Since dismiss deletes this object, store the instance values which
// we still need
bool view = m_view;
NotificationDialog::Type type = m_type;
ModalDialog::dismiss();
if (view)
{
if(type == T_Friends)
{
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
OnlineProfileFriends::getInstance()->push();
}
else if (type == T_Achievements)
{
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
OnlineProfileAchievements::getInstance()->push();
}
}
return;
}
}

View File

@ -1,68 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2013 Glenn De Jonghe
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_NOTIFICATION_DIALOG_HPP
#define HEADER_NOTIFICATION_DIALOG_HPP
#include "guiengine/modaldialog.hpp"
#include "guiengine/widgets.hpp"
#include "utils/types.hpp"
#include <irrString.h>
/**
* \brief Dialog that allows a user to sign in
* \ingroup states_screens
*/
class NotificationDialog : public GUIEngine::ModalDialog
{
public:
enum Type
{
T_Friends = 1,
T_Achievements = 2
};
private:
bool m_self_destroy;
bool m_view;
Type m_type;
irr::core::stringw m_info;
GUIEngine::LabelWidget * m_info_widget;
GUIEngine::RibbonWidget * m_options_widget;
GUIEngine::IconButtonWidget * m_view_widget;
GUIEngine::IconButtonWidget * m_cancel_widget;
public:
NotificationDialog(Type type, const core::stringw &info);
~NotificationDialog();
virtual void beforeAddingWidgets();
virtual void load();
void onEnterPressedInternal();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
virtual bool onEscapePressed();
virtual void onUpdate(float dt);
};
#endif

View File

@ -286,7 +286,8 @@ void FeatureUnlockedCutScene::init()
{
if (m_unlocked_stuff[n].m_unlock_model.size() > 0)
{
m_unlocked_stuff[n].m_root_gift_node = irr_driver->addMesh( irr_driver->getMesh(m_unlocked_stuff[n].m_unlock_model) );
m_unlocked_stuff[n].m_root_gift_node = irr_driver->addMesh(
irr_driver->getMesh(m_unlocked_stuff[n].m_unlock_model), "unlocked_model");
m_unlocked_stuff[n].m_scale = 0.7f;
//m_unlocked_stuff[n].m_root_gift_node->setScale(core::vector3df(0.2f, 0.2f, 0.2f));
}
@ -336,13 +337,13 @@ void FeatureUnlockedCutScene::init()
m_unlocked_stuff[n].m_w,
m_unlocked_stuff[n].m_h);
m_unlocked_stuff[n].m_root_gift_node = irr_driver->getSceneManager()->addEmptySceneNode();
m_unlocked_stuff[n].m_side_1 = irr_driver->addMesh(mesh, m_unlocked_stuff[n].m_root_gift_node);
m_unlocked_stuff[n].m_side_1 = irr_driver->addMesh(mesh, "unlocked_picture", m_unlocked_stuff[n].m_root_gift_node);
//mesh->drop();
mesh = irr_driver->createTexturedQuadMesh(&m,
m_unlocked_stuff[n].m_w,
m_unlocked_stuff[n].m_h);
m_unlocked_stuff[n].m_side_2 = irr_driver->addMesh(mesh, m_unlocked_stuff[n].m_root_gift_node);
m_unlocked_stuff[n].m_side_2 = irr_driver->addMesh(mesh, "unlocked_picture", m_unlocked_stuff[n].m_root_gift_node);
m_unlocked_stuff[n].m_side_2->setRotation(core::vector3df(0.0f, 180.0f, 0.0f));
//mesh->drop();
#ifdef DEBUG

View File

@ -97,6 +97,9 @@ void MainMenuScreen::init()
{
Screen::init();
m_user_id = getWidget<ButtonWidget>("user-id");
assert(m_user_id);
// reset in case we're coming back from a race
StateManager::get()->resetActivePlayers();
input_manager->getDeviceList()->setAssignMode(NO_ASSIGN);
@ -155,9 +158,11 @@ void MainMenuScreen::init()
void MainMenuScreen::onUpdate(float delta)
{
PlayerProfile *player = PlayerManager::getCurrentPlayer();
if(PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST ||
PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
{
m_user_id->setText(player->getLastOnlineName() + "@stk");
m_online->setActivated();
m_online->setLabel( _("Online"));
}
@ -165,9 +170,14 @@ void MainMenuScreen::onUpdate(float delta)
{
m_online->setActivated();
m_online->setLabel( _("Login" ));
m_user_id->setText(player->getName());
}
else // now must be either logging in or logging out
else
{
// now must be either logging in or logging out
m_online->setDeactivated();
m_user_id->setText(player->getName());
}
m_online->setLabel(PlayerManager::getCurrentOnlineId() ? _("Online")
: _("Login" ) );
@ -210,6 +220,12 @@ void MainMenuScreen::onUpdate(float delta)
void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if(name=="user-id")
{
UserScreen::getInstance()->push();
return;
}
// most interesting stuff is in the ribbons, so start there
RibbonWidget* ribbon = dynamic_cast<RibbonWidget*>(widget);
@ -446,7 +462,6 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
//OnlineScreen::getInstance()->push();
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
OnlineProfileAchievements::getInstance()->push();
}
else
{

View File

@ -20,8 +20,8 @@
#include "guiengine/screen.hpp"
namespace GUIEngine { class Widget; class ListWidget;
class IconButtonWidget; }
namespace GUIEngine { class Widget; class ListWidget;
class ButtonWidget; class IconButtonWidget; }
/**
* \brief Handles the main menu
@ -35,6 +35,9 @@ private:
/** Keep the widget to avoid looking it up every frame. */
GUIEngine::IconButtonWidget* m_online;
/** Keep the widget to to the user name. */
GUIEngine::ButtonWidget *m_user_id;
MainMenuScreen();
public:

View File

@ -99,7 +99,7 @@ CheckLine::CheckLine(const XMLNode &node, unsigned int index)
}
buffer->recalculateBoundingBox();
mesh->setBoundingBox(buffer->getBoundingBox());
m_debug_node = irr_driver->addMesh(mesh);
m_debug_node = irr_driver->addMesh(mesh, "checkdebug");
mesh->drop();
}
else

View File

@ -89,7 +89,7 @@ LODNode* ModelDefinitionLoader::instanciateAsLOD(const XMLNode* node, scene::ISc
//cache.push_back(a_mesh);
irr_driver->grabAllTextures(a_mesh);
m_track->addCachedMesh(a_mesh);
scene::IMeshSceneNode* scene_node = irr_driver->addMesh(a_mesh);
scene::IMeshSceneNode* scene_node = irr_driver->addMesh(a_mesh, group[m].m_model_file);
m_track->handleAnimatedTextures( scene_node, *group[m].m_xml );
@ -135,4 +135,4 @@ void ModelDefinitionLoader::cleanLibraryNodesAfterLoad()
file_manager->popTextureSearchPath();
file_manager->popModelSearchPath();
}
}
}

View File

@ -551,7 +551,7 @@ void QuadGraph::createDebugMesh()
c.setBlue((i%2) ? 0 : 255);
v[i].Color = c;
}
m_node = irr_driver->addMesh(m_mesh);
m_node = irr_driver->addMesh(m_mesh, "quad_graph_debug");
#ifdef DEBUG
m_node->setName("track-debug-mesh");
#endif
@ -1006,7 +1006,7 @@ void QuadGraph::makeMiniMap(const core::dimension2du &dimension,
/*track_color*/ &fill_color,
/*lap line color*/ &red );
m_node = irr_driver->addMesh(m_mesh);
m_node = irr_driver->addMesh(m_mesh, "mini_map");
#ifdef DEBUG
m_node->setName("minimap-mesh");
#endif

View File

@ -999,7 +999,7 @@ bool Track::loadMainTrack(const XMLNode &root)
// The merged mesh is grabbed by the octtree, so we don't need
// to keep a reference to it.
scene::ISceneNode *scene_node = irr_driver->addMesh(tangent_mesh);
scene::ISceneNode *scene_node = irr_driver->addMesh(tangent_mesh, "track_main");
//scene::IMeshSceneNode *scene_node = irr_driver->addOctTree(merged_mesh);
// We should drop the merged mesh (since it's now referred to in the
// scene node), but then we need to grab it since it's in the
@ -1213,7 +1213,7 @@ bool Track::loadMainTrack(const XMLNode &root)
// create a node out of this mesh just for bullet; delete it after, normal maps are special
// and require tangent meshes
scene_node = irr_driver->addMesh(original_mesh);
scene_node = irr_driver->addMesh(original_mesh, "original_mesh");
scene_node->setPosition(xyz);
scene_node->setRotation(hpr);
@ -1228,7 +1228,7 @@ bool Track::loadMainTrack(const XMLNode &root)
irr_driver->grabAllTextures(mesh);
m_all_cached_meshes.push_back(mesh);
scene_node = irr_driver->addMesh(mesh);
scene_node = irr_driver->addMesh(mesh, "original_mesh_with_tangents");
scene_node->setPosition(xyz);
scene_node->setRotation(hpr);
scene_node->setScale(scale);
@ -1276,7 +1276,7 @@ bool Track::loadMainTrack(const XMLNode &root)
m_all_cached_meshes.push_back(a_mesh);
irr_driver->grabAllTextures(a_mesh);
a_mesh->grab();
scene_node = irr_driver->addMesh(a_mesh);
scene_node = irr_driver->addMesh(a_mesh, model_name);
scene_node->setPosition(xyz);
scene_node->setRotation(hpr);
scene_node->setScale(scale);
@ -1532,7 +1532,7 @@ void Track::createWater(const XMLNode &node)
}
else
{*/
scene_node = irr_driver->addMesh(mesh);
scene_node = irr_driver->addMesh(mesh, "water");
//}
if(!mesh || !scene_node)

View File

@ -370,7 +370,7 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNod
else if (animated)
{
scene::IAnimatedMeshSceneNode *node =
irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)m_mesh, parent);
irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)m_mesh, m_model_file, parent);
m_node = node;
m_frame_start = node->getStartFrame();
@ -387,7 +387,7 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node, scene::ISceneNod
if (xml_node)
xml_node->get("displacing", &displacing);
m_node = irr_driver->addMesh(m_mesh, parent);
m_node = irr_driver->addMesh(m_mesh, m_model_file, parent);
STKMeshSceneNode* stkmesh = dynamic_cast<STKMeshSceneNode*>(m_node);
if (displacing && stkmesh != NULL)