1195 Multiplayer kart selection commit 18

This commit is contained in:
Dk 2014-03-05 23:02:23 +05:30
parent de7d0aa995
commit c5d23f7154
7 changed files with 974 additions and 972 deletions

View File

@ -145,6 +145,7 @@ when the border that intersect at this corner are enabled.
left_border="110" right_border="110" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" />
<!-- This one is a bit special. Only area(s) LEFT and/or RIGHT will be rendered. They will be overlaid
on top of the spinner's background -->
<element type="spinner" state="down" image="ocean/glassspinner_down.png"

File diff suppressed because it is too large Load Diff

View File

@ -39,172 +39,172 @@ using namespace irr;
#include "utils/ptr_vector.hpp"
/**
\page skin Overview of GUI skin
\page skin Overview of GUI skin
The GUIEngine::Skin is the one handling skinning. It loads images and their
sizing from a XML file. Since the irrLicht way of handling skin is quite
"boxy" and results in games looking like Window 95, this class overrides it
very much; in pretty much all callbacks, rather drawing plainly what irrLicht
asks it to draw, it first checks which widget we're asked to render and
redirects the call to a more specific method.
The GUIEngine::Skin is the one handling skinning. It loads images and their
sizing from a XML file. Since the irrLicht way of handling skin is quite
"boxy" and results in games looking like Window 95, this class overrides it
very much; in pretty much all callbacks, rather drawing plainly what irrLicht
asks it to draw, it first checks which widget we're asked to render and
redirects the call to a more specific method.
Furthermore, since irrLicht widgets were quite basic, a few widgets were
created by combining several irrLicht widgets (e.g. 2 buttons and a label in
a box make a spinner). Because of this, some jumping through hoops is
performed (we get a callback for each of these sub-widgets, but want to draw
the whole thing as a single block)
Furthermore, since irrLicht widgets were quite basic, a few widgets were
created by combining several irrLicht widgets (e.g. 2 buttons and a label in
a box make a spinner). Because of this, some jumping through hoops is
performed (we get a callback for each of these sub-widgets, but want to draw
the whole thing as a single block)
There are two types of images : some will be simply stretched as a whole,
others will have non-stretchable borders (you cannot choose which one you
must use, it's hardcoded for each element type; though, as you will see
below, for all "advanced stretching" images you can easily fake "simple
stretch")
There are two types of images : some will be simply stretched as a whole,
others will have non-stretchable borders (you cannot choose which one you
must use, it's hardcoded for each element type; though, as you will see
below, for all "advanced stretching" images you can easily fake "simple
stretch")
\section Describing a skin in a XML file
\section Describing a skin in a XML file
All elements will have at least 2 properties :
\li \c type="X" : sets what you're skinning with this entry
\li \c image="skinDirectory/imageName.png" : sets which image is used for
this element
All elements will have at least 2 properties :
\li \c type="X" : sets what you're skinning with this entry
\li \c image="skinDirectory/imageName.png" : sets which image is used for
this element
For more information, I highly recommend simply looking at existing skins,
they will show the format of the XML file describing a skin quite well.
For more information, I highly recommend simply looking at existing skins,
they will show the format of the XML file describing a skin quite well.
\section states Widget States
\section states Widget States
Most elements also support states :
\li \c state="neutral"
\li \c state="focused"
\li \c state="down"
Most elements also support states :
\li \c state="neutral"
\li \c state="focused"
\li \c state="down"
You can thus give different looks for different states. Not all widgets
support all states, see entries and comments below to know what's
supported. Note that checkboxes are an exception and have the following
styles :
\li \lc "neutral+unchecked"
\li \lc "neutral+checked"
\li \lc "focused+unchecked"
\li \lc "focused+checked"
You can thus give different looks for different states. Not all widgets
support all states, see entries and comments below to know what's
supported. Note that checkboxes are an exception and have the following
styles :
\li \lc "neutral+unchecked"
\li \lc "neutral+checked"
\li \lc "focused+unchecked"
\li \lc "focused+checked"
\section stretch Advanced stretching
"Advanced stretching" images are split this way :
\section stretch Advanced stretching
"Advanced stretching" images are split this way :
\code
+----+--------------------+----+
| | | |
+----+--------------------+----+
| | | |
| | | |
| | | |
+----+--------------------+----+
| | | |
+----+--------------------+----+
\endcode
\code
+----+--------------------+----+
| | | |
+----+--------------------+----+
| | | |
| | | |
| | | |
+----+--------------------+----+
| | | |
+----+--------------------+----+
\endcode
The center border will be stretched in all directions. The 4 corners will not
stretch at all. Horizontal borders will stretch horizontally, vertical
borders will stretch vertically. Use properties left_border="X"
right_border="X" top_border="X" bottom_border="X" to specify the size of each
border in pixels (setting all borders to '0' makes the whole image scaled).
The center border will be stretched in all directions. The 4 corners will not
stretch at all. Horizontal borders will stretch horizontally, vertical
borders will stretch vertically. Use properties left_border="X"
right_border="X" top_border="X" bottom_border="X" to specify the size of each
border in pixels (setting all borders to '0' makes the whole image scaled).
In some cases, you may not want vertical stretching to occur (like if the left
and right sides of the image must not be stretched vertically, e.g. for the
spinner). In this case, pass parameter preserve_h_aspect_ratios="true" to
make the left and right areas stretch by keeping their aspect ratio.
In some cases, you may not want vertical stretching to occur (like if the left
and right sides of the image must not be stretched vertically, e.g. for the
spinner). In this case, pass parameter preserve_h_aspect_ratios="true" to
make the left and right areas stretch by keeping their aspect ratio.
Some components may fill the full inner area with stuff; others will only take
a smaller area at the center. To adjust for this, there are properties
"hborder_out_portion" and "vborder_out_portion" that take a float from 0 to 1,
representing the percentage of each border that goes out of the widget's area
(this might include stuff like shadows, etc.). The 'h' one is for horizontal
borders, the 'v' one is for vertical borders.
Some components may fill the full inner area with stuff; others will only take
a smaller area at the center. To adjust for this, there are properties
"hborder_out_portion" and "vborder_out_portion" that take a float from 0 to 1,
representing the percentage of each border that goes out of the widget's area
(this might include stuff like shadows, etc.). The 'h' one is for horizontal
borders, the 'v' one is for vertical borders.
Finnally : the image is split, as shown above, into 9 areas. In some cases,
you may not want all areas to be rendered. Then you can pass parameter
areas="body+left+right+top+bottom" and explicitely specify which parts you
want to see. The 4 corner areas are only visible when the border that
intersect at this corner are enabled.
Finnally : the image is split, as shown above, into 9 areas. In some cases,
you may not want all areas to be rendered. Then you can pass parameter
areas="body+left+right+top+bottom" and explicitely specify which parts you
want to see. The 4 corner areas are only visible when the border that
intersect at this corner are enabled.
*/
*/
/**
* \ingroup guiengine
*/
namespace GUIEngine
/**
* \ingroup guiengine
*/
namespace GUIEngine
{
/**
* In order to avoid calculating render information every frame, it's
* stored in a SkinWidgetContainer for each widget (or each widget part
* if it requires many)
* \ingroup guiengine
*/
* In order to avoid calculating render information every frame, it's
* stored in a SkinWidgetContainer for each widget (or each widget part
* if it requires many)
* \ingroup guiengine
*/
class SkinWidgetContainer
{
public:
int m_skin_x, m_skin_y, m_skin_w, m_skin_h;
public:
int m_skin_x, m_skin_y, m_skin_w, m_skin_h;
bool m_skin_dest_areas_inited;
bool m_skin_dest_areas_yflip_inited;
int m_skin_dest_x, m_skin_dest_y, m_skin_dest_x2, m_skin_dest_y2;
bool m_skin_dest_areas_inited;
bool m_skin_dest_areas_yflip_inited;
int m_skin_dest_x, m_skin_dest_y, m_skin_dest_x2, m_skin_dest_y2;
// see comments in Skin::drawBoxFromStretchableTexture for
// explaination of what these are
core::rect<s32> m_skin_dest_area_left;
core::rect<s32> m_skin_dest_area_center;
core::rect<s32> m_skin_dest_area_right;
// see comments in Skin::drawBoxFromStretchableTexture for
// explaination of what these are
core::rect<s32> m_skin_dest_area_left;
core::rect<s32> m_skin_dest_area_center;
core::rect<s32> m_skin_dest_area_right;
core::rect<s32> m_skin_dest_area_top;
core::rect<s32> m_skin_dest_area_bottom;
core::rect<s32> m_skin_dest_area_top;
core::rect<s32> m_skin_dest_area_bottom;
core::rect<s32> m_skin_dest_area_top_left;
core::rect<s32> m_skin_dest_area_top_right;
core::rect<s32> m_skin_dest_area_bottom_left;
core::rect<s32> m_skin_dest_area_bottom_right;
core::rect<s32> m_skin_dest_area_top_left;
core::rect<s32> m_skin_dest_area_top_right;
core::rect<s32> m_skin_dest_area_bottom_left;
core::rect<s32> m_skin_dest_area_bottom_right;
// y flip
core::rect<s32> m_skin_dest_area_left_yflip;
core::rect<s32> m_skin_dest_area_center_yflip;
core::rect<s32> m_skin_dest_area_right_yflip;
// y flip
core::rect<s32> m_skin_dest_area_left_yflip;
core::rect<s32> m_skin_dest_area_center_yflip;
core::rect<s32> m_skin_dest_area_right_yflip;
core::rect<s32> m_skin_dest_area_top_yflip;
core::rect<s32> m_skin_dest_area_bottom_yflip;
core::rect<s32> m_skin_dest_area_top_yflip;
core::rect<s32> m_skin_dest_area_bottom_yflip;
core::rect<s32> m_skin_dest_area_top_left_yflip;
core::rect<s32> m_skin_dest_area_top_right_yflip;
core::rect<s32> m_skin_dest_area_bottom_left_yflip;
core::rect<s32> m_skin_dest_area_bottom_right_yflip;
core::rect<s32> m_skin_dest_area_top_left_yflip;
core::rect<s32> m_skin_dest_area_top_right_yflip;
core::rect<s32> m_skin_dest_area_bottom_left_yflip;
core::rect<s32> m_skin_dest_area_bottom_right_yflip;
short m_skin_r, m_skin_g, m_skin_b;
short m_skin_r, m_skin_g, m_skin_b;
SkinWidgetContainer()
{
m_skin_dest_areas_inited = false;
m_skin_dest_areas_yflip_inited = false;
m_skin_x = -1;
m_skin_y = -1;
m_skin_w = -1;
m_skin_h = -1;
m_skin_r = -1;
m_skin_g = -1;
m_skin_b = -1;
} // SkinWidgetContainer
SkinWidgetContainer()
{
m_skin_dest_areas_inited = false;
m_skin_dest_areas_yflip_inited = false;
m_skin_x = -1;
m_skin_y = -1;
m_skin_w = -1;
m_skin_h = -1;
m_skin_r = -1;
m_skin_g = -1;
m_skin_b = -1;
} // SkinWidgetContainer
}; // class SkinWidgetContainer
// ========================================================================
class Widget;
/**
* \brief class containing render params for the
* 'drawBoxFromStretchableTexture' function see \ref skin for more
* information about skinning in STK
* \ingroup guiengine
*/
* \brief class containing render params for the
* 'drawBoxFromStretchableTexture' function see \ref skin for more
* information about skinning in STK
* \ingroup guiengine
*/
class BoxRenderParams
{
video::ITexture* m_image;
bool m_y_flip_set;
public:
public:
int m_left_border, m_right_border, m_top_border, m_bottom_border;
bool m_preserve_h_aspect_ratios;
float m_hborder_out_portion, m_vborder_out_portion;
@ -258,10 +258,10 @@ a smaller area at the center. To adjust for this, there are properties
// ========================================================================
/**
* \brief Object used to render the GUI widgets
* see \ref skin for more information about skinning in STK
* \ingroup guiengine
*/
* \brief Object used to render the GUI widgets
* see \ref skin for more information about skinning in STK
* \ingroup guiengine
*/
class Skin : public gui::IGUISkin
{
gui::IGUISkin* m_fallback_skin;
@ -271,65 +271,65 @@ a smaller area at the center. To adjust for this, there are properties
std::vector<Widget*> m_tooltips;
std::vector<bool> m_tooltip_at_mouse;
#ifdef USE_PER_LINE_BACKGROUND
public:
public:
#endif
LEAK_CHECK()
void drawBoxFromStretchableTexture(SkinWidgetContainer* w,
const core::rect< s32 > &dest,
BoxRenderParams& params,
bool deactivated=false,
const core::rect<s32>* clipRect=NULL);
private:
void drawBoxFromStretchableTexture(SkinWidgetContainer* w,
const core::rect< s32 > &dest,
BoxRenderParams& params,
bool deactivated=false,
const core::rect<s32>* clipRect=NULL);
private:
// my utility methods, to work around irrlicht's very
// Windows-95-like-look-enforcing skin system
void process3DPane(gui::IGUIElement *element,
const core::rect< s32 > &rect, const bool pressed);
const core::rect< s32 > &rect, const bool pressed);
void drawButton(Widget* w, const core::rect< s32 > &rect,
const bool pressed, const bool focused);
const bool pressed, const bool focused);
void drawProgress(Widget* w, const core::rect< s32 > &rect,
const bool pressed, const bool focused);
const bool pressed, const bool focused);
void drawRatingBar(Widget* w, const core::rect< s32 > &rect,
const bool pressed, const bool focused);
const bool pressed, const bool focused);
void drawRibbon(const core::rect< s32 > &rect, Widget* widget,
const bool pressed, bool focused);
const bool pressed, bool focused);
void drawRibbonChild(const core::rect< s32 > &rect, Widget* widget,
const bool pressed, bool focused);
const bool pressed, bool focused);
void drawSpinnerChild(const core::rect< s32 > &rect, Widget* widget,
const bool pressed, bool focused);
const bool pressed, bool focused);
void drawSpinnerBody(const core::rect< s32 > &rect, Widget* widget,
const bool pressed, bool focused);
const bool pressed, bool focused);
void drawGauge(const core::rect< s32 > &rect, Widget* widget,
bool focused);
bool focused);
void drawGaugeFill(const core::rect< s32 > &rect, Widget* widget,
bool focused);
bool focused);
void drawCheckBox(const core::rect< s32 > &rect, Widget* widget,
bool focused);
bool focused);
void drawList(const core::rect< s32 > &rect, Widget* widget,
bool focused);
bool focused);
void drawListHeader(const core::rect< s32 > &rect, Widget* widget);
void drawListSelection(const core::rect< s32 > &rect, Widget* widget,
bool focused, const core::rect< s32 > *clip);
bool focused, const core::rect< s32 > *clip);
void drawIconButton(const core::rect< s32 > &rect, Widget* widget,
const bool pressed, bool focused);
const bool pressed, bool focused);
void drawScrollbarBackground(const core::rect< s32 > &rect);
void drawScrollbarThumb(const core::rect< s32 > &rect);
void drawScrollbarButton(const core::rect< s32 > &rect,
const bool pressed, const bool bottomArrow);
const bool pressed, const bool bottomArrow);
void drawTooltip(Widget* widget, bool atMouse);
public:
public:
// dirty way to have dialogs that zoom in
bool m_dialog;
float m_dialog_size;
/**
* \brief load a skin from the file specified in the user configuration file
* \throw std::runtime_error if file cannot be read
*/
* \brief load a skin from the file specified in the user configuration file
* \throw std::runtime_error if file cannot be read
*/
Skin(gui::IGUISkin* fallback_skin);
~Skin();
@ -342,66 +342,66 @@ a smaller area at the center. To adjust for this, there are properties
// irrlicht's callbacks
virtual void draw2DRectangle (gui::IGUIElement *element,
const video::SColor &color,
const core::rect< s32 > &pos,
const core::rect< s32 > *clip);
const video::SColor &color,
const core::rect< s32 > &pos,
const core::rect< s32 > *clip);
virtual void draw3DButtonPanePressed(gui::IGUIElement *element,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
virtual void draw3DButtonPaneStandard(gui::IGUIElement *element,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
virtual void draw3DMenuPane (gui::IGUIElement *element,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
virtual void draw3DSunkenPane (gui::IGUIElement *element,
video::SColor bgcolor,
bool flat, bool fillBackGround,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
video::SColor bgcolor,
bool flat, bool fillBackGround,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
virtual void draw3DTabBody (gui::IGUIElement *element, bool border,
bool background,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip,
s32 tabHeight=-1,
gui::EGUI_ALIGNMENT alignment=
gui::EGUIA_UPPERLEFT);
bool background,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip,
s32 tabHeight=-1,
gui::EGUI_ALIGNMENT alignment=
gui::EGUIA_UPPERLEFT);
virtual void draw3DTabButton (gui::IGUIElement *element,
bool active,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip,
gui::EGUI_ALIGNMENT alignment=
gui::EGUIA_UPPERLEFT);
bool active,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip,
gui::EGUI_ALIGNMENT alignment=
gui::EGUIA_UPPERLEFT);
virtual void draw3DToolBar (gui::IGUIElement *element,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
const core::rect< s32 > &rect,
const core::rect< s32 > *clip);
virtual core::rect< s32 >
draw3DWindowBackground(gui::IGUIElement *element,
bool drawTitleBar,
video::SColor titleBarColor,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip,
core::rect<s32>* checkClientArea=0);
draw3DWindowBackground(gui::IGUIElement *element,
bool drawTitleBar,
video::SColor titleBarColor,
const core::rect< s32 > &rect,
const core::rect< s32 > *clip,
core::rect<s32>* checkClientArea=0);
virtual void drawIcon (gui::IGUIElement *element,
gui::EGUI_DEFAULT_ICON icon,
const core::position2di position,
u32 starttime, u32 currenttime,
bool loop=false,
const core::rect< s32 > *clip=NULL);
gui::EGUI_DEFAULT_ICON icon,
const core::position2di position,
u32 starttime, u32 currenttime,
bool loop=false,
const core::rect< s32 > *clip=NULL);
virtual video::SColor getColor (gui::EGUI_DEFAULT_COLOR color) const;
virtual const wchar_t*
getDefaultText(gui::EGUI_DEFAULT_TEXT text) const;
getDefaultText(gui::EGUI_DEFAULT_TEXT text) const;
virtual gui::IGUIFont* getFont(gui::EGUI_DEFAULT_FONT which=
gui::EGDF_DEFAULT) const ;
gui::EGDF_DEFAULT) const ;
virtual u32 getIcon (gui::EGUI_DEFAULT_ICON icon) const ;
virtual s32 getSize (gui::EGUI_DEFAULT_SIZE size) const ;
virtual gui::IGUISpriteBank * getSpriteBank () const ;
virtual void setColor (gui::EGUI_DEFAULT_COLOR which,
video::SColor newColor);
video::SColor newColor);
virtual void setDefaultText (gui::EGUI_DEFAULT_TEXT which,
const wchar_t* newText);
const wchar_t* newText);
virtual void setFont (gui::IGUIFont *font,
gui::EGUI_DEFAULT_FONT which=gui::EGDF_DEFAULT);
gui::EGUI_DEFAULT_FONT which=gui::EGDF_DEFAULT);
virtual void setIcon (gui::EGUI_DEFAULT_ICON icon, u32 index);
virtual void setSize (gui::EGUI_DEFAULT_SIZE which, s32 size);
virtual void setSpriteBank (gui::IGUISpriteBank *bank);

View File

@ -63,17 +63,17 @@ void SpinnerWidget::add()
if (min_s.size() > 0)
{
if (!StringUtils::parseString<int>(min_s, &m_min))
if (!StringUtils::parseString<int>(min_s, &m_min))
{
Log::warn("invalid value for spinner widget minimum value : %s", min_s.c_str());
Log::warn("invalid value for spinner widget minimum value : %s", min_s.c_str());
}
}
if (max_s.size() > 0)
{
if (!StringUtils::parseString<int>(max_s, &m_max))
{
Log::warn("invalid value for spinner widget maximum value : %s", max_s.c_str());
if (!StringUtils::parseString<int>(max_s, &m_max))
{
Log::warn("invalid value for spinner widget maximum value : %s", max_s.c_str());
}
}
@ -108,10 +108,10 @@ void SpinnerWidget::add()
rect<s32> widget_size = rect<s32>(m_x, m_y, m_x + m_w, m_y + m_h);
IGUIButton * btn = GUIEngine::getGUIEnv()->addButton(widget_size, m_parent, widgetID, L"");
m_element = btn;
m_element->setTabOrder( m_element->getID() );
// left arrow
rect<s32> subsize_left_arrow = rect<s32>(0 ,0, m_h, m_h);
IGUIButton * left_arrow = GUIEngine::getGUIEnv()->addButton(subsize_left_arrow, btn, getNewNoFocusID(), L" ");
@ -120,7 +120,7 @@ void SpinnerWidget::add()
m_children[0].m_event_handler = this;
m_children[0].m_properties[PROP_ID] = "left";
m_children[0].m_id = m_children[0].m_element->getID();
m_badge_x_shift = subsize_left_arrow.getWidth();
// label
@ -147,8 +147,8 @@ void SpinnerWidget::add()
{
rect<s32> subsize_label = rect<s32>(m_h, 0, m_w - m_h, m_h);
IGUIStaticText* label = GUIEngine::getGUIEnv()->addStaticText(stringw(m_value).c_str(), subsize_label,
false /* border */, true /* word wrap */,
btn, getNewNoFocusID());
false /* border */, true /* word wrap */,
btn, getNewNoFocusID());
m_children[1].m_element = label;
m_children[1].m_event_handler = this;
m_children[1].m_id = label->getID();
@ -162,9 +162,9 @@ void SpinnerWidget::add()
{
label->setText(m_labels[m_value].c_str() );
}
}
// right arrow
rect<s32> subsize_right_arrow = rect<s32>(m_w - m_h, 0, m_w, m_h);
@ -176,7 +176,7 @@ void SpinnerWidget::add()
m_children[2].m_id = m_children[2].m_element->getID();
// refresh display
setValue(m_value);
}
@ -267,8 +267,8 @@ EventPropagation SpinnerWidget::leftPressed(const int playerID)
// -----------------------------------------------------------------------------
EventPropagation SpinnerWidget::transmitEvent(Widget* w,
const std::string& originator,
const int playerID)
const std::string& originator,
const int playerID)
{
assert(m_magic_number == 0xCAFEC001);
@ -385,7 +385,7 @@ void SpinnerWidget::setValue(irr::core::stringw new_value)
}
std::cerr << "ERROR [SpinnerWidget::setValue] : cannot find element named '"
<< irr::core::stringc(new_value.c_str()).c_str() << "'\n";
<< irr::core::stringc(new_value.c_str()).c_str() << "'\n";
assert(false);
}

View File

@ -32,154 +32,156 @@ namespace irr
namespace GUIEngine
{
/** \brief A spinner or gauge widget (to select numbers / percentages).
* \ingroup widgetsgroup
*/
* \ingroup widgetsgroup
*/
class SpinnerWidget : public Widget
{
public:
class ISpinnerConfirmListener
{
public:
class ISpinnerConfirmListener
{
public:
virtual ~ISpinnerConfirmListener() {}
/**
* \brief Invoked when the spinner is selected and "fire" is pressed
* \return whether to block the event from further processing
*/
virtual EventPropagation onSpinnerConfirmed() = 0;
};
protected:
ISpinnerConfirmListener* m_listener;
int m_value, m_min, m_max;
/** If each value the spinner can take has an associated text, this vector will be non-empty */
std::vector<irr::core::stringw> m_labels;
/** Whether the value of this spinner is displayed using an icon rather than with a plain label */
bool m_graphical;
/** \brief Whether this widget is a gauge
* the behaviour is the same but the look is a bit different, instead of displaying a number,
* it displays how close the value is to the maximum by filling a line
*/
bool m_gauge;
//for setting background in multiplayer kart selection screen
bool m_use_background_color;
int m_spinner_widget_player_id;
/** \brief Whether to wrap back to the first value when going "beyond" the last value */
bool m_wrap_around;
/** \brief implementing method from base class Widget */
virtual EventPropagation transmitEvent(Widget* w,
const std::string& originator,
const int playerID);
/** \brief implementing method from base class Widget */
virtual EventPropagation rightPressed(const int playerID);
/** \brief implementing method from base class Widget */
virtual EventPropagation leftPressed(const int playerID);
/** When inferring widget size from its label length, this method will be called to
* if/how much space must be added to the raw label's size for the widget to be large enough */
virtual int getWidthNeededAroundLabel() const { return 25; }
/** When inferring widget size from its label length, this method will be called to
* if/how much space must be added to the raw label's size for the widget to be large enough */
virtual int getHeightNeededAroundLabel() const { return 8; }
/** Call only if this spinner is graphical. Returns the current texture to display */
irr::video::ITexture* getTexture();
public:
LEAK_CHECK()
SpinnerWidget(const bool gauge=false);
virtual ~SpinnerWidget() {}
virtual void move(const int x, const int y, const int w, const int h);
void addLabel(irr::core::stringw label);
void clearLabels();
// next four functions are for background colour behind playername in multikart screen selection
void setUseBackgroundColor() {m_use_background_color=true;}
bool getUseBackgroundColor() {return m_use_background_color;}
void setSpinnerWidgetPlayerID(int playerID) {m_spinner_widget_player_id=playerID;}
int getSpinnerWidgetPlayerID() {return m_spinner_widget_player_id;}
void setListener(ISpinnerConfirmListener* listener) { m_listener = listener; }
/** \brief implement method from base class Widget */
virtual void add();
virtual ~ISpinnerConfirmListener() {}
/**
* \brief sets the current value of the spinner
* \param new_value the new value that will be become the current value of this spinner.
*/
void setValue(const int new_value);
* \brief Invoked when the spinner is selected and "fire" is pressed
* \return whether to block the event from further processing
*/
virtual EventPropagation onSpinnerConfirmed() = 0;
};
protected:
ISpinnerConfirmListener* m_listener;
int m_value, m_min, m_max;
/** If each value the spinner can take has an associated text, this vector will be non-empty */
std::vector<irr::core::stringw> m_labels;
/** Whether the value of this spinner is displayed using an icon rather than with a plain label */
bool m_graphical;
/** \brief Whether this widget is a gauge
* the behaviour is the same but the look is a bit different, instead of displaying a number,
* it displays how close the value is to the maximum by filling a line
*/
bool m_gauge;
//for setting background
bool m_use_background_color;
int m_spinner_widget_player_id;
/** \brief Whether to wrap back to the first value when going "beyond" the last value */
bool m_wrap_around;
/** \brief implementing method from base class Widget */
virtual EventPropagation transmitEvent(Widget* w,
const std::string& originator,
const int playerID);
/** \brief implementing method from base class Widget */
virtual EventPropagation rightPressed(const int playerID);
/** \brief implementing method from base class Widget */
virtual EventPropagation leftPressed(const int playerID);
/** When inferring widget size from its label length, this method will be called to
* if/how much space must be added to the raw label's size for the widget to be large enough */
virtual int getWidthNeededAroundLabel() const { return 25; }
/** When inferring widget size from its label length, this method will be called to
* if/how much space must be added to the raw label's size for the widget to be large enough */
virtual int getHeightNeededAroundLabel() const { return 8; }
/** Call only if this spinner is graphical. Returns the current texture to display */
irr::video::ITexture* getTexture();
// to set the background image
// irr::video::ITexture* getBackgroundColor();
public:
LEAK_CHECK()
SpinnerWidget(const bool gauge=false);
virtual ~SpinnerWidget() {}
virtual void move(const int x, const int y, const int w, const int h);
void addLabel(irr::core::stringw label);
void clearLabels();
/**
* \brief sets the current value of the spinner
* \pre the 'new_value' string passed must be the name of an item
* (added through SpinnerWidget::addLabel)in the spinner
*/
void setValue(irr::core::stringw new_value);
// next four functions are for background colour behind playername in multikart screen selection
void setUseBackgroundColor() {m_use_background_color=true;}
bool getUseBackgroundColor() {return m_use_background_color;}
void setSpinnerWidgetPlayerID(int playerID) {m_spinner_widget_player_id=playerID;}
int getSpinnerWidgetPlayerID() {return m_spinner_widget_player_id;}
/**
* \return whether this spinner is of "gauge" type
*/
bool isGauge() const { return m_gauge; }
/**
* \brief retrieve the current value of the spinner
* \return the current value of the spinner, in a int form
*/
int getValue() const { return m_value; }
/**
* \brief retrieve the current value of the spinner
* \return the current value of the spinner, in a string form
*/
irr::core::stringw getStringValue() const;
void setListener(ISpinnerConfirmListener* listener) { m_listener = listener; }
/**
* \return the maximum value the spinner can take
*/
int getMax() const { return m_max; }
/**
* \brief Sets the maximum value for a spinner.
*/
void setMax(int n) {m_max = n; }
/**
* \return the minimum value the spinner can take
*/
int getMin() const { return m_min; }
/** \brief implement method from base class Widget */
virtual void add();
void setMin(int n) { m_min = n; }
/**
* \brief sets the current value of the spinner
* \param new_value the new value that will be become the current value of this spinner.
*/
void setValue(const int new_value);
/**
* \brief sets the current value of the spinner
* \pre the 'new_value' string passed must be the name of an item
* (added through SpinnerWidget::addLabel)in the spinner
*/
void setValue(irr::core::stringw new_value);
/**
* \return whether this spinner is of "gauge" type
*/
bool isGauge() const { return m_gauge; }
/**
* \brief retrieve the current value of the spinner
* \return the current value of the spinner, in a int form
*/
int getValue() const { return m_value; }
/**
* \brief retrieve the current value of the spinner
* \return the current value of the spinner, in a string form
*/
irr::core::stringw getStringValue() const;
/** Override method from base class Widget */
virtual void setActivated();
/**
* \return the maximum value the spinner can take
*/
int getMax() const { return m_max; }
/**
* \brief Sets the maximum value for a spinner.
*/
void setMax(int n) {m_max = n; }
/**
* \return the minimum value the spinner can take
*/
int getMin() const { return m_min; }
void setMin(int n) { m_min = n; }
/** Override method from base class Widget */
virtual void setActivated();
/** Override method from base class Widget */
virtual void setDeactivated();
bool isActivated() { return !m_deactivated; }
/** Override method from base class Widget */
virtual void setDeactivated();
bool isActivated() { return !m_deactivated; }
/** Display custom text in spinner */
void setCustomText(const core::stringw& text);
/** Display custom text in spinner */
void setCustomText(const core::stringw& text);
};
}
#endif

View File

@ -68,11 +68,11 @@ KartSelectionScreen* KartSelectionScreen::m_instance_ptr = NULL;
class PlayerKartWidget;
/** Currently, navigation for multiple players at the same time is implemented
in a somewhat clunky way. An invisible "dispatcher" widget is added above
kart icons. When a player moves up, he focuses the dispatcher, which in
turn moves the selection to the appropriate spinner. "tabbing roots" are
used to make navigation back down possible. (FIXME: maybe find a cleaner
way?) */
in a somewhat clunky way. An invisible "dispatcher" widget is added above
kart icons. When a player moves up, he focuses the dispatcher, which in
turn moves the selection to the appropriate spinner. "tabbing roots" are
used to make navigation back down possible. (FIXME: maybe find a cleaner
way?) */
static int g_root_id;
// ------------------------------------------------------------------------
@ -110,8 +110,8 @@ void FocusDispatcher::add()
core::rect<s32> widget_size(m_x, m_y, m_x + m_w, m_y + m_h);
m_element = GUIEngine::getGUIEnv()->addButton(widget_size, NULL,
m_reserved_id,
L"Dispatcher", L"");
m_reserved_id,
L"Dispatcher", L"");
m_id = m_element->getID();
m_element->setTabStop(true);
@ -128,7 +128,7 @@ static FocusDispatcher* g_dispatcher = NULL;
* management or badging */
PlayerNameSpinner::PlayerNameSpinner(KartSelectionScreen* parent,
const int player_id)
const int player_id)
{
m_player_id = player_id;
m_incorrect = false;
@ -153,14 +153,14 @@ void PlayerNameSpinner::markAsIncorrect()
m_incorrect = true;
irr::video::ITexture* texture = irr_driver->getTexture(FileManager::GUI,
"red_mark.png" );
"red_mark.png" );
const int mark_size = m_h;
const int mark_x = m_w - mark_size*2;
const int mark_y = 0;
core::recti red_mark_area(mark_x, mark_y, mark_x + mark_size,
mark_y + mark_size);
mark_y + mark_size);
m_red_mark_widget = GUIEngine::getGUIEnv()->addImage( red_mark_area,
/* parent */ m_element );
/* parent */ m_element );
m_red_mark_widget->setImage(texture);
m_red_mark_widget->setScaleImage(true);
m_red_mark_widget->setTabStop(false);
@ -190,11 +190,11 @@ void PlayerNameSpinner::markAsCorrect()
* number, name, the kart view, the kart's name) */
PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
StateManager::ActivePlayer* associated_player,
Online::Profile* associated_user,
core::recti area, const int player_id,
std::string kart_group,
const int irrlicht_widget_id) : Widget(WTYPE_DIV)
StateManager::ActivePlayer* associated_player,
Online::Profile* associated_user,
core::recti area, const int player_id,
std::string kart_group,
const int irrlicht_widget_id) : Widget(WTYPE_DIV)
{
#ifdef DEBUG
if (associated_player)
@ -233,7 +233,7 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
m_player_ident_spinner->m_y = player_name_y;
m_player_ident_spinner->m_w = player_name_w;
m_player_ident_spinner->m_h = player_name_h;
if (parent->m_multiplayer && associated_player)
{
@ -275,7 +275,7 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
//m_player_ident_spinner->m_event_handler = this;
m_children.push_back(m_player_ident_spinner);
// ----- Kart model view
@ -325,16 +325,16 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
const KartModel &kart_model = props->getMasterKartModel();
m_model_view->addModel( kart_model.getModel(), Vec3(0,0,0),
Vec3(35.0f, 35.0f, 35.0f),
kart_model.getBaseFrame() );
Vec3(35.0f, 35.0f, 35.0f),
kart_model.getBaseFrame() );
m_model_view->addModel( kart_model.getWheelModel(0),
kart_model.getWheelGraphicsPosition(0) );
kart_model.getWheelGraphicsPosition(0) );
m_model_view->addModel( kart_model.getWheelModel(1),
kart_model.getWheelGraphicsPosition(1) );
kart_model.getWheelGraphicsPosition(1) );
m_model_view->addModel( kart_model.getWheelModel(2),
kart_model.getWheelGraphicsPosition(2) );
kart_model.getWheelGraphicsPosition(2) );
m_model_view->addModel( kart_model.getWheelModel(3),
kart_model.getWheelGraphicsPosition(3) );
kart_model.getWheelGraphicsPosition(3) );
for(size_t i=0 ; i < kart_model.getSpeedWeightedObjectsCount() ; i++)
{
const SpeedWeightedObject& obj = kart_model.getSpeedWeightedObject(i);
@ -401,8 +401,8 @@ void PlayerKartWidget::setPlayerID(const int newPlayerID)
!= m_associated_player)
{
Log::warn("[KartSelectionScreen]", "Internal "
"inconsistency, PlayerKartWidget has IDs and "
"pointers that do not correspond to one player");
"inconsistency, PlayerKartWidget has IDs and "
"pointers that do not correspond to one player");
fprintf(stderr,
" Player: %p - Index: %d - m_associated_player: %p\n",
StateManager::get()->getActivePlayer(newPlayerID),
@ -440,7 +440,7 @@ void PlayerKartWidget::add()
assert(m_magic_number == 0x33445566);
assert(KartSelectionScreen::getRunningInstance()
->m_kart_widgets.contains(this));
->m_kart_widgets.contains(this));
if (m_associated_player) // if player is local
{
bool mineInList = false;
@ -489,7 +489,7 @@ void PlayerKartWidget::add()
for (int n=0; n<player_amount; n++)
{
core::stringw name = PlayerManager::get()->getPlayer(n)->getName();
m_player_ident_spinner->addLabel( translations->fribidize(name) );
}
@ -541,16 +541,16 @@ void PlayerKartWidget::markAsReady()
stringw playerNameString = m_player_ident_spinner->getStringValue();
core::rect<s32> rect(core::position2di(m_player_ident_spinner->m_x,
m_player_ident_spinner->m_y),
core::dimension2di(m_player_ident_spinner->m_w,
m_player_ident_spinner->m_h));
m_player_ident_spinner->m_y),
core::dimension2di(m_player_ident_spinner->m_w,
m_player_ident_spinner->m_h));
// 'playerNameString' is already fribidize, so we need to use
// 'insertValues' and not _("...", a) so it's not flipped again
m_ready_text =
GUIEngine::getGUIEnv()->addStaticText(
StringUtils::insertValues(_("%s is ready"),
playerNameString).c_str(),
rect );
StringUtils::insertValues(_("%s is ready"),
playerNameString).c_str(),
rect );
m_ready_text->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_CENTER );
m_children.remove(m_player_ident_spinner);
@ -648,25 +648,25 @@ void PlayerKartWidget::onUpdate(float delta)
if (m_player_ident_spinner != NULL)
{
m_player_ident_spinner->move(player_name_x,
player_name_y,
player_name_w,
player_name_h );
player_name_y,
player_name_w,
player_name_h );
}
if (m_ready_text != NULL)
{
m_ready_text->setRelativePosition(
core::recti(core::position2di(player_name_x, player_name_y),
core::dimension2di(player_name_w, player_name_h)) );
core::recti(core::position2di(player_name_x, player_name_y),
core::dimension2di(player_name_w, player_name_h)) );
}
m_model_view->move(model_x,
model_y,
model_w,
model_h);
model_y,
model_w,
model_h);
m_kart_name->move(kart_name_x,
kart_name_y,
kart_name_w,
kart_name_h);
kart_name_y,
kart_name_w,
kart_name_h);
// When coming from the overworld, we must rebuild the preview scene at
// least once, since the scene is being cleared by leaving the overworld
@ -680,9 +680,9 @@ void PlayerKartWidget::onUpdate(float delta)
// -------------------------------------------------------------------------
/** Event callback */
GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(
Widget* w,
const std::string& originator,
const int m_player_id)
Widget* w,
const std::string& originator,
const int m_player_id)
{
assert(m_magic_number == 0x33445566);
// if it's declared ready, there is really nothing to process
@ -702,17 +702,17 @@ GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(
if(UserConfigParams::logGUI())
{
Log::info("[KartSelectionScreen]", "Identity changed "
"for player %s : %s",m_player_id,
irr::core::stringc(
m_player_ident_spinner->getStringValue()
.c_str()).c_str());
"for player %s : %s",m_player_id,
irr::core::stringc(
m_player_ident_spinner->getStringValue()
.c_str()).c_str());
}
if (m_parent_screen->m_multiplayer)
{
m_associated_player->setPlayerProfile(
PlayerManager::get()->getPlayer(m_player_ident_spinner
->getValue()) );
PlayerManager::get()->getPlayer(m_player_ident_spinner
->getValue()) );
}
}
@ -757,7 +757,7 @@ void PlayerKartWidget::setSize(const int x, const int y, const int w, const int
player_name_y = y + player_id_h;
const int modelMaxHeight = h - kart_name_h - player_name_h
- player_id_h;
- player_id_h;
const int modelMaxWidth = w;
const int bestSize = std::min(modelMaxWidth, modelMaxHeight);
const int modelY = y + player_name_h + player_id_h;
@ -802,7 +802,7 @@ EventPropagation PlayerKartWidget::onSpinnerConfirmed()
bool sameKart(const PlayerKartWidget& player1, const PlayerKartWidget& player2)
{
return player1.getKartInternalName() == player2.getKartInternalName() &&
player1.getKartInternalName() != RANDOM_KART_ID;
player1.getKartInternalName() != RANDOM_KART_ID;
}
#if 0
@ -844,7 +844,7 @@ void KartHoverListener::onSelectionChanged(DynamicRibbonWidget* theWidget,
assert(w != NULL);
w->setSelection(m_parent->m_kart_widgets[playerID]
.m_kartInternalName, playerID, true);
.m_kartInternalName, playerID, true);
return;
}
@ -917,16 +917,16 @@ void KartSelectionScreen::beforeAddingWidget()
#define FOR_GETTEXT_ONLY(x)
//I18N: kart group name
FOR_GETTEXT_ONLY( _("standard") )
//I18N: kart group name
FOR_GETTEXT_ONLY( _("Add-Ons") )
//I18N: kart group name
FOR_GETTEXT_ONLY( _("Add-Ons") )
// add others after
for (int n=0; n<group_amount; n++)
{
// try to translate group names
tabs->addTextChild( _(groups[n].c_str()) , groups[n]);
} // for n<group_amount
// add others after
for (int n=0; n<group_amount; n++)
{
// try to translate group names
tabs->addTextChild( _(groups[n].c_str()) , groups[n]);
} // for n<group_amount
DynamicRibbonWidget* w = getWidget<DynamicRibbonWidget>("karts");
@ -945,7 +945,7 @@ void KartSelectionScreen::init()
RibbonWidget* tabs = getWidget<RibbonWidget>("kartgroups");
assert( tabs != NULL );
tabs->select(UserConfigParams::m_last_used_kart_group,
PLAYER_ID_GAME_MASTER);
PLAYER_ID_GAME_MASTER);
Widget* placeholder = getWidget("playerskarts");
assert(placeholder != NULL);
@ -986,31 +986,31 @@ void KartSelectionScreen::init()
/*
TODO: Ultimately, it'd be nice to *not* clear m_kart_widgets so that
when players return to the kart selection screen, it will appear as
it did when they left (at least when returning from the track menu).
Rebuilding the screen is a little tricky.
TODO: Ultimately, it'd be nice to *not* clear m_kart_widgets so that
when players return to the kart selection screen, it will appear as
it did when they left (at least when returning from the track menu).
Rebuilding the screen is a little tricky.
*/
/*
if (m_kart_widgets.size() > 0)
{
// trying to rebuild the screen
for (int n = 0; n < m_kart_widgets.size(); n++)
if (m_kart_widgets.size() > 0)
{
PlayerKartWidget *pkw;
pkw = m_kart_widgets.get(n);
manualAddWidget(pkw);
pkw->add();
}
// trying to rebuild the screen
for (int n = 0; n < m_kart_widgets.size(); n++)
{
PlayerKartWidget *pkw;
pkw = m_kart_widgets.get(n);
manualAddWidget(pkw);
pkw->add();
}
}
else */
// For now this is what will happen
{
playerJoin( input_manager->getDeviceList()->getLatestUsedDevice(),
true );
true );
w->updateItemDisplay();
}
@ -1079,20 +1079,20 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
if (w == NULL)
{
Log::error("[KartSelectionScreen]", "playerJoin(): Called outside of "
"kart selection screen.");
"kart selection screen.");
return false;
}
else if (device == NULL)
{
Log::error("[KartSelectionScreen]", "playerJoin(): Received null "
"device pointer");
"device pointer");
return false;
}
if (StateManager::get()->activePlayerCount() >= MAX_PLAYER_COUNT)
{
Log::error("[KartSelectionScreen]", "Maximum number of players "
"reached");
"reached");
sfx_manager->quickSound( "anvil" );
return false;
}
@ -1103,9 +1103,9 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
// start at the rightmost of the screen
const int shift = irr_driver->getFrameSize().Width;
core::recti kartsArea(kartsAreaWidget->m_x + shift,
kartsAreaWidget->m_y,
kartsAreaWidget->m_x + shift + kartsAreaWidget->m_w,
kartsAreaWidget->m_y + kartsAreaWidget->m_h);
kartsAreaWidget->m_y,
kartsAreaWidget->m_x + shift + kartsAreaWidget->m_w,
kartsAreaWidget->m_y + kartsAreaWidget->m_h);
// ---- Create new active player
PlayerProfile* profile_to_use = PlayerManager::get()->getCurrentPlayer();
@ -1149,7 +1149,7 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
// ---- Create player/kart widget
PlayerKartWidget* newPlayerWidget =
new PlayerKartWidget(this, aplayer, NULL, kartsArea, m_kart_widgets.size(),
selected_kart_group);
selected_kart_group);
manualAddWidget(newPlayerWidget);
m_kart_widgets.push_back(newPlayerWidget);
@ -1166,12 +1166,12 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
const int splitWidth = fullarea->m_w / 2;
m_kart_widgets[0].move( fullarea->m_x, fullarea->m_y, splitWidth,
fullarea->m_h );
fullarea->m_h );
m_multiplayer_message = new BubbleWidget();
m_multiplayer_message->m_properties[PROP_TEXT_ALIGN] = "center";
m_multiplayer_message->setText( _("Everyone:\nPress 'Select' now to "
"join the game!") );
"join the game!") );
m_multiplayer_message->m_x =
(int)(fullarea->m_x + splitWidth + splitWidth*0.2f);
m_multiplayer_message->m_y = (int)(fullarea->m_y + fullarea->m_h*0.3f);
@ -1188,7 +1188,7 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
for (int n=0; n<amount; n++)
{
m_kart_widgets[n].move( fullarea->m_x + splitWidth*n,
fullarea->m_y, splitWidth, fullarea->m_h);
fullarea->m_y, splitWidth, fullarea->m_h);
}
}
@ -1201,7 +1201,7 @@ bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
w->setSelection(new_player_id, new_player_id, true);
newPlayerWidget->m_player_ident_spinner
->setFocusForPlayer(new_player_id);
->setFocusForPlayer(new_player_id);
}
if (!m_multiplayer)
@ -1223,9 +1223,9 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
if (w == NULL)
{
Log::error("[KartSelectionScreen]", "ERROR: playerQuit() called "
"outside of kart selection screen, "
"or the XML file for this screen was changed without "
"adapting the code accordingly");
"outside of kart selection screen, "
"or the XML file for this screen was changed without "
"adapting the code accordingly");
return false;
}
@ -1258,7 +1258,7 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
if (playerID == -1)
{
Log::warn("[KartSelectionScreen]", " playerQuit cannot find "
"passed player");
"passed player");
return false;
}
if(UserConfigParams::logGUI())
@ -1295,7 +1295,7 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
// be updated in onUpdate, and will stop when the widget has disappeared)
Widget* fullarea = getWidget("playerskarts");
m_removed_widget->move(m_removed_widget->m_x + m_removed_widget->m_w/2,
fullarea->m_y + fullarea->m_h, 0, 0);
fullarea->m_y + fullarea->m_h, 0, 0);
// update selections
@ -1312,7 +1312,7 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
if (!success)
{
Log::warn("[KartSelectionScreen]", "Failed to select kart %s"
" for player %u, what's going on??", selectedKart.c_str(),n);
" for player %u, what's going on??", selectedKart.c_str(),n);
}
}
}
@ -1404,14 +1404,14 @@ void KartSelectionScreen::playerConfirm(const int playerID)
m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
m_kart_widgets[playerID].getAssociatedPlayer()->getProfile();
const bool kart_conflict = sameKart(m_kart_widgets[n],
m_kart_widgets[playerID]);
m_kart_widgets[playerID]);
if (player_ready && (ident_conflict || kart_conflict) &&
!willNeedDuplicates)
{
if (UserConfigParams::logGUI())
Log::warn("[KartSelectionScreen]", "You can't select this identity "
"or kart, someone already took it!!");
"or kart, someone already took it!!");
sfx_manager->quickSound( "anvil" );
return;
@ -1420,7 +1420,7 @@ void KartSelectionScreen::playerConfirm(const int playerID)
// If two PlayerKart entries are associated to the same ActivePlayer,
// something went wrong
assert(m_kart_widgets[n].getAssociatedPlayer() !=
m_kart_widgets[playerID].getAssociatedPlayer());
m_kart_widgets[playerID].getAssociatedPlayer());
}
// Mark this player as ready to start
@ -1457,8 +1457,8 @@ void KartSelectionScreen::playerConfirm(const int playerID)
// ----------------------------------------------------------------------------
void KartSelectionScreen::updateKartWidgetModel(uint8_t widget_id,
const std::string& selection,
const irr::core::stringw& selectionText)
const std::string& selection,
const irr::core::stringw& selectionText)
{
// Update the displayed model
ModelViewWidget* w3 = m_kart_widgets[widget_id].m_model_view;
@ -1471,30 +1471,30 @@ void KartSelectionScreen::updateKartWidgetModel(uint8_t widget_id,
ItemManager::getItemModel(Item::ITEM_BONUS_BOX);
w3->clearModels();
w3->addModel( model, Vec3(0.0f, -12.0f, 0.0f),
Vec3(35.0f, 35.0f, 35.0f) );
Vec3(35.0f, 35.0f, 35.0f) );
w3->update(0);
m_kart_widgets[widget_id].m_kart_name
->setText( _("Random Kart"), false );
->setText( _("Random Kart"), false );
}
// selection contains the name of the kart, so check only for substr
else if (StringUtils::startsWith(selection, ID_LOCKED))
{
w3->clearModels();
w3->addModel(irr_driver->getAnimatedMesh(
file_manager->getAsset(FileManager::MODEL, "chest.b3d") )->getMesh(20),
Vec3(0,0,0), Vec3(15.0f, 15.0f, 15.0f) );
file_manager->getAsset(FileManager::MODEL, "chest.b3d") )->getMesh(20),
Vec3(0,0,0), Vec3(15.0f, 15.0f, 15.0f) );
w3->update(0);
if (m_multiplayer)
{
m_kart_widgets[widget_id].m_kart_name
->setText(_("Locked"), false );
->setText(_("Locked"), false );
}
else
{
m_kart_widgets[widget_id].m_kart_name
->setText(_("Locked : solve active challenges to gain "
"access to more!"), false );
->setText(_("Locked : solve active challenges to gain "
"access to more!"), false );
}
}
else
@ -1507,20 +1507,20 @@ void KartSelectionScreen::updateKartWidgetModel(uint8_t widget_id,
w3->clearModels();
w3->addModel( kart_model.getModel(), Vec3(0,0,0),
Vec3(35.0f, 35.0f, 35.0f),
kart_model.getBaseFrame() );
Vec3(35.0f, 35.0f, 35.0f),
kart_model.getBaseFrame() );
w3->addModel( kart_model.getWheelModel(0),
kart_model.getWheelGraphicsPosition(0) );
kart_model.getWheelGraphicsPosition(0) );
w3->addModel( kart_model.getWheelModel(1),
kart_model.getWheelGraphicsPosition(1) );
kart_model.getWheelGraphicsPosition(1) );
w3->addModel( kart_model.getWheelModel(2),
kart_model.getWheelGraphicsPosition(2) );
kart_model.getWheelGraphicsPosition(2) );
w3->addModel( kart_model.getWheelModel(3),
kart_model.getWheelGraphicsPosition(3) );
kart_model.getWheelGraphicsPosition(3) );
w3->update(0);
m_kart_widgets[widget_id].m_kart_name
->setText( selectionText.c_str(), false );
->setText( selectionText.c_str(), false );
}
else
{
@ -1536,8 +1536,8 @@ void KartSelectionScreen::updateKartWidgetModel(uint8_t widget_id,
* Callback handling events from the kart selection menu
*/
void KartSelectionScreen::eventCallback(Widget* widget,
const std::string& name,
const int playerID)
const std::string& name,
const int playerID)
{
// don't allow changing group after someone confirmed
if (name == "kartgroups" && !m_game_master_confirmed)
@ -1573,13 +1573,13 @@ void KartSelectionScreen::eventCallback(Widget* widget,
const std::string& selected_kart =
m_kart_widgets[n].getKartInternalName();
if (!w->setSelection( selected_kart, n,
n != PLAYER_ID_GAME_MASTER))
n != PLAYER_ID_GAME_MASTER))
{
// if we get here, it means one player "lost" his kart in
// the tab switch
if (UserConfigParams::logGUI())
Log::info("[KartSelectionScreen]", "Player %u"
" lost their selection when switching tabs!!!",n);
" lost their selection when switching tabs!!!",n);
// Select a random kart in this case
const int count = w->getItems().size();
@ -1594,15 +1594,15 @@ void KartSelectionScreen::eventCallback(Widget* widget,
// must remain on the tabs)
const bool success =
w->setSelection( randomID, n,
n != PLAYER_ID_GAME_MASTER );
n != PLAYER_ID_GAME_MASTER );
if (!success)
Log::warn("[KartSelectionScreen]",
"setting kart of player %u failed");
"setting kart of player %u failed");
}
else
{
Log::warn("[KartSelectionScreen]", " 0 items "
"in the ribbon");
"in the ribbon");
}
}
}
@ -1696,12 +1696,12 @@ void KartSelectionScreen::allPlayersDone()
if(UserConfigParams::logGUI())
{
Log::info("[KartSelectionScreen]", "players : %d",players.size());
for (unsigned int n=0; n<players.size(); n++)
{
Log::info("[KartSelectionScreen]", " Player %u is %s on %s",n,
core::stringc(
players[n].getConstProfile()->getName().c_str()).c_str(),
players[n].getConstProfile()->getName().c_str()).c_str(),
players[n].getDevice()->m_name.c_str());
}
}
@ -1709,7 +1709,7 @@ void KartSelectionScreen::allPlayersDone()
for (unsigned int n=0; n<players.size(); n++)
{
StateManager::get()->getActivePlayer(n)->getProfile()
->incrementUseFrequency();
->incrementUseFrequency();
}
// ---- Give player info to race manager
race_manager->setNumLocalPlayers( players.size() );
@ -1751,7 +1751,7 @@ void KartSelectionScreen::allPlayersDone()
randomID = random.get(item_count);
if (items[randomID].m_code_name != ID_DONT_USE &&
!StringUtils::startsWith(items[randomID].m_code_name,
ID_LOCKED))
ID_LOCKED))
{
selected_kart = items[randomID].m_code_name;
done = true;
@ -1786,7 +1786,7 @@ void KartSelectionScreen::allPlayersDone()
if (!m_multiplayer)
{
input_manager->getDeviceList()
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
->setSinglePlayer( StateManager::get()->getActivePlayer(0) );
}
else
{
@ -1827,9 +1827,9 @@ bool KartSelectionScreen::validateIdentChoices()
if (m_multiplayer)
{
assert(m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
PlayerManager::get()->getPlayer(m_kart_widgets[n]
.m_player_ident_spinner->getValue())
);
PlayerManager::get()->getPlayer(m_kart_widgets[n]
.m_player_ident_spinner->getValue())
);
}
}
}
@ -1837,7 +1837,7 @@ bool KartSelectionScreen::validateIdentChoices()
// perform actual checking
for (int n=0; n<amount; n++)
{
// skip players that took a guest account, they can be many on the
// same identity in this case
if (m_kart_widgets[n].getAssociatedPlayer()->getProfile()
@ -1861,18 +1861,18 @@ bool KartSelectionScreen::validateIdentChoices()
// player m is ready, so player n should not choose
// this name
m_kart_widgets[n].m_player_ident_spinner
->markAsIncorrect();
->markAsIncorrect();
}
else if (m_kart_widgets[n].isReady() &&
!m_kart_widgets[m].isReady())
!m_kart_widgets[m].isReady())
{
// player n is ready, so player m should not
// choose this name
m_kart_widgets[m].m_player_ident_spinner
->markAsIncorrect();
->markAsIncorrect();
}
else if (m_kart_widgets[n].isReady() &&
m_kart_widgets[m].isReady())
m_kart_widgets[m].isReady())
{
// it should be impossible for two players to confirm
// they're ready with the same name
@ -1920,9 +1920,9 @@ bool KartSelectionScreen::validateKartChoices()
{
Log::warn("[KartSelectionScreen]", "Kart conflict!!");
Log::warn("KartSelectionScreen]", " Player %u chose %s",n,
m_kart_widgets[n].getKartInternalName().c_str());
m_kart_widgets[n].getKartInternalName().c_str());
Log::warn("[KartSelectionScreen]", " Player %u chose %s",m,
m_kart_widgets[m].getKartInternalName().c_str());
m_kart_widgets[m].getKartInternalName().c_str());
}
// two players took the same kart. check if one is ready
@ -1930,14 +1930,14 @@ bool KartSelectionScreen::validateKartChoices()
m_kart_widgets[m].isReady())
{
if (UserConfigParams::logGUI())
Log::info("[KartSelectionScreen]", " --> Setting red badge on player %u", n);
Log::info("[KartSelectionScreen]", " --> Setting red badge on player %u", n);
// player m is ready, so player n should not choose
// this name
m_kart_widgets[n].m_model_view->setBadge(BAD_BADGE);
}
else if (m_kart_widgets[n].isReady() &&
!m_kart_widgets[m].isReady())
!m_kart_widgets[m].isReady())
{
if (UserConfigParams::logGUI())
Log::info("[KartSelectionScreen]", " --> Setting red badge on player %u",m);
@ -1947,7 +1947,7 @@ bool KartSelectionScreen::validateKartChoices()
m_kart_widgets[m].m_model_view->setBadge(BAD_BADGE);
}
else if (m_kart_widgets[n].isReady() &&
m_kart_widgets[m].isReady())
m_kart_widgets[m].isReady())
{
// it should be impossible for two players to confirm
// they're ready with the same kart
@ -1978,7 +1978,7 @@ void KartSelectionScreen::renumberKarts()
{
m_kart_widgets[n].setPlayerID(n);
m_kart_widgets[n].move( fullarea->m_x + splitWidth*n, fullarea->m_y,
splitWidth, fullarea->m_h );
splitWidth, fullarea->m_h );
}
w->updateItemDisplay();
@ -2021,18 +2021,18 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
if (PlayerManager::get()->getCurrentPlayer()->isLocked(prop->getIdent()))
{
w->addItem(
_("Locked : solve active challenges to gain access "
"to more!"),
ID_LOCKED+prop->getIdent(),
prop->getAbsoluteIconFile(), LOCKED_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
_("Locked : solve active challenges to gain access "
"to more!"),
ID_LOCKED+prop->getIdent(),
prop->getAbsoluteIconFile(), LOCKED_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}
else
{
w->addItem(translations->fribidize(prop->getName()),
prop->getIdent(),
prop->getAbsoluteIconFile(), 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
prop->getIdent(),
prop->getAbsoluteIconFile(), 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
usableKartCount++;
}
}
@ -2053,17 +2053,17 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
if (PlayerManager::get()->getCurrentPlayer()->isLocked(prop->getIdent()))
{
w->addItem(
_("Locked : solve active challenges to gain access "
"to more!"),
ID_LOCKED+prop->getIdent(), icon_path, LOCKED_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
_("Locked : solve active challenges to gain access "
"to more!"),
ID_LOCKED+prop->getIdent(), icon_path, LOCKED_BADGE,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
}
else
{
w->addItem(translations->fribidize(prop->getName()),
prop->getIdent(),
icon_path, 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
prop->getIdent(),
icon_path, 0,
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
usableKartCount++;
}
}
@ -2093,13 +2093,13 @@ EventPropagation FocusDispatcher::focused(const int playerID)
if(UserConfigParams::logGUI())
Log::info("[KartSelectionScreen]", "FocusDispatcher focused by player %u",
playerID);
playerID);
// since this screen is multiplayer, redirect focus to the right widget
const int amount = m_parent->m_kart_widgets.size();
for (int n=0; n<amount; n++)
{
if (m_parent->m_kart_widgets[n].getPlayerID() == playerID)
{
@ -2116,7 +2116,7 @@ EventPropagation FocusDispatcher::focused(const int playerID)
// ")" << std::endl;
m_parent->m_kart_widgets[n].m_player_ident_spinner
->setFocusForPlayer(playerID);
->setFocusForPlayer(playerID);
return GUIEngine::EVENT_BLOCK;

View File

@ -33,7 +33,7 @@ namespace GUIEngine
class Widget;
class BubbleWidget;
enum EventPropagation;
}
namespace Online
{
@ -44,15 +44,15 @@ class PlayerKartWidget;
class KartHoverListener;
/**
* \brief screen where players can choose their kart
* \ingroup states_screens
*/
* \brief screen where players can choose their kart
* \ingroup states_screens
*/
class KartSelectionScreen : public GUIEngine::Screen
{
friend class KartHoverListener;
friend class PlayerNameSpinner;
friend class FocusDispatcher;
protected:
protected:
/** Contains the custom widget shown for every player. (ref only since
* we're adding them to a Screen, and the Screen will take ownership
* of these widgets)
@ -74,8 +74,8 @@ class KartSelectionScreen : public GUIEngine::Screen
KartSelectionScreen(const char* filename);
/** Stores whether any player confirmed their choice; then, some things
* are "frozen", for instance the selected kart group tab
*/
* are "frozen", for instance the selected kart group tab
*/
bool m_game_master_confirmed;
PlayerKartWidget* m_removed_widget;
@ -91,14 +91,14 @@ class KartSelectionScreen : public GUIEngine::Screen
void renumberKarts();
/** Checks identities chosen by players, making sure no duplicates are
* used.
* \return Whether all choices are ok
*/
* used.
* \return Whether all choices are ok
*/
bool validateIdentChoices();
/** Checks karts chosen by players, making sure no duplicates are used.
* \return Whether all choices are ok
*/
* \return Whether all choices are ok
*/
bool validateKartChoices();
/** Fill the ribbon with the karts from the currently selected group */
@ -107,12 +107,12 @@ class KartSelectionScreen : public GUIEngine::Screen
virtual void playerConfirm(const int playerID);
/** updates model of a kart widget, to have the good selection when the user validates */
void updateKartWidgetModel(uint8_t widget_id,
const std::string& selection,
const irr::core::stringw& selectionText);
const std::string& selection,
const irr::core::stringw& selectionText);
/** Stores a pointer to the current selection screen */
static KartSelectionScreen* m_instance_ptr;
public:
public:
/** Returns the current instance */
static KartSelectionScreen* getRunningInstance();
@ -131,23 +131,23 @@ class KartSelectionScreen : public GUIEngine::Screen
bool playerJoin(InputDevice* device, bool firstPlayer);
/**
* \brief Called when a player hits 'rescue'/'cancel' on his device
* to leave the game
* \return true if event was handled succesfully
*/
* \brief Called when a player hits 'rescue'/'cancel' on his device
* to leave the game
* \return true if event was handled succesfully
*/
bool playerQuit(StateManager::ActivePlayer* player);
/** \brief implement callback from parent class GUIEngine::Screen */
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void init() OVERRIDE;
virtual void beforeAddingWidget() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void tearDown() OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
const int playerID) OVERRIDE;
const int playerID) OVERRIDE;
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void onUpdate(float dt) OVERRIDE;
@ -165,11 +165,11 @@ class KartSelectionScreen : public GUIEngine::Screen
//!----------------------------------------------------------------------------
//! FocusDispatcher :
/** Currently, navigation for multiple players at the same time is implemented
in a somewhat clunky way. An invisible "dispatcher" widget is added above
kart icons. When a player moves up, he focuses the dispatcher, which in
turn moves the selection to the appropriate spinner. "tabbing roots" are
used to make navigation back down possible. (FIXME: maybe find a cleaner
way?) */
in a somewhat clunky way. An invisible "dispatcher" widget is added above
kart icons. When a player moves up, he focuses the dispatcher, which in
turn moves the selection to the appropriate spinner. "tabbing roots" are
used to make navigation back down possible. (FIXME: maybe find a cleaner
way?) */
class FocusDispatcher : public GUIEngine::Widget
{
KartSelectionScreen* m_parent;
@ -177,12 +177,12 @@ class FocusDispatcher : public GUIEngine::Widget
bool m_is_initialised;
public:
public:
LEAK_CHECK()
// ------------------------------------------------------------------------
FocusDispatcher(KartSelectionScreen* parent);
// ------------------------------------------------------------------------
FocusDispatcher(KartSelectionScreen* parent);
// ------------------------------------------------------------------------
void setRootID(const int reservedID);
@ -206,7 +206,7 @@ class PlayerNameSpinner : public GUIEngine::SpinnerWidget
KartSelectionScreen* m_parent;
//virtual EventPropagation focused(const int m_playerID) ;
public:
public:
PlayerNameSpinner(KartSelectionScreen* parent, const int playerID);
// ------------------------------------------------------------------------
void setID(const int m_playerID);
@ -217,7 +217,7 @@ class PlayerNameSpinner : public GUIEngine::SpinnerWidget
// ------------------------------------------------------------------------
/** Remove any red mark set with 'markAsIncorrect' */
void markAsCorrect();
};
/** A widget representing the kart selection for a player (i.e. the player's
@ -258,12 +258,12 @@ class PlayerKartWidget : public GUIEngine::Widget,
long m_magic_number;
#endif
public:
public:
LEAK_CHECK()
/** Sub-widgets created by this widget */
PlayerNameSpinner* m_player_ident_spinner;
/** Sub-widgets created by this widget */
PlayerNameSpinner* m_player_ident_spinner;
GUIEngine::ModelViewWidget* m_model_view;
GUIEngine::LabelWidget* m_kart_name;
@ -278,11 +278,11 @@ class PlayerKartWidget : public GUIEngine::Widget,
bool m_not_updated_yet;
PlayerKartWidget(KartSelectionScreen* parent,
StateManager::ActivePlayer* associated_player,
Online::Profile* associated_user,
core::recti area, const int player_id,
std::string kart_group,
const int irrlicht_idget_id=-1);
StateManager::ActivePlayer* associated_player,
Online::Profile* associated_user,
core::recti area, const int player_id,
std::string kart_group,
const int irrlicht_idget_id=-1);
// ------------------------------------------------------------------------
~PlayerKartWidget();
@ -323,9 +323,9 @@ class PlayerKartWidget : public GUIEngine::Widget,
// -------------------------------------------------------------------------
/** Event callback */
virtual GUIEngine::EventPropagation transmitEvent(
GUIEngine::Widget* w,
const std::string& originator,
const int m_player_id);
GUIEngine::Widget* w,
const std::string& originator,
const int m_player_id);
// -------------------------------------------------------------------------
/** Sets the size of the widget as a whole, and placed children widgets
@ -353,7 +353,7 @@ class PlayerKartWidget : public GUIEngine::Widget,
class KartHoverListener : public GUIEngine::DynamicRibbonHoverListener
{
KartSelectionScreen* m_parent;
public:
public:
unsigned int m_magic_number;
KartHoverListener(KartSelectionScreen* parent);
@ -363,9 +363,9 @@ class KartHoverListener : public GUIEngine::DynamicRibbonHoverListener
// ------------------------------------------------------------------------
void onSelectionChanged(GUIEngine::DynamicRibbonWidget* theWidget,
const std::string& selectionID,
const irr::core::stringw& selectionText,
const int playerID);
const std::string& selectionID,
const irr::core::stringw& selectionText,
const int playerID);
}; // KartHoverListener
#endif