Add required code and color selector for rainbow karts
This commit is contained in:
parent
68e8da2353
commit
bb0cf72635
19
data/gui/kart_color_slider.stkgui
Normal file
19
data/gui/kart_color_slider.stkgui
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<stkgui>
|
||||||
|
<div x="2%" y="10%" width="96%" height="70%" layout="vertical-row">
|
||||||
|
<div id="kart-screen" layout="horizontal-row" width="100%" height="60%" proportion="10" align="center">
|
||||||
|
<placeholder width="100%" layout="horizontal-row" height="100%">
|
||||||
|
<!-- Content is added programmatically -->
|
||||||
|
</placeholder>
|
||||||
|
</div>
|
||||||
|
<label text="Left-hand side most to use the original color, otherwise pick one from slider."
|
||||||
|
width="100%" text_align="center" word_wrap="true"
|
||||||
|
I18N="In the kart color slider dialog"/>
|
||||||
|
<spacer height="30" width="10"/>
|
||||||
|
<div proportion="1" width="100%" layout="horizontal-row">
|
||||||
|
<gauge id="color-slider" min_value="0" max_value="100" proportion="1"/>
|
||||||
|
</div>
|
||||||
|
<spacer height="30" width="10"/>
|
||||||
|
<button id="close" text="Apply" align="center"/>
|
||||||
|
</div>
|
||||||
|
</stkgui>
|
@ -62,6 +62,8 @@
|
|||||||
I18N="In the user screen" text="Delete" label_location="bottom"/>
|
I18N="In the user screen" text="Delete" label_location="bottom"/>
|
||||||
<icon-button id="rename" width="64" height="64" icon="gui/rename.png"
|
<icon-button id="rename" width="64" height="64" icon="gui/rename.png"
|
||||||
I18N="In the user screen" text="Rename" label_location="bottom"/>
|
I18N="In the user screen" text="Rename" label_location="bottom"/>
|
||||||
|
<icon-button id="default_kart_color" width="64" height="64" icon="gui/edit.png"
|
||||||
|
I18N="In the user screen" text="Default kart color" label_location="bottom"/>
|
||||||
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
|
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
|
||||||
I18N="In the user screen" text="Cancel" label_location="bottom"/>
|
I18N="In the user screen" text="Cancel" label_location="bottom"/>
|
||||||
</buttonbar>
|
</buttonbar>
|
||||||
|
@ -67,6 +67,8 @@
|
|||||||
I18N="In the user screen" text="Delete" label_location="bottom"/>
|
I18N="In the user screen" text="Delete" label_location="bottom"/>
|
||||||
<icon-button id="rename" width="64" height="64" icon="gui/rename.png"
|
<icon-button id="rename" width="64" height="64" icon="gui/rename.png"
|
||||||
I18N="In the user screen" text="Rename" label_location="bottom"/>
|
I18N="In the user screen" text="Rename" label_location="bottom"/>
|
||||||
|
<icon-button id="default_kart_color" width="64" height="64" icon="gui/edit.png"
|
||||||
|
I18N="In the user screen" text="Default kart color" label_location="bottom"/>
|
||||||
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
|
<icon-button id="cancel" width="64" height="64" icon="gui/main_quit.png"
|
||||||
I18N="In the user screen" text="Cancel" label_location="bottom"/>
|
I18N="In the user screen" text="Cancel" label_location="bottom"/>
|
||||||
</buttonbar>
|
</buttonbar>
|
||||||
|
@ -48,6 +48,7 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest)
|
|||||||
m_last_online_name = "";
|
m_last_online_name = "";
|
||||||
m_last_was_online = false;
|
m_last_was_online = false;
|
||||||
m_remember_password = false;
|
m_remember_password = false;
|
||||||
|
m_default_kart_color = 0.0f;
|
||||||
initRemainingData();
|
initRemainingData();
|
||||||
} // PlayerProfile
|
} // PlayerProfile
|
||||||
|
|
||||||
@ -76,6 +77,7 @@ PlayerProfile::PlayerProfile(const XMLNode* node)
|
|||||||
m_remember_password = false;
|
m_remember_password = false;
|
||||||
m_story_mode_status = NULL;
|
m_story_mode_status = NULL;
|
||||||
m_achievements_status = NULL;
|
m_achievements_status = NULL;
|
||||||
|
m_default_kart_color = 0.0f;
|
||||||
m_icon_filename = "";
|
m_icon_filename = "";
|
||||||
|
|
||||||
node->getAndDecode("name", &m_local_name);
|
node->getAndDecode("name", &m_local_name);
|
||||||
@ -89,7 +91,7 @@ PlayerProfile::PlayerProfile(const XMLNode* node)
|
|||||||
node->get("last-was-online", &m_last_was_online );
|
node->get("last-was-online", &m_last_was_online );
|
||||||
node->get("remember-password", &m_remember_password);
|
node->get("remember-password", &m_remember_password);
|
||||||
node->get("icon-filename", &m_icon_filename );
|
node->get("icon-filename", &m_icon_filename );
|
||||||
|
node->get("default-kart-color", &m_default_kart_color);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
m_magic_number = 0xABCD1234;
|
m_magic_number = 0xABCD1234;
|
||||||
#endif
|
#endif
|
||||||
@ -211,7 +213,8 @@ void PlayerProfile::save(UTFWriter &out)
|
|||||||
<< L"\" saved-token=\"" << m_saved_token << L"\"\n";
|
<< L"\" saved-token=\"" << m_saved_token << L"\"\n";
|
||||||
out << L" last-online-name=\"" << m_last_online_name
|
out << L" last-online-name=\"" << m_last_online_name
|
||||||
<< L"\" last-was-online=\"" << m_last_was_online << L"\"\n";
|
<< L"\" last-was-online=\"" << m_last_was_online << L"\"\n";
|
||||||
out << L" remember-password=\"" << m_remember_password << L"\">\n";
|
out << L" remember-password=\"" << m_remember_password << L"\"\n";
|
||||||
|
out << L" default-kart-color=\"" << m_default_kart_color << L"\">\n";
|
||||||
{
|
{
|
||||||
if(m_story_mode_status)
|
if(m_story_mode_status)
|
||||||
m_story_mode_status->save(out);
|
m_story_mode_status->save(out);
|
||||||
|
@ -106,6 +106,9 @@ private:
|
|||||||
/** True if the login data are saved. */
|
/** True if the login data are saved. */
|
||||||
bool m_remember_password;
|
bool m_remember_password;
|
||||||
|
|
||||||
|
/** Default kart color (in hue) used in game, 0.0f to use the original. */
|
||||||
|
float m_default_kart_color;
|
||||||
|
|
||||||
/** The complete challenge state. */
|
/** The complete challenge state. */
|
||||||
StoryModeStatus *m_story_mode_status;
|
StoryModeStatus *m_story_mode_status;
|
||||||
|
|
||||||
@ -300,6 +303,10 @@ public:
|
|||||||
/** Sets if this player was logged in last time it was used. */
|
/** Sets if this player was logged in last time it was used. */
|
||||||
void setRememberPassword(bool b) { m_remember_password = b; }
|
void setRememberPassword(bool b) { m_remember_password = b; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
void setDefaultKartColor(float c) { m_default_kart_color = c; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
float getDefaultKartColor() const { return m_default_kart_color; }
|
||||||
|
|
||||||
}; // class PlayerProfile
|
}; // class PlayerProfile
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,34 +21,13 @@
|
|||||||
|
|
||||||
#include "utils/no_copy.hpp"
|
#include "utils/no_copy.hpp"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace irr
|
|
||||||
{
|
|
||||||
namespace scene { class IMesh; }
|
|
||||||
}
|
|
||||||
|
|
||||||
enum KartRenderType: unsigned int
|
|
||||||
{
|
|
||||||
KRT_DEFAULT,
|
|
||||||
KRT_RED,
|
|
||||||
KRT_ORANGE,
|
|
||||||
KRT_YELLOW,
|
|
||||||
KRT_GREEN,
|
|
||||||
KRT_PALE_BLUE,
|
|
||||||
KRT_BLUE,
|
|
||||||
KRT_PURPLE,
|
|
||||||
KRT_TRANSPARENT,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \ingroup graphics
|
* \ingroup graphics
|
||||||
*/
|
*/
|
||||||
class RenderInfo : public NoCopy
|
class RenderInfo : public NoCopy
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
float m_static_hue;
|
float m_hue;
|
||||||
|
|
||||||
bool m_transparent;
|
bool m_transparent;
|
||||||
|
|
||||||
@ -56,31 +35,17 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
RenderInfo(float hue = 0.0f, bool transparent = false)
|
RenderInfo(float hue = 0.0f, bool transparent = false)
|
||||||
{
|
{
|
||||||
m_static_hue = hue;
|
m_hue = hue;
|
||||||
m_transparent = transparent;
|
m_transparent = transparent;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
~RenderInfo() {}
|
void setHue(float hue) { m_hue = hue; }
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
void setHue(float hue) { m_static_hue = hue; }
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setTransparent(bool transparent) { m_transparent = transparent; }
|
void setTransparent(bool transparent) { m_transparent = transparent; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
float getHue() const { return m_static_hue; }
|
float getHue() const { return m_hue; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool isTransparent() const { return m_transparent; }
|
bool isTransparent() const { return m_transparent; }
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
void setKartModelRenderInfo(KartRenderType krt)
|
|
||||||
{
|
|
||||||
setHue(krt == KRT_RED ? 1.0f :
|
|
||||||
krt == KRT_ORANGE ? 0.06f :
|
|
||||||
krt == KRT_YELLOW ? 0.17f :
|
|
||||||
krt == KRT_GREEN ? 0.35f :
|
|
||||||
krt == KRT_PALE_BLUE ? 0.5f :
|
|
||||||
krt == KRT_BLUE ? 0.66f :
|
|
||||||
krt == KRT_PURPLE ? 0.8f : 0.0f);
|
|
||||||
setTransparent(krt == KRT_TRANSPARENT ? true : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // RenderInfo
|
}; // RenderInfo
|
||||||
|
|
||||||
|
@ -39,8 +39,9 @@ using namespace GUIEngine;
|
|||||||
using namespace irr::core;
|
using namespace irr::core;
|
||||||
using namespace irr::gui;
|
using namespace irr::gui;
|
||||||
|
|
||||||
ModelViewWidget::ModelViewWidget() :
|
ModelViewWidget::ModelViewWidget(unsigned rtt_size) :
|
||||||
IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, false, false)
|
IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, false, false),
|
||||||
|
m_rtt_size(rtt_size)
|
||||||
{
|
{
|
||||||
m_rtt_main_node = NULL;
|
m_rtt_main_node = NULL;
|
||||||
m_camera = NULL;
|
m_camera = NULL;
|
||||||
@ -48,7 +49,7 @@ IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, false,
|
|||||||
m_type = WTYPE_MODEL_VIEW;
|
m_type = WTYPE_MODEL_VIEW;
|
||||||
m_render_target = NULL;
|
m_render_target = NULL;
|
||||||
m_rotation_mode = ROTATE_OFF;
|
m_rotation_mode = ROTATE_OFF;
|
||||||
m_render_info.reset(new RenderInfo());
|
m_render_info = std::make_shared<RenderInfo>();
|
||||||
m_angle = 0;
|
m_angle = 0;
|
||||||
|
|
||||||
// so that the base class doesn't complain there is no icon defined
|
// so that the base class doesn't complain there is no icon defined
|
||||||
@ -84,6 +85,7 @@ void ModelViewWidget::add()
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
void ModelViewWidget::clearModels()
|
void ModelViewWidget::clearModels()
|
||||||
{
|
{
|
||||||
|
m_render_info->setHue(0.0f);
|
||||||
m_models.clearWithoutDeleting();
|
m_models.clearWithoutDeleting();
|
||||||
m_model_location.clear();
|
m_model_location.clear();
|
||||||
m_model_frames.clear();
|
m_model_frames.clear();
|
||||||
@ -178,7 +180,7 @@ void ModelViewWidget::update(float delta)
|
|||||||
{
|
{
|
||||||
std::string name = "model view ";
|
std::string name = "model view ";
|
||||||
name += m_properties[PROP_ID].c_str();
|
name += m_properties[PROP_ID].c_str();
|
||||||
m_render_target = irr_driver->createRenderTarget(irr::core::dimension2du(512,512), name);
|
m_render_target = irr_driver->createRenderTarget(irr::core::dimension2du(m_rtt_size, m_rtt_size), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_rtt_main_node == NULL)
|
if (m_rtt_main_node == NULL)
|
||||||
|
@ -65,11 +65,13 @@ namespace GUIEngine
|
|||||||
|
|
||||||
std::shared_ptr<RenderInfo> m_render_info;
|
std::shared_ptr<RenderInfo> m_render_info;
|
||||||
|
|
||||||
|
const unsigned m_rtt_size;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LEAK_CHECK()
|
LEAK_CHECK()
|
||||||
|
|
||||||
ModelViewWidget();
|
ModelViewWidget(unsigned rtt_size = 512);
|
||||||
virtual ~ModelViewWidget();
|
virtual ~ModelViewWidget();
|
||||||
|
|
||||||
void add();
|
void add();
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "config/player_manager.hpp"
|
#include "config/player_manager.hpp"
|
||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
|
#include "graphics/render_info.hpp"
|
||||||
#include "guiengine/widgets/kart_stats_widget.hpp"
|
#include "guiengine/widgets/kart_stats_widget.hpp"
|
||||||
#include "guiengine/widgets/model_view_widget.hpp"
|
#include "guiengine/widgets/model_view_widget.hpp"
|
||||||
#include "guiengine/widgets/player_name_spinner.hpp"
|
#include "guiengine/widgets/player_name_spinner.hpp"
|
||||||
@ -217,7 +218,8 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
|||||||
kart_model.getFrame(KartModel::AF_WIN_END) :
|
kart_model.getFrame(KartModel::AF_WIN_END) :
|
||||||
kart_model.getBaseFrame(),
|
kart_model.getBaseFrame(),
|
||||||
kart_model.getAnimationSpeed());
|
kart_model.getAnimationSpeed());
|
||||||
|
m_model_view->getModelViewRenderInfo()->setHue(
|
||||||
|
m_associated_player->getConstProfile()->getDefaultKartColor());
|
||||||
model_location.setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
model_location.setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
||||||
for (unsigned i = 0; i < 4; i++)
|
for (unsigned i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
@ -642,6 +644,8 @@ GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(Widget* w,
|
|||||||
m_handicapped = false;
|
m_handicapped = false;
|
||||||
m_model_view->unsetBadge(ANCHOR_BADGE);
|
m_model_view->unsetBadge(ANCHOR_BADGE);
|
||||||
}
|
}
|
||||||
|
m_model_view->getModelViewRenderInfo()->setHue(
|
||||||
|
m_associated_player->getConstProfile()->getDefaultKartColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
|
|
||||||
#include "graphics/render_info.hpp"
|
|
||||||
#include "items/powerup.hpp"
|
#include "items/powerup.hpp"
|
||||||
#include "karts/abstract_kart_animation.hpp"
|
#include "karts/abstract_kart_animation.hpp"
|
||||||
#include "karts/kart_model.hpp"
|
#include "karts/kart_model.hpp"
|
||||||
@ -36,7 +35,8 @@
|
|||||||
AbstractKart::AbstractKart(const std::string& ident,
|
AbstractKart::AbstractKart(const std::string& ident,
|
||||||
int world_kart_id, int position,
|
int world_kart_id, int position,
|
||||||
const btTransform& init_transform,
|
const btTransform& init_transform,
|
||||||
PerPlayerDifficulty difficulty, KartRenderType krt)
|
PerPlayerDifficulty difficulty,
|
||||||
|
std::shared_ptr<RenderInfo> ri)
|
||||||
: Moveable()
|
: Moveable()
|
||||||
{
|
{
|
||||||
m_world_kart_id = world_kart_id;
|
m_world_kart_id = world_kart_id;
|
||||||
@ -60,7 +60,7 @@ AbstractKart::AbstractKart(const std::string& ident,
|
|||||||
// released when the kart is deleted, but since the original
|
// released when the kart is deleted, but since the original
|
||||||
// kart_model is stored in the kart_properties all the time,
|
// kart_model is stored in the kart_properties all the time,
|
||||||
// there is no risk of a mesh being deleted to early.
|
// there is no risk of a mesh being deleted to early.
|
||||||
m_kart_model = m_kart_properties->getKartModelCopy(krt);
|
m_kart_model = m_kart_properties->getKartModelCopy(ri);
|
||||||
m_kart_width = m_kart_model->getWidth();
|
m_kart_width = m_kart_model->getWidth();
|
||||||
m_kart_height = m_kart_model->getHeight();
|
m_kart_height = m_kart_model->getHeight();
|
||||||
m_kart_length = m_kart_model->getLength();
|
m_kart_length = m_kart_model->getLength();
|
||||||
|
@ -45,12 +45,12 @@ class KartModel;
|
|||||||
class KartProperties;
|
class KartProperties;
|
||||||
class Material;
|
class Material;
|
||||||
class Powerup;
|
class Powerup;
|
||||||
|
class RenderInfo;
|
||||||
class SFXBuffer;
|
class SFXBuffer;
|
||||||
class Skidding;
|
class Skidding;
|
||||||
class SlipStream;
|
class SlipStream;
|
||||||
class TerrainInfo;
|
class TerrainInfo;
|
||||||
|
|
||||||
enum KartRenderType: unsigned int;
|
|
||||||
|
|
||||||
/** An abstract interface for the actual karts. Some functions are actually
|
/** An abstract interface for the actual karts. Some functions are actually
|
||||||
* implemented here in order to allow inlining.
|
* implemented here in order to allow inlining.
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
int world_kart_id,
|
int world_kart_id,
|
||||||
int position, const btTransform& init_transform,
|
int position, const btTransform& init_transform,
|
||||||
PerPlayerDifficulty difficulty,
|
PerPlayerDifficulty difficulty,
|
||||||
KartRenderType krt);
|
std::shared_ptr<RenderInfo> ri);
|
||||||
virtual ~AbstractKart();
|
virtual ~AbstractKart();
|
||||||
virtual core::stringw getName() const;
|
virtual core::stringw getName() const;
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
@ -29,7 +29,8 @@ GhostKart::GhostKart(const std::string& ident, unsigned int world_kart_id,
|
|||||||
int position)
|
int position)
|
||||||
: Kart(ident, world_kart_id,
|
: Kart(ident, world_kart_id,
|
||||||
position, btTransform(btQuaternion(0, 0, 0, 1)),
|
position, btTransform(btQuaternion(0, 0, 0, 1)),
|
||||||
PLAYER_DIFFICULTY_NORMAL, KRT_TRANSPARENT)
|
PLAYER_DIFFICULTY_NORMAL,
|
||||||
|
std::make_shared<RenderInfo>(0.0f, true/*transparent*/))
|
||||||
{
|
{
|
||||||
} // GhostKart
|
} // GhostKart
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include "graphics/material_manager.hpp"
|
#include "graphics/material_manager.hpp"
|
||||||
#include "graphics/particle_emitter.hpp"
|
#include "graphics/particle_emitter.hpp"
|
||||||
#include "graphics/particle_kind_manager.hpp"
|
#include "graphics/particle_kind_manager.hpp"
|
||||||
#include "graphics/render_info.hpp"
|
|
||||||
#include "graphics/shadow.hpp"
|
#include "graphics/shadow.hpp"
|
||||||
#include "graphics/skid_marks.hpp"
|
#include "graphics/skid_marks.hpp"
|
||||||
#include "graphics/slip_stream.hpp"
|
#include "graphics/slip_stream.hpp"
|
||||||
@ -106,9 +105,9 @@
|
|||||||
*/
|
*/
|
||||||
Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||||
int position, const btTransform& init_transform,
|
int position, const btTransform& init_transform,
|
||||||
PerPlayerDifficulty difficulty, KartRenderType krt)
|
PerPlayerDifficulty difficulty, std::shared_ptr<RenderInfo> ri)
|
||||||
: AbstractKart(ident, world_kart_id, position, init_transform,
|
: AbstractKart(ident, world_kart_id, position, init_transform,
|
||||||
difficulty, krt)
|
difficulty, ri)
|
||||||
|
|
||||||
#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
|
#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
|
||||||
# pragma warning(1:4355)
|
# pragma warning(1:4355)
|
||||||
|
@ -53,8 +53,6 @@ class SlipStream;
|
|||||||
class Stars;
|
class Stars;
|
||||||
class TerrainInfo;
|
class TerrainInfo;
|
||||||
|
|
||||||
enum KartRenderType: unsigned int;
|
|
||||||
|
|
||||||
/** The main kart class. All type of karts are of this object, but with
|
/** The main kart class. All type of karts are of this object, but with
|
||||||
* different controllers. The controllers are what turn a kart into a
|
* different controllers. The controllers are what turn a kart into a
|
||||||
* player kart (i.e. the controller handle input), or an AI kart (the
|
* player kart (i.e. the controller handle input), or an AI kart (the
|
||||||
@ -247,7 +245,7 @@ public:
|
|||||||
Kart(const std::string& ident, unsigned int world_kart_id,
|
Kart(const std::string& ident, unsigned int world_kart_id,
|
||||||
int position, const btTransform& init_transform,
|
int position, const btTransform& init_transform,
|
||||||
PerPlayerDifficulty difficulty,
|
PerPlayerDifficulty difficulty,
|
||||||
KartRenderType krt);
|
std::shared_ptr<RenderInfo> ri);
|
||||||
virtual ~Kart();
|
virtual ~Kart();
|
||||||
virtual void init(RaceManager::KartType type);
|
virtual void init(RaceManager::KartType type);
|
||||||
virtual void kartIsInRestNow();
|
virtual void kartIsInRestNow();
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "graphics/material.hpp"
|
#include "graphics/material.hpp"
|
||||||
#include "graphics/material_manager.hpp"
|
#include "graphics/material_manager.hpp"
|
||||||
#include "graphics/mesh_tools.hpp"
|
#include "graphics/mesh_tools.hpp"
|
||||||
#include "graphics/render_info.hpp"
|
|
||||||
#include "graphics/sp/sp_animation.hpp"
|
#include "graphics/sp/sp_animation.hpp"
|
||||||
#include "graphics/sp/sp_mesh.hpp"
|
#include "graphics/sp/sp_mesh.hpp"
|
||||||
#include "graphics/sp/sp_mesh_buffer.hpp"
|
#include "graphics/sp/sp_mesh_buffer.hpp"
|
||||||
@ -132,7 +131,6 @@ KartModel::KartModel(bool is_master)
|
|||||||
m_animation_speed = 25;
|
m_animation_speed = 25;
|
||||||
m_current_animation = AF_DEFAULT;
|
m_current_animation = AF_DEFAULT;
|
||||||
m_play_non_loop = false;
|
m_play_non_loop = false;
|
||||||
m_krt = KRT_DEFAULT;
|
|
||||||
m_support_colorization = false;
|
m_support_colorization = false;
|
||||||
} // KartModel
|
} // KartModel
|
||||||
|
|
||||||
@ -316,7 +314,7 @@ KartModel::~KartModel()
|
|||||||
* It is also marked not to be a master copy, so attachModel can be called
|
* It is also marked not to be a master copy, so attachModel can be called
|
||||||
* for this instance.
|
* for this instance.
|
||||||
*/
|
*/
|
||||||
KartModel* KartModel::makeCopy(KartRenderType krt)
|
KartModel* KartModel::makeCopy(std::shared_ptr<RenderInfo> ri)
|
||||||
{
|
{
|
||||||
// Make sure that we are copying from a master objects, and
|
// Make sure that we are copying from a master objects, and
|
||||||
// that there is indeed no animated node defined here ...
|
// that there is indeed no animated node defined here ...
|
||||||
@ -337,13 +335,11 @@ KartModel* KartModel::makeCopy(KartRenderType krt)
|
|||||||
km->m_animated_node = NULL;
|
km->m_animated_node = NULL;
|
||||||
km->m_hat_name = m_hat_name;
|
km->m_hat_name = m_hat_name;
|
||||||
km->m_hat_bone = m_hat_bone;
|
km->m_hat_bone = m_hat_bone;
|
||||||
km->m_krt = krt;
|
|
||||||
km->m_support_colorization = m_support_colorization;
|
km->m_support_colorization = m_support_colorization;
|
||||||
km->m_render_info = std::make_shared<RenderInfo>();
|
km->m_render_info = ri;
|
||||||
km->m_inverse_bone_matrices = m_inverse_bone_matrices;
|
km->m_inverse_bone_matrices = m_inverse_bone_matrices;
|
||||||
km->m_version = m_version;
|
km->m_version = m_version;
|
||||||
km->m_exhaust_xml = m_exhaust_xml;
|
km->m_exhaust_xml = m_exhaust_xml;
|
||||||
km->m_render_info->setKartModelRenderInfo(krt);
|
|
||||||
|
|
||||||
km->m_nitro_emitter_position[0] = m_nitro_emitter_position[0];
|
km->m_nitro_emitter_position[0] = m_nitro_emitter_position[0];
|
||||||
km->m_nitro_emitter_position[1] = m_nitro_emitter_position[1];
|
km->m_nitro_emitter_position[1] = m_nitro_emitter_position[1];
|
||||||
@ -1225,8 +1221,7 @@ void KartModel::resetVisualWheelPosition()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
std::shared_ptr<RenderInfo> KartModel::getRenderInfo()
|
std::shared_ptr<RenderInfo> KartModel::getRenderInfo()
|
||||||
{
|
{
|
||||||
return m_support_colorization || m_krt == KRT_TRANSPARENT ?
|
return m_support_colorization ? m_render_info : NULL;
|
||||||
m_render_info : NULL;
|
|
||||||
} // getRenderInfo
|
} // getRenderInfo
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -40,8 +40,6 @@ class KartProperties;
|
|||||||
class RenderInfo;
|
class RenderInfo;
|
||||||
class XMLNode;
|
class XMLNode;
|
||||||
|
|
||||||
enum KartRenderType: unsigned int;
|
|
||||||
|
|
||||||
/** A speed-weighted object is an object whose characteristics are influenced by the kart's speed */
|
/** A speed-weighted object is an object whose characteristics are influenced by the kart's speed */
|
||||||
struct SpeedWeightedObject
|
struct SpeedWeightedObject
|
||||||
{
|
{
|
||||||
@ -311,11 +309,7 @@ private:
|
|||||||
/** Pointer to the kart object belonging to this kart model. */
|
/** Pointer to the kart object belonging to this kart model. */
|
||||||
AbstractKart* m_kart;
|
AbstractKart* m_kart;
|
||||||
|
|
||||||
/** Tell the render type of this kart model, either colorized (red / blue now)
|
/** For our engine to get the desired hue for colorization. */
|
||||||
* or transparent (ghost kart). */
|
|
||||||
KartRenderType m_krt;
|
|
||||||
|
|
||||||
/** For our engine to get the desired hue / saturation for colorization. */
|
|
||||||
std::shared_ptr<RenderInfo> m_render_info;
|
std::shared_ptr<RenderInfo> m_render_info;
|
||||||
|
|
||||||
/** True if this kart model can be colorization in red / blue (now only
|
/** True if this kart model can be colorization in red / blue (now only
|
||||||
@ -350,7 +344,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
KartModel(bool is_master);
|
KartModel(bool is_master);
|
||||||
~KartModel();
|
~KartModel();
|
||||||
KartModel* makeCopy(KartRenderType krt);
|
KartModel* makeCopy(std::shared_ptr<RenderInfo> ri);
|
||||||
void reset();
|
void reset();
|
||||||
void loadInfo(const XMLNode &node);
|
void loadInfo(const XMLNode &node);
|
||||||
bool loadModels(const KartProperties &kart_properties);
|
bool loadModels(const KartProperties &kart_properties);
|
||||||
|
@ -305,9 +305,9 @@ void KartProperties::load(const std::string &filename, const std::string &node)
|
|||||||
* \param krt The KartRenderType, like default, red, blue or transparent.
|
* \param krt The KartRenderType, like default, red, blue or transparent.
|
||||||
* see the RenderInfo include for details
|
* see the RenderInfo include for details
|
||||||
*/
|
*/
|
||||||
KartModel* KartProperties::getKartModelCopy(KartRenderType krt) const
|
KartModel* KartProperties::getKartModelCopy(std::shared_ptr<RenderInfo> ri) const
|
||||||
{
|
{
|
||||||
return m_kart_model->makeCopy(krt);
|
return m_kart_model->makeCopy(ri);
|
||||||
} // getKartModelCopy
|
} // getKartModelCopy
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -43,9 +43,9 @@ class CachedCharacteristic;
|
|||||||
class CombinedCharacteristic;
|
class CombinedCharacteristic;
|
||||||
class KartModel;
|
class KartModel;
|
||||||
class Material;
|
class Material;
|
||||||
|
class RenderInfo;
|
||||||
class XMLNode;
|
class XMLNode;
|
||||||
|
|
||||||
enum KartRenderType: unsigned int;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief This class stores the properties of a kart.
|
* \brief This class stores the properties of a kart.
|
||||||
@ -241,7 +241,7 @@ public:
|
|||||||
video::ITexture *getMinimapIcon () const {return m_minimap_icon; }
|
video::ITexture *getMinimapIcon () const {return m_minimap_icon; }
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
KartModel* getKartModelCopy(KartRenderType krt) const;
|
KartModel* getKartModelCopy(std::shared_ptr<RenderInfo> ri=nullptr) const;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns a pointer to the main KartModel object. This copy
|
/** Returns a pointer to the main KartModel object. This copy
|
||||||
* should not be modified, not attachModel be called on it. */
|
* should not be modified, not attachModel be called on it. */
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "karts/max_speed.hpp"
|
#include "karts/max_speed.hpp"
|
||||||
#include "karts/skidding.hpp"
|
#include "karts/skidding.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
#include "graphics/render_info.hpp"
|
|
||||||
#include "network/rewind_manager.hpp"
|
#include "network/rewind_manager.hpp"
|
||||||
#include "network/network_string.hpp"
|
#include "network/network_string.hpp"
|
||||||
#include "physics/btKart.hpp"
|
#include "physics/btKart.hpp"
|
||||||
@ -35,10 +34,10 @@
|
|||||||
KartRewinder::KartRewinder(const std::string& ident,unsigned int world_kart_id,
|
KartRewinder::KartRewinder(const std::string& ident,unsigned int world_kart_id,
|
||||||
int position, const btTransform& init_transform,
|
int position, const btTransform& init_transform,
|
||||||
PerPlayerDifficulty difficulty,
|
PerPlayerDifficulty difficulty,
|
||||||
KartRenderType krt)
|
std::shared_ptr<RenderInfo> ri)
|
||||||
: Rewinder(/*can_be_destroyed*/ false)
|
: Rewinder(/*can_be_destroyed*/ false)
|
||||||
, Kart(ident, world_kart_id, position, init_transform, difficulty,
|
, Kart(ident, world_kart_id, position, init_transform, difficulty,
|
||||||
krt)
|
ri)
|
||||||
{
|
{
|
||||||
} // KartRewinder
|
} // KartRewinder
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
class AbstractKart;
|
class AbstractKart;
|
||||||
class BareNetworkString;
|
class BareNetworkString;
|
||||||
|
|
||||||
enum KartRenderType: unsigned int;
|
|
||||||
|
|
||||||
class KartRewinder : public Rewinder, public Kart
|
class KartRewinder : public Rewinder, public Kart
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -40,7 +38,7 @@ public:
|
|||||||
unsigned int world_kart_id,
|
unsigned int world_kart_id,
|
||||||
int position, const btTransform& init_transform,
|
int position, const btTransform& init_transform,
|
||||||
PerPlayerDifficulty difficulty,
|
PerPlayerDifficulty difficulty,
|
||||||
KartRenderType krt);
|
std::shared_ptr<RenderInfo> ri);
|
||||||
virtual ~KartRewinder() {};
|
virtual ~KartRewinder() {};
|
||||||
virtual BareNetworkString* saveState() const;
|
virtual BareNetworkString* saveState() const;
|
||||||
void reset();
|
void reset();
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#include "karts/kart_with_stats.hpp"
|
#include "karts/kart_with_stats.hpp"
|
||||||
|
|
||||||
#include "graphics/render_info.hpp"
|
|
||||||
#include "karts/explosion_animation.hpp"
|
#include "karts/explosion_animation.hpp"
|
||||||
#include "karts/rescue_animation.hpp"
|
#include "karts/rescue_animation.hpp"
|
||||||
#include "items/item.hpp"
|
#include "items/item.hpp"
|
||||||
@ -29,7 +28,7 @@ KartWithStats::KartWithStats(const std::string& ident,
|
|||||||
int position, const btTransform& init_transform,
|
int position, const btTransform& init_transform,
|
||||||
PerPlayerDifficulty difficulty)
|
PerPlayerDifficulty difficulty)
|
||||||
: Kart(ident, world_kart_id, position,
|
: Kart(ident, world_kart_id, position,
|
||||||
init_transform, difficulty, KRT_DEFAULT)
|
init_transform, difficulty, nullptr)
|
||||||
{
|
{
|
||||||
} // KartWithStats
|
} // KartWithStats
|
||||||
|
|
||||||
|
@ -413,7 +413,8 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
|
|||||||
m_kart_position_map[index] = (unsigned)(pos_index - 1);
|
m_kart_position_map[index] = (unsigned)(pos_index - 1);
|
||||||
|
|
||||||
AbstractKart *new_kart = new Kart(kart_ident, index, position, init_pos,
|
AbstractKart *new_kart = new Kart(kart_ident, index, position, init_pos,
|
||||||
difficulty, team == SOCCER_TEAM_BLUE ? KRT_BLUE : KRT_RED);
|
difficulty, team == SOCCER_TEAM_BLUE ?
|
||||||
|
std::make_shared<RenderInfo>(0.66f) : std::make_shared<RenderInfo>(1.0f));
|
||||||
new_kart->init(race_manager->getKartType(index));
|
new_kart->init(race_manager->getKartType(index));
|
||||||
Controller *controller = NULL;
|
Controller *controller = NULL;
|
||||||
|
|
||||||
|
@ -724,7 +724,7 @@ void ThreeStrikesBattle::loadCustomModels()
|
|||||||
{
|
{
|
||||||
AbstractKart* sta = new Kart(sta_list[i], (int)m_karts.size(),
|
AbstractKart* sta = new Kart(sta_list[i], (int)m_karts.size(),
|
||||||
(int)m_karts.size() + 1, pos[i], PLAYER_DIFFICULTY_NORMAL,
|
(int)m_karts.size() + 1, pos[i], PLAYER_DIFFICULTY_NORMAL,
|
||||||
KRT_RED);
|
std::make_shared<RenderInfo>(1.0f));
|
||||||
sta->init(RaceManager::KartType::KT_SPARE_TIRE);
|
sta->init(RaceManager::KartType::KT_SPARE_TIRE);
|
||||||
sta->setController(new SpareTireAI(sta));
|
sta->setController(new SpareTireAI(sta));
|
||||||
|
|
||||||
|
@ -337,36 +337,47 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
|
|||||||
if (race_manager->hasGhostKarts())
|
if (race_manager->hasGhostKarts())
|
||||||
gk = ReplayPlay::get()->getNumGhostKart();
|
gk = ReplayPlay::get()->getNumGhostKart();
|
||||||
|
|
||||||
|
std::shared_ptr<RenderInfo> ri = std::make_shared<RenderInfo>();
|
||||||
int position = index+1;
|
int position = index+1;
|
||||||
btTransform init_pos = getStartTransform(index - gk);
|
btTransform init_pos = getStartTransform(index - gk);
|
||||||
AbstractKart *new_kart;
|
AbstractKart *new_kart;
|
||||||
if (RewindManager::get()->isEnabled())
|
if (RewindManager::get()->isEnabled())
|
||||||
new_kart = new KartRewinder(kart_ident, index, position, init_pos,
|
new_kart = new KartRewinder(kart_ident, index, position, init_pos,
|
||||||
difficulty, KRT_DEFAULT);
|
difficulty, ri);
|
||||||
else
|
else
|
||||||
new_kart = new Kart(kart_ident, index, position, init_pos, difficulty,
|
new_kart = new Kart(kart_ident, index, position, init_pos, difficulty,
|
||||||
KRT_DEFAULT);
|
ri);
|
||||||
|
|
||||||
new_kart->init(race_manager->getKartType(index));
|
new_kart->init(race_manager->getKartType(index));
|
||||||
Controller *controller = NULL;
|
Controller *controller = NULL;
|
||||||
switch(kart_type)
|
switch(kart_type)
|
||||||
{
|
{
|
||||||
case RaceManager::KT_PLAYER:
|
case RaceManager::KT_PLAYER:
|
||||||
|
{
|
||||||
controller = new LocalPlayerController(new_kart,
|
controller = new LocalPlayerController(new_kart,
|
||||||
StateManager::get()->getActivePlayer(local_player_id));
|
StateManager::get()->getActivePlayer(local_player_id));
|
||||||
|
const float hue = StateManager::get()->getActivePlayer(local_player_id)
|
||||||
|
->getConstProfile()->getDefaultKartColor();
|
||||||
|
if (hue > 0.0f)
|
||||||
|
{
|
||||||
|
ri->setHue(hue);
|
||||||
|
}
|
||||||
m_num_players ++;
|
m_num_players ++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case RaceManager::KT_NETWORK_PLAYER:
|
case RaceManager::KT_NETWORK_PLAYER:
|
||||||
|
{
|
||||||
controller = new NetworkPlayerController(new_kart);
|
controller = new NetworkPlayerController(new_kart);
|
||||||
m_num_players++;
|
m_num_players++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case RaceManager::KT_AI:
|
case RaceManager::KT_AI:
|
||||||
|
{
|
||||||
controller = loadAIController(new_kart);
|
controller = loadAIController(new_kart);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case RaceManager::KT_GHOST:
|
case RaceManager::KT_GHOST:
|
||||||
break;
|
|
||||||
case RaceManager::KT_LEADER:
|
case RaceManager::KT_LEADER:
|
||||||
break;
|
|
||||||
case RaceManager::KT_SPARE_TIRE:
|
case RaceManager::KT_SPARE_TIRE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
137
src/states_screens/dialogs/kart_color_slider_dialog.cpp
Normal file
137
src/states_screens/dialogs/kart_color_slider_dialog.cpp
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
|
// Copyright (C) 2010-2015 Marianne Gagnon
|
||||||
|
//
|
||||||
|
// 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/kart_color_slider_dialog.hpp"
|
||||||
|
|
||||||
|
#include "config/player_profile.hpp"
|
||||||
|
#include "config/user_config.hpp"
|
||||||
|
#include "karts/kart_model.hpp"
|
||||||
|
#include "karts/kart_properties.hpp"
|
||||||
|
#include "karts/kart_properties_manager.hpp"
|
||||||
|
#include "graphics/irr_driver.hpp"
|
||||||
|
#include "graphics/render_info.hpp"
|
||||||
|
#include "guiengine/engine.hpp"
|
||||||
|
#include "guiengine/widgets/button_widget.hpp"
|
||||||
|
#include "guiengine/widgets/label_widget.hpp"
|
||||||
|
#include "guiengine/widgets/model_view_widget.hpp"
|
||||||
|
#include "guiengine/widgets/spinner_widget.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace GUIEngine;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
KartColorSliderDialog::KartColorSliderDialog(PlayerProfile* pp)
|
||||||
|
: ModalDialog(0.75f, 0.75f, MODAL_DIALOG_LOCATION_BOTTOM)
|
||||||
|
{
|
||||||
|
loadFromFile("kart_color_slider.stkgui");
|
||||||
|
m_player_profile = pp;
|
||||||
|
getWidget<SpinnerWidget>("color-slider")->setValue(int(pp->getDefaultKartColor() * 100.0f));
|
||||||
|
m_model_view->getModelViewRenderInfo()->setHue(
|
||||||
|
float(getWidget<SpinnerWidget>("color-slider")->getValue()) / 100.0f);
|
||||||
|
} // KartColorSliderDialog
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
void KartColorSliderDialog::beforeAddingWidgets()
|
||||||
|
{
|
||||||
|
Widget* kart_screen = getWidget<Widget>("kart-screen");
|
||||||
|
m_model_view = new ModelViewWidget(irr_driver->getActualScreenSize().Height > 1280 ||
|
||||||
|
irr_driver->getActualScreenSize().Width > 1280 ? 1024 : 512);
|
||||||
|
|
||||||
|
const KartProperties* props = kart_properties_manager->getKart(UserConfigParams::m_default_kart);
|
||||||
|
const KartModel& kart_model = props->getMasterKartModel();
|
||||||
|
|
||||||
|
core::matrix4 model_location;
|
||||||
|
|
||||||
|
float scale = 35.0f;
|
||||||
|
if (kart_model.getLength() > 1.45f)
|
||||||
|
{
|
||||||
|
// if kart is too long, size it down a bit so that it fits
|
||||||
|
scale = 30.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
model_location.setScale(core::vector3df(scale, scale, scale));
|
||||||
|
|
||||||
|
// Add the kart model (including wheels and speed weight objects)
|
||||||
|
const bool has_win_anime =
|
||||||
|
(((kart_model.getFrame(KartModel::AF_WIN_LOOP_START) > -1 ||
|
||||||
|
kart_model.getFrame(KartModel::AF_WIN_START) > -1) &&
|
||||||
|
kart_model.getFrame(KartModel::AF_WIN_END) > -1) ||
|
||||||
|
(kart_model.getFrame(KartModel::AF_SELECTION_START) > -1 &&
|
||||||
|
kart_model.getFrame(KartModel::AF_SELECTION_END) > -1));
|
||||||
|
m_model_view->addModel(kart_model.getModel(), model_location,
|
||||||
|
has_win_anime ?
|
||||||
|
kart_model.getFrame(KartModel::AF_SELECTION_START) > -1 ?
|
||||||
|
kart_model.getFrame(KartModel::AF_SELECTION_START) :
|
||||||
|
kart_model.getFrame(KartModel::AF_WIN_LOOP_START) > -1 ?
|
||||||
|
kart_model.getFrame(KartModel::AF_WIN_LOOP_START) :
|
||||||
|
kart_model.getFrame(KartModel::AF_WIN_START) :
|
||||||
|
kart_model.getBaseFrame(),
|
||||||
|
has_win_anime ?
|
||||||
|
kart_model.getFrame(KartModel::AF_SELECTION_END) > -1 ?
|
||||||
|
kart_model.getFrame(KartModel::AF_SELECTION_END) :
|
||||||
|
kart_model.getFrame(KartModel::AF_WIN_END) :
|
||||||
|
kart_model.getBaseFrame(),
|
||||||
|
kart_model.getAnimationSpeed());
|
||||||
|
|
||||||
|
model_location.setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
||||||
|
for (unsigned i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
model_location.setTranslation(kart_model
|
||||||
|
.getWheelGraphicsPosition(i).toIrrVector());
|
||||||
|
m_model_view->addModel(kart_model.getWheelModel(i), model_location);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < kart_model.getSpeedWeightedObjectsCount();
|
||||||
|
i++)
|
||||||
|
{
|
||||||
|
const SpeedWeightedObject& obj =
|
||||||
|
kart_model.getSpeedWeightedObject(i);
|
||||||
|
core::matrix4 swol = obj.m_location;
|
||||||
|
if (!obj.m_bone_name.empty())
|
||||||
|
{
|
||||||
|
core::matrix4 inv =
|
||||||
|
kart_model.getInverseBoneMatrix(obj.m_bone_name);
|
||||||
|
swol = inv * obj.m_location;
|
||||||
|
}
|
||||||
|
m_model_view->addModel(obj.m_model, swol, -1, -1, 0.0f,
|
||||||
|
obj.m_bone_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_model_view->setRotateContinuously(35.0f);
|
||||||
|
m_model_view->update(0);
|
||||||
|
kart_screen->getChildren().push_back(m_model_view);
|
||||||
|
m_model_view->move(kart_screen->m_w / 2, kart_screen->m_h / 2,
|
||||||
|
kart_screen->m_w / 2, kart_screen->m_w / 2);
|
||||||
|
} // beforeAddingWidgets
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
GUIEngine::EventPropagation KartColorSliderDialog::processEvent(const std::string& eventSource)
|
||||||
|
{
|
||||||
|
if (eventSource == "color-slider")
|
||||||
|
{
|
||||||
|
m_model_view->getModelViewRenderInfo()->setHue(
|
||||||
|
float(getWidget<SpinnerWidget>("color-slider")->getValue()) / 100.0f);
|
||||||
|
}
|
||||||
|
else if (eventSource == "close")
|
||||||
|
{
|
||||||
|
float color = float(getWidget<SpinnerWidget>("color-slider")->getValue());
|
||||||
|
m_player_profile->setDefaultKartColor(color / 100.0f);
|
||||||
|
ModalDialog::dismiss();
|
||||||
|
return GUIEngine::EVENT_BLOCK;
|
||||||
|
}
|
||||||
|
return GUIEngine::EVENT_LET;
|
||||||
|
} // processEvent
|
49
src/states_screens/dialogs/kart_color_slider_dialog.hpp
Normal file
49
src/states_screens/dialogs/kart_color_slider_dialog.hpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// SuperTuxKart - a fun racing game with go-kart
|
||||||
|
// Copyright (C) 2018 SuperTuxKart-Team
|
||||||
|
//
|
||||||
|
// 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_KART_COLOR_SLIDER_HPP
|
||||||
|
#define HEADER_KART_COLOR_SLIDER_HPP
|
||||||
|
|
||||||
|
#include "guiengine/modaldialog.hpp"
|
||||||
|
#include "utils/cpp2011.hpp"
|
||||||
|
|
||||||
|
class PlayerProfile;
|
||||||
|
namespace GUIEngine { class ModelViewWidget; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \ingroup states_screens
|
||||||
|
*/
|
||||||
|
class KartColorSliderDialog : public GUIEngine::ModalDialog
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
PlayerProfile* m_player_profile;
|
||||||
|
|
||||||
|
GUIEngine::ModelViewWidget* m_model_view;
|
||||||
|
|
||||||
|
public:
|
||||||
|
KartColorSliderDialog(PlayerProfile* pp);
|
||||||
|
|
||||||
|
~KartColorSliderDialog() {}
|
||||||
|
|
||||||
|
virtual void beforeAddingWidgets() OVERRIDE;
|
||||||
|
|
||||||
|
GUIEngine::EventPropagation processEvent(const std::string& eventSource) OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -25,7 +25,6 @@
|
|||||||
#include "challenges/unlock_manager.hpp"
|
#include "challenges/unlock_manager.hpp"
|
||||||
#include "config/player_manager.hpp"
|
#include "config/player_manager.hpp"
|
||||||
#include "graphics/central_settings.hpp"
|
#include "graphics/central_settings.hpp"
|
||||||
#include "graphics/render_info.hpp"
|
|
||||||
#include "graphics/sp/sp_base.hpp"
|
#include "graphics/sp/sp_base.hpp"
|
||||||
#include "graphics/sp/sp_mesh.hpp"
|
#include "graphics/sp/sp_mesh.hpp"
|
||||||
#include "graphics/sp/sp_mesh_buffer.hpp"
|
#include "graphics/sp/sp_mesh_buffer.hpp"
|
||||||
@ -334,7 +333,7 @@ void FeatureUnlockedCutScene::init()
|
|||||||
else if (m_unlocked_stuff[n].m_unlocked_kart != NULL)
|
else if (m_unlocked_stuff[n].m_unlocked_kart != NULL)
|
||||||
{
|
{
|
||||||
KartModel *kart_model =
|
KartModel *kart_model =
|
||||||
m_unlocked_stuff[n].m_unlocked_kart->getKartModelCopy(KRT_DEFAULT);
|
m_unlocked_stuff[n].m_unlocked_kart->getKartModelCopy();
|
||||||
m_all_kart_models.push_back(kart_model);
|
m_all_kart_models.push_back(kart_model);
|
||||||
m_unlocked_stuff[n].m_root_gift_node = kart_model->attachModel(true, false);
|
m_unlocked_stuff[n].m_root_gift_node = kart_model->attachModel(true, false);
|
||||||
m_unlocked_stuff[n].m_scale = 5.0f;
|
m_unlocked_stuff[n].m_scale = 5.0f;
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "config/player_manager.hpp"
|
#include "config/player_manager.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/lod_node.hpp"
|
#include "graphics/lod_node.hpp"
|
||||||
#include "graphics/render_info.hpp"
|
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
#include "guiengine/scalable_font.hpp"
|
#include "guiengine/scalable_font.hpp"
|
||||||
#include "guiengine/widgets/button_widget.hpp"
|
#include "guiengine/widgets/button_widget.hpp"
|
||||||
@ -184,7 +183,7 @@ void GrandPrixLose::setKarts(std::vector<std::string> ident_arg)
|
|||||||
const KartProperties* kart = kart_properties_manager->getKart(ident_arg[n]);
|
const KartProperties* kart = kart_properties_manager->getKart(ident_arg[n]);
|
||||||
if (kart != NULL)
|
if (kart != NULL)
|
||||||
{
|
{
|
||||||
KartModel* kart_model = kart->getKartModelCopy(KRT_DEFAULT);
|
KartModel* kart_model = kart->getKartModelCopy();
|
||||||
m_all_kart_models.push_back(kart_model);
|
m_all_kart_models.push_back(kart_model);
|
||||||
scene::ISceneNode* kart_main_node = kart_model->attachModel(true, false);
|
scene::ISceneNode* kart_main_node = kart_model->attachModel(true, false);
|
||||||
LODNode* lnode = dynamic_cast<LODNode*>(kart_main_node);
|
LODNode* lnode = dynamic_cast<LODNode*>(kart_main_node);
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "config/player_manager.hpp"
|
#include "config/player_manager.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/lod_node.hpp"
|
#include "graphics/lod_node.hpp"
|
||||||
#include "graphics/render_info.hpp"
|
|
||||||
#include "guiengine/engine.hpp"
|
#include "guiengine/engine.hpp"
|
||||||
#include "guiengine/scalable_font.hpp"
|
#include "guiengine/scalable_font.hpp"
|
||||||
#include "guiengine/widgets/button_widget.hpp"
|
#include "guiengine/widgets/button_widget.hpp"
|
||||||
@ -345,7 +344,7 @@ void GrandPrixWin::setKarts(const std::string idents_arg[3])
|
|||||||
const KartProperties* kp = kart_properties_manager->getKart(idents[i]);
|
const KartProperties* kp = kart_properties_manager->getKart(idents[i]);
|
||||||
if (kp == NULL) continue;
|
if (kp == NULL) continue;
|
||||||
|
|
||||||
KartModel* kart_model = kp->getKartModelCopy(KRT_DEFAULT);
|
KartModel* kart_model = kp->getKartModelCopy();
|
||||||
m_all_kart_models.push_back(kart_model);
|
m_all_kart_models.push_back(kart_model);
|
||||||
scene::ISceneNode* kart_main_node = kart_model->attachModel(true, false);
|
scene::ISceneNode* kart_main_node = kart_model->attachModel(true, false);
|
||||||
LODNode* lnode = dynamic_cast<LODNode*>(kart_main_node);
|
LODNode* lnode = dynamic_cast<LODNode*>(kart_main_node);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "config/player_manager.hpp"
|
#include "config/player_manager.hpp"
|
||||||
#include "config/user_config.hpp"
|
#include "config/user_config.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
|
#include "graphics/render_info.hpp"
|
||||||
#include "guiengine/widgets/bubble_widget.hpp"
|
#include "guiengine/widgets/bubble_widget.hpp"
|
||||||
#include "guiengine/widgets/kart_stats_widget.hpp"
|
#include "guiengine/widgets/kart_stats_widget.hpp"
|
||||||
#include "guiengine/widgets/model_view_widget.hpp"
|
#include "guiengine/widgets/model_view_widget.hpp"
|
||||||
@ -202,7 +203,9 @@ void KartHoverListener::onSelectionChanged(DynamicRibbonWidget* theWidget,
|
|||||||
if (m_parent->m_kart_widgets[player_id].getKartInternalName() == selectionID)
|
if (m_parent->m_kart_widgets[player_id].getKartInternalName() == selectionID)
|
||||||
return; // already selected
|
return; // already selected
|
||||||
|
|
||||||
m_parent->updateKartWidgetModel(player_id, selectionID, selectionText);
|
m_parent->updateKartWidgetModel(player_id, selectionID, selectionText,
|
||||||
|
m_parent->m_kart_widgets[player_id].getAssociatedPlayer()->getProfile()
|
||||||
|
->getDefaultKartColor());
|
||||||
m_parent->m_kart_widgets[player_id].setKartInternalName(selectionID);
|
m_parent->m_kart_widgets[player_id].setKartInternalName(selectionID);
|
||||||
m_parent->updateKartStats(player_id, selectionID);
|
m_parent->updateKartStats(player_id, selectionID);
|
||||||
m_parent->validateKartChoices();
|
m_parent->validateKartChoices();
|
||||||
@ -821,7 +824,7 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id,
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void KartSelectionScreen::updateKartWidgetModel(int widget_id,
|
void KartSelectionScreen::updateKartWidgetModel(int widget_id,
|
||||||
const std::string& selection,
|
const std::string& selection,
|
||||||
const irr::core::stringw& selectionText)
|
const irr::core::stringw& selectionText, float kart_color)
|
||||||
{
|
{
|
||||||
// Update the displayed model
|
// Update the displayed model
|
||||||
ModelViewWidget* w3 = m_kart_widgets[widget_id].m_model_view;
|
ModelViewWidget* w3 = m_kart_widgets[widget_id].m_model_view;
|
||||||
@ -907,6 +910,7 @@ void KartSelectionScreen::updateKartWidgetModel(int widget_id,
|
|||||||
kart_model.getBaseFrame(),
|
kart_model.getBaseFrame(),
|
||||||
kart_model.getAnimationSpeed());
|
kart_model.getAnimationSpeed());
|
||||||
|
|
||||||
|
w3->getModelViewRenderInfo()->setHue(kart_color);
|
||||||
model_location.setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
model_location.setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
||||||
for (unsigned i = 0; i < 4; i++)
|
for (unsigned i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,8 @@ protected:
|
|||||||
* user validates */
|
* user validates */
|
||||||
void updateKartWidgetModel(int widget_id,
|
void updateKartWidgetModel(int widget_id,
|
||||||
const std::string& selection,
|
const std::string& selection,
|
||||||
const irr::core::stringw& selectionText);
|
const irr::core::stringw& selectionText,
|
||||||
|
float kart_color);
|
||||||
|
|
||||||
/** Adds a message to the screen which indicates that players must press fire to join. */
|
/** Adds a message to the screen which indicates that players must press fire to join. */
|
||||||
void addMultiplayerMessage();
|
void addMultiplayerMessage();
|
||||||
|
@ -169,7 +169,8 @@ void NetworkKartSelectionScreen::playerSelected(uint8_t player_id,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
KartSelectionScreen::updateKartWidgetModel(widget_id, kart_name,
|
KartSelectionScreen::updateKartWidgetModel(widget_id, kart_name,
|
||||||
irr::core::stringw(kart_name.c_str()));
|
irr::core::stringw(kart_name.c_str()),
|
||||||
|
/*Todo get color*/0.0f);
|
||||||
KartSelectionScreen::updateKartStats(widget_id, kart_name);
|
KartSelectionScreen::updateKartStats(widget_id, kart_name);
|
||||||
m_kart_widgets[widget_id].setKartInternalName(kart_name);
|
m_kart_widgets[widget_id].setKartInternalName(kart_name);
|
||||||
m_kart_widgets[widget_id].markAsReady(); // mark player ready
|
m_kart_widgets[widget_id].markAsReady(); // mark player ready
|
||||||
|
@ -157,8 +157,8 @@ void SoccerSetupScreen::beforeAddingWidget()
|
|||||||
info.support_colorization = kart_model.supportColorization();
|
info.support_colorization = kart_model.supportColorization();
|
||||||
if (info.support_colorization)
|
if (info.support_colorization)
|
||||||
{
|
{
|
||||||
kart_view->getModelViewRenderInfo()->setKartModelRenderInfo
|
kart_view->getModelViewRenderInfo()->setHue
|
||||||
(info.team == SOCCER_TEAM_BLUE ? KRT_BLUE : KRT_RED);
|
(info.team == SOCCER_TEAM_BLUE ? 0.66f : 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
core::matrix4 model_location;
|
core::matrix4 model_location;
|
||||||
@ -277,9 +277,9 @@ void SoccerSetupScreen::changeTeam(int player_id, SoccerTeam team)
|
|||||||
// Change the kart color
|
// Change the kart color
|
||||||
if (m_kart_view_info[player_id].support_colorization)
|
if (m_kart_view_info[player_id].support_colorization)
|
||||||
{
|
{
|
||||||
KartRenderType krt = team == SOCCER_TEAM_RED ? KRT_RED : KRT_BLUE;
|
const float hue = team == SOCCER_TEAM_RED ? 1.0f : 0.66f;
|
||||||
m_kart_view_info[player_id].view->getModelViewRenderInfo()
|
m_kart_view_info[player_id].view->getModelViewRenderInfo()
|
||||||
->setKartModelRenderInfo(krt);
|
->setHue(hue);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_kart_view_info.size(); i++)
|
for (unsigned int i = 0; i < m_kart_view_info.size(); i++)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "guiengine/widgets/list_widget.hpp"
|
#include "guiengine/widgets/list_widget.hpp"
|
||||||
#include "guiengine/widgets/text_box_widget.hpp"
|
#include "guiengine/widgets/text_box_widget.hpp"
|
||||||
#include "states_screens/dialogs/message_dialog.hpp"
|
#include "states_screens/dialogs/message_dialog.hpp"
|
||||||
|
#include "states_screens/dialogs/kart_color_slider_dialog.hpp"
|
||||||
#include "states_screens/dialogs/recovery_dialog.hpp"
|
#include "states_screens/dialogs/recovery_dialog.hpp"
|
||||||
#include "states_screens/main_menu_screen.hpp"
|
#include "states_screens/main_menu_screen.hpp"
|
||||||
#include "states_screens/options_screen_audio.hpp"
|
#include "states_screens/options_screen_audio.hpp"
|
||||||
@ -153,6 +154,7 @@ void BaseUserScreen::init()
|
|||||||
getWidget<IconButtonWidget>("new_user")->setActive(!in_game);
|
getWidget<IconButtonWidget>("new_user")->setActive(!in_game);
|
||||||
getWidget<IconButtonWidget>("rename")->setActive(!in_game);
|
getWidget<IconButtonWidget>("rename")->setActive(!in_game);
|
||||||
getWidget<IconButtonWidget>("delete")->setActive(!in_game);
|
getWidget<IconButtonWidget>("delete")->setActive(!in_game);
|
||||||
|
getWidget<IconButtonWidget>("default_kart_color")->setActive(!in_game);
|
||||||
|
|
||||||
m_new_registered_data = false;
|
m_new_registered_data = false;
|
||||||
if (m_auto_login)
|
if (m_auto_login)
|
||||||
@ -380,6 +382,10 @@ void BaseUserScreen::eventCallback(Widget* widget,
|
|||||||
// Init will automatically be called, which
|
// Init will automatically be called, which
|
||||||
// refreshes the player list
|
// refreshes the player list
|
||||||
}
|
}
|
||||||
|
else if (button == "default_kart_color")
|
||||||
|
{
|
||||||
|
new KartColorSliderDialog(getSelectedPlayer());
|
||||||
|
}
|
||||||
else if (button == "delete")
|
else if (button == "delete")
|
||||||
{
|
{
|
||||||
deletePlayer();
|
deletePlayer();
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "graphics/particle_emitter.hpp"
|
#include "graphics/particle_emitter.hpp"
|
||||||
#include "graphics/particle_kind_manager.hpp"
|
#include "graphics/particle_kind_manager.hpp"
|
||||||
#include "graphics/stk_particle.hpp"
|
#include "graphics/stk_particle.hpp"
|
||||||
#include "graphics/render_info.hpp"
|
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "io/xml_node.hpp"
|
#include "io/xml_node.hpp"
|
||||||
#include "input/device_manager.hpp"
|
#include "input/device_manager.hpp"
|
||||||
|
Loading…
Reference in New Issue
Block a user