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" left_border="110" right_border="110" top_border="0" bottom_border="36"
preserve_h_aspect_ratios="true" hborder_out_portion="0.0" /> 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 <!-- 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 --> on top of the spinner's background -->
<element type="spinner" state="down" image="ocean/glassspinner_down.png" <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" #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 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 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 "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 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 asks it to draw, it first checks which widget we're asked to render and
redirects the call to a more specific method. redirects the call to a more specific method.
Furthermore, since irrLicht widgets were quite basic, a few widgets were 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 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 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 performed (we get a callback for each of these sub-widgets, but want to draw
the whole thing as a single block) the whole thing as a single block)
There are two types of images : some will be simply stretched as a whole, 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 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 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 below, for all "advanced stretching" images you can easily fake "simple
stretch") 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 : All elements will have at least 2 properties :
\li \c type="X" : sets what you're skinning with this entry \li \c type="X" : sets what you're skinning with this entry
\li \c image="skinDirectory/imageName.png" : sets which image is used for \li \c image="skinDirectory/imageName.png" : sets which image is used for
this element this element
For more information, I highly recommend simply looking at existing skins, 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. 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 : Most elements also support states :
\li \c state="neutral" \li \c state="neutral"
\li \c state="focused" \li \c state="focused"
\li \c state="down" \li \c state="down"
You can thus give different looks for different states. Not all widgets You can thus give different looks for different states. Not all widgets
support all states, see entries and comments below to know what's support all states, see entries and comments below to know what's
supported. Note that checkboxes are an exception and have the following supported. Note that checkboxes are an exception and have the following
styles : styles :
\li \lc "neutral+unchecked" \li \lc "neutral+unchecked"
\li \lc "neutral+checked" \li \lc "neutral+checked"
\li \lc "focused+unchecked" \li \lc "focused+unchecked"
\li \lc "focused+checked" \li \lc "focused+checked"
\section stretch Advanced stretching \section stretch Advanced stretching
"Advanced stretching" images are split this way : "Advanced stretching" images are split this way :
\code \code
+----+--------------------+----+ +----+--------------------+----+
| | | | | | | |
+----+--------------------+----+ +----+--------------------+----+
| | | | | | | |
| | | | | | | |
| | | | | | | |
+----+--------------------+----+ +----+--------------------+----+
| | | | | | | |
+----+--------------------+----+ +----+--------------------+----+
\endcode \endcode
The center border will be stretched in all directions. The 4 corners will not The center border will be stretched in all directions. The 4 corners will not
stretch at all. Horizontal borders will stretch horizontally, vertical stretch at all. Horizontal borders will stretch horizontally, vertical
borders will stretch vertically. Use properties left_border="X" borders will stretch vertically. Use properties left_border="X"
right_border="X" top_border="X" bottom_border="X" to specify the size of each 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). 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 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 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 spinner). In this case, pass parameter preserve_h_aspect_ratios="true" to
make the left and right areas stretch by keeping their aspect ratio. 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 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 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, "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 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 (this might include stuff like shadows, etc.). The 'h' one is for horizontal
borders, the 'v' one is for vertical borders. borders, the 'v' one is for vertical borders.
Finnally : the image is split, as shown above, into 9 areas. In some cases, 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 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 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 want to see. The 4 corner areas are only visible when the border that
intersect at this corner are enabled. intersect at this corner are enabled.
*/ */
/** /**
* \ingroup guiengine * \ingroup guiengine
*/ */
namespace GUIEngine namespace GUIEngine
{ {
/** /**
* In order to avoid calculating render information every frame, it's * In order to avoid calculating render information every frame, it's
* stored in a SkinWidgetContainer for each widget (or each widget part * stored in a SkinWidgetContainer for each widget (or each widget part
* if it requires many) * if it requires many)
* \ingroup guiengine * \ingroup guiengine
*/ */
class SkinWidgetContainer class SkinWidgetContainer
{ {
public: public:
int m_skin_x, m_skin_y, m_skin_w, m_skin_h; int m_skin_x, m_skin_y, m_skin_w, m_skin_h;
bool m_skin_dest_areas_inited; bool m_skin_dest_areas_inited;
bool m_skin_dest_areas_yflip_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; int m_skin_dest_x, m_skin_dest_y, m_skin_dest_x2, m_skin_dest_y2;
// see comments in Skin::drawBoxFromStretchableTexture for // see comments in Skin::drawBoxFromStretchableTexture for
// explaination of what these are // explaination of what these are
core::rect<s32> m_skin_dest_area_left; core::rect<s32> m_skin_dest_area_left;
core::rect<s32> m_skin_dest_area_center; core::rect<s32> m_skin_dest_area_center;
core::rect<s32> m_skin_dest_area_right; core::rect<s32> m_skin_dest_area_right;
core::rect<s32> m_skin_dest_area_top; core::rect<s32> m_skin_dest_area_top;
core::rect<s32> m_skin_dest_area_bottom; 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_left;
core::rect<s32> m_skin_dest_area_top_right; 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_left;
core::rect<s32> m_skin_dest_area_bottom_right; core::rect<s32> m_skin_dest_area_bottom_right;
// y flip // y flip
core::rect<s32> m_skin_dest_area_left_yflip; 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_center_yflip;
core::rect<s32> m_skin_dest_area_right_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_top_yflip;
core::rect<s32> m_skin_dest_area_bottom_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_left_yflip;
core::rect<s32> m_skin_dest_area_top_right_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_left_yflip;
core::rect<s32> m_skin_dest_area_bottom_right_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() SkinWidgetContainer()
{ {
m_skin_dest_areas_inited = false; m_skin_dest_areas_inited = false;
m_skin_dest_areas_yflip_inited = false; m_skin_dest_areas_yflip_inited = false;
m_skin_x = -1; m_skin_x = -1;
m_skin_y = -1; m_skin_y = -1;
m_skin_w = -1; m_skin_w = -1;
m_skin_h = -1; m_skin_h = -1;
m_skin_r = -1; m_skin_r = -1;
m_skin_g = -1; m_skin_g = -1;
m_skin_b = -1; m_skin_b = -1;
} // SkinWidgetContainer } // SkinWidgetContainer
}; // class SkinWidgetContainer }; // class SkinWidgetContainer
// ======================================================================== // ========================================================================
class Widget; class Widget;
/** /**
* \brief class containing render params for the * \brief class containing render params for the
* 'drawBoxFromStretchableTexture' function see \ref skin for more * 'drawBoxFromStretchableTexture' function see \ref skin for more
* information about skinning in STK * information about skinning in STK
* \ingroup guiengine * \ingroup guiengine
*/ */
class BoxRenderParams class BoxRenderParams
{ {
video::ITexture* m_image; video::ITexture* m_image;
bool m_y_flip_set; bool m_y_flip_set;
public: public:
int m_left_border, m_right_border, m_top_border, m_bottom_border; int m_left_border, m_right_border, m_top_border, m_bottom_border;
bool m_preserve_h_aspect_ratios; bool m_preserve_h_aspect_ratios;
float m_hborder_out_portion, m_vborder_out_portion; 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 * \brief Object used to render the GUI widgets
* see \ref skin for more information about skinning in STK * see \ref skin for more information about skinning in STK
* \ingroup guiengine * \ingroup guiengine
*/ */
class Skin : public gui::IGUISkin class Skin : public gui::IGUISkin
{ {
gui::IGUISkin* m_fallback_skin; 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<Widget*> m_tooltips;
std::vector<bool> m_tooltip_at_mouse; std::vector<bool> m_tooltip_at_mouse;
#ifdef USE_PER_LINE_BACKGROUND #ifdef USE_PER_LINE_BACKGROUND
public: public:
#endif #endif
LEAK_CHECK() LEAK_CHECK()
void drawBoxFromStretchableTexture(SkinWidgetContainer* w, void drawBoxFromStretchableTexture(SkinWidgetContainer* w,
const core::rect< s32 > &dest, const core::rect< s32 > &dest,
BoxRenderParams& params, BoxRenderParams& params,
bool deactivated=false, bool deactivated=false,
const core::rect<s32>* clipRect=NULL); const core::rect<s32>* clipRect=NULL);
private: private:
// my utility methods, to work around irrlicht's very // my utility methods, to work around irrlicht's very
// Windows-95-like-look-enforcing skin system // Windows-95-like-look-enforcing skin system
void process3DPane(gui::IGUIElement *element, 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, 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, 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, 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, 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, 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, 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, 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, void drawGauge(const core::rect< s32 > &rect, Widget* widget,
bool focused); bool focused);
void drawGaugeFill(const core::rect< s32 > &rect, Widget* widget, void drawGaugeFill(const core::rect< s32 > &rect, Widget* widget,
bool focused); bool focused);
void drawCheckBox(const core::rect< s32 > &rect, Widget* widget, void drawCheckBox(const core::rect< s32 > &rect, Widget* widget,
bool focused); bool focused);
void drawList(const core::rect< s32 > &rect, Widget* widget, void drawList(const core::rect< s32 > &rect, Widget* widget,
bool focused); bool focused);
void drawListHeader(const core::rect< s32 > &rect, Widget* widget); void drawListHeader(const core::rect< s32 > &rect, Widget* widget);
void drawListSelection(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, 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 drawScrollbarBackground(const core::rect< s32 > &rect);
void drawScrollbarThumb(const core::rect< s32 > &rect); void drawScrollbarThumb(const core::rect< s32 > &rect);
void drawScrollbarButton(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); void drawTooltip(Widget* widget, bool atMouse);
public:
public:
// dirty way to have dialogs that zoom in // dirty way to have dialogs that zoom in
bool m_dialog; bool m_dialog;
float m_dialog_size; float m_dialog_size;
/** /**
* \brief load a skin from the file specified in the user configuration file * \brief load a skin from the file specified in the user configuration file
* \throw std::runtime_error if file cannot be read * \throw std::runtime_error if file cannot be read
*/ */
Skin(gui::IGUISkin* fallback_skin); Skin(gui::IGUISkin* fallback_skin);
~Skin(); ~Skin();
@ -342,66 +342,66 @@ a smaller area at the center. To adjust for this, there are properties
// irrlicht's callbacks // irrlicht's callbacks
virtual void draw2DRectangle (gui::IGUIElement *element, virtual void draw2DRectangle (gui::IGUIElement *element,
const video::SColor &color, const video::SColor &color,
const core::rect< s32 > &pos, const core::rect< s32 > &pos,
const core::rect< s32 > *clip); const core::rect< s32 > *clip);
virtual void draw3DButtonPanePressed(gui::IGUIElement *element, virtual void draw3DButtonPanePressed(gui::IGUIElement *element,
const core::rect< s32 > &rect, const core::rect< s32 > &rect,
const core::rect< s32 > *clip); const core::rect< s32 > *clip);
virtual void draw3DButtonPaneStandard(gui::IGUIElement *element, virtual void draw3DButtonPaneStandard(gui::IGUIElement *element,
const core::rect< s32 > &rect, const core::rect< s32 > &rect,
const core::rect< s32 > *clip); const core::rect< s32 > *clip);
virtual void draw3DMenuPane (gui::IGUIElement *element, virtual void draw3DMenuPane (gui::IGUIElement *element,
const core::rect< s32 > &rect, const core::rect< s32 > &rect,
const core::rect< s32 > *clip); const core::rect< s32 > *clip);
virtual void draw3DSunkenPane (gui::IGUIElement *element, virtual void draw3DSunkenPane (gui::IGUIElement *element,
video::SColor bgcolor, video::SColor bgcolor,
bool flat, bool fillBackGround, bool flat, bool fillBackGround,
const core::rect< s32 > &rect, const core::rect< s32 > &rect,
const core::rect< s32 > *clip); const core::rect< s32 > *clip);
virtual void draw3DTabBody (gui::IGUIElement *element, bool border, virtual void draw3DTabBody (gui::IGUIElement *element, bool border,
bool background, bool background,
const core::rect< s32 > &rect, const core::rect< s32 > &rect,
const core::rect< s32 > *clip, const core::rect< s32 > *clip,
s32 tabHeight=-1, s32 tabHeight=-1,
gui::EGUI_ALIGNMENT alignment= gui::EGUI_ALIGNMENT alignment=
gui::EGUIA_UPPERLEFT); gui::EGUIA_UPPERLEFT);
virtual void draw3DTabButton (gui::IGUIElement *element, virtual void draw3DTabButton (gui::IGUIElement *element,
bool active, bool active,
const core::rect< s32 > &rect, const core::rect< s32 > &rect,
const core::rect< s32 > *clip, const core::rect< s32 > *clip,
gui::EGUI_ALIGNMENT alignment= gui::EGUI_ALIGNMENT alignment=
gui::EGUIA_UPPERLEFT); gui::EGUIA_UPPERLEFT);
virtual void draw3DToolBar (gui::IGUIElement *element, virtual void draw3DToolBar (gui::IGUIElement *element,
const core::rect< s32 > &rect, const core::rect< s32 > &rect,
const core::rect< s32 > *clip); const core::rect< s32 > *clip);
virtual core::rect< s32 > virtual core::rect< s32 >
draw3DWindowBackground(gui::IGUIElement *element, draw3DWindowBackground(gui::IGUIElement *element,
bool drawTitleBar, bool drawTitleBar,
video::SColor titleBarColor, video::SColor titleBarColor,
const core::rect< s32 > &rect, const core::rect< s32 > &rect,
const core::rect< s32 > *clip, const core::rect< s32 > *clip,
core::rect<s32>* checkClientArea=0); core::rect<s32>* checkClientArea=0);
virtual void drawIcon (gui::IGUIElement *element, virtual void drawIcon (gui::IGUIElement *element,
gui::EGUI_DEFAULT_ICON icon, gui::EGUI_DEFAULT_ICON icon,
const core::position2di position, const core::position2di position,
u32 starttime, u32 currenttime, u32 starttime, u32 currenttime,
bool loop=false, bool loop=false,
const core::rect< s32 > *clip=NULL); const core::rect< s32 > *clip=NULL);
virtual video::SColor getColor (gui::EGUI_DEFAULT_COLOR color) const; virtual video::SColor getColor (gui::EGUI_DEFAULT_COLOR color) const;
virtual const wchar_t* 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= 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 u32 getIcon (gui::EGUI_DEFAULT_ICON icon) const ;
virtual s32 getSize (gui::EGUI_DEFAULT_SIZE size) const ; virtual s32 getSize (gui::EGUI_DEFAULT_SIZE size) const ;
virtual gui::IGUISpriteBank * getSpriteBank () const ; virtual gui::IGUISpriteBank * getSpriteBank () const ;
virtual void setColor (gui::EGUI_DEFAULT_COLOR which, virtual void setColor (gui::EGUI_DEFAULT_COLOR which,
video::SColor newColor); video::SColor newColor);
virtual void setDefaultText (gui::EGUI_DEFAULT_TEXT which, virtual void setDefaultText (gui::EGUI_DEFAULT_TEXT which,
const wchar_t* newText); const wchar_t* newText);
virtual void setFont (gui::IGUIFont *font, 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 setIcon (gui::EGUI_DEFAULT_ICON icon, u32 index);
virtual void setSize (gui::EGUI_DEFAULT_SIZE which, s32 size); virtual void setSize (gui::EGUI_DEFAULT_SIZE which, s32 size);
virtual void setSpriteBank (gui::IGUISpriteBank *bank); virtual void setSpriteBank (gui::IGUISpriteBank *bank);

View File

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

View File

@ -32,154 +32,156 @@ namespace irr
namespace GUIEngine namespace GUIEngine
{ {
/** \brief A spinner or gauge widget (to select numbers / percentages). /** \brief A spinner or gauge widget (to select numbers / percentages).
* \ingroup widgetsgroup * \ingroup widgetsgroup
*/ */
class SpinnerWidget : public Widget class SpinnerWidget : public Widget
{ {
public:
class ISpinnerConfirmListener
{
public: public:
class ISpinnerConfirmListener virtual ~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();
/** /**
* \brief sets the current value of the spinner * \brief Invoked when the spinner is selected and "fire" is pressed
* \param new_value the new value that will be become the current value of this spinner. * \return whether to block the event from further processing
*/ */
void setValue(const int new_value); 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();
/** // next four functions are for background colour behind playername in multikart screen selection
* \brief sets the current value of the spinner void setUseBackgroundColor() {m_use_background_color=true;}
* \pre the 'new_value' string passed must be the name of an item bool getUseBackgroundColor() {return m_use_background_color;}
* (added through SpinnerWidget::addLabel)in the spinner void setSpinnerWidgetPlayerID(int playerID) {m_spinner_widget_player_id=playerID;}
*/ int getSpinnerWidgetPlayerID() {return m_spinner_widget_player_id;}
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; }
/** void setListener(ISpinnerConfirmListener* listener) { m_listener = listener; }
* \brief retrieve the current value of the spinner
* \return the current value of the spinner, in a string form
*/
irr::core::stringw getStringValue() const;
/** /** \brief implement method from base class Widget */
* \return the maximum value the spinner can take virtual void add();
*/
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; } /**
* \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 */ /** Display custom text in spinner */
virtual void setDeactivated(); void setCustomText(const core::stringw& text);
bool isActivated() { return !m_deactivated; }
/** Display custom text in spinner */
void setCustomText(const core::stringw& text);
}; };
} }
#endif #endif

View File

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

View File

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