From c5d23f71544aece00fa88d520f1240e90ce75314 Mon Sep 17 00:00:00 2001 From: Dk Date: Wed, 5 Mar 2014 23:02:23 +0530 Subject: [PATCH] 1195 Multiplayer kart selection commit 18 --- data/skins/Ocean.stkskin | 1 + src/guiengine/skin.cpp | 833 +++++++++++------------ src/guiengine/skin.hpp | 398 +++++------ src/guiengine/widgets/spinner_widget.cpp | 32 +- src/guiengine/widgets/spinner_widget.hpp | 268 ++++---- src/states_screens/kart_selection.cpp | 320 ++++----- src/states_screens/kart_selection.hpp | 94 +-- 7 files changed, 974 insertions(+), 972 deletions(-) diff --git a/data/skins/Ocean.stkskin b/data/skins/Ocean.stkskin index 1f023372d..031c1a9b6 100644 --- a/data/skins/Ocean.stkskin +++ b/data/skins/Ocean.stkskin @@ -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" /> + createXMLTree(file); if(!root) { Log::error("skin", "Could not read XML file '%s'.", - file.c_str()); + file.c_str()); throw std::runtime_error("Invalid skin file"); } @@ -175,7 +175,7 @@ namespace SkinConfig else { Log::error("skin", "Unknown node in XML file '%s'.", - node->getName().c_str()); + node->getName().c_str()); } }// nend for @@ -216,17 +216,17 @@ void BoxRenderParams::setTexture(ITexture* image) m_image = image; /* - The source texture is split this way to allow for a stretchable center - and borders that don't stretch : + The source texture is split this way to allow for a stretchable center + and borders that don't stretch : - +----+--------------------+----+ - | | | | - +----a--------------------b----+ <-- top_border - | | | | - | | | | - +----c--------------------d----+ <-- height - bottom-border - | | | | - +----+--------------------+----+ + +----+--------------------+----+ + | | | | + +----a--------------------b----+ <-- top_border + | | | | + | | | | + +----c--------------------d----+ <-- height - bottom-border + | | | | + +----+--------------------+----+ */ const int texture_w = image->getSize().Width; @@ -260,26 +260,26 @@ void BoxRenderParams::calculateYFlipIfNeeded() if (m_y_flip_set) return; #define FLIP_Y( X ) { const int y1 = X.UpperLeftCorner.Y; \ - const int y2 = X.LowerRightCorner.Y; \ - X##_yflip = X; \ - X##_yflip.UpperLeftCorner.Y = y2;\ - X##_yflip.LowerRightCorner.Y = y1;} +const int y2 = X.LowerRightCorner.Y; \ +X##_yflip = X; \ +X##_yflip.UpperLeftCorner.Y = y2;\ +X##_yflip.LowerRightCorner.Y = y1;} FLIP_Y(m_source_area_left) - FLIP_Y(m_source_area_center) - FLIP_Y(m_source_area_right) + FLIP_Y(m_source_area_center) + FLIP_Y(m_source_area_right) - FLIP_Y(m_source_area_top) - FLIP_Y(m_source_area_bottom) + FLIP_Y(m_source_area_top) + FLIP_Y(m_source_area_bottom) - FLIP_Y(m_source_area_top_left) - FLIP_Y(m_source_area_top_right) - FLIP_Y(m_source_area_bottom_left) - FLIP_Y(m_source_area_bottom_right) + FLIP_Y(m_source_area_top_left) + FLIP_Y(m_source_area_top_right) + FLIP_Y(m_source_area_bottom_left) + FLIP_Y(m_source_area_bottom_right) #undef FLIP_Y - m_y_flip_set = true; + m_y_flip_set = true; } // calculateYFlipIfNeeded // ---------------------------------------------------------------------------- @@ -290,7 +290,7 @@ void BoxRenderParams::calculateYFlipIfNeeded() Skin::Skin(IGUISkin* fallback_skin) { std::string skin_name = file_manager->getAsset(FileManager::SKIN, - UserConfigParams::m_skin_file); + UserConfigParams::m_skin_file); try { @@ -303,7 +303,7 @@ Skin::Skin(IGUISkin* fallback_skin) UserConfigParams::m_skin_file.revertToDefaults(); skin_name = file_manager->getAsset(FileManager::SKIN, - UserConfigParams::m_skin_file); + UserConfigParams::m_skin_file); SkinConfig::loadFromFile( skin_name ); } @@ -363,28 +363,28 @@ void Skin::drawBgImage() const int clipped_x_space = (texture_w - screen_w); dest = core::recti(-clipped_x_space/2, 0, - screen_w+clipped_x_space/2, texture_h); + screen_w+clipped_x_space/2, texture_h); } irr_driver->getVideoDriver()->enableMaterial2D(); draw2DImage(bg_image, dest, source_area, - /* no clipping */0, /*color*/ 0, - /*alpha*/false); + /* no clipping */0, /*color*/ 0, + /*alpha*/false); irr_driver->getVideoDriver()->enableMaterial2D(false); } // drawBgImage // ---------------------------------------------------------------------------- void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, - const core::recti &dest, - BoxRenderParams& params, - bool deactivated, - const core::recti* clipRect) + const core::recti &dest, + BoxRenderParams& params, + bool deactivated, + const core::recti* clipRect) { // check if widget moved. if so, recalculate coords if (w->m_skin_x != dest.UpperLeftCorner.X || - w->m_skin_y != dest.UpperLeftCorner.Y || - w->m_skin_w != dest.getWidth() || - w->m_skin_h != dest.getHeight() ) + w->m_skin_y != dest.UpperLeftCorner.Y || + w->m_skin_w != dest.getWidth() || + w->m_skin_h != dest.getHeight() ) { w->m_skin_dest_areas_inited = false; w->m_skin_dest_areas_yflip_inited = false; @@ -408,20 +408,20 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const int texture_h = source->getSize().Height; /* - The dest area is split this way. Borders can go a bit beyond the given - area so components inside don't go over the borders - (how much it exceeds horizontally is specified in 'hborder_out_portion'. - vertically is always the totality) + The dest area is split this way. Borders can go a bit beyond the given + area so components inside don't go over the borders + (how much it exceeds horizontally is specified in 'hborder_out_portion'. + vertically is always the totality) - a----b--------------------c----+ - | | | | - d----e--------------------f----g <-- top_border - | | | | - | | | | - | | | | - h----i--------------------j----k <-- height - bottom-border - | | | | - +----l--------------------m----n + a----b--------------------c----+ + | | | | + d----e--------------------f----g <-- top_border + | | | | + | | | | + | | | | + h----i--------------------j----k <-- height - bottom-border + | | | | + +----l--------------------m----n */ if (!w->m_skin_dest_areas_inited) @@ -440,11 +440,11 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, if (preserve_h_aspect_ratios) { dest_left_border = (int)( left_border - * (w->m_skin_dest_y2 - w->m_skin_dest_y) - / texture_h); + * (w->m_skin_dest_y2 - w->m_skin_dest_y) + / texture_h); dest_right_border = (int)(right_border - * (w->m_skin_dest_y2 - w->m_skin_dest_y) - / texture_h); + * (w->m_skin_dest_y2 - w->m_skin_dest_y) + / texture_h); } else { @@ -463,21 +463,21 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const float vborder_in_portion = 1 - vborder_out_portion; const int ax = (int)(w->m_skin_dest_x - - dest_left_border * hborder_out_portion); + - dest_left_border * hborder_out_portion); const int ay = (int)(w->m_skin_dest_y - - dest_top_border * vborder_out_portion); + - dest_top_border * vborder_out_portion); const int bx = (int)(w->m_skin_dest_x - + dest_left_border*hborder_in_portion); + + dest_left_border*hborder_in_portion); const int by = ay; const int cx = (int)(w->m_skin_dest_x2 - - dest_right_border*hborder_in_portion); + - dest_right_border*hborder_in_portion); const int cy = ay; const int dx = ax; const int dy = (int)(w->m_skin_dest_y - + dest_top_border*vborder_in_portion); + + dest_top_border*vborder_in_portion); const int ex = bx; const int ey = dy; @@ -486,12 +486,12 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const int fy = dy; const int gx = (int)(w->m_skin_dest_x2 - + dest_right_border*hborder_out_portion); + + dest_right_border*hborder_out_portion); const int gy = dy; const int hx = ax; const int hy = (int)(w->m_skin_dest_y2 - - dest_bottom_border*vborder_in_portion); + - dest_bottom_border*vborder_in_portion); const int ix = bx; const int iy = hy; @@ -504,7 +504,7 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, const int lx = bx; const int ly = (int)(w->m_skin_dest_y2 - + dest_bottom_border*vborder_out_portion); + + dest_bottom_border*vborder_out_portion); const int mx = cx; const int my = ly; @@ -532,25 +532,25 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, if (!w->m_skin_dest_areas_yflip_inited) { #define FLIP_Y( X ) { const int y1 = X.UpperLeftCorner.Y \ - - w->m_skin_dest_y; \ - const int y2 = X.LowerRightCorner.Y - w->m_skin_dest_y; \ - X##_yflip = X; \ - X##_yflip.UpperLeftCorner.Y = w->m_skin_dest_y + \ + - w->m_skin_dest_y; \ +const int y2 = X.LowerRightCorner.Y - w->m_skin_dest_y; \ +X##_yflip = X; \ +X##_yflip.UpperLeftCorner.Y = w->m_skin_dest_y + \ (w->m_skin_dest_y2 - w->m_skin_dest_y) - y2;\ - X##_yflip.LowerRightCorner.Y = w->m_skin_dest_y + \ +X##_yflip.LowerRightCorner.Y = w->m_skin_dest_y + \ (w->m_skin_dest_y2 - w->m_skin_dest_y) - y1;} - FLIP_Y(w->m_skin_dest_area_left) - FLIP_Y(w->m_skin_dest_area_center) - FLIP_Y(w->m_skin_dest_area_right) + FLIP_Y(w->m_skin_dest_area_left) + FLIP_Y(w->m_skin_dest_area_center) + FLIP_Y(w->m_skin_dest_area_right) - FLIP_Y(w->m_skin_dest_area_top) - FLIP_Y(w->m_skin_dest_area_bottom) + FLIP_Y(w->m_skin_dest_area_top) + FLIP_Y(w->m_skin_dest_area_bottom) - FLIP_Y(w->m_skin_dest_area_top_left) - FLIP_Y(w->m_skin_dest_area_top_right) - FLIP_Y(w->m_skin_dest_area_bottom_left) - FLIP_Y(w->m_skin_dest_area_bottom_right) + FLIP_Y(w->m_skin_dest_area_top_left) + FLIP_Y(w->m_skin_dest_area_top_right) + FLIP_Y(w->m_skin_dest_area_bottom_left) + FLIP_Y(w->m_skin_dest_area_bottom_right) #undef FLIP_Y } @@ -574,7 +574,7 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, #undef GET_AREA #define GET_AREA( X ) X = (vertical_flip ? w->m_skin_##X##_yflip \ - : w->m_skin_##X) + : w->m_skin_##X) core::recti& GET_AREA(dest_area_left); core::recti& GET_AREA(dest_area_center); core::recti& GET_AREA(dest_area_right); @@ -592,7 +592,7 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, // create a color object if ( (w->m_skin_r != -1 && w->m_skin_g != -1 && w->m_skin_b != -1) || - ID_DEBUG || deactivated) + ID_DEBUG || deactivated) { SColor thecolor(255, w->m_skin_r, w->m_skin_g, w->m_skin_b); colorptr = new SColor[4](); @@ -614,66 +614,66 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, if ((areas & BoxRenderParams::LEFT) != 0) { draw2DImage(source, dest_area_left, - m_source_area_left, clipRect, - colorptr, true /* alpha */); + m_source_area_left, clipRect, + colorptr, true /* alpha */); } if ((areas & BoxRenderParams::BODY) != 0) { draw2DImage(source, dest_area_center, - m_source_area_center, clipRect, - colorptr, true /* alpha */); + m_source_area_center, clipRect, + colorptr, true /* alpha */); } if ((areas & BoxRenderParams::RIGHT) != 0) { draw2DImage(source, dest_area_right, - m_source_area_right, clipRect, - colorptr, true /* alpha */); + m_source_area_right, clipRect, + colorptr, true /* alpha */); } if ((areas & BoxRenderParams::TOP) != 0) { draw2DImage(source, dest_area_top, - m_source_area_top, clipRect, - colorptr, true /* alpha */); + m_source_area_top, clipRect, + colorptr, true /* alpha */); } if ((areas & BoxRenderParams::BOTTOM) != 0) { draw2DImage(source, dest_area_bottom, - m_source_area_bottom, clipRect, - colorptr, true /* alpha */); + m_source_area_bottom, clipRect, + colorptr, true /* alpha */); } if ( ((areas & BoxRenderParams::LEFT) != 0) && - ((areas & BoxRenderParams::TOP ) != 0) ) + ((areas & BoxRenderParams::TOP ) != 0) ) { draw2DImage(source, dest_area_top_left, - m_source_area_top_left, clipRect, - colorptr, true /* alpha */); + m_source_area_top_left, clipRect, + colorptr, true /* alpha */); } if ( ((areas & BoxRenderParams::RIGHT) != 0) && - ((areas & BoxRenderParams::TOP ) != 0) ) + ((areas & BoxRenderParams::TOP ) != 0) ) { draw2DImage(source, dest_area_top_right, - m_source_area_top_right, clipRect, - colorptr, true /* alpha */); + m_source_area_top_right, clipRect, + colorptr, true /* alpha */); } if ( ((areas & BoxRenderParams::LEFT ) != 0) && - ((areas & BoxRenderParams::BOTTOM) != 0) ) + ((areas & BoxRenderParams::BOTTOM) != 0) ) { draw2DImage(source, dest_area_bottom_left, - m_source_area_bottom_left, - clipRect, colorptr, - /*alpha*/true ); + m_source_area_bottom_left, + clipRect, colorptr, + /*alpha*/true ); } if ( ((areas & BoxRenderParams::RIGHT ) != 0) && - ((areas & BoxRenderParams::BOTTOM) != 0) ) + ((areas & BoxRenderParams::BOTTOM) != 0) ) { draw2DImage(source, dest_area_bottom_right, - m_source_area_bottom_right, - clipRect, colorptr, - /*alpha*/true ); + m_source_area_bottom_right, + clipRect, colorptr, + /*alpha*/true ); } if (colorptr != NULL) @@ -689,12 +689,12 @@ void Skin::drawBoxFromStretchableTexture(SkinWidgetContainer* w, * for other players is not supported) */ void Skin::drawButton(Widget* w, const core::recti &rect, - const bool pressed, const bool focused) + const bool pressed, const bool focused) { // if within an appearing dialog, grow if (m_dialog && m_dialog_size < 1.0f && w->m_parent != NULL && - w->m_parent->getType() == gui::EGUIET_WINDOW) + w->m_parent->getType() == gui::EGUIET_WINDOW) { core::recti sized_rect = rect; core::position2d center = @@ -703,28 +703,28 @@ void Skin::drawButton(Widget* w, const core::recti &rect, sized_rect.UpperLeftCorner.X = center.X + (int)(((int)rect.UpperLeftCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); sized_rect.UpperLeftCorner.Y = center.Y + (int)(((int)rect.UpperLeftCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); sized_rect.LowerRightCorner.X = center.X + (int)(((int)rect.LowerRightCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); sized_rect.LowerRightCorner.Y = center.Y + (int)(((int)rect.LowerRightCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); if (focused) { drawBoxFromStretchableTexture(w, sized_rect, - SkinConfig::m_render_params["button::focused"], - w->m_deactivated); + SkinConfig::m_render_params["button::focused"], + w->m_deactivated); } else { drawBoxFromStretchableTexture(w, sized_rect, - SkinConfig::m_render_params["button::neutral"], - w->m_deactivated); + SkinConfig::m_render_params["button::neutral"], + w->m_deactivated); } } else // not within an appearing dialog @@ -732,14 +732,14 @@ void Skin::drawButton(Widget* w, const core::recti &rect, if (focused) { drawBoxFromStretchableTexture(w, rect, - SkinConfig::m_render_params["button::focused"], - w->m_deactivated); + SkinConfig::m_render_params["button::focused"], + w->m_deactivated); } else { drawBoxFromStretchableTexture(w, rect, - SkinConfig::m_render_params["button::neutral"], - w->m_deactivated); + SkinConfig::m_render_params["button::neutral"], + w->m_deactivated); } // if not focused } // not within an appearing dialog } // drawButton @@ -750,12 +750,12 @@ void Skin::drawButton(Widget* w, const core::recti &rect, * for other players is not supported) */ void Skin::drawProgress(Widget* w, const core::recti &rect, - const bool pressed, const bool focused) + const bool pressed, const bool focused) { core::recti sized_rect = rect; // if within an appearing dialog, grow if (m_dialog && m_dialog_size < 1.0f && w->m_parent != NULL && - w->m_parent->getType() == gui::EGUIET_WINDOW ) + w->m_parent->getType() == gui::EGUIET_WINDOW ) { core::position2d center = core::position2d(irr_driver->getFrameSize()/2); @@ -763,42 +763,42 @@ void Skin::drawProgress(Widget* w, const core::recti &rect, sized_rect.UpperLeftCorner.X = center.X + (int)(((int)rect.UpperLeftCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); sized_rect.UpperLeftCorner.Y = center.Y + (int)(((int)rect.UpperLeftCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); sized_rect.LowerRightCorner.X = center.X + (int)(((int)rect.LowerRightCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); sized_rect.LowerRightCorner.Y = center.Y + (int)(((int)rect.LowerRightCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); drawBoxFromStretchableTexture(w, sized_rect, - SkinConfig::m_render_params["progress::neutral"], - w->m_deactivated); + SkinConfig::m_render_params["progress::neutral"], + w->m_deactivated); } else { ProgressBarWidget * progress = (ProgressBarWidget*)w; drawBoxFromStretchableTexture(w, rect, - SkinConfig::m_render_params["progress::neutral"], - w->m_deactivated); + SkinConfig::m_render_params["progress::neutral"], + w->m_deactivated); //the " - 10" is a dirty hack to avoid to have the right arrow // before the left one //FIXME core::recti rect2 = rect; rect2.LowerRightCorner.X -= (rect.getWidth() - 10) - - progress->getValue()*rect.getWidth()/100; + - progress->getValue()*rect.getWidth()/100; drawBoxFromStretchableTexture(w, rect2, - SkinConfig::m_render_params["progress::fill"], - w->m_deactivated); + SkinConfig::m_render_params["progress::fill"], + w->m_deactivated); #if 0 - draw2DImage( - SkinConfig::m_render_params["progress::fill"].getImage(), - sized_rect, core::recti(0,0,progress->m_w, progress->m_h), - 0 /* no clipping */, colors, true); + draw2DImage( + SkinConfig::m_render_params["progress::fill"].getImage(), + sized_rect, core::recti(0,0,progress->m_w, progress->m_h), + 0 /* no clipping */, colors, true); #endif } @@ -810,7 +810,7 @@ void Skin::drawProgress(Widget* w, const core::recti &rect, * for other players is not supported) */ void Skin::drawRatingBar(Widget *w, const core::recti &rect, - const bool pressed, const bool focused) + const bool pressed, const bool focused) { RatingBarWidget *ratingBar = (RatingBarWidget*)w; @@ -818,7 +818,7 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect, const int texture_w = texture->getSize().Width / 4; const int texture_h = texture->getSize().Height; const float aspect_ratio = 1.0f; - + const int star_number = ratingBar->getStarNumber(); int star_h = rect.getHeight(); @@ -830,7 +830,7 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect, star_w = (int)(star_w * scale_factor); star_h = (int)(star_h * scale_factor); } - + // center horizontally and vertically const int x_from = rect.UpperLeftCorner.X; const int y_from = rect.UpperLeftCorner.Y; @@ -841,9 +841,9 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect, ratingBar->setStepValuesByMouse(irr_driver->getDevice()->getCursorControl()->getPosition(), stars_rect); SColor colors[] = { SColor(100,255,255,255), - SColor(100,255,255,255), - SColor(100,255,255,255), - SColor(100,255,255,255) }; + SColor(100,255,255,255), + SColor(100,255,255,255), + SColor(100,255,255,255) }; for (int i = 0; i < star_number; i++) { @@ -853,17 +853,17 @@ void Skin::drawRatingBar(Widget *w, const core::recti &rect, star_rect.UpperLeftCorner.Y = y_from; star_rect.LowerRightCorner.X = x_from + (i + 1) * star_w; star_rect.LowerRightCorner.Y = y_from + star_h; - + int step = ratingBar->getStepsOfStar(i); - + const core::recti source_area(texture_w * step, 0, - texture_w * (step + 1), texture_h); + texture_w * (step + 1), texture_h); draw2DImage(texture, - star_rect, source_area, - 0 /* no clipping */, - (w->m_deactivated || ID_DEBUG) ? colors : 0, - true /* alpha */); + star_rect, source_area, + 0 /* no clipping */, + (w->m_deactivated || ID_DEBUG) ? colors : 0, + true /* alpha */); } } // drawRatingBar @@ -876,18 +876,18 @@ SColor Skin::getColor(const std::string &name) // ---------------------------------------------------------------------------- void Skin::drawRibbon(const core::recti &rect, Widget* widget, - const bool pressed, bool focused) + const bool pressed, bool focused) { } // drawRibbon // ---------------------------------------------------------------------------- /** - * @param focused whether this element is focus by the master player (whether - * the widget is focused for other players is automatically determined) - * FIXME: ugly to pass some focuses through parameter and others not xD - */ + * @param focused whether this element is focus by the master player (whether + * the widget is focused for other players is automatically determined) + * FIXME: ugly to pass some focuses through parameter and others not xD + */ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, - const bool pressed, bool focused) + const bool pressed, bool focused) { // for now, when this kind of widget is disabled, just hide it. we can // change that behaviour if we ever need to... @@ -900,7 +900,7 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, if (GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) != NULL) { focusedElem = GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) - ->getIrrlichtElement(); + ->getIrrlichtElement(); } const bool parent_focused = @@ -920,8 +920,8 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, } const bool mouseIn = rect.isPointInside(irr_driver->getDevice() - ->getCursorControl() - ->getPosition() ); + ->getCursorControl() + ->getPosition() ); BoxRenderParams* params; @@ -938,7 +938,7 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, // automatically guess from position on-screen if tabs go up or down const bool vertical_flip = (unsigned int)rect.UpperLeftCorner.Y < - GUIEngine::getDriver()->getCurrentRenderTargetSize().Height/2; + GUIEngine::getDriver()->getCurrentRenderTargetSize().Height/2; params->m_vertical_flip = vertical_flip; core::recti rect2 = rect; @@ -950,8 +950,8 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, } drawBoxFromStretchableTexture(widget, rect2, *params, - parentRibbon->m_deactivated || - widget->m_deactivated); + parentRibbon->m_deactivated || + widget->m_deactivated); for (unsigned int n=0; nm_event_handler != NULL && - widget->m_event_handler->m_properties[PROP_SQUARE] == "true") + widget->m_event_handler->m_properties[PROP_SQUARE] == "true") use_glow = false; if (widget->m_event_handler != NULL && - widget->m_event_handler->m_event_handler != NULL && - widget->m_event_handler->m_event_handler - ->m_properties[PROP_SQUARE] == "true") + widget->m_event_handler->m_event_handler != NULL && + widget->m_event_handler->m_event_handler + ->m_properties[PROP_SQUARE] == "true") use_glow = false; /* in combo ribbons, always show selection */ RibbonWidget* parentRibbonWidget = NULL; if (widget->m_event_handler != NULL && - widget->m_event_handler->m_type == WTYPE_RIBBON) + widget->m_event_handler->m_type == WTYPE_RIBBON) { parentRibbonWidget = dynamic_cast(widget->m_event_handler); @@ -986,23 +986,23 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, const bool mark_focused = focused || (parent_focused && parentRibbonWidget != NULL && - parentRibbonWidget->m_mouse_focus == widget) || - (mark_selected && !always_show_selection && - parent_focused); + parentRibbonWidget->m_mouse_focus == widget) || + (mark_selected && !always_show_selection && + parent_focused); /* draw "selection bubble" if relevant */ if (always_show_selection && mark_selected) { ITexture* tex_bubble = SkinConfig::m_render_params["selectionHalo::neutral"] - .getImage(); + .getImage(); const int texture_w = tex_bubble->getSize().Width; const int texture_h = tex_bubble->getSize().Height; const float aspectRatio = (float)texture_w / (float)texture_h; core::recti source_area = core::recti(0, 0, - texture_w,texture_h); + texture_w,texture_h); const float outgrow = 0.35f; // make slightly bigger than the // icon it's on @@ -1012,27 +1012,27 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, const int y_shift_up = int((rectHeight - rect.getHeight()) / 2.0f); core::position2di pos(rect.UpperLeftCorner.X + x_gap, - rect.UpperLeftCorner.Y - y_shift_up); + rect.UpperLeftCorner.Y - y_shift_up); core::recti rect2(pos, - core::dimension2di(rectWidth, rectHeight) ); + core::dimension2di(rectWidth, rectHeight) ); if (widget->m_deactivated || ID_DEBUG) { SColor colors[] = { SColor(100,255,255,255), - SColor(100,255,255,255), - SColor(100,255,255,255), - SColor(100,255,255,255) }; + SColor(100,255,255,255), + SColor(100,255,255,255), + SColor(100,255,255,255) }; draw2DImage(tex_bubble, rect2, - source_area, - 0 /* no clipping */, - colors, true /* alpha */); + source_area, + 0 /* no clipping */, + colors, true /* alpha */); } else { draw2DImage(tex_bubble, rect2, - source_area, - 0 /* no clipping */, 0, - true /* alpha */); + source_area, + 0 /* no clipping */, 0, + true /* alpha */); } } @@ -1060,13 +1060,13 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, const int glow_center_x = rect.UpperLeftCorner.X - + rect.getWidth()/2; + + rect.getWidth()/2; const int glow_center_y = rect.UpperLeftCorner.Y - + rect.getHeight() - 5; + + rect.getHeight() - 5; ITexture* tex_ficonhighlight = SkinConfig::m_render_params["focusHalo::neutral"] - .getImage(); + .getImage(); const int texture_w = tex_ficonhighlight->getSize().Width; const int texture_h = tex_ficonhighlight->getSize().Height; @@ -1074,15 +1074,15 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, const core::recti rect2(glow_center_x - 45 - grow, - glow_center_y - 25 - grow/2, - glow_center_x + 45 + grow, - glow_center_y + 25 + grow/2); + glow_center_y - 25 - grow/2, + glow_center_x + 45 + grow, + glow_center_y + 25 + grow/2); draw2DImage(tex_ficonhighlight, rect2, - source_area, - /*clipping*/ 0, - /*color*/ 0, - /*alpha*/true ); + source_area, + /*clipping*/ 0, + /*color*/ 0, + /*alpha*/true ); } // if we're not using glow, draw square focus instead else @@ -1096,15 +1096,15 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, return; drawBoxFromStretchableTexture(parentRibbonWidget, rect, - SkinConfig::m_render_params["squareFocusHalo::neutral"]); + SkinConfig::m_render_params["squareFocusHalo::neutral"]); nPlayersOnThisItem++; } } // end if mark_focused // ---- Draw selection for other players than player 1 if (parentRibbon->isFocusedForPlayer(1) && - parentRibbon->getSelectionIDString(1) == - widget->m_properties[PROP_ID]) + parentRibbon->getSelectionIDString(1) == + widget->m_properties[PROP_ID]) { if (nPlayersOnThisItem > 0) { @@ -1115,20 +1115,20 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, rect2.LowerRightCorner.X += enlarge; rect2.LowerRightCorner.Y += enlarge; drawBoxFromStretchableTexture(parentRibbonWidget, rect2, - SkinConfig::m_render_params["squareFocusHalo2::neutral"]); + SkinConfig::m_render_params["squareFocusHalo2::neutral"]); } else { drawBoxFromStretchableTexture(parentRibbonWidget, rect, - SkinConfig::m_render_params["squareFocusHalo2::neutral"]); + SkinConfig::m_render_params["squareFocusHalo2::neutral"]); } nPlayersOnThisItem++; } if (parentRibbon->isFocusedForPlayer(2) && - parentRibbon->getSelectionIDString(2) == - widget->m_properties[PROP_ID]) + parentRibbon->getSelectionIDString(2) == + widget->m_properties[PROP_ID]) { if (nPlayersOnThisItem > 0) { @@ -1139,19 +1139,19 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, rect2.LowerRightCorner.X += enlarge; rect2.LowerRightCorner.Y += enlarge; drawBoxFromStretchableTexture(parentRibbonWidget, rect2, - SkinConfig::m_render_params["squareFocusHalo3::neutral"]); + SkinConfig::m_render_params["squareFocusHalo3::neutral"]); } else { drawBoxFromStretchableTexture(parentRibbonWidget, rect, - SkinConfig::m_render_params["squareFocusHalo3::neutral"]); + SkinConfig::m_render_params["squareFocusHalo3::neutral"]); } nPlayersOnThisItem++; } if (parentRibbon->isFocusedForPlayer(3) && - parentRibbon->getSelectionIDString(3) == - widget->m_properties[PROP_ID]) + parentRibbon->getSelectionIDString(3) == + widget->m_properties[PROP_ID]) { if (nPlayersOnThisItem > 0) { @@ -1162,12 +1162,12 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, rect2.LowerRightCorner.X += enlarge; rect2.LowerRightCorner.Y += enlarge; drawBoxFromStretchableTexture(parentRibbonWidget, rect2, - SkinConfig::m_render_params["squareFocusHalo4::neutral"]); + SkinConfig::m_render_params["squareFocusHalo4::neutral"]); } else { drawBoxFromStretchableTexture(parentRibbonWidget, rect, - SkinConfig::m_render_params["squareFocusHalo4::neutral"]); + SkinConfig::m_render_params["squareFocusHalo4::neutral"]); } nPlayersOnThisItem++; } @@ -1178,11 +1178,11 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, if (/*mark_selected && widget->hasTooltip() && - (focused || parent_focused) &&*/ - parentRibbon->m_mouse_focus == widget) + (focused || parent_focused) &&*/ + parentRibbon->m_mouse_focus == widget) { if (rect.isPointInside(irr_driver->getDevice()->getCursorControl() - ->getPosition())) + ->getPosition())) { m_tooltip_at_mouse.push_back(true); m_tooltips.push_back(widget); @@ -1197,7 +1197,7 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget, * FIXME: ugly to pass some focuses through parameter and others not xD */ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, - const bool pressed, bool focused) + const bool pressed, bool focused) { if (!widget->isVisible()) return; @@ -1214,8 +1214,8 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, if (focused_widget != NULL && widget->m_children.size()>2) { if (widget->m_children[0].getID() == focused_widget->getID() || - widget->m_children[1].getID() == focused_widget->getID() || - widget->m_children[2].getID() == focused_widget->getID()) + widget->m_children[1].getID() == focused_widget->getID() || + widget->m_children[2].getID() == focused_widget->getID()) { focused = true; } @@ -1223,14 +1223,13 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, } BoxRenderParams& params = (focused || pressed) - ? SkinConfig::m_render_params["spinner::focused"] - : SkinConfig::m_render_params["spinner::neutral"]; + ? SkinConfig::m_render_params["spinner::focused"] + : SkinConfig::m_render_params["spinner::neutral"]; // defining a spinner widget to use the spinner widget class property(getBackgroundColor) SpinnerWidget* q = dynamic_cast(widget); if(q->getUseBackgroundColor()) { - int player_id=q->getSpinnerWidgetPlayerID(); if(player_id==0) params=SkinConfig::m_render_params["spinner1::neutral"]; @@ -1258,8 +1257,8 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, rect2.LowerRightCorner.X -= 2; rect2.LowerRightCorner.Y += 5; drawBoxFromStretchableTexture(widget, rect2, - SkinConfig::m_render_params["squareFocusHalo::neutral"]); - + SkinConfig::m_render_params["squareFocusHalo::neutral"]); + } else if (widget->isFocusedForPlayer(1)) @@ -1270,8 +1269,8 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, rect2.LowerRightCorner.X -= 2; rect2.LowerRightCorner.Y += 5; drawBoxFromStretchableTexture(widget, rect2, - SkinConfig::m_render_params["squareFocusHalo2::neutral"]); - + SkinConfig::m_render_params["squareFocusHalo2::neutral"]); + } else if (widget->isFocusedForPlayer(2)) @@ -1282,7 +1281,7 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, rect2.LowerRightCorner.X -= 2; rect2.LowerRightCorner.Y += 5; drawBoxFromStretchableTexture(widget, rect2, - SkinConfig::m_render_params["squareFocusHalo3::neutral"]); + SkinConfig::m_render_params["squareFocusHalo3::neutral"]); } else if (widget->isFocusedForPlayer(3)) { @@ -1292,51 +1291,51 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, rect2.LowerRightCorner.X -= 2; rect2.LowerRightCorner.Y += 5; drawBoxFromStretchableTexture(widget, rect2, - SkinConfig::m_render_params["squareFocusHalo4::neutral"]); + SkinConfig::m_render_params["squareFocusHalo4::neutral"]); } - + core::recti sized_rect = rect; if (m_dialog && m_dialog_size < 1.0f && widget->m_parent != NULL && - widget->m_parent->getType() == gui::EGUIET_WINDOW) + widget->m_parent->getType() == gui::EGUIET_WINDOW) { core::position2d center(irr_driver->getFrameSize()/2); const float texture_size = sin(m_dialog_size*M_PI*0.5f); sized_rect.UpperLeftCorner.X = center.X + (int)(((int)rect.UpperLeftCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); sized_rect.UpperLeftCorner.Y = center.Y + (int)(((int)rect.UpperLeftCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); sized_rect.LowerRightCorner.X = center.X + (int)(((int)rect.LowerRightCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); sized_rect.LowerRightCorner.Y = center.Y + (int)(((int)rect.LowerRightCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); } drawBoxFromStretchableTexture(widget, sized_rect, params, - widget->m_deactivated); - + widget->m_deactivated); + // ---- If this spinner is of "gauge" type, draw filling const SpinnerWidget* w = dynamic_cast(widget); - + if (w->isGauge() && !w->m_deactivated) { const int handle_size = (int)( widget->m_h*params.m_left_border - /(float)params.getImage()->getSize().Height ); + /(float)params.getImage()->getSize().Height ); const float value = (float)(w->getValue() - w->getMin()) - / (w->getMax() - w->getMin()); + / (w->getMax() - w->getMin()); const core::recti dest_area(rect.UpperLeftCorner.X + handle_size, - rect.UpperLeftCorner.Y, - rect.UpperLeftCorner.X + handle_size + - (int)((widget->m_w - - 2*handle_size)*value), - rect.UpperLeftCorner.Y + widget->m_h); + rect.UpperLeftCorner.Y, + rect.UpperLeftCorner.X + handle_size + + (int)((widget->m_w + - 2*handle_size)*value), + rect.UpperLeftCorner.Y + widget->m_h); const ITexture* texture = SkinConfig::m_render_params["gaugefill::neutral"].getImage(); @@ -1346,9 +1345,9 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, const core::recti source_area(0, 0, texture_w, texture_h); draw2DImage(texture, - dest_area, source_area, - 0 /* no clipping */, 0, - true /* alpha */); + dest_area, source_area, + 0 /* no clipping */, 0, + true /* alpha */); } @@ -1365,7 +1364,7 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget, * other players is not supported) */ void Skin::drawSpinnerChild(const core::recti &rect, Widget* widget, - const bool pressed, bool focused) + const bool pressed, bool focused) { if (!widget->isVisible()) return; @@ -1382,13 +1381,13 @@ void Skin::drawSpinnerChild(const core::recti &rect, Widget* widget, return; core::recti rect2(spinner->m_x, spinner->m_y, - spinner->m_x + spinner->m_w, - spinner->m_y + spinner->m_h ); + spinner->m_x + spinner->m_w, + spinner->m_y + spinner->m_h ); BoxRenderParams& params = SkinConfig::m_render_params["spinner::down"]; params.areas = areas; drawBoxFromStretchableTexture(widget, rect, params, - widget->m_deactivated); + widget->m_deactivated); } } @@ -1396,23 +1395,23 @@ void Skin::drawSpinnerChild(const core::recti &rect, Widget* widget, // ---------------------------------------------------------------------------- /** * @param focused whether this element is focus by the master player (focus for - * other players is not supported) +* other players is not supported) */ void Skin::drawIconButton(const core::recti &rect, Widget* widget, - const bool pressed, bool focused) + const bool pressed, bool focused) { RibbonWidget* parentRibbon = dynamic_cast(widget->m_event_handler); IGUIElement* focusedElem = NULL; if (GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) != NULL) { focusedElem = GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) - ->getIrrlichtElement(); + ->getIrrlichtElement(); } const bool parent_focused = (widget->m_event_handler == NULL ? false : - (focusedElem == widget->m_event_handler->m_element)); + (focusedElem == widget->m_event_handler->m_element)); const bool mark_focused = focused || (parent_focused && parentRibbon != NULL && - parentRibbon->getSelectionIDString(PLAYER_ID_GAME_MASTER) == widget->m_properties[PROP_ID]); + parentRibbon->getSelectionIDString(PLAYER_ID_GAME_MASTER) == widget->m_properties[PROP_ID]); if (focused) { @@ -1436,35 +1435,35 @@ void Skin::drawIconButton(const core::recti &rect, Widget* widget, const core::recti rect2(glow_center_x - 45 - grow, - glow_center_y - 25 - grow/2, - glow_center_x + 45 + grow, - glow_center_y + 25 + grow/2); + glow_center_y - 25 - grow/2, + glow_center_x + 45 + grow, + glow_center_y + 25 + grow/2); draw2DImage(tex_ficonhighlight, rect2, - source_area, - 0 /* no clipping */, 0, - true /* alpha */); + source_area, + 0 /* no clipping */, 0, + true /* alpha */); } core::recti sized_rect = rect; if (m_dialog && m_dialog_size < 1.0f && widget->m_parent != NULL && - widget->m_parent->getType() == gui::EGUIET_WINDOW) + widget->m_parent->getType() == gui::EGUIET_WINDOW) { core::position2d center(irr_driver->getFrameSize()/2); const float texture_size = sin(m_dialog_size*M_PI*0.5f); sized_rect.UpperLeftCorner.X = center.X + (int)(((int)rect.UpperLeftCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); sized_rect.UpperLeftCorner.Y = center.Y + (int)(((int)rect.UpperLeftCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); sized_rect.LowerRightCorner.X = center.X + (int)(((int)rect.LowerRightCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); sized_rect.LowerRightCorner.Y = center.Y + (int)(((int)rect.LowerRightCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); } IconButtonWidget* icon_widget = (IconButtonWidget*) widget; @@ -1479,13 +1478,13 @@ void Skin::drawIconButton(const core::recti &rect, Widget* widget, if (widget->m_deactivated || ID_DEBUG) { SColor colors[] = { SColor(100,255,255,255), - SColor(100,255,255,255), - SColor(100,255,255,255), - SColor(100,255,255,255) }; + SColor(100,255,255,255), + SColor(100,255,255,255), + SColor(100,255,255,255) }; core::recti r(0,0,icon_widget->m_texture_w, icon_widget->m_texture_h); draw2DImage(icon_widget->m_texture, sized_rect, - r, 0 /* no clipping */, colors, - true /* alpha */); + r, 0 /* no clipping */, colors, + true /* alpha */); } else { @@ -1493,16 +1492,16 @@ void Skin::drawIconButton(const core::recti &rect, Widget* widget, const bool mouseInside = rect.isPointInside(irr_driver->getDevice()->getCursorControl() - ->getPosition()); + ->getPosition()); if (icon_widget->m_highlight_texture != NULL && - (mark_focused || mouseInside) ) + (mark_focused || mouseInside) ) { t = icon_widget->m_highlight_texture; } core::recti r(0,0,icon_widget->m_texture_w, icon_widget->m_texture_h); draw2DImage(t, sized_rect, r,0 - /* no clipping */, 0, - true /* alpha */); + /* no clipping */, 0, + true /* alpha */); } if (widget->m_type == WTYPE_MODEL_VIEW) @@ -1514,7 +1513,7 @@ void Skin::drawIconButton(const core::recti &rect, Widget* widget, // ---------------------------------------------------------------------------- /** * @param focused whether this element is focus by the master player (focus - * for other players is not supported) +* for other players is not supported) */ void Skin::drawCheckBox(const core::recti &rect, Widget* widget, bool focused) { @@ -1525,18 +1524,18 @@ void Skin::drawCheckBox(const core::recti &rect, Widget* widget, bool focused) if (w->getState() == true) { texture = focused - ? SkinConfig::m_render_params["checkbox::focused+checked"] - .getImage() - : SkinConfig::m_render_params["checkbox::neutral+checked"] - .getImage(); + ? SkinConfig::m_render_params["checkbox::focused+checked"] + .getImage() + : SkinConfig::m_render_params["checkbox::neutral+checked"] + .getImage(); } else { texture = focused - ? SkinConfig::m_render_params["checkbox::focused+unchecked"] - .getImage() - : SkinConfig::m_render_params["checkbox::neutral+unchecked"] - .getImage(); + ? SkinConfig::m_render_params["checkbox::focused+unchecked"] + .getImage() + : SkinConfig::m_render_params["checkbox::neutral+unchecked"] + .getImage(); } const int texture_w = texture->getSize().Width; @@ -1547,18 +1546,18 @@ void Skin::drawCheckBox(const core::recti &rect, Widget* widget, bool focused) if (widget->m_deactivated) { SColor colors[] = { SColor(100,255,255,255), - SColor(100,255,255,255), - SColor(100,255,255,255), - SColor(100,255,255,255) }; + SColor(100,255,255,255), + SColor(100,255,255,255), + SColor(100,255,255,255) }; draw2DImage( texture, rect, source_area, - 0 /* no clipping */, colors, - true /* alpha */); + 0 /* no clipping */, colors, + true /* alpha */); } else { draw2DImage( texture, rect, source_area, - 0 /* no clipping */, 0, - true /* alpha */); + 0 /* no clipping */, 0, + true /* alpha */); } } // drawCheckBox @@ -1578,30 +1577,30 @@ void Skin::drawList(const core::recti &rect, Widget* widget, bool focused) // ---------------------------------------------------------------------------- /** * @param focused whether this element is focus by the master player (focus for - * other players is not supported) +* other players is not supported) */ void Skin::drawListSelection(const core::recti &rect, Widget* widget, - bool focused, const core::recti *clip) + bool focused, const core::recti *clip) { ListWidget* list = dynamic_cast(widget); assert(list != NULL); drawBoxFromStretchableTexture(&list->m_selection_skin_info, rect, - SkinConfig::m_render_params["listitem::focused"], - list->m_deactivated, clip); + SkinConfig::m_render_params["listitem::focused"], + list->m_deactivated, clip); } // drawListSelection // ---------------------------------------------------------------------------- void Skin::drawListHeader(const irr::core::rect< irr::s32 > &rect, - Widget* widget) + Widget* widget) { bool isSelected = - (((ListWidget*)widget->m_event_handler)->m_selected_column == widget && + (((ListWidget*)widget->m_event_handler)->m_selected_column == widget && ((ListWidget*)widget->m_event_handler)->m_sort_default == false); drawBoxFromStretchableTexture(widget, rect, (isSelected ? SkinConfig::m_render_params["list_header::down"] - : SkinConfig::m_render_params["list_header::neutral"]), + : SkinConfig::m_render_params["list_header::neutral"]), false, NULL /* clip */); if (isSelected) @@ -1616,11 +1615,11 @@ void Skin::drawListHeader(const irr::core::rect< irr::s32 > &rect, SkinConfig::m_render_params["list_sort_down::neutral"].getImage(); core::recti destRect(rect.UpperLeftCorner, - core::dimension2di(rect.getHeight(), - rect.getHeight())); + core::dimension2di(rect.getHeight(), + rect.getHeight())); core::recti srcRect(core::position2d(0,0), img->getSize()); draw2DImage(img, destRect, srcRect, - NULL, NULL, /* alpha */true); + NULL, NULL, /* alpha */true); } } // drawListHeader @@ -1646,26 +1645,26 @@ void Skin::renderSections(PtrVector* within_vector) if (widget.m_is_bounding_box_round) { core::recti rect(widget.m_x, widget.m_y, - widget.m_x + widget.m_w, - widget.m_y + widget.m_h ); + widget.m_x + widget.m_w, + widget.m_y + widget.m_h ); drawBoxFromStretchableTexture(&widget, rect, - SkinConfig::m_render_params["rounded_section::neutral"]); + SkinConfig::m_render_params["rounded_section::neutral"]); } else { core::recti rect(widget.m_x, widget.m_y, - widget.m_x + widget.m_w, - widget.m_y + widget.m_h ); + widget.m_x + widget.m_w, + widget.m_y + widget.m_h ); drawBoxFromStretchableTexture(&widget, rect, - SkinConfig::m_render_params["section::neutral"]); + SkinConfig::m_render_params["section::neutral"]); } - + renderSections( &widget.m_children ); } else if (widget.isBottomBar()) { const core::dimension2du &framesize = - irr_driver->getFrameSize(); + irr_driver->getFrameSize(); // bar.png is 128 pixels high const float y_size = (framesize.Height - widget.m_y) / 128.0f; @@ -1678,13 +1677,13 @@ void Skin::renderSections(PtrVector* within_vector) tex = irr_driver->getTexture(FileManager::GUI, "main_help.png"); if(!tex) Log::fatal("Skin", - "Can't find fallback texture 'main_help.png, aborting."); + "Can't find fallback texture 'main_help.png, aborting."); } core::recti r1(0, (int)(widget.m_y - 40*y_size), - framesize.Width, framesize.Height); + framesize.Width, framesize.Height); core::recti r2(core::dimension2di(0,0), tex->getSize()); draw2DImage(tex, r1, r2, - 0, 0, /*alpha*/true); + 0, 0, /*alpha*/true); } else if (widget.isTopBar()) { @@ -1692,10 +1691,10 @@ void Skin::renderSections(PtrVector* within_vector) irr_driver->getTexture(FileManager::GUI, "top_bar.png"); core::recti r1(0, 0, - (int)widget.m_w, (int)widget.m_h); + (int)widget.m_w, (int)widget.m_h); core::recti r2(core::dimension2di(0,0), tex->getSize()); draw2DImage(tex, r1, r2, - 0, 0, /*alpha*/false); + 0, 0, /*alpha*/false); } else { @@ -1719,9 +1718,9 @@ void Skin::drawScrollbarBackground(const irr::core::rect< irr::s32 > &rect) SkinConfig::m_render_params["scrollbar_background::neutral"]; draw2DImage(p.getImage(), rect2, - p.m_source_area_center, - 0 /* no clipping */, 0, - true /* alpha */); + p.m_source_area_center, + 0 /* no clipping */, 0, + true /* alpha */); } // drawScrollbarBackground @@ -1732,26 +1731,26 @@ void Skin::drawScrollbarThumb(const irr::core::rect< irr::s32 > &rect) SkinConfig::m_render_params["scrollbar_thumb::neutral"]; draw2DImage(p.getImage(), rect, - p.m_source_area_center, - 0 /* no clipping */, 0, - true /* alpha */); + p.m_source_area_center, + 0 /* no clipping */, 0, + true /* alpha */); } // drawScrollbarThumb // ---------------------------------------------------------------------------- void Skin::drawScrollbarButton(const irr::core::rect< irr::s32 > &rect, - const bool pressed, const bool bottomArrow) + const bool pressed, const bool bottomArrow) { BoxRenderParams& p = (pressed) - ? SkinConfig::m_render_params["scrollbar_button::down"] - : SkinConfig::m_render_params["scrollbar_button::neutral"]; + ? SkinConfig::m_render_params["scrollbar_button::down"] + : SkinConfig::m_render_params["scrollbar_button::neutral"]; if (!bottomArrow) { draw2DImage(p.getImage(), rect, - p.m_source_area_center, - 0 /* no clipping */, 0, - true /* alpha */); + p.m_source_area_center, + 0 /* no clipping */, 0, + true /* alpha */); } else { @@ -1763,9 +1762,9 @@ void Skin::drawScrollbarButton(const irr::core::rect< irr::s32 > &rect, const int y1 = source_area.LowerRightCorner.Y; draw2DImage(p.getImage(), rect, - core::recti(x0, y1, x1, y0), - 0 /* no clipping */, 0, - true /* alpha */); + core::recti(x0, y1, x1, y0), + 0 /* no clipping */, 0, + true /* alpha */); } } // drawScrollbarButton @@ -1799,9 +1798,9 @@ void Skin::drawTooltip(Widget* widget, bool atMouse) core::recti r(pos, size); drawBoxFromStretchableTexture(widget, r, - SkinConfig::m_render_params["tooltip::neutral"]); + SkinConfig::m_render_params["tooltip::neutral"]); font->draw(widget->getTooltipText(), r, video::SColor(255, 0, 0, 0), - false, false); + false, false); } // drawTooltip #if 0 @@ -1811,7 +1810,7 @@ void Skin::drawTooltip(Widget* widget, bool atMouse) // ---------------------------------------------------------------------------- void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, - const core::recti &rect, const core::recti *clip) + const core::recti &rect, const core::recti *clip) { if (GUIEngine::getStateManager()->getGameState() == GUIEngine::GAME) return; // ignore in game mode @@ -1840,7 +1839,7 @@ void Skin::draw2DRectangle (IGUIElement *element, const video::SColor &color, // ----------------------------------------------------------------------------- void Skin::process3DPane(IGUIElement *element, const core::recti &rect, - const bool pressed) + const bool pressed) { const int id = element->getID(); @@ -1850,8 +1849,8 @@ void Skin::process3DPane(IGUIElement *element, const core::recti &rect, if (widget == NULL) { if (element->getType() == gui::EGUIET_BUTTON && - element->getParent() != NULL && - element->getParent()->getType() == EGUIET_SCROLL_BAR) + element->getParent() != NULL && + element->getParent()->getType() == EGUIET_SCROLL_BAR) { const int parentHeight = element->getParent()->getRelativePosition().getHeight(); @@ -1878,12 +1877,12 @@ void Skin::process3DPane(IGUIElement *element, const core::recti &rect, // accordingly if (widget->m_event_handler != NULL && - widget->m_event_handler->m_type == WTYPE_RIBBON) + widget->m_event_handler->m_type == WTYPE_RIBBON) { drawRibbonChild(rect, widget, pressed, focused); } else if (widget->m_event_handler != NULL && - widget->m_event_handler->m_type == WTYPE_SPINNER) + widget->m_event_handler->m_type == WTYPE_SPINNER) { if (!widget->m_event_handler->m_deactivated) drawSpinnerChild(rect, widget, pressed, focused); @@ -1895,7 +1894,7 @@ void Skin::process3DPane(IGUIElement *element, const core::recti &rect, else if (type == WTYPE_BUTTON) { if (widget->m_event_handler != NULL && - widget->m_event_handler->getType() == WTYPE_LIST) + widget->m_event_handler->getType() == WTYPE_LIST) { drawListHeader(rect, widget); } @@ -1942,33 +1941,33 @@ void Skin::process3DPane(IGUIElement *element, const core::recti &rect, // ----------------------------------------------------------------------------- void doDrawBadge(ITexture* texture, const core::recti& rect, - float max_icon_size, bool badge_at_left) + float max_icon_size, bool badge_at_left) { // In case of a problem if(!texture) return; const core::dimension2d& texture_size = texture->getSize(); const float aspectRatio = (float)texture_size.Width - / (float)texture_size.Height; + / (float)texture_size.Height; const int h = rect.getHeight() <= 50 - ? rect.getHeight() - : std::min( (int)(rect.getHeight()*max_icon_size), - (int)(texture_size.Height) ); + ? rect.getHeight() + : std::min( (int)(rect.getHeight()*max_icon_size), + (int)(texture_size.Height) ); int w = (int)(aspectRatio*h); const core::recti source_area(0, 0, texture_size.Width, - texture_size.Height); + texture_size.Height); const core::recti rect2(badge_at_left ? rect.UpperLeftCorner.X - : rect.LowerRightCorner.X - w, - rect.LowerRightCorner.Y - h, - badge_at_left ? rect.UpperLeftCorner.X + w - : rect.LowerRightCorner.X, - rect.LowerRightCorner.Y ); + : rect.LowerRightCorner.X - w, + rect.LowerRightCorner.Y - h, + badge_at_left ? rect.UpperLeftCorner.X + w + : rect.LowerRightCorner.X, + rect.LowerRightCorner.Y ); draw2DImage(texture, rect2, source_area, - 0 /* no clipping */, 0, - true /* alpha */); + 0 /* no clipping */, 0, + true /* alpha */); } // doDrawBadge // ---------------------------------------------------------------------------- @@ -1977,21 +1976,21 @@ void Skin::drawBadgeOn(const Widget* widget, const core::recti& rect) if (widget->m_badges & LOCKED_BADGE) { video::ITexture* texture = irr_driver->getTexture(FileManager::GUI, - "gui_lock.png"); + "gui_lock.png"); float max_icon_size = 0.5f; // Lock badge can be quite big doDrawBadge(texture, rect, max_icon_size, true); } if (widget->m_badges & OK_BADGE) { video::ITexture* texture = irr_driver->getTexture(FileManager::GUI, - "green_check.png"); + "green_check.png"); float max_icon_size = 0.35f; doDrawBadge(texture, rect, max_icon_size, true); } if (widget->m_badges & BAD_BADGE) { video::ITexture* texture = irr_driver->getTexture(FileManager::GUI, - "red_mark.png"); + "red_mark.png"); float max_icon_size = 0.35f; doDrawBadge(texture, rect, max_icon_size, false); } @@ -1999,44 +1998,44 @@ void Skin::drawBadgeOn(const Widget* widget, const core::recti& rect) { float max_icon_size = 0.43f; video::ITexture* texture = irr_driver->getTexture(FileManager::GUI, - "cup_bronze.png"); + "cup_bronze.png"); doDrawBadge(texture, rect, max_icon_size, false); } if (widget->m_badges & KEYBOARD_BADGE) { float max_icon_size = 0.43f; video::ITexture* texture = irr_driver->getTexture(FileManager::GUI, - "keyboard.png"); + "keyboard.png"); doDrawBadge(texture, rect, max_icon_size, true); } if (widget->m_badges & GAMEPAD_BADGE) { float max_icon_size = 0.43f; video::ITexture* texture = irr_driver->getTexture(FileManager::GUI, - "gamepad.png"); + "gamepad.png"); doDrawBadge(texture, rect, max_icon_size, true); } if (widget->m_badges & LOADING_BADGE) { float max_icon_size = 0.43f; video::ITexture* texture = irr_driver->getTexture(FileManager::GUI, - "hourglass.png"); + "hourglass.png"); doDrawBadge(texture, rect, max_icon_size, true); } } // drawBadgeOn // ----------------------------------------------------------------------------- void Skin::draw3DButtonPanePressed (IGUIElement *element, - const core::recti &rect, - const core::recti *clip) + const core::recti &rect, + const core::recti *clip) { process3DPane(element, rect, true /* pressed */ ); } // draw3DButtonPanePressed // ----------------------------------------------------------------------------- void Skin::draw3DButtonPaneStandard (IGUIElement *element, - const core::recti &rect, - const core::recti *clip) + const core::recti &rect, + const core::recti *clip) { if (element->getType()==gui::EGUIET_SCROLL_BAR) { @@ -2050,8 +2049,8 @@ void Skin::draw3DButtonPaneStandard (IGUIElement *element, // ----------------------------------------------------------------------------- void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, - bool flat, bool fillBackGround, - const core::recti &rect, const core::recti *clip) + bool flat, bool fillBackGround, + const core::recti &rect, const core::recti *clip) { const int id = element->getID(); Widget* widget = GUIEngine::getWidget(id); @@ -2064,7 +2063,7 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, if (GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) != NULL) { focusedElem = GUIEngine::getFocusForPlayer(PLAYER_ID_GAME_MASTER) - ->getIrrlichtElement(); + ->getIrrlichtElement(); } const bool focused = (focusedElem == element); @@ -2082,30 +2081,30 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, // if within an appearing dialog, grow if (m_dialog && m_dialog_size < 1.0f && widget->m_parent != NULL && - widget->m_parent->getType() == gui::EGUIET_WINDOW) + widget->m_parent->getType() == gui::EGUIET_WINDOW) { core::position2d center(irr_driver->getFrameSize()/2); const float texture_size = sin(m_dialog_size*M_PI*0.5f); borderArea.UpperLeftCorner.X = center.X + (int)(((int)rect.UpperLeftCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); borderArea.UpperLeftCorner.Y = center.Y + (int)(((int)rect.UpperLeftCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); borderArea.LowerRightCorner.X = center.X + (int)(((int)rect.LowerRightCorner.X - - (int)center.X)*texture_size); + - (int)center.X)*texture_size); borderArea.LowerRightCorner.Y = center.Y + (int)(((int)rect.LowerRightCorner.Y - - (int)center.Y)*texture_size); + - (int)center.Y)*texture_size); } GL32_draw2DRectangle(focused ? border_color_focus : border_color, borderArea); core::recti innerArea = borderArea; innerArea.UpperLeftCorner += position2d< s32 >( 3, 3 ); innerArea.LowerRightCorner -= position2d< s32 >( 3, 3 ); - GL32_draw2DRectangle(focused ? bg_color_focused : bg_color, innerArea); + GL32_draw2DRectangle(focused ? bg_color_focused : bg_color, innerArea); return; } else if (type == WTYPE_LIST) @@ -2113,9 +2112,9 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, //drawList(rect, widget, focused); drawList(core::recti(widget->m_x, widget->m_y, - widget->m_x + widget->m_w, - widget->m_y + widget->m_h), - widget, focused); + widget->m_x + widget->m_w, + widget->m_y + widget->m_h), + widget, focused); } else if (type == WTYPE_BUBBLE) { @@ -2152,10 +2151,10 @@ void Skin::draw3DSunkenPane (IGUIElement *element, video::SColor bgcolor, if (bubble->isFocusedForPlayer(PLAYER_ID_GAME_MASTER)) drawBoxFromStretchableTexture(widget, rect2, - SkinConfig::m_render_params["textbubble::focused"]); + SkinConfig::m_render_params["textbubble::focused"]); else drawBoxFromStretchableTexture(widget, rect2, - SkinConfig::m_render_params["textbubble::neutral"]); + SkinConfig::m_render_params["textbubble::neutral"]); return; } @@ -2169,19 +2168,19 @@ void Skin::drawBGFadeColor() SColor color = SkinConfig::m_colors["dialog_background::neutral"]; if (m_dialog_size < 1.0f) color.setAlpha( (unsigned int)(color.getAlpha()*m_dialog_size )); - GL32_draw2DRectangle(color, - core::recti(position2d< s32 >(0,0), - GUIEngine::getDriver()->getCurrentRenderTargetSize()) ); + GL32_draw2DRectangle(color, + core::recti(position2d< s32 >(0,0), + GUIEngine::getDriver()->getCurrentRenderTargetSize()) ); } // drawBGFadeColor // ----------------------------------------------------------------------------- core::recti Skin::draw3DWindowBackground(IGUIElement *element, - bool drawTitleBar, - video::SColor titleBarColor, - const core::recti &rect, - const core::recti *clip, - core::recti* checkClientArea) + bool drawTitleBar, + video::SColor titleBarColor, + const core::recti &rect, + const core::recti *clip, + core::recti* checkClientArea) { if (ModalDialog::getCurrent() == NULL) return rect; @@ -2200,14 +2199,14 @@ core::recti Skin::draw3DWindowBackground(IGUIElement *element, sized_rect.LowerRightCorner.X = (int)(center.X +(w/2.0f)*texture_size); sized_rect.LowerRightCorner.Y = (int)(center.Y +(h/2.0f)*texture_size); drawBoxFromStretchableTexture( ModalDialog::getCurrent(), sized_rect, - SkinConfig::m_render_params["window::neutral"]); + SkinConfig::m_render_params["window::neutral"]); m_dialog_size += GUIEngine::getLatestDt()*5; } else { drawBoxFromStretchableTexture( ModalDialog::getCurrent(), rect, - SkinConfig::m_render_params["window::neutral"]); + SkinConfig::m_render_params["window::neutral"]); } return rect; @@ -2216,32 +2215,32 @@ core::recti Skin::draw3DWindowBackground(IGUIElement *element, // ----------------------------------------------------------------------------- void Skin::draw3DMenuPane (IGUIElement *element, const core::recti &rect, - const core::recti *clip) + const core::recti *clip) { SColor color = SColor(150, 96, 74, 196); - GL32_draw2DRectangle(color, rect); + GL32_draw2DRectangle(color, rect); } // draw3DMenuPane // ----------------------------------------------------------------------------- void Skin::draw3DTabBody (IGUIElement *element, bool border, bool background, - const core::recti &rect, const core::recti *clip, - s32 tabHeight, gui::EGUI_ALIGNMENT alignment) + const core::recti &rect, const core::recti *clip, + s32 tabHeight, gui::EGUI_ALIGNMENT alignment) { } // draw3DTabBody // ----------------------------------------------------------------------------- void Skin::draw3DTabButton (IGUIElement *element, bool active, - const core::recti &rect, const core::recti *clip, - gui::EGUI_ALIGNMENT alignment) + const core::recti &rect, const core::recti *clip, + gui::EGUI_ALIGNMENT alignment) { } // draw3DTabButton // ----------------------------------------------------------------------------- void Skin::draw3DToolBar (IGUIElement *element, const core::recti &rect, - const core::recti *clip) + const core::recti *clip) { } // draw3DToolBar @@ -2250,7 +2249,7 @@ void Skin::draw3DToolBar (IGUIElement *element, const core::recti &rect, ITexture* Skin::getImage(const char* name) { if (SkinConfig::m_render_params.find(name) - != SkinConfig::m_render_params.end()) + != SkinConfig::m_render_params.end()) { BoxRenderParams& p = SkinConfig::m_render_params[name]; return p.getImage(); @@ -2264,12 +2263,12 @@ ITexture* Skin::getImage(const char* name) // ----------------------------------------------------------------------------- void Skin::drawIcon (IGUIElement *element, EGUI_DEFAULT_ICON icon, - const core::position2di position, u32 starttime, - u32 currenttime, bool loop, const core::recti *clip) + const core::position2di position, u32 starttime, + u32 currenttime, bool loop, const core::recti *clip) { // we won't let irrLicht decide when to call this, we draw them ourselves. /* m_fallback_skin->drawIcon(element, icon, position, starttime, - currenttime, loop, clip); */ + currenttime, loop, clip); */ } // ----------------------------------------------------------------------------- @@ -2277,33 +2276,33 @@ void Skin::drawIcon (IGUIElement *element, EGUI_DEFAULT_ICON icon, video::SColor Skin::getColor (EGUI_DEFAULT_COLOR color) const { /* - EGDC_3D_DARK_SHADOW Dark shadow for three-dimensional display elements. - EGDC_3D_SHADOW Shadow color for three-dimensional display elements - (for edges facing away from the light source). - EGDC_3D_FACE Face color for three-dimensional display elements and for - dialog box backgrounds. - EGDC_3D_HIGH_LIGHT Highlight color for three-dimensional display - elements (for edges facing the light source.). - EGDC_3D_LIGHT Light color for three-dimensional display elements (for - edges facing the light source.). - EGDC_ACTIVE_BORDER Active window border. - EGDC_ACTIVE_CAPTION Active window title bar text. - EGDC_APP_WORKSPACE Background color of multiple document interface - (MDI) applications. - EGDC_BUTTON_TEXT Text on a button. - EGDC_GRAY_TEXT Grayed (disabled) text. - EGDC_HIGH_LIGHT Item(s) selected in a control. - EGDC_HIGH_LIGHT_TEXT Text of item(s) selected in a control. - EGDC_INACTIVE_BORDER Inactive window border. - EGDC_INACTIVE_CAPTION Inactive window caption. - EGDC_TOOLTIP Tool tip text color. - EGDC_TOOLTIP_BACKGROUND Tool tip background color. - EGDC_SCROLLBAR Scrollbar gray area. - EGDC_WINDOW Window background. - EGDC_WINDOW_SYMBOL Window symbols like on close buttons, scroll bars - and check boxes. - EGDC_ICON Icons in a list or tree. - EGDC_ICON_HIGH_LIGHT Selected icons in a list or tree. + EGDC_3D_DARK_SHADOW Dark shadow for three-dimensional display elements. + EGDC_3D_SHADOW Shadow color for three-dimensional display elements + (for edges facing away from the light source). + EGDC_3D_FACE Face color for three-dimensional display elements and for + dialog box backgrounds. + EGDC_3D_HIGH_LIGHT Highlight color for three-dimensional display + elements (for edges facing the light source.). + EGDC_3D_LIGHT Light color for three-dimensional display elements (for + edges facing the light source.). + EGDC_ACTIVE_BORDER Active window border. + EGDC_ACTIVE_CAPTION Active window title bar text. + EGDC_APP_WORKSPACE Background color of multiple document interface + (MDI) applications. + EGDC_BUTTON_TEXT Text on a button. + EGDC_GRAY_TEXT Grayed (disabled) text. + EGDC_HIGH_LIGHT Item(s) selected in a control. + EGDC_HIGH_LIGHT_TEXT Text of item(s) selected in a control. + EGDC_INACTIVE_BORDER Inactive window border. + EGDC_INACTIVE_CAPTION Inactive window caption. + EGDC_TOOLTIP Tool tip text color. + EGDC_TOOLTIP_BACKGROUND Tool tip background color. + EGDC_SCROLLBAR Scrollbar gray area. + EGDC_WINDOW Window background. + EGDC_WINDOW_SYMBOL Window symbols like on close buttons, scroll bars + and check boxes. + EGDC_ICON Icons in a list or tree. + EGDC_ICON_HIGH_LIGHT Selected icons in a list or tree. */ switch(color) diff --git a/src/guiengine/skin.hpp b/src/guiengine/skin.hpp index 53d8c6a31..5392e78df 100644 --- a/src/guiengine/skin.hpp +++ b/src/guiengine/skin.hpp @@ -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 m_skin_dest_area_left; - core::rect m_skin_dest_area_center; - core::rect m_skin_dest_area_right; + // see comments in Skin::drawBoxFromStretchableTexture for + // explaination of what these are + core::rect m_skin_dest_area_left; + core::rect m_skin_dest_area_center; + core::rect m_skin_dest_area_right; - core::rect m_skin_dest_area_top; - core::rect m_skin_dest_area_bottom; + core::rect m_skin_dest_area_top; + core::rect m_skin_dest_area_bottom; - core::rect m_skin_dest_area_top_left; - core::rect m_skin_dest_area_top_right; - core::rect m_skin_dest_area_bottom_left; - core::rect m_skin_dest_area_bottom_right; + core::rect m_skin_dest_area_top_left; + core::rect m_skin_dest_area_top_right; + core::rect m_skin_dest_area_bottom_left; + core::rect m_skin_dest_area_bottom_right; - // y flip - core::rect m_skin_dest_area_left_yflip; - core::rect m_skin_dest_area_center_yflip; - core::rect m_skin_dest_area_right_yflip; + // y flip + core::rect m_skin_dest_area_left_yflip; + core::rect m_skin_dest_area_center_yflip; + core::rect m_skin_dest_area_right_yflip; - core::rect m_skin_dest_area_top_yflip; - core::rect m_skin_dest_area_bottom_yflip; + core::rect m_skin_dest_area_top_yflip; + core::rect m_skin_dest_area_bottom_yflip; - core::rect m_skin_dest_area_top_left_yflip; - core::rect m_skin_dest_area_top_right_yflip; - core::rect m_skin_dest_area_bottom_left_yflip; - core::rect m_skin_dest_area_bottom_right_yflip; + core::rect m_skin_dest_area_top_left_yflip; + core::rect m_skin_dest_area_top_right_yflip; + core::rect m_skin_dest_area_bottom_left_yflip; + core::rect 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 m_tooltips; std::vector 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* clipRect=NULL); - private: + void drawBoxFromStretchableTexture(SkinWidgetContainer* w, + const core::rect< s32 > &dest, + BoxRenderParams& params, + bool deactivated=false, + const core::rect* 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* checkClientArea=0); + draw3DWindowBackground(gui::IGUIElement *element, + bool drawTitleBar, + video::SColor titleBarColor, + const core::rect< s32 > &rect, + const core::rect< s32 > *clip, + core::rect* 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); diff --git a/src/guiengine/widgets/spinner_widget.cpp b/src/guiengine/widgets/spinner_widget.cpp index a7793e3df..bb5894939 100644 --- a/src/guiengine/widgets/spinner_widget.cpp +++ b/src/guiengine/widgets/spinner_widget.cpp @@ -63,17 +63,17 @@ void SpinnerWidget::add() if (min_s.size() > 0) { - if (!StringUtils::parseString(min_s, &m_min)) + if (!StringUtils::parseString(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(max_s, &m_max)) - { - Log::warn("invalid value for spinner widget maximum value : %s", max_s.c_str()); + if (!StringUtils::parseString(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 widget_size = rect(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 subsize_left_arrow = rect(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 subsize_label = rect(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 subsize_right_arrow = rect(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); } diff --git a/src/guiengine/widgets/spinner_widget.hpp b/src/guiengine/widgets/spinner_widget.hpp index 02506f6ad..edaff980b 100644 --- a/src/guiengine/widgets/spinner_widget.hpp +++ b/src/guiengine/widgets/spinner_widget.hpp @@ -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 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 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 diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index b80c7cea4..b1d887a22 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -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 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; ngetPlayer(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 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; naddTextChild( _(groups[n].c_str()) , groups[n]); - } // for naddTextChild( _(groups[n].c_str()) , groups[n]); + } // for n("karts"); @@ -945,7 +945,7 @@ void KartSelectionScreen::init() RibbonWidget* tabs = getWidget("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; nm_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; ngetName().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; ngetActivePlayer(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; ngetProfile() @@ -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; nm_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; diff --git a/src/states_screens/kart_selection.hpp b/src/states_screens/kart_selection.hpp index 27feb2688..fab5e7063 100644 --- a/src/states_screens/kart_selection.hpp +++ b/src/states_screens/kart_selection.hpp @@ -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