diff --git a/src/addons/addons_manager.cpp b/src/addons/addons_manager.cpp index 77474a64c..4d50a63c4 100644 --- a/src/addons/addons_manager.cpp +++ b/src/addons/addons_manager.cpp @@ -456,22 +456,22 @@ bool AddonsManager::uninstall(const Addon &addon) m_addons_list.getData()[index].setInstalled(false); //remove the addons directory - bool error = false; - // if the user deleted the data directory for an add-on with - // filesystem tools, removeTrack/removeKart will trigger an assert - // because the kart/track was never added in the first place - if (file_manager->fileExists(addon.getDataDir())) - { - error = !file_manager->removeDirectory(addon.getDataDir()); - if(addon.getType()=="kart") - { - kart_properties_manager->removeKart(addon.getId()); - } - else if(addon.getType()=="track" || addon.getType()=="arena") - { - track_manager->removeTrack(addon.getId()); - } - } + bool error = false; + // if the user deleted the data directory for an add-on with + // filesystem tools, removeTrack/removeKart will trigger an assert + // because the kart/track was never added in the first place + if (file_manager->fileExists(addon.getDataDir())) + { + error = !file_manager->removeDirectory(addon.getDataDir()); + if(addon.getType()=="kart") + { + kart_properties_manager->removeKart(addon.getId()); + } + else if(addon.getType()=="track" || addon.getType()=="arena") + { + track_manager->removeTrack(addon.getId()); + } + } saveInstalled(); return !error; } // uninstall diff --git a/src/addons/network_http.cpp b/src/addons/network_http.cpp index 3246193d8..d5b36d7f1 100644 --- a/src/addons/network_http.cpp +++ b/src/addons/network_http.cpp @@ -494,19 +494,19 @@ CURLcode NetworkHttp::downloadFileInternal(Request *request) curl_easy_setopt(m_curl_session, CURLOPT_URL, full_url.c_str()); std::string uagent = (std::string)"SuperTuxKart/" + STK_VERSION; - // Add platform to user-agent string for informational purposes. - // Add more cases as necessary. - #ifdef WIN32 - uagent += (std::string)" (Windows)"; - #elif defined(__APPLE__) - uagent += (std::string)" (Macintosh)"; - #elif defined(__FreeBSD__) - uagent += (std::string)" (FreeBSD)"; - #elif defined(linux) - uagent += (std::string)" (Linux)"; - #else - // Unknown system type - #endif + // Add platform to user-agent string for informational purposes. + // Add more cases as necessary. + #ifdef WIN32 + uagent += (std::string)" (Windows)"; + #elif defined(__APPLE__) + uagent += (std::string)" (Macintosh)"; + #elif defined(__FreeBSD__) + uagent += (std::string)" (FreeBSD)"; + #elif defined(linux) + uagent += (std::string)" (Linux)"; + #else + // Unknown system type + #endif curl_easy_setopt(m_curl_session, CURLOPT_USERAGENT, uagent.c_str()); curl_easy_setopt(m_curl_session, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(m_curl_session, CURLOPT_PROGRESSDATA, request); diff --git a/src/config/user_config.cpp b/src/config/user_config.cpp index 8af0e9069..ec2563d50 100644 --- a/src/config/user_config.cpp +++ b/src/config/user_config.cpp @@ -721,11 +721,11 @@ bool UserConfig::loadConfig() void UserConfig::postLoadInit() { - for (int i = 0; i < UserConfigParams::m_all_players.size(); i++) - { - PlayerProfile* player = UserConfigParams::m_all_players.get(i); - if (player->isGuestAccount()) player->setName(_LTR("Guest")); - } + for (int i = 0; i < UserConfigParams::m_all_players.size(); i++) + { + PlayerProfile* player = UserConfigParams::m_all_players.get(i); + if (player->isGuestAccount()) player->setName(_LTR("Guest")); + } } // ---------------------------------------------------------------------------- diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index 41d3ac770..5af9625a8 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -354,27 +354,27 @@ namespace UserConfigParams &m_wiimote_group, "At what raw input value maximum steering is reached (between 1 and 25).") ); - PARAM_PREFIX FloatUserConfigParam m_wiimote_weight_linear + PARAM_PREFIX FloatUserConfigParam m_wiimote_weight_linear PARAM_DEFAULT( FloatUserConfigParam(0.2f, "wiimote-weight-linear", &m_wiimote_group, - "A weight applied to the linear component of mapping wiimote angle to steering angle")); + "A weight applied to the linear component of mapping wiimote angle to steering angle")); PARAM_PREFIX FloatUserConfigParam m_wiimote_weight_square PARAM_DEFAULT( FloatUserConfigParam(0.8f, "wiimote-weight-square", &m_wiimote_group, - "A weight applied to the square component of mapping wiimote angle to steering angle")); + "A weight applied to the square component of mapping wiimote angle to steering angle")); PARAM_PREFIX FloatUserConfigParam m_wiimote_weight_asin PARAM_DEFAULT( FloatUserConfigParam(0.0f, "wiimote-weight-asin", &m_wiimote_group, - "A weight applied to the asin component of mapping wiimote angle to steering angle")); + "A weight applied to the asin component of mapping wiimote angle to steering angle")); PARAM_PREFIX FloatUserConfigParam m_wiimote_weight_sin PARAM_DEFAULT( FloatUserConfigParam(0.0f, "wiimote-weight-sin", &m_wiimote_group, - "A weight applied to the sin component of mapping wiimote angle to steering angle")); + "A weight applied to the sin component of mapping wiimote angle to steering angle")); - // ---- GP start order + // ---- GP start order PARAM_PREFIX GroupUserConfigParam m_gp_start_order PARAM_DEFAULT( GroupUserConfigParam("GpStartOrder", "Order karts start in GP") ); @@ -719,7 +719,7 @@ public: const irr::core::stringw& getWarning() { return m_warning; } void resetWarning() { m_warning=""; } void setWarning(irr::core::stringw& warning) { m_warning=warning; } - void postLoadInit(); + void postLoadInit(); void addDefaultPlayer(); }; // UserConfig diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index f5bc6a8ff..45332fa8b 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -265,8 +265,8 @@ void IrrDriver::initDevice() if(m_modes.size()==0) { createListOfVideoModes(); - // The debug name is only set if irrlicht is compiled in debug - // mode. So we use this to print a warning to the user. + // The debug name is only set if irrlicht is compiled in debug + // mode. So we use this to print a warning to the user. if(m_device->getDebugName()) { Log::warn("irr_driver", @@ -858,8 +858,8 @@ scene::ISceneNode *IrrDriver::addBillboard(const core::dimension2d< f32 > size, m_scene_manager->addBillboardSceneNode(parent, size); assert(node->getMaterialCount() > 0); node->setMaterialTexture(0, texture); - if(alphaTesting) - node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); + if(alphaTesting) + node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); return node; } // addMesh diff --git a/src/graphics/lod_node.hpp b/src/graphics/lod_node.hpp index 00c4c4a6f..c3c3adc2d 100644 --- a/src/graphics/lod_node.hpp +++ b/src/graphics/lod_node.hpp @@ -112,8 +112,8 @@ public: std::vector& getAllNodes() { return m_nodes; } //! OnAnimate() is called just before rendering the whole scene. - /** This method will be called once per frame, independent - of whether the scene node is visible or not. */ + /** This method will be called once per frame, independent + of whether the scene node is visible or not. */ virtual void OnAnimate(u32 timeMs); virtual void OnRegisterSceneNode(); diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index 77858cc63..715fa13bc 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -1426,11 +1426,11 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m { /** //! Texture is clamped to the last pixel - ETC_CLAMP, - //! Texture is clamped to the edge pixel - ETC_CLAMP_TO_EDGE, - //! Texture is clamped to the border pixel (if exists) - ETC_CLAMP_TO_BORDER, + ETC_CLAMP, + //! Texture is clamped to the edge pixel + ETC_CLAMP_TO_EDGE, + //! Texture is clamped to the border pixel (if exists) + ETC_CLAMP_TO_BORDER, */ for (unsigned int n=0; ngetAbsoluteTransformation(); + core::matrix4 transform = m_node->getAbsoluteTransformation(); core::vector3df velocity(m_particle_type->getVelocityX(), m_particle_type->getVelocityY(), m_particle_type->getVelocityZ()); diff --git a/src/guiengine/abstract_top_level_container.hpp b/src/guiengine/abstract_top_level_container.hpp index 6efb8f83d..1f7bb874f 100644 --- a/src/guiengine/abstract_top_level_container.hpp +++ b/src/guiengine/abstract_top_level_container.hpp @@ -77,12 +77,12 @@ namespace GUIEngine Widget* getWidget(const int id); /** This function searches and returns a widget by name, cast as specified type, - * if that widget is found and the type is correct. - * \param name The name of the widget to find - * \return an object by name, casted to specified type, or NULL if + * if that widget is found and the type is correct. + * \param name The name of the widget to find + * \return an object by name, casted to specified type, or NULL if * not found/wrong type */ template - T* getWidget(const char* name) + T* getWidget(const char* name) { Widget* out = getWidget(name); T* outCasted = dynamic_cast( out ); diff --git a/src/guiengine/skin.cpp b/src/guiengine/skin.cpp index a6b8f0187..ee0ecee0b 100644 --- a/src/guiengine/skin.cpp +++ b/src/guiengine/skin.cpp @@ -128,7 +128,7 @@ namespace SkinConfig if(node->get("type", &type) == 0) { - Log::error("skin", "All elements must have a type\n"); + Log::error("skin", "All elements must have a type\n"); return; } node->get("state", &state); @@ -155,7 +155,7 @@ namespace SkinConfig 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 diff --git a/src/guiengine/widgets/CGUIEditBox.cpp b/src/guiengine/widgets/CGUIEditBox.cpp index 1ae5f90f3..5f852c194 100644 --- a/src/guiengine/widgets/CGUIEditBox.cpp +++ b/src/guiengine/widgets/CGUIEditBox.cpp @@ -17,12 +17,12 @@ #include "utils/time.hpp" /* - todo: - optional scrollbars - ctrl+left/right to select word - double click/ctrl click: word select + drag to select whole words, triple click to select line - optional? dragging selected text - numerical + todo: + optional scrollbars + ctrl+left/right to select word + double click/ctrl click: word select + drag to select whole words, triple click to select line + optional? dragging selected text + numerical */ @@ -33,336 +33,336 @@ StkTime::TimeType getTime() //! constructor CGUIEditBox::CGUIEditBox(const wchar_t* text, bool border, - IGUIEnvironment* environment, IGUIElement* parent, s32 id, - const core::rect& rectangle, bool is_rtl) - : IGUIEditBox(environment, parent, id, rectangle), MouseMarking(false), - Border(border), OverrideColorEnabled(false), MarkBegin(0), MarkEnd(0), - OverrideColor(video::SColor(101,255,255,255)), OverrideFont(0), LastBreakFont(0), - Operator(0), BlinkStartTime(0), CursorPos(0), HScrollPos(0), VScrollPos(0), Max(0), - WordWrap(false), MultiLine(false), AutoScroll(true), PasswordBox(false), - PasswordChar(L'*'), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER), - CurrentTextRect(0,0,1,1), FrameRect(rectangle) + IGUIEnvironment* environment, IGUIElement* parent, s32 id, + const core::rect& rectangle, bool is_rtl) + : IGUIEditBox(environment, parent, id, rectangle), MouseMarking(false), + Border(border), OverrideColorEnabled(false), MarkBegin(0), MarkEnd(0), + OverrideColor(video::SColor(101,255,255,255)), OverrideFont(0), LastBreakFont(0), + Operator(0), BlinkStartTime(0), CursorPos(0), HScrollPos(0), VScrollPos(0), Max(0), + WordWrap(false), MultiLine(false), AutoScroll(true), PasswordBox(false), + PasswordChar(L'*'), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_CENTER), + CurrentTextRect(0,0,1,1), FrameRect(rectangle) { m_rtl = is_rtl; - #ifdef _DEBUG - setDebugName("CGUIEditBox"); - #endif + #ifdef _DEBUG + setDebugName("CGUIEditBox"); + #endif - Text = text; + Text = text; - if (Environment) - Operator = Environment->getOSOperator(); + if (Environment) + Operator = Environment->getOSOperator(); - if (Operator) - Operator->grab(); + if (Operator) + Operator->grab(); - // this element can be tabbed to - setTabStop(true); - setTabOrder(-1); + // this element can be tabbed to + setTabStop(true); + setTabOrder(-1); - IGUISkin *skin = 0; - if (Environment) - skin = Environment->getSkin(); - if (Border && skin) - { - FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1; - FrameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; - FrameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1; - FrameRect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; - } + IGUISkin *skin = 0; + if (Environment) + skin = Environment->getSkin(); + if (Border && skin) + { + FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1; + FrameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; + FrameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1; + FrameRect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; + } - breakText(); + breakText(); - calculateScrollPos(); + calculateScrollPos(); } //! destructor CGUIEditBox::~CGUIEditBox() { - if (OverrideFont) - OverrideFont->drop(); + if (OverrideFont) + OverrideFont->drop(); - if (Operator) - Operator->drop(); + if (Operator) + Operator->drop(); } //! Sets another skin independent font. void CGUIEditBox::setOverrideFont(IGUIFont* font) { - if (OverrideFont == font) - return; + if (OverrideFont == font) + return; - if (OverrideFont) - OverrideFont->drop(); + if (OverrideFont) + OverrideFont->drop(); - OverrideFont = font; + OverrideFont = font; - if (OverrideFont) - OverrideFont->grab(); + if (OverrideFont) + OverrideFont->grab(); - breakText(); + breakText(); } //! Sets another color for the text. void CGUIEditBox::setOverrideColor(video::SColor color) { - OverrideColor = color; - OverrideColorEnabled = true; + OverrideColor = color; + OverrideColorEnabled = true; } video::SColor CGUIEditBox::getOverrideColor() const { - return OverrideColor; + return OverrideColor; } //! Turns the border on or off void CGUIEditBox::setDrawBorder(bool border) { - Border = border; + Border = border; } //! Sets if the text should use the overide color or the color in the gui skin. void CGUIEditBox::enableOverrideColor(bool enable) { - OverrideColorEnabled = enable; + OverrideColorEnabled = enable; } bool CGUIEditBox::isOverrideColorEnabled() const { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return OverrideColorEnabled; + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return OverrideColorEnabled; } //! Enables or disables word wrap void CGUIEditBox::setWordWrap(bool enable) { - WordWrap = enable; - breakText(); + WordWrap = enable; + breakText(); } void CGUIEditBox::updateAbsolutePosition() { core::rect oldAbsoluteRect(AbsoluteRect); - IGUIElement::updateAbsolutePosition(); - if ( oldAbsoluteRect != AbsoluteRect ) - { + IGUIElement::updateAbsolutePosition(); + if ( oldAbsoluteRect != AbsoluteRect ) + { breakText(); - } + } } //! Checks if word wrap is enabled bool CGUIEditBox::isWordWrapEnabled() const { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return WordWrap; + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return WordWrap; } //! Enables or disables newlines. void CGUIEditBox::setMultiLine(bool enable) { - MultiLine = enable; + MultiLine = enable; } //! Checks if multi line editing is enabled bool CGUIEditBox::isMultiLineEnabled() const { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return MultiLine; + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return MultiLine; } void CGUIEditBox::setPasswordBox(bool passwordBox, wchar_t passwordChar) { - PasswordBox = passwordBox; - if (PasswordBox) - { - PasswordChar = passwordChar; - setMultiLine(false); - setWordWrap(false); - BrokenText.clear(); - } + PasswordBox = passwordBox; + if (PasswordBox) + { + PasswordChar = passwordChar; + setMultiLine(false); + setWordWrap(false); + BrokenText.clear(); + } } bool CGUIEditBox::isPasswordBox() const { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return PasswordBox; + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return PasswordBox; } //! Sets text justification void CGUIEditBox::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) { - HAlign = horizontal; - VAlign = vertical; + HAlign = horizontal; + VAlign = vertical; } //! called if an event happened. bool CGUIEditBox::OnEvent(const SEvent& event) { - if (isEnabled()) - { + if (isEnabled()) + { - switch(event.EventType) - { - case EET_GUI_EVENT: - if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) - { - if (event.GUIEvent.Caller == this) - { - MouseMarking = false; - setTextMarkers(0,0); - } - } - break; - case EET_KEY_INPUT_EVENT: - if (processKey(event)) - return true; - break; - case EET_MOUSE_INPUT_EVENT: - if (processMouse(event)) - return true; - break; - default: - break; - } - } + switch(event.EventType) + { + case EET_GUI_EVENT: + if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUS_LOST) + { + if (event.GUIEvent.Caller == this) + { + MouseMarking = false; + setTextMarkers(0,0); + } + } + break; + case EET_KEY_INPUT_EVENT: + if (processKey(event)) + return true; + break; + case EET_MOUSE_INPUT_EVENT: + if (processMouse(event)) + return true; + break; + default: + break; + } + } - return IGUIElement::OnEvent(event); + return IGUIElement::OnEvent(event); } bool CGUIEditBox::processKey(const SEvent& event) { - if (!event.KeyInput.PressedDown) - return false; + if (!event.KeyInput.PressedDown) + return false; - bool textChanged = false; - s32 newMarkBegin = MarkBegin; - s32 newMarkEnd = MarkEnd; + bool textChanged = false; + s32 newMarkBegin = MarkBegin; + s32 newMarkEnd = MarkEnd; - // control shortcut handling + // control shortcut handling - if (event.KeyInput.Control) - { - // german backlash '\' entered with control + '?' - if ( event.KeyInput.Char == '\\' ) - { - inputChar(event.KeyInput.Char); - return true; - } + if (event.KeyInput.Control) + { + // german backlash '\' entered with control + '?' + if ( event.KeyInput.Char == '\\' ) + { + inputChar(event.KeyInput.Char); + return true; + } - switch(event.KeyInput.Key) - { - case KEY_KEY_A: - // select all - newMarkBegin = 0; - newMarkEnd = Text.size(); - break; - case KEY_KEY_C: - // copy to clipboard - if (!PasswordBox && Operator && MarkBegin != MarkEnd) - { - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + switch(event.KeyInput.Key) + { + case KEY_KEY_A: + // select all + newMarkBegin = 0; + newMarkEnd = Text.size(); + break; + case KEY_KEY_C: + // copy to clipboard + if (!PasswordBox && Operator && MarkBegin != MarkEnd) + { + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - core::stringc s; - s = Text.subString(realmbgn, realmend - realmbgn).c_str(); - Operator->copyToClipboard(s.c_str()); - } - break; - case KEY_KEY_X: - // cut to the clipboard - if (!PasswordBox && Operator && MarkBegin != MarkEnd) - { - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + core::stringc s; + s = Text.subString(realmbgn, realmend - realmbgn).c_str(); + Operator->copyToClipboard(s.c_str()); + } + break; + case KEY_KEY_X: + // cut to the clipboard + if (!PasswordBox && Operator && MarkBegin != MarkEnd) + { + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - // copy - core::stringc sc; - sc = Text.subString(realmbgn, realmend - realmbgn).c_str(); - Operator->copyToClipboard(sc.c_str()); + // copy + core::stringc sc; + sc = Text.subString(realmbgn, realmend - realmbgn).c_str(); + Operator->copyToClipboard(sc.c_str()); - if (isEnabled()) - { - // delete - core::stringw s; - s = Text.subString(0, realmbgn); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; + if (isEnabled()) + { + // delete + core::stringw s; + s = Text.subString(0, realmbgn); + s.append( Text.subString(realmend, Text.size()-realmend) ); + Text = s; - CursorPos = realmbgn; - newMarkBegin = 0; - newMarkEnd = 0; - textChanged = true; - } - } - break; + CursorPos = realmbgn; + newMarkBegin = 0; + newMarkEnd = 0; + textChanged = true; + } + } + break; - case KEY_KEY_V: - if ( !isEnabled() ) - break; + case KEY_KEY_V: + if ( !isEnabled() ) + break; - // paste from the clipboard - if (Operator) - { - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + // paste from the clipboard + if (Operator) + { + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - // add new character - const c8* p = Operator->getTextFromClipboard(); - if (p) - { - if (MarkBegin == MarkEnd) - { - // insert text - core::stringw s = Text.subString(0, CursorPos); - s.append(p); - s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); + // add new character + const c8* p = Operator->getTextFromClipboard(); + if (p) + { + if (MarkBegin == MarkEnd) + { + // insert text + core::stringw s = Text.subString(0, CursorPos); + s.append(p); + s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); - if (!Max || s.size()<=Max) // thx to Fish FH for fix - { - Text = s; - s = p; - CursorPos += s.size(); - } - } - else - { - // replace text + if (!Max || s.size()<=Max) // thx to Fish FH for fix + { + Text = s; + s = p; + CursorPos += s.size(); + } + } + else + { + // replace text - core::stringw s = Text.subString(0, realmbgn); - s.append(p); - s.append( Text.subString(realmend, Text.size()-realmend) ); + core::stringw s = Text.subString(0, realmbgn); + s.append(p); + s.append( Text.subString(realmend, Text.size()-realmend) ); - if (!Max || s.size()<=Max) // thx to Fish FH for fix - { - Text = s; - s = p; - CursorPos = realmbgn + s.size(); - } - } - } + if (!Max || s.size()<=Max) // thx to Fish FH for fix + { + Text = s; + s = p; + CursorPos = realmbgn + s.size(); + } + } + } - newMarkBegin = 0; - newMarkEnd = 0; - textChanged = true; - } - break; - case KEY_HOME: + newMarkBegin = 0; + newMarkEnd = 0; + textChanged = true; + } + break; + case KEY_HOME: if (!m_rtl) { // move/highlight to start of text @@ -379,8 +379,8 @@ bool CGUIEditBox::processKey(const SEvent& event) newMarkEnd = 0; } } - break; - case KEY_END: + break; + case KEY_END: if (!m_rtl) { // move/highlight to end of text @@ -397,15 +397,15 @@ bool CGUIEditBox::processKey(const SEvent& event) newMarkEnd = 0; } } - break; - default: - return false; - } - } - // default keyboard handling - else - switch(event.KeyInput.Key) - { + break; + default: + return false; + } + } + // default keyboard handling + else + switch(event.KeyInput.Key) + { /* case KEY_KEY_Q: inputChar(L'\u05DC'); @@ -433,72 +433,72 @@ bool CGUIEditBox::processKey(const SEvent& event) return true; */ - case KEY_END: - if (!m_rtl) - { - s32 p = Text.size(); - if (WordWrap || MultiLine) - { - p = getLineFromPos(CursorPos); - p = BrokenTextPositions[p] + (s32)BrokenText[p].size(); - if (p > 0 && (Text[p-1] == L'\r' || Text[p-1] == L'\n' )) - p-=1; - } - - if (event.KeyInput.Shift) - { - if (MarkBegin == MarkEnd) - newMarkBegin = CursorPos; - - newMarkEnd = p; - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } - CursorPos = p; - BlinkStartTime = getTime(); - } - break; - case KEY_HOME: + case KEY_END: if (!m_rtl) - { + { + s32 p = Text.size(); + if (WordWrap || MultiLine) + { + p = getLineFromPos(CursorPos); + p = BrokenTextPositions[p] + (s32)BrokenText[p].size(); + if (p > 0 && (Text[p-1] == L'\r' || Text[p-1] == L'\n' )) + p-=1; + } - s32 p = 0; - if (WordWrap || MultiLine) - { - p = getLineFromPos(CursorPos); - p = BrokenTextPositions[p]; - } + if (event.KeyInput.Shift) + { + if (MarkBegin == MarkEnd) + newMarkBegin = CursorPos; - if (event.KeyInput.Shift) - { - if (MarkBegin == MarkEnd) - newMarkBegin = CursorPos; - newMarkEnd = p; - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } - CursorPos = p; - BlinkStartTime = getTime(); - } - break; - case KEY_RETURN: - if (MultiLine) - { - inputChar(L'\n'); - return true; - } - else - { - sendGuiEvent( EGET_EDITBOX_ENTER ); - } - break; - case KEY_LEFT: + newMarkEnd = p; + } + else + { + newMarkBegin = 0; + newMarkEnd = 0; + } + CursorPos = p; + BlinkStartTime = getTime(); + } + break; + case KEY_HOME: + if (!m_rtl) + { + + s32 p = 0; + if (WordWrap || MultiLine) + { + p = getLineFromPos(CursorPos); + p = BrokenTextPositions[p]; + } + + if (event.KeyInput.Shift) + { + if (MarkBegin == MarkEnd) + newMarkBegin = CursorPos; + newMarkEnd = p; + } + else + { + newMarkBegin = 0; + newMarkEnd = 0; + } + CursorPos = p; + BlinkStartTime = getTime(); + } + break; + case KEY_RETURN: + if (MultiLine) + { + inputChar(L'\n'); + return true; + } + else + { + sendGuiEvent( EGET_EDITBOX_ENTER ); + } + break; + case KEY_LEFT: if (!m_rtl) { if (event.KeyInput.Shift) @@ -520,9 +520,9 @@ bool CGUIEditBox::processKey(const SEvent& event) if (CursorPos > 0) CursorPos--; BlinkStartTime = getTime(); } - break; + break; - case KEY_RIGHT: + case KEY_RIGHT: if (!m_rtl) { if (event.KeyInput.Shift) @@ -544,309 +544,309 @@ bool CGUIEditBox::processKey(const SEvent& event) if (Text.size() > (u32)CursorPos) CursorPos++; BlinkStartTime = getTime(); } - break; - case KEY_UP: - if (MultiLine || (WordWrap && BrokenText.size() > 1) ) - { - s32 lineNo = getLineFromPos(CursorPos); - s32 mb = (MarkBegin == MarkEnd) ? CursorPos : (MarkBegin > MarkEnd ? MarkBegin : MarkEnd); - if (lineNo > 0) - { - s32 cp = CursorPos - BrokenTextPositions[lineNo]; - if ((s32)BrokenText[lineNo-1].size() < cp) - CursorPos = BrokenTextPositions[lineNo-1] + (s32)BrokenText[lineNo-1].size()-1; - else - CursorPos = BrokenTextPositions[lineNo-1] + cp; - } + break; + case KEY_UP: + if (MultiLine || (WordWrap && BrokenText.size() > 1) ) + { + s32 lineNo = getLineFromPos(CursorPos); + s32 mb = (MarkBegin == MarkEnd) ? CursorPos : (MarkBegin > MarkEnd ? MarkBegin : MarkEnd); + if (lineNo > 0) + { + s32 cp = CursorPos - BrokenTextPositions[lineNo]; + if ((s32)BrokenText[lineNo-1].size() < cp) + CursorPos = BrokenTextPositions[lineNo-1] + (s32)BrokenText[lineNo-1].size()-1; + else + CursorPos = BrokenTextPositions[lineNo-1] + cp; + } - if (event.KeyInput.Shift) - { - newMarkBegin = mb; - newMarkEnd = CursorPos; - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } + if (event.KeyInput.Shift) + { + newMarkBegin = mb; + newMarkEnd = CursorPos; + } + else + { + newMarkBegin = 0; + newMarkEnd = 0; + } - } - else - { - return false; - } - break; - case KEY_DOWN: - if (MultiLine || (WordWrap && BrokenText.size() > 1) ) - { - s32 lineNo = getLineFromPos(CursorPos); - s32 mb = (MarkBegin == MarkEnd) ? CursorPos : (MarkBegin < MarkEnd ? MarkBegin : MarkEnd); - if (lineNo < (s32)BrokenText.size()-1) - { - s32 cp = CursorPos - BrokenTextPositions[lineNo]; - if ((s32)BrokenText[lineNo+1].size() < cp) - CursorPos = BrokenTextPositions[lineNo+1] + BrokenText[lineNo+1].size()-1; - else - CursorPos = BrokenTextPositions[lineNo+1] + cp; - } + } + else + { + return false; + } + break; + case KEY_DOWN: + if (MultiLine || (WordWrap && BrokenText.size() > 1) ) + { + s32 lineNo = getLineFromPos(CursorPos); + s32 mb = (MarkBegin == MarkEnd) ? CursorPos : (MarkBegin < MarkEnd ? MarkBegin : MarkEnd); + if (lineNo < (s32)BrokenText.size()-1) + { + s32 cp = CursorPos - BrokenTextPositions[lineNo]; + if ((s32)BrokenText[lineNo+1].size() < cp) + CursorPos = BrokenTextPositions[lineNo+1] + BrokenText[lineNo+1].size()-1; + else + CursorPos = BrokenTextPositions[lineNo+1] + cp; + } - if (event.KeyInput.Shift) - { - newMarkBegin = mb; - newMarkEnd = CursorPos; - } - else - { - newMarkBegin = 0; - newMarkEnd = 0; - } + if (event.KeyInput.Shift) + { + newMarkBegin = mb; + newMarkEnd = CursorPos; + } + else + { + newMarkBegin = 0; + newMarkEnd = 0; + } - } - else - { - return false; - } - break; + } + else + { + return false; + } + break; - case KEY_BACK: - if ( !isEnabled() ) - break; + case KEY_BACK: + if ( !isEnabled() ) + break; - if (Text.size()) - { - core::stringw s; + if (Text.size()) + { + core::stringw s; - if (MarkBegin != MarkEnd) - { - // delete marked text - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + if (MarkBegin != MarkEnd) + { + // delete marked text + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - s = Text.subString(0, realmbgn); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; + s = Text.subString(0, realmbgn); + s.append( Text.subString(realmend, Text.size()-realmend) ); + Text = s; - CursorPos = realmbgn; - } - else - { - // delete text behind cursor - if (CursorPos>0) - s = Text.subString(0, CursorPos-1); - else - s = L""; - s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); - Text = s; - --CursorPos; - } + CursorPos = realmbgn; + } + else + { + // delete text behind cursor + if (CursorPos>0) + s = Text.subString(0, CursorPos-1); + else + s = L""; + s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); + Text = s; + --CursorPos; + } - if (CursorPos < 0) - CursorPos = 0; - BlinkStartTime = getTime(); - newMarkBegin = 0; - newMarkEnd = 0; - textChanged = true; - } - break; - case KEY_DELETE: - if ( !isEnabled() ) - break; + if (CursorPos < 0) + CursorPos = 0; + BlinkStartTime = getTime(); + newMarkBegin = 0; + newMarkEnd = 0; + textChanged = true; + } + break; + case KEY_DELETE: + if ( !isEnabled() ) + break; - if (Text.size() != 0) - { - core::stringw s; + if (Text.size() != 0) + { + core::stringw s; - if (MarkBegin != MarkEnd) - { - // delete marked text - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + if (MarkBegin != MarkEnd) + { + // delete marked text + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - s = Text.subString(0, realmbgn); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; + s = Text.subString(0, realmbgn); + s.append( Text.subString(realmend, Text.size()-realmend) ); + Text = s; - CursorPos = realmbgn; - } - else - { - // delete text before cursor - s = Text.subString(0, CursorPos); - s.append( Text.subString(CursorPos+1, Text.size()-CursorPos-1) ); - Text = s; - } + CursorPos = realmbgn; + } + else + { + // delete text before cursor + s = Text.subString(0, CursorPos); + s.append( Text.subString(CursorPos+1, Text.size()-CursorPos-1) ); + Text = s; + } - if (CursorPos > (s32)Text.size()) - CursorPos = (s32)Text.size(); + if (CursorPos > (s32)Text.size()) + CursorPos = (s32)Text.size(); - BlinkStartTime = getTime(); - newMarkBegin = 0; - newMarkEnd = 0; - textChanged = true; - } - break; + BlinkStartTime = getTime(); + newMarkBegin = 0; + newMarkEnd = 0; + textChanged = true; + } + break; - case KEY_ESCAPE: - case KEY_TAB: - case KEY_SHIFT: - case KEY_F1: - case KEY_F2: - case KEY_F3: - case KEY_F4: - case KEY_F5: - case KEY_F6: - case KEY_F7: - case KEY_F8: - case KEY_F9: - case KEY_F10: - case KEY_F11: - case KEY_F12: - case KEY_F13: - case KEY_F14: - case KEY_F15: - case KEY_F16: - case KEY_F17: - case KEY_F18: - case KEY_F19: - case KEY_F20: - case KEY_F21: - case KEY_F22: - case KEY_F23: - case KEY_F24: - // ignore these keys - return false; + case KEY_ESCAPE: + case KEY_TAB: + case KEY_SHIFT: + case KEY_F1: + case KEY_F2: + case KEY_F3: + case KEY_F4: + case KEY_F5: + case KEY_F6: + case KEY_F7: + case KEY_F8: + case KEY_F9: + case KEY_F10: + case KEY_F11: + case KEY_F12: + case KEY_F13: + case KEY_F14: + case KEY_F15: + case KEY_F16: + case KEY_F17: + case KEY_F18: + case KEY_F19: + case KEY_F20: + case KEY_F21: + case KEY_F22: + case KEY_F23: + case KEY_F24: + // ignore these keys + return false; - default: - inputChar(event.KeyInput.Char); - return true; - } + default: + inputChar(event.KeyInput.Char); + return true; + } // Set new text markers setTextMarkers( newMarkBegin, newMarkEnd ); - // break the text if it has changed - if (textChanged) - { - breakText(); - sendGuiEvent(EGET_EDITBOX_CHANGED); - } + // break the text if it has changed + if (textChanged) + { + breakText(); + sendGuiEvent(EGET_EDITBOX_CHANGED); + } - calculateScrollPos(); + calculateScrollPos(); - return true; + return true; } //! draws the element and its children void CGUIEditBox::draw() { - if (!IsVisible) - return; + if (!IsVisible) + return; - const bool focus = Environment->hasFocus(this); + const bool focus = Environment->hasFocus(this); - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; - FrameRect = AbsoluteRect; + FrameRect = AbsoluteRect; - // draw the border + // draw the border - if (Border) - { - EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE; - if ( isEnabled() ) - col = focus ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE; - skin->draw3DSunkenPane(this, skin->getColor(col), - false, true, FrameRect, &AbsoluteClippingRect); + if (Border) + { + EGUI_DEFAULT_COLOR col = EGDC_GRAY_EDITABLE; + if ( isEnabled() ) + col = focus ? EGDC_FOCUSED_EDITABLE : EGDC_EDITABLE; + skin->draw3DSunkenPane(this, skin->getColor(col), + false, true, FrameRect, &AbsoluteClippingRect); - FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1; - FrameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; - FrameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1; - FrameRect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; - } - core::rect localClipRect = FrameRect; - localClipRect.clipAgainst(AbsoluteClippingRect); + FrameRect.UpperLeftCorner.X += skin->getSize(EGDS_TEXT_DISTANCE_X)+1; + FrameRect.UpperLeftCorner.Y += skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; + FrameRect.LowerRightCorner.X -= skin->getSize(EGDS_TEXT_DISTANCE_X)+1; + FrameRect.LowerRightCorner.Y -= skin->getSize(EGDS_TEXT_DISTANCE_Y)+1; + } + core::rect localClipRect = FrameRect; + localClipRect.clipAgainst(AbsoluteClippingRect); - // draw the text + // draw the text - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); + IGUIFont* font = OverrideFont; + if (!OverrideFont) + font = skin->getFont(); - s32 cursorLine = 0; - s32 charcursorpos = 0; + s32 cursorLine = 0; + s32 charcursorpos = 0; - if (font) - { - if (LastBreakFont != font) - { - breakText(); - } + if (font) + { + if (LastBreakFont != font) + { + breakText(); + } - // calculate cursor pos + // calculate cursor pos - core::stringw *txtLine = &Text; - s32 startPos = 0; + core::stringw *txtLine = &Text; + s32 startPos = 0; - core::stringw s, s2; + core::stringw s, s2; - // get mark position - const bool ml = (!PasswordBox && (WordWrap || MultiLine)); - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - const s32 hlineStart = ml ? getLineFromPos(realmbgn) : 0; - const s32 hlineCount = ml ? getLineFromPos(realmend) - hlineStart + 1 : 1; - const s32 lineCount = ml ? BrokenText.size() : 1; + // get mark position + const bool ml = (!PasswordBox && (WordWrap || MultiLine)); + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + const s32 hlineStart = ml ? getLineFromPos(realmbgn) : 0; + const s32 hlineCount = ml ? getLineFromPos(realmend) - hlineStart + 1 : 1; + const s32 lineCount = ml ? BrokenText.size() : 1; - // Save the override color information. - // Then, alter it if the edit box is disabled. - const bool prevOver = OverrideColorEnabled; - const video::SColor prevColor = OverrideColor; + // Save the override color information. + // Then, alter it if the edit box is disabled. + const bool prevOver = OverrideColorEnabled; + const video::SColor prevColor = OverrideColor; - if (Text.size()) - { - if (!isEnabled() && !OverrideColorEnabled) - { - OverrideColorEnabled = true; - OverrideColor = skin->getColor(EGDC_GRAY_TEXT); - } + if (Text.size()) + { + if (!isEnabled() && !OverrideColorEnabled) + { + OverrideColorEnabled = true; + OverrideColor = skin->getColor(EGDC_GRAY_TEXT); + } - for (s32 i=0; i < lineCount; ++i) - { - setTextRect(i); + for (s32 i=0; i < lineCount; ++i) + { + setTextRect(i); - // clipping test - don't draw anything outside the visible area - core::rect c = localClipRect; - c.clipAgainst(CurrentTextRect); - if (!c.isValid()) - continue; + // clipping test - don't draw anything outside the visible area + core::rect c = localClipRect; + c.clipAgainst(CurrentTextRect); + if (!c.isValid()) + continue; - // get current line - if (PasswordBox) - { - if (BrokenText.size() != 1) - { - BrokenText.clear(); - BrokenText.push_back(core::stringw()); - } - if (BrokenText[0].size() != Text.size()) - { - BrokenText[0] = Text; - for (u32 q = 0; q < Text.size(); ++q) - { - BrokenText[0] [q] = PasswordChar; - } - } - txtLine = &BrokenText[0]; - startPos = 0; - } - else - { - txtLine = ml ? &BrokenText[i] : &Text; - startPos = ml ? BrokenTextPositions[i] : 0; - } + // get current line + if (PasswordBox) + { + if (BrokenText.size() != 1) + { + BrokenText.clear(); + BrokenText.push_back(core::stringw()); + } + if (BrokenText[0].size() != Text.size()) + { + BrokenText[0] = Text; + for (u32 q = 0; q < Text.size(); ++q) + { + BrokenText[0] [q] = PasswordChar; + } + } + txtLine = &BrokenText[0]; + startPos = 0; + } + else + { + txtLine = ml ? &BrokenText[i] : &Text; + startPos = ml ? BrokenTextPositions[i] : 0; + } if (m_rtl) @@ -863,74 +863,74 @@ void CGUIEditBox::draw() false, true, &localClipRect); } - // draw mark and marked text - if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount) - { + // draw mark and marked text + if (focus && MarkBegin != MarkEnd && i >= hlineStart && i < hlineStart + hlineCount) + { - s32 mbegin = 0, mend = 0; - s32 lineStartPos = 0, lineEndPos = txtLine->size(); + s32 mbegin = 0, mend = 0; + s32 lineStartPos = 0, lineEndPos = txtLine->size(); - if (i == hlineStart) - { - // highlight start is on this line - s = txtLine->subString(0, realmbgn - startPos); - mbegin = font->getDimension(s.c_str()).Width; + if (i == hlineStart) + { + // highlight start is on this line + s = txtLine->subString(0, realmbgn - startPos); + mbegin = font->getDimension(s.c_str()).Width; - // deal with kerning - mbegin += font->getKerningWidth( - &((*txtLine)[realmbgn - startPos]), - realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0); + // deal with kerning + mbegin += font->getKerningWidth( + &((*txtLine)[realmbgn - startPos]), + realmbgn - startPos > 0 ? &((*txtLine)[realmbgn - startPos - 1]) : 0); - lineStartPos = realmbgn - startPos; - } - if (i == hlineStart + hlineCount - 1) - { - // highlight end is on this line - s2 = txtLine->subString(0, realmend - startPos); - mend = font->getDimension(s2.c_str()).Width; - lineEndPos = (s32)s2.size(); - } - else - mend = font->getDimension(txtLine->c_str()).Width; + lineStartPos = realmbgn - startPos; + } + if (i == hlineStart + hlineCount - 1) + { + // highlight end is on this line + s2 = txtLine->subString(0, realmend - startPos); + mend = font->getDimension(s2.c_str()).Width; + lineEndPos = (s32)s2.size(); + } + else + mend = font->getDimension(txtLine->c_str()).Width; - CurrentTextRect.UpperLeftCorner.X += mbegin; - CurrentTextRect.LowerRightCorner.X = CurrentTextRect.UpperLeftCorner.X + mend - mbegin; + CurrentTextRect.UpperLeftCorner.X += mbegin; + CurrentTextRect.LowerRightCorner.X = CurrentTextRect.UpperLeftCorner.X + mend - mbegin; - // draw mark - skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), CurrentTextRect, &localClipRect); + // draw mark + skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), CurrentTextRect, &localClipRect); - // draw marked text - s = txtLine->subString(lineStartPos, lineEndPos - lineStartPos); + // draw marked text + s = txtLine->subString(lineStartPos, lineEndPos - lineStartPos); - if (s.size()) - font->draw(s.c_str(), CurrentTextRect, - OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT), - false, true, &localClipRect); + if (s.size()) + font->draw(s.c_str(), CurrentTextRect, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_HIGH_LIGHT_TEXT), + false, true, &localClipRect); - } - } + } + } - // Return the override color information to its previous settings. - OverrideColorEnabled = prevOver; - OverrideColor = prevColor; - } + // Return the override color information to its previous settings. + OverrideColorEnabled = prevOver; + OverrideColor = prevColor; + } - // draw cursor + // draw cursor - if (WordWrap || MultiLine) - { - cursorLine = getLineFromPos(CursorPos); - txtLine = &BrokenText[cursorLine]; - startPos = BrokenTextPositions[cursorLine]; - } - s = txtLine->subString(0,CursorPos-startPos); - charcursorpos = font->getDimension(s.c_str()).Width ; + if (WordWrap || MultiLine) + { + cursorLine = getLineFromPos(CursorPos); + txtLine = &BrokenText[cursorLine]; + startPos = BrokenTextPositions[cursorLine]; + } + s = txtLine->subString(0,CursorPos-startPos); + charcursorpos = font->getDimension(s.c_str()).Width ; // + font->getKerningWidth(L"_", CursorPos-startPos > 0 ? &((*txtLine)[CursorPos-startPos-1]) : 0); - if (focus && (getTime() - BlinkStartTime) % 2 == 0 && !m_rtl) - { - //setTextRect(cursorLine); - //CurrentTextRect.UpperLeftCorner.X += charcursorpos; + if (focus && (getTime() - BlinkStartTime) % 2 == 0 && !m_rtl) + { + //setTextRect(cursorLine); + //CurrentTextRect.UpperLeftCorner.X += charcursorpos; setTextRect(0); @@ -940,26 +940,26 @@ void CGUIEditBox::draw() irr_driver->getVideoDriver()->draw2DRectangle( video::SColor(255,0,0,0), caret_rect ); /* - font->draw(L"_", CurrentTextRect, - OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), - false, true, &localClipRect); + font->draw(L"_", CurrentTextRect, + OverrideColorEnabled ? OverrideColor : skin->getColor(EGDC_BUTTON_TEXT), + false, true, &localClipRect); */ - } - } + } + } - // draw children - IGUIElement::draw(); + // draw children + IGUIElement::draw(); } //! Sets the new caption of this element. void CGUIEditBox::setText(const wchar_t* text) { - Text = text; - if (u32(CursorPos) > Text.size()) - CursorPos = Text.size(); - HScrollPos = 0; - breakText(); + Text = text; + if (u32(CursorPos) > Text.size()) + CursorPos = Text.size(); + HScrollPos = 0; + breakText(); } @@ -967,7 +967,7 @@ void CGUIEditBox::setText(const wchar_t* text) //! \param enable: If set to true, the text will move around with the cursor position void CGUIEditBox::setAutoScroll(bool enable) { - AutoScroll = enable; + AutoScroll = enable; } @@ -975,8 +975,8 @@ void CGUIEditBox::setAutoScroll(bool enable) //! \return true if automatic scrolling is enabled, false if not bool CGUIEditBox::isAutoScrollEnabled() const { - _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; - return AutoScroll; + _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; + return AutoScroll; } @@ -984,19 +984,19 @@ bool CGUIEditBox::isAutoScrollEnabled() const //! \return Returns the size in pixels of the text core::dimension2du CGUIEditBox::getTextDimension() { - core::rect ret; + core::rect ret; - setTextRect(0); - ret = CurrentTextRect; + setTextRect(0); + ret = CurrentTextRect; - for (u32 i=1; i < BrokenText.size(); ++i) - { - setTextRect(i); - ret.addInternalPoint(CurrentTextRect.UpperLeftCorner); - ret.addInternalPoint(CurrentTextRect.LowerRightCorner); - } + for (u32 i=1; i < BrokenText.size(); ++i) + { + setTextRect(i); + ret.addInternalPoint(CurrentTextRect.UpperLeftCorner); + ret.addInternalPoint(CurrentTextRect.LowerRightCorner); + } - return core::dimension2du(ret.getSize()); + return core::dimension2du(ret.getSize()); } @@ -1005,428 +1005,428 @@ core::dimension2du CGUIEditBox::getTextDimension() //! infinity. void CGUIEditBox::setMax(u32 max) { - Max = max; + Max = max; - if (Text.size() > Max && Max != 0) - Text = Text.subString(0, Max); + if (Text.size() > Max && Max != 0) + Text = Text.subString(0, Max); } //! Returns maximum amount of characters, previously set by setMax(); u32 CGUIEditBox::getMax() const { - return Max; + return Max; } bool CGUIEditBox::processMouse(const SEvent& event) { - switch(event.MouseInput.Event) - { - case irr::EMIE_LMOUSE_LEFT_UP: - if (Environment->hasFocus(this) && !m_rtl) - { - CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); - if (MouseMarking) - { - setTextMarkers( MarkBegin, CursorPos ); - } - MouseMarking = false; - calculateScrollPos(); - return true; - } - break; - case irr::EMIE_MOUSE_MOVED: - { - if (MouseMarking) - { - CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); - setTextMarkers( MarkBegin, CursorPos ); - calculateScrollPos(); - return true; - } - } - break; - case EMIE_LMOUSE_PRESSED_DOWN: - if (!Environment->hasFocus(this)) - { - BlinkStartTime = getTime(); - MouseMarking = true; - CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); - setTextMarkers(CursorPos, CursorPos ); - calculateScrollPos(); - return true; - } - else if (!m_rtl) - { - if (!AbsoluteClippingRect.isPointInside( - core::position2d(event.MouseInput.X, event.MouseInput.Y))) - { - return false; - } - else - { - // move cursor - CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); + switch(event.MouseInput.Event) + { + case irr::EMIE_LMOUSE_LEFT_UP: + if (Environment->hasFocus(this) && !m_rtl) + { + CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); + if (MouseMarking) + { + setTextMarkers( MarkBegin, CursorPos ); + } + MouseMarking = false; + calculateScrollPos(); + return true; + } + break; + case irr::EMIE_MOUSE_MOVED: + { + if (MouseMarking) + { + CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); + setTextMarkers( MarkBegin, CursorPos ); + calculateScrollPos(); + return true; + } + } + break; + case EMIE_LMOUSE_PRESSED_DOWN: + if (!Environment->hasFocus(this)) + { + BlinkStartTime = getTime(); + MouseMarking = true; + CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); + setTextMarkers(CursorPos, CursorPos ); + calculateScrollPos(); + return true; + } + else if (!m_rtl) + { + if (!AbsoluteClippingRect.isPointInside( + core::position2d(event.MouseInput.X, event.MouseInput.Y))) + { + return false; + } + else + { + // move cursor + CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y); s32 newMarkBegin = MarkBegin; - if (!MouseMarking) - newMarkBegin = CursorPos; + if (!MouseMarking) + newMarkBegin = CursorPos; - MouseMarking = true; - setTextMarkers( newMarkBegin, CursorPos); - calculateScrollPos(); - return true; - } - } - default: - break; - } + MouseMarking = true; + setTextMarkers( newMarkBegin, CursorPos); + calculateScrollPos(); + return true; + } + } + default: + break; + } - return false; + return false; } s32 CGUIEditBox::getCursorPos(s32 x, s32 y) { - IGUIFont* font = OverrideFont; - IGUISkin* skin = Environment->getSkin(); - if (!OverrideFont) - font = skin->getFont(); + IGUIFont* font = OverrideFont; + IGUISkin* skin = Environment->getSkin(); + if (!OverrideFont) + font = skin->getFont(); - const u32 lineCount = (WordWrap || MultiLine) ? BrokenText.size() : 1; + const u32 lineCount = (WordWrap || MultiLine) ? BrokenText.size() : 1; - core::stringw *txtLine=0; - s32 startPos=0; - x+=3; + core::stringw *txtLine=0; + s32 startPos=0; + x+=3; - for (u32 i=0; i < lineCount; ++i) - { - setTextRect(i); - if (i == 0 && y < CurrentTextRect.UpperLeftCorner.Y) - y = CurrentTextRect.UpperLeftCorner.Y; - if (i == lineCount - 1 && y > CurrentTextRect.LowerRightCorner.Y ) - y = CurrentTextRect.LowerRightCorner.Y; + for (u32 i=0; i < lineCount; ++i) + { + setTextRect(i); + if (i == 0 && y < CurrentTextRect.UpperLeftCorner.Y) + y = CurrentTextRect.UpperLeftCorner.Y; + if (i == lineCount - 1 && y > CurrentTextRect.LowerRightCorner.Y ) + y = CurrentTextRect.LowerRightCorner.Y; - // is it inside this region? - if (y >= CurrentTextRect.UpperLeftCorner.Y && y <= CurrentTextRect.LowerRightCorner.Y) - { - // we've found the clicked line - txtLine = (WordWrap || MultiLine) ? &BrokenText[i] : &Text; - startPos = (WordWrap || MultiLine) ? BrokenTextPositions[i] : 0; - break; - } - } + // is it inside this region? + if (y >= CurrentTextRect.UpperLeftCorner.Y && y <= CurrentTextRect.LowerRightCorner.Y) + { + // we've found the clicked line + txtLine = (WordWrap || MultiLine) ? &BrokenText[i] : &Text; + startPos = (WordWrap || MultiLine) ? BrokenTextPositions[i] : 0; + break; + } + } - if (x < CurrentTextRect.UpperLeftCorner.X) - x = CurrentTextRect.UpperLeftCorner.X; + if (x < CurrentTextRect.UpperLeftCorner.X) + x = CurrentTextRect.UpperLeftCorner.X; - s32 idx = txtLine ? font->getCharacterFromPos(txtLine->c_str(), x - CurrentTextRect.UpperLeftCorner.X) : -1; + s32 idx = txtLine ? font->getCharacterFromPos(txtLine->c_str(), x - CurrentTextRect.UpperLeftCorner.X) : -1; - // click was on or left of the line - if (idx != -1) - return idx + startPos; + // click was on or left of the line + if (idx != -1) + return idx + startPos; - // click was off the right edge of the line, go to end. - return txtLine->size() + startPos; + // click was off the right edge of the line, go to end. + return txtLine->size() + startPos; } //! Breaks the single text line. void CGUIEditBox::breakText() { - IGUISkin* skin = Environment->getSkin(); + IGUISkin* skin = Environment->getSkin(); - if ((!WordWrap && !MultiLine) || !skin) - return; + if ((!WordWrap && !MultiLine) || !skin) + return; - BrokenText.clear(); // need to reallocate :/ - BrokenTextPositions.set_used(0); + BrokenText.clear(); // need to reallocate :/ + BrokenTextPositions.set_used(0); - IGUIFont* font = OverrideFont; - if (!OverrideFont) - font = skin->getFont(); + IGUIFont* font = OverrideFont; + if (!OverrideFont) + font = skin->getFont(); - if (!font) - return; + if (!font) + return; - LastBreakFont = font; + LastBreakFont = font; - core::stringw line; - core::stringw word; - core::stringw whitespace; - s32 lastLineStart = 0; - s32 size = Text.size(); - s32 length = 0; - s32 elWidth = RelativeRect.getWidth() - 6; - wchar_t c; + core::stringw line; + core::stringw word; + core::stringw whitespace; + s32 lastLineStart = 0; + s32 size = Text.size(); + s32 length = 0; + s32 elWidth = RelativeRect.getWidth() - 6; + wchar_t c; - for (s32 i=0; igetDimension(whitespace.c_str()).Width; - s32 worldlgth = font->getDimension(word.c_str()).Width; + if (c == L' ' || c == 0 || i == (size-1)) + { + if (word.size()) + { + // here comes the next whitespace, look if + // we can break the last word to the next line. + s32 whitelgth = font->getDimension(whitespace.c_str()).Width; + s32 worldlgth = font->getDimension(word.c_str()).Width; - if (WordWrap && length + worldlgth + whitelgth > elWidth) - { - // break to next line - length = worldlgth; - BrokenText.push_back(line); - BrokenTextPositions.push_back(lastLineStart); - lastLineStart = i - (s32)word.size(); - line = word; - } - else - { - // add word to line - line += whitespace; - line += word; - length += whitelgth + worldlgth; - } + if (WordWrap && length + worldlgth + whitelgth > elWidth) + { + // break to next line + length = worldlgth; + BrokenText.push_back(line); + BrokenTextPositions.push_back(lastLineStart); + lastLineStart = i - (s32)word.size(); + line = word; + } + else + { + // add word to line + line += whitespace; + line += word; + length += whitelgth + worldlgth; + } - word = L""; - whitespace = L""; - } + word = L""; + whitespace = L""; + } - whitespace += c; + whitespace += c; - // compute line break - if (lineBreak) - { - line += whitespace; - line += word; - BrokenText.push_back(line); - BrokenTextPositions.push_back(lastLineStart); - lastLineStart = i+1; - line = L""; - word = L""; - whitespace = L""; - length = 0; - } - } - else - { - // yippee this is a word.. - word += c; - } - } + // compute line break + if (lineBreak) + { + line += whitespace; + line += word; + BrokenText.push_back(line); + BrokenTextPositions.push_back(lastLineStart); + lastLineStart = i+1; + line = L""; + word = L""; + whitespace = L""; + length = 0; + } + } + else + { + // yippee this is a word.. + word += c; + } + } - line += whitespace; - line += word; - BrokenText.push_back(line); - BrokenTextPositions.push_back(lastLineStart); + line += whitespace; + line += word; + BrokenText.push_back(line); + BrokenTextPositions.push_back(lastLineStart); } void CGUIEditBox::setTextRect(s32 line) { - core::dimension2du d; + core::dimension2du d; - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; - IGUIFont* font = OverrideFont ? OverrideFont : skin->getFont(); + IGUIFont* font = OverrideFont ? OverrideFont : skin->getFont(); - if (!font) - return; + if (!font) + return; - // get text dimension - const u32 lineCount = (WordWrap || MultiLine) ? BrokenText.size() : 1; - if (WordWrap || MultiLine) - { - d = font->getDimension(BrokenText[line].c_str()); - } - else - { - d = font->getDimension(Text.c_str()); - d.Height = AbsoluteRect.getHeight(); - } - d.Height += font->getKerningHeight(); + // get text dimension + const u32 lineCount = (WordWrap || MultiLine) ? BrokenText.size() : 1; + if (WordWrap || MultiLine) + { + d = font->getDimension(BrokenText[line].c_str()); + } + else + { + d = font->getDimension(Text.c_str()); + d.Height = AbsoluteRect.getHeight(); + } + d.Height += font->getKerningHeight(); - // justification - switch (HAlign) - { - case EGUIA_CENTER: - // align to h centre - CurrentTextRect.UpperLeftCorner.X = (FrameRect.getWidth()/2) - (d.Width/2); - CurrentTextRect.LowerRightCorner.X = (FrameRect.getWidth()/2) + (d.Width/2); - break; - case EGUIA_LOWERRIGHT: - // align to right edge - CurrentTextRect.UpperLeftCorner.X = FrameRect.getWidth() - d.Width; - CurrentTextRect.LowerRightCorner.X = FrameRect.getWidth(); - break; - default: - // align to left edge - CurrentTextRect.UpperLeftCorner.X = 0; - CurrentTextRect.LowerRightCorner.X = d.Width; + // justification + switch (HAlign) + { + case EGUIA_CENTER: + // align to h centre + CurrentTextRect.UpperLeftCorner.X = (FrameRect.getWidth()/2) - (d.Width/2); + CurrentTextRect.LowerRightCorner.X = (FrameRect.getWidth()/2) + (d.Width/2); + break; + case EGUIA_LOWERRIGHT: + // align to right edge + CurrentTextRect.UpperLeftCorner.X = FrameRect.getWidth() - d.Width; + CurrentTextRect.LowerRightCorner.X = FrameRect.getWidth(); + break; + default: + // align to left edge + CurrentTextRect.UpperLeftCorner.X = 0; + CurrentTextRect.LowerRightCorner.X = d.Width; - } + } - switch (VAlign) - { - case EGUIA_CENTER: - // align to v centre - CurrentTextRect.UpperLeftCorner.Y = - (FrameRect.getHeight()/2) - (lineCount*d.Height)/2 + d.Height*line; - break; - case EGUIA_LOWERRIGHT: - // align to bottom edge - CurrentTextRect.UpperLeftCorner.Y = - FrameRect.getHeight() - lineCount*d.Height + d.Height*line; - break; - default: - // align to top edge - CurrentTextRect.UpperLeftCorner.Y = d.Height*line; - break; - } + switch (VAlign) + { + case EGUIA_CENTER: + // align to v centre + CurrentTextRect.UpperLeftCorner.Y = + (FrameRect.getHeight()/2) - (lineCount*d.Height)/2 + d.Height*line; + break; + case EGUIA_LOWERRIGHT: + // align to bottom edge + CurrentTextRect.UpperLeftCorner.Y = + FrameRect.getHeight() - lineCount*d.Height + d.Height*line; + break; + default: + // align to top edge + CurrentTextRect.UpperLeftCorner.Y = d.Height*line; + break; + } - CurrentTextRect.UpperLeftCorner.X -= HScrollPos; - CurrentTextRect.LowerRightCorner.X -= HScrollPos; - CurrentTextRect.UpperLeftCorner.Y -= VScrollPos; - CurrentTextRect.LowerRightCorner.Y = CurrentTextRect.UpperLeftCorner.Y + d.Height; + CurrentTextRect.UpperLeftCorner.X -= HScrollPos; + CurrentTextRect.LowerRightCorner.X -= HScrollPos; + CurrentTextRect.UpperLeftCorner.Y -= VScrollPos; + CurrentTextRect.LowerRightCorner.Y = CurrentTextRect.UpperLeftCorner.Y + d.Height; - CurrentTextRect += FrameRect.UpperLeftCorner; + CurrentTextRect += FrameRect.UpperLeftCorner; } s32 CGUIEditBox::getLineFromPos(s32 pos) { - if (!WordWrap && !MultiLine) - return 0; + if (!WordWrap && !MultiLine) + return 0; - s32 i=0; - while (i < (s32)BrokenTextPositions.size()) - { - if (BrokenTextPositions[i] > pos) - return i-1; - ++i; - } - return (s32)BrokenTextPositions.size() - 1; + s32 i=0; + while (i < (s32)BrokenTextPositions.size()) + { + if (BrokenTextPositions[i] > pos) + return i-1; + ++i; + } + return (s32)BrokenTextPositions.size() - 1; } void CGUIEditBox::inputChar(wchar_t c) { - if (!isEnabled()) - return; + if (!isEnabled()) + return; - if (c != 0) - { - if (Text.size() < Max || Max == 0) - { - core::stringw s; + if (c != 0) + { + if (Text.size() < Max || Max == 0) + { + core::stringw s; - if (MarkBegin != MarkEnd) - { - // replace marked text - const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; - const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; + if (MarkBegin != MarkEnd) + { + // replace marked text + const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd; + const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin; - s = Text.subString(0, realmbgn); - s.append(c); - s.append( Text.subString(realmend, Text.size()-realmend) ); - Text = s; - CursorPos = realmbgn+1; - } - else - { - // add new character - s = Text.subString(0, CursorPos); - s.append(c); - s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); - Text = s; - ++CursorPos; - } + s = Text.subString(0, realmbgn); + s.append(c); + s.append( Text.subString(realmend, Text.size()-realmend) ); + Text = s; + CursorPos = realmbgn+1; + } + else + { + // add new character + s = Text.subString(0, CursorPos); + s.append(c); + s.append( Text.subString(CursorPos, Text.size()-CursorPos) ); + Text = s; + ++CursorPos; + } - BlinkStartTime = getTime(); - setTextMarkers(0, 0); - } - } - breakText(); - sendGuiEvent(EGET_EDITBOX_CHANGED); - calculateScrollPos(); + BlinkStartTime = getTime(); + setTextMarkers(0, 0); + } + } + breakText(); + sendGuiEvent(EGET_EDITBOX_CHANGED); + calculateScrollPos(); } void CGUIEditBox::calculateScrollPos() { - if (!AutoScroll) - return; + if (!AutoScroll) + return; - // calculate horizontal scroll position - s32 cursLine = getLineFromPos(CursorPos); - setTextRect(cursLine); + // calculate horizontal scroll position + s32 cursLine = getLineFromPos(CursorPos); + setTextRect(cursLine); - // don't do horizontal scrolling when wordwrap is enabled. - if (!WordWrap) - { - // get cursor position - IGUISkin* skin = Environment->getSkin(); - if (!skin) - return; - IGUIFont* font = OverrideFont ? OverrideFont : skin->getFont(); - if (!font) - return; + // don't do horizontal scrolling when wordwrap is enabled. + if (!WordWrap) + { + // get cursor position + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + IGUIFont* font = OverrideFont ? OverrideFont : skin->getFont(); + if (!font) + return; - core::stringw *txtLine = MultiLine ? &BrokenText[cursLine] : &Text; - s32 cPos = MultiLine ? CursorPos - BrokenTextPositions[cursLine] : CursorPos; + core::stringw *txtLine = MultiLine ? &BrokenText[cursLine] : &Text; + s32 cPos = MultiLine ? CursorPos - BrokenTextPositions[cursLine] : CursorPos; - s32 cStart = CurrentTextRect.UpperLeftCorner.X + HScrollPos + - font->getDimension(txtLine->subString(0, cPos).c_str()).Width; + s32 cStart = CurrentTextRect.UpperLeftCorner.X + HScrollPos + + font->getDimension(txtLine->subString(0, cPos).c_str()).Width; - s32 cEnd = cStart + font->getDimension(L"_ ").Width; + s32 cEnd = cStart + font->getDimension(L"_ ").Width; - if (FrameRect.LowerRightCorner.X < cEnd) - HScrollPos = cEnd - FrameRect.LowerRightCorner.X; - else if (FrameRect.UpperLeftCorner.X > cStart) - HScrollPos = cStart - FrameRect.UpperLeftCorner.X; - else - HScrollPos = 0; + if (FrameRect.LowerRightCorner.X < cEnd) + HScrollPos = cEnd - FrameRect.LowerRightCorner.X; + else if (FrameRect.UpperLeftCorner.X > cStart) + HScrollPos = cStart - FrameRect.UpperLeftCorner.X; + else + HScrollPos = 0; - // todo: adjust scrollbar - } + // todo: adjust scrollbar + } - // vertical scroll position - if (FrameRect.LowerRightCorner.Y < CurrentTextRect.LowerRightCorner.Y + VScrollPos) - VScrollPos = CurrentTextRect.LowerRightCorner.Y - FrameRect.LowerRightCorner.Y + VScrollPos; + // vertical scroll position + if (FrameRect.LowerRightCorner.Y < CurrentTextRect.LowerRightCorner.Y + VScrollPos) + VScrollPos = CurrentTextRect.LowerRightCorner.Y - FrameRect.LowerRightCorner.Y + VScrollPos; - else if (FrameRect.UpperLeftCorner.Y > CurrentTextRect.UpperLeftCorner.Y + VScrollPos) - VScrollPos = CurrentTextRect.UpperLeftCorner.Y - FrameRect.UpperLeftCorner.Y + VScrollPos; - else - VScrollPos = 0; + else if (FrameRect.UpperLeftCorner.Y > CurrentTextRect.UpperLeftCorner.Y + VScrollPos) + VScrollPos = CurrentTextRect.UpperLeftCorner.Y - FrameRect.UpperLeftCorner.Y + VScrollPos; + else + VScrollPos = 0; - // todo: adjust scrollbar + // todo: adjust scrollbar } //! set text markers @@ -1443,8 +1443,8 @@ void CGUIEditBox::setTextMarkers(s32 begin, s32 end) //! send some gui event to parent void CGUIEditBox::sendGuiEvent(EGUI_EVENT_TYPE type) { - if ( Parent ) - { + if ( Parent ) + { SEvent e; e.EventType = EET_GUI_EVENT; e.GUIEvent.Caller = this; @@ -1452,53 +1452,53 @@ void CGUIEditBox::sendGuiEvent(EGUI_EVENT_TYPE type) e.GUIEvent.EventType = type; Parent->OnEvent(e); - } + } } //! Writes attributes of the element. void CGUIEditBox::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const { - // IGUIEditBox::serializeAttributes(out,options); + // IGUIEditBox::serializeAttributes(out,options); - out->addBool ("OverrideColorEnabled",OverrideColorEnabled ); - out->addColor ("OverrideColor", OverrideColor); - // out->addFont("OverrideFont",OverrideFont); - out->addInt ("MaxChars", Max); - out->addBool ("WordWrap", WordWrap); - out->addBool ("MultiLine", MultiLine); - out->addBool ("AutoScroll", AutoScroll); - out->addBool ("PasswordBox", PasswordBox); - core::stringw ch = L" "; - ch[0] = PasswordChar; - out->addString("PasswordChar", ch.c_str()); - out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames); - out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames); + out->addBool ("OverrideColorEnabled",OverrideColorEnabled ); + out->addColor ("OverrideColor", OverrideColor); + // out->addFont("OverrideFont",OverrideFont); + out->addInt ("MaxChars", Max); + out->addBool ("WordWrap", WordWrap); + out->addBool ("MultiLine", MultiLine); + out->addBool ("AutoScroll", AutoScroll); + out->addBool ("PasswordBox", PasswordBox); + core::stringw ch = L" "; + ch[0] = PasswordChar; + out->addString("PasswordChar", ch.c_str()); + out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames); + out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames); - IGUIEditBox::serializeAttributes(out,options); + IGUIEditBox::serializeAttributes(out,options); } //! Reads attributes of the element void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { - IGUIEditBox::deserializeAttributes(in,options); + IGUIEditBox::deserializeAttributes(in,options); - setOverrideColor(in->getAttributeAsColor("OverrideColor")); - enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); - setMax(in->getAttributeAsInt("MaxChars")); - setWordWrap(in->getAttributeAsBool("WordWrap")); - setMultiLine(in->getAttributeAsBool("MultiLine")); - setAutoScroll(in->getAttributeAsBool("AutoScroll")); - core::stringw ch = in->getAttributeAsStringW("PasswordChar"); + setOverrideColor(in->getAttributeAsColor("OverrideColor")); + enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); + setMax(in->getAttributeAsInt("MaxChars")); + setWordWrap(in->getAttributeAsBool("WordWrap")); + setMultiLine(in->getAttributeAsBool("MultiLine")); + setAutoScroll(in->getAttributeAsBool("AutoScroll")); + core::stringw ch = in->getAttributeAsStringW("PasswordChar"); - if (!ch.size()) - setPasswordBox(in->getAttributeAsBool("PasswordBox")); - else - setPasswordBox(in->getAttributeAsBool("PasswordBox"), ch[0]); + if (!ch.size()) + setPasswordBox(in->getAttributeAsBool("PasswordBox")); + else + setPasswordBox(in->getAttributeAsBool("PasswordBox"), ch[0]); - setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames), - (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames)); + setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames), + (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames)); - // setOverrideFont(in->getAttributeAsFont("OverrideFont")); + // setOverrideFont(in->getAttributeAsFont("OverrideFont")); } diff --git a/src/guiengine/widgets/dynamic_ribbon_widget.cpp b/src/guiengine/widgets/dynamic_ribbon_widget.cpp index dcef197f5..d40464cfc 100644 --- a/src/guiengine/widgets/dynamic_ribbon_widget.cpp +++ b/src/guiengine/widgets/dynamic_ribbon_widget.cpp @@ -1,4 +1,4 @@ -// SuperTuxKart - a fun racing game with go-kart +// Supertuxkart - a fun racing game with go-kart // Copyright (C) 2009-2013 Marianne Gagnon // // This program is free software; you can redistribute it and/or @@ -945,37 +945,37 @@ void DynamicRibbonWidget::updateItemDisplay() IconButtonWidget* icon = dynamic_cast(&row.m_children[i]); assert(icon != NULL); - //FIXME : it is a bit hackish - if(i < item_placement[n].size()) - { - icon_id = item_placement[n][i]; - if (icon_id < item_amount && icon_id != -1) - { - std::string item_icon = (m_items[icon_id].m_animated ? - m_items[icon_id].m_all_images[0] : - m_items[icon_id].m_sshot_file); - icon->setImage( item_icon.c_str(), m_items[icon_id].m_image_path_type ); + //FIXME : it is a bit hackish + if(i < item_placement[n].size()) + { + icon_id = item_placement[n][i]; + if (icon_id < item_amount && icon_id != -1) + { + std::string item_icon = (m_items[icon_id].m_animated ? + m_items[icon_id].m_all_images[0] : + m_items[icon_id].m_sshot_file); + icon->setImage( item_icon.c_str(), m_items[icon_id].m_image_path_type ); - icon->m_properties[PROP_ID] = m_items[icon_id].m_code_name; - icon->setLabel(m_items[icon_id].m_user_name); - icon->m_text = m_items[icon_id].m_user_name; - icon->m_badges = m_items[icon_id].m_badges; + icon->m_properties[PROP_ID] = m_items[icon_id].m_code_name; + icon->setLabel(m_items[icon_id].m_user_name); + icon->m_text = m_items[icon_id].m_user_name; + icon->m_badges = m_items[icon_id].m_badges; - //std::cout << " item " << i << " is " << m_items[icon_id].m_code_name << "\n"; + //std::cout << " item " << i << " is " << m_items[icon_id].m_code_name << "\n"; - //std::wcout << L"Setting widget text '" << icon->m_text.c_str() << L"'\n"; + //std::wcout << L"Setting widget text '" << icon->m_text.c_str() << L"'\n"; - // if the ribbon has no "ribbon-wide" label, call will do nothing - row.setLabel(i, m_items[icon_id].m_user_name); - } - else - { - icon->setImage( "textures/transparence.png", IconButtonWidget::ICON_PATH_TYPE_RELATIVE ); - icon->resetAllBadges(); - icon->m_properties[PROP_ID] = RibbonWidget::NO_ITEM_ID; - //std::cout << " item " << i << " is a FILLER\n"; - } - } + // if the ribbon has no "ribbon-wide" label, call will do nothing + row.setLabel(i, m_items[icon_id].m_user_name); + } + else + { + icon->setImage( "textures/transparence.png", IconButtonWidget::ICON_PATH_TYPE_RELATIVE ); + icon->resetAllBadges(); + icon->m_properties[PROP_ID] = RibbonWidget::NO_ITEM_ID; + //std::cout << " item " << i << " is a FILLER\n"; + } + } } // next column } // next row } diff --git a/src/guiengine/widgets/spinner_widget.cpp b/src/guiengine/widgets/spinner_widget.cpp index c0af78aaf..1489c5f85 100644 --- a/src/guiengine/widgets/spinner_widget.cpp +++ b/src/guiengine/widgets/spinner_widget.cpp @@ -64,7 +64,7 @@ void SpinnerWidget::add() { int i; std::istringstream myStream(min_s); - myStream >> i; + myStream >> i; bool is_number = (i!=0); if (is_number) { @@ -80,7 +80,7 @@ void SpinnerWidget::add() { int i; std::istringstream myStream(max_s); - myStream >> i; + myStream >> i; bool is_number = (i!=0); if (is_number) { diff --git a/src/input/device_manager.hpp b/src/input/device_manager.hpp index 75331d08c..c18a5b43f 100644 --- a/src/input/device_manager.hpp +++ b/src/input/device_manager.hpp @@ -156,7 +156,7 @@ public: StateManager::ActivePlayer** player /* out */, PlayerAction* action /* out */ ); - void clearLatestUsedDevice(); + void clearLatestUsedDevice(); InputDevice* getLatestUsedDevice(); bool initialize(); void serialize(); diff --git a/src/input/wiimote.cpp b/src/input/wiimote.cpp index 809f88ecc..69d81bf75 100644 --- a/src/input/wiimote.cpp +++ b/src/input/wiimote.cpp @@ -105,7 +105,7 @@ void Wiimote::update() const float sign = normalized_angle >= 0.0f ? 1.0f : -1.0f; const float normalized_angle_2 = w1 * normalized_angle + w2 * sign*normalized_angle*normalized_angle - + wa * asin(normalized_angle)*(2.0f/M_PI) + + wa * asin(normalized_angle)*(2.0f/M_PI) + ws * sin(normalized_angle*(M_PI/2.0f)); const float JOYSTICK_ABS_MAX_ANGLE = 32766.0f; diff --git a/src/input/wiimote_manager.cpp b/src/input/wiimote_manager.cpp index 25167b48b..61be4e05b 100644 --- a/src/input/wiimote_manager.cpp +++ b/src/input/wiimote_manager.cpp @@ -304,19 +304,19 @@ void* WiimoteManager::threadFuncWrapper(void *data) */ int WiimoteManager::askUserToConnectWiimotes() { - new MessageDialog( + new MessageDialog( #ifdef WIN32 - _("Connect your wiimote to the Bluetooth manager, then click on Ok." + _("Connect your wiimote to the Bluetooth manager, then click on Ok." "Detailed instructions at supertuxkart.net/Wiimote"), #else - _("Press the buttons 1+2 simultaneously on your wiimote to put " - "it in discovery mode, then click on Ok." + _("Press the buttons 1+2 simultaneously on your wiimote to put " + "it in discovery mode, then click on Ok." "Detailed instructions at supertuxkart.net/Wiimote"), #endif - MessageDialog::MESSAGE_DIALOG_OK_CANCEL, - new WiimoteDialogListener(), true); + MessageDialog::MESSAGE_DIALOG_OK_CANCEL, + new WiimoteDialogListener(), true); - return getNumberOfWiimotes(); + return getNumberOfWiimotes(); } // askUserToConnectWiimotes // ============================================================================ @@ -325,23 +325,23 @@ int WiimoteManager::askUserToConnectWiimotes() */ void WiimoteManager::WiimoteDialogListener::onConfirm() { - GUIEngine::ModalDialog::dismiss(); + GUIEngine::ModalDialog::dismiss(); - wiimote_manager->launchDetection(5); + wiimote_manager->launchDetection(5); - int nb_wiimotes = wiimote_manager->getNumberOfWiimotes(); - if(nb_wiimotes > 0) - { - core::stringw msg = StringUtils::insertValues( - _("Found %d wiimote(s)"), - core::stringw(nb_wiimotes)); + int nb_wiimotes = wiimote_manager->getNumberOfWiimotes(); + if(nb_wiimotes > 0) + { + core::stringw msg = StringUtils::insertValues( + _("Found %d wiimote(s)"), + core::stringw(nb_wiimotes)); - new MessageDialog( msg ); + new MessageDialog( msg ); - } - else - { - new MessageDialog( _("Could not detect any wiimote :/") ); - } + } + else + { + new MessageDialog( _("Could not detect any wiimote :/") ); + } } // WiimoteDialogListeneronConfirm #endif // ENABLE_WIIUSE diff --git a/src/input/wiimote_manager.hpp b/src/input/wiimote_manager.hpp index 410243a2d..e701472ec 100644 --- a/src/input/wiimote_manager.hpp +++ b/src/input/wiimote_manager.hpp @@ -63,8 +63,8 @@ private: bool m_shut; #endif - /** True if wii is enabled via command line option. */ - static bool m_enabled; + /** True if wii is enabled via command line option. */ + static bool m_enabled; /** Wiimotes update thread */ void threadFunc(); @@ -75,11 +75,11 @@ public: WiimoteManager(); ~WiimoteManager(); - /** Sets the wiimote to be enabled. */ - static void enable() { m_enabled = true; } + /** Sets the wiimote to be enabled. */ + static void enable() { m_enabled = true; } - /** Returns if the wii was enabled on the command line. */ - static bool isEnabled() { return m_enabled; } + /** Returns if the wii was enabled on the command line. */ + static bool isEnabled() { return m_enabled; } void launchDetection(int timeout); void update(); @@ -87,20 +87,20 @@ public: void enableAccelerometer(bool state); - /** A simple listener to allow the user to connect wiimotes. It - * will display a feedback windows (# wiimotes connected or 'no wiimotes - * found'). - */ - class WiimoteDialogListener : public MessageDialog::IConfirmDialogListener - { - public: - virtual void onConfirm() OVERRIDE; - }; // class WiimoteDialoListener + /** A simple listener to allow the user to connect wiimotes. It + * will display a feedback windows (# wiimotes connected or 'no wiimotes + * found'). + */ + class WiimoteDialogListener : public MessageDialog::IConfirmDialogListener + { + public: + virtual void onConfirm() OVERRIDE; + }; // class WiimoteDialoListener - /** Shows a dialog allowing the user to connect wiimotes. - * \return Number of wiimotes connected. - */ - int askUserToConnectWiimotes(); + /** Shows a dialog allowing the user to connect wiimotes. + * \return Number of wiimotes connected. + */ + int askUserToConnectWiimotes(); // ------------------------------------------------------------------------ /** Returns the number of wiimotes connected. */ unsigned int getNumberOfWiimotes() const {return m_wiimotes.size();} diff --git a/src/items/rubber_ball.cpp b/src/items/rubber_ball.cpp index 7201732e5..35582fb8e 100644 --- a/src/items/rubber_ball.cpp +++ b/src/items/rubber_ball.cpp @@ -578,7 +578,7 @@ float RubberBall::updateHeight() if(m_current_max_height>m_max_height) m_current_max_height = m_max_height; m_interval = m_current_max_height / 10.0f; - // Avoid too small hops and esp. a division by zero + // Avoid too small hops and esp. a division by zero if(m_interval<0.01f) m_interval = 0.1f; } diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index 81b706478..8024f23f9 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -53,7 +53,7 @@ AbstractKart::AbstractKart(const std::string& ident, m_kart_width = m_kart_model->getWidth(); m_kart_height = m_kart_model->getHeight(); m_kart_length = m_kart_model->getLength(); - m_kart_highest_point = m_kart_model->getHighestPoint(); + m_kart_highest_point = m_kart_model->getHighestPoint(); m_wheel_graphics_position = m_kart_model->getWheelsGraphicsPosition(); } // AbstractKart diff --git a/src/karts/abstract_kart.hpp b/src/karts/abstract_kart.hpp index 25163fd52..bbf77cd7c 100644 --- a/src/karts/abstract_kart.hpp +++ b/src/karts/abstract_kart.hpp @@ -51,8 +51,8 @@ private: float m_kart_width; /** Height of the kart, copy of the data from KartModel. */ float m_kart_height; - /** Coordinate on up axis */ - float m_kart_highest_point; + /** Coordinate on up axis */ + float m_kart_highest_point; /** The position of all four wheels in the 3d model */ const Vec3* m_wheel_graphics_position; @@ -151,9 +151,9 @@ public: // ------------------------------------------------------------------------ /** Returns the width of the kart. */ float getKartWidth() const {return m_kart_width; } - // ------------------------------------------------------------------------ - /** Returns the highest point of the kart (coordinate on up axis) */ - float getHighestPoint() const { return m_kart_highest_point; } + // ------------------------------------------------------------------------ + /** Returns the highest point of the kart (coordinate on up axis) */ + float getHighestPoint() const { return m_kart_highest_point; } // ------------------------------------------------------------------------ /** Returns true if this kart has no wheels. */ bool isWheeless() const; diff --git a/src/karts/abstract_kart_animation.hpp b/src/karts/abstract_kart_animation.hpp index 2eb72958a..14f318e82 100644 --- a/src/karts/abstract_kart_animation.hpp +++ b/src/karts/abstract_kart_animation.hpp @@ -41,8 +41,8 @@ private: /** Name of this animation, used for debug prints only. */ std::string m_name; protected: - /** A pointer to the kart which is animated by this class. */ - AbstractKart *m_kart; + /** A pointer to the kart which is animated by this class. */ + AbstractKart *m_kart; /** Timer for the explosion. */ float m_timer; diff --git a/src/karts/controller/ai_base_controller.cpp b/src/karts/controller/ai_base_controller.cpp index 259295778..2580b5fa1 100644 --- a/src/karts/controller/ai_base_controller.cpp +++ b/src/karts/controller/ai_base_controller.cpp @@ -119,8 +119,8 @@ AIBaseController::AIBaseController(AbstractKart *kart, //----------------------------------------------------------------------------- void AIBaseController::reset() { - m_stuck_trigger_rescue = false; - m_collision_times.clear(); + m_stuck_trigger_rescue = false; + m_collision_times.clear(); } // reset //----------------------------------------------------------------------------- @@ -220,7 +220,7 @@ void AIBaseController::computePath() */ void AIBaseController::update(float dt) { - m_stuck_trigger_rescue = false; + m_stuck_trigger_rescue = false; if(QuadGraph::get()) { @@ -255,52 +255,52 @@ void AIBaseController::update(float dt) */ void AIBaseController::crashed(const Material *m) { - // Defines how many collision in what time will trigger a rescue. - // Note that typically it takes ~0.5 seconds for the AI to hit - // the track again if it is stuck (i.e. time for the push back plus - // time for the AI to accelerate and hit the terrain again). - const unsigned int NUM_COLLISION = 3; - const float COLLISION_TIME = 1.5f; + // Defines how many collision in what time will trigger a rescue. + // Note that typically it takes ~0.5 seconds for the AI to hit + // the track again if it is stuck (i.e. time for the push back plus + // time for the AI to accelerate and hit the terrain again). + const unsigned int NUM_COLLISION = 3; + const float COLLISION_TIME = 1.5f; - float time = World::getWorld()->getTime(); - if(m_collision_times.size()==0) - { - m_collision_times.push_back(time); - return; - } + float time = World::getWorld()->getTime(); + if(m_collision_times.size()==0) + { + m_collision_times.push_back(time); + return; + } - // Filter out multiple collisions report caused by single collision - // (bullet can report a collision more than once per frame, and - // resolving it can take a few frames as well, causing more reported - // collisions to happen). The time of 0.2 seconds was experimentally - // found, typically it takes 0.5 seconds for a kart to be pushed back - // from the terrain and accelerate to hit the same terrain again. - if(time - m_collision_times.back() < 0.2f) - return; + // Filter out multiple collisions report caused by single collision + // (bullet can report a collision more than once per frame, and + // resolving it can take a few frames as well, causing more reported + // collisions to happen). The time of 0.2 seconds was experimentally + // found, typically it takes 0.5 seconds for a kart to be pushed back + // from the terrain and accelerate to hit the same terrain again. + if(time - m_collision_times.back() < 0.2f) + return; - // Remove all outdated entries, i.e. entries that are older than the - // collision time plus 1 second. Older entries must be deleted, - // otherwise a collision that happened (say) 10 seconds ago could - // contribute to a stuck condition. - while(m_collision_times.size()>0 && - time - m_collision_times[0] > 1.0f+COLLISION_TIME) - m_collision_times.erase(m_collision_times.begin()); + // Remove all outdated entries, i.e. entries that are older than the + // collision time plus 1 second. Older entries must be deleted, + // otherwise a collision that happened (say) 10 seconds ago could + // contribute to a stuck condition. + while(m_collision_times.size()>0 && + time - m_collision_times[0] > 1.0f+COLLISION_TIME) + m_collision_times.erase(m_collision_times.begin()); - m_collision_times.push_back(time); + m_collision_times.push_back(time); - // Now detect if there are enough collision records in the - // specified time interval. - if(time - m_collision_times.front() > COLLISION_TIME - && m_collision_times.size()>=NUM_COLLISION) - { - // We can't call m_kart->forceRescue here, since crased() is - // called during physics processing, and forceRescue() removes the - // chassis from the physics world, which would then cause - // inconsistencies and potentially a crash during the physics - // processing. So only set a flag, which is tested during update. - m_stuck_trigger_rescue = true; - } + // Now detect if there are enough collision records in the + // specified time interval. + if(time - m_collision_times.front() > COLLISION_TIME + && m_collision_times.size()>=NUM_COLLISION) + { + // We can't call m_kart->forceRescue here, since crased() is + // called during physics processing, and forceRescue() removes the + // chassis from the physics world, which would then cause + // inconsistencies and potentially a crash during the physics + // processing. So only set a flag, which is tested during update. + m_stuck_trigger_rescue = true; + } } // crashed(Material) diff --git a/src/karts/controller/ai_base_controller.hpp b/src/karts/controller/ai_base_controller.hpp index d981892cf..a47339ec3 100644 --- a/src/karts/controller/ai_base_controller.hpp +++ b/src/karts/controller/ai_base_controller.hpp @@ -108,7 +108,7 @@ public: virtual void handleZipper(bool play_sound) {}; virtual void finishedRace(float time) {}; virtual void collectedItem(const Item &item, int add_info=-1, - float previous_energy=0) {}; + float previous_energy=0) {}; virtual void setPosition(int p) {}; virtual bool isNetworkController() const { return false; } virtual bool isPlayerController() const { return false; } diff --git a/src/karts/controller/controller.hpp b/src/karts/controller/controller.hpp index 4ba13d25f..c5414c9ed 100644 --- a/src/karts/controller/controller.hpp +++ b/src/karts/controller/controller.hpp @@ -72,20 +72,20 @@ public: virtual bool isPlayerController () const = 0; virtual bool isNetworkController() const = 0; virtual bool disableSlipstreamBonus() const = 0; - // --------------------------------------------------------------------------- + // --------------------------------------------------------------------------- /** Sets the controller name for this controller. */ virtual void setControllerName(const std::string &name) { m_controller_name = name; } - // --------------------------------------------------------------------------- + // --------------------------------------------------------------------------- /** Returns the name of this controller. */ const std::string &getControllerName() const { return m_controller_name; } - // --------------------------------------------------------------------------- + // --------------------------------------------------------------------------- /** Returns the active player for this controller (NULL * if this controller does not belong to a player. */ StateManager::ActivePlayer *getPlayer () {return m_player;} - // --------------------------------------------------------------------------- - /** Returns the player object (or NULL if it's a computer controller). */ + // --------------------------------------------------------------------------- + /** Returns the player object (or NULL if it's a computer controller). */ const StateManager::ActivePlayer *getPlayer () const { return m_player; } // ------------------------------------------------------------------------ diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index 4510a01c3..0592299f7 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -208,7 +208,7 @@ void SkiddingAI::reset() m_track_node = QuadGraph::get()->findOutOfRoadSector(m_kart->getXYZ()); } - AIBaseController::reset(); + AIBaseController::reset(); } // reset //----------------------------------------------------------------------------- @@ -486,8 +486,8 @@ void SkiddingAI::handleSteering(float dt) *finite state machine. */ //Reaction to being outside of the road - float side_dist = - m_world->getDistanceToCenterForKart( m_kart->getWorldKartId() ); + float side_dist = + m_world->getDistanceToCenterForKart( m_kart->getWorldKartId() ); if( fabsf(side_dist) > 0.5f* QuadGraph::get()->getNode(m_track_node).getPathWidth()+0.5f ) diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 5a8cedc92..de120ecad 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -278,7 +278,7 @@ KartModel* KartModel::makeCopy() km->m_kart_width = m_kart_width; km->m_kart_length = m_kart_length; km->m_kart_height = m_kart_height; - km->m_kart_highest_point= m_kart_highest_point; + km->m_kart_highest_point= m_kart_highest_point; km->m_kart_lowest_point = m_kart_lowest_point; km->m_mesh = m_mesh; km->m_model_filename = m_model_filename; @@ -473,7 +473,7 @@ bool KartModel::loadModels(const KartProperties &kart_properties) MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]), &kart_min, &kart_max); #endif - m_kart_highest_point = kart_max.getY(); + m_kart_highest_point = kart_max.getY(); m_kart_lowest_point = kart_min.getY(); // Load the speed weighted object models. We need to do that now because it can affect the dimensions of the kart @@ -490,7 +490,7 @@ bool KartModel::loadModels(const KartProperties &kart_properties) // Update min/max Vec3 obj_min, obj_max; - MeshTools::minMax3D(obj.m_model, &obj_min, &obj_max); + MeshTools::minMax3D(obj.m_model, &obj_min, &obj_max); obj_min += obj.m_position; obj_max += obj.m_position; kart_min.min(obj_min); @@ -870,37 +870,35 @@ void KartModel::update(float dt, float rotation_dt, float steer, } // update //----------------------------------------------------------------------------- void KartModel::attachHat(){ - m_hat_node = NULL; - if(m_hat_name.size()>0) + m_hat_node = NULL; + if(m_hat_name.size()>0) + { + scene::IBoneSceneNode *bone = m_animated_node->getJointNode("Head"); + if(!bone) + bone = m_animated_node->getJointNode("head"); + if(bone) { - scene::IBoneSceneNode *bone = m_animated_node->getJointNode("Head"); - if(!bone) - bone = m_animated_node->getJointNode("head"); - if(bone) - { - - // Till we have all models fixed, accept Head and head as bone naartme - scene::IMesh *hat_mesh = - irr_driver->getAnimatedMesh( - file_manager->getModelFile(m_hat_name)); - m_hat_node = irr_driver->addMesh(hat_mesh); - bone->addChild(m_hat_node); - m_animated_node->setCurrentFrame((float)m_animation_frame[AF_STRAIGHT]); - m_animated_node->OnAnimate(0); - bone->updateAbsolutePosition(); - - // With the hat node attached to the head bone, we have to - // reverse the transformation of the bone, so that the hat - // is still properly placed. Esp. the hat offset needs - // to be rotated. - const core::matrix4 mat = bone->getAbsoluteTransformation(); - core::matrix4 inv; - mat.getInverse(inv); - core::vector3df rotated_offset; - inv.rotateVect(rotated_offset, m_hat_offset); - m_hat_node->setPosition(rotated_offset); - m_hat_node->setScale(inv.getScale()); - m_hat_node->setRotation(inv.getRotationDegrees()); - } // if bone - } // if(m_hat_name) + // Till we have all models fixed, accept Head and head as bone naartme + scene::IMesh *hat_mesh = + irr_driver->getAnimatedMesh( + file_manager->getModelFile(m_hat_name)); + m_hat_node = irr_driver->addMesh(hat_mesh); + bone->addChild(m_hat_node); + m_animated_node->setCurrentFrame((float)m_animation_frame[AF_STRAIGHT]); + m_animated_node->OnAnimate(0); + bone->updateAbsolutePosition(); + // With the hat node attached to the head bone, we have to + // reverse the transformation of the bone, so that the hat + // is still properly placed. Esp. the hat offset needs + // to be rotated. + const core::matrix4 mat = bone->getAbsoluteTransformation(); + core::matrix4 inv; + mat.getInverse(inv); + core::vector3df rotated_offset; + inv.rotateVect(rotated_offset, m_hat_offset); + m_hat_node->setPosition(rotated_offset); + m_hat_node->setScale(inv.getScale()); + m_hat_node->setRotation(inv.getRotationDegrees()); + } // if bone + } // if(m_hat_name) } diff --git a/src/karts/kart_model.hpp b/src/karts/kart_model.hpp index 9c5ea11e9..bc01dafc2 100644 --- a/src/karts/kart_model.hpp +++ b/src/karts/kart_model.hpp @@ -200,7 +200,7 @@ private: float m_kart_height; /** Largest coordinate on up axis. */ - float m_kart_highest_point; + float m_kart_highest_point; /** Smallest coordinate on up axis. */ float m_kart_lowest_point; @@ -304,12 +304,12 @@ public: // ------------------------------------------------------------------------ /** Returns the height of the kart. */ float getHeight () const {return m_kart_height; } - // ------------------------------------------------------------------------ - /** Highest coordinate on up axis */ - float getHighestPoint () const { return m_kart_highest_point; } - // ------------------------------------------------------------------------ - /** Lowest coordinate on up axis */ - float getLowestPoint () const { return m_kart_lowest_point; } + // ------------------------------------------------------------------------ + /** Highest coordinate on up axis */ + float getHighestPoint () const { return m_kart_highest_point; } + // ------------------------------------------------------------------------ + /** Lowest coordinate on up axis */ + float getLowestPoint () const { return m_kart_lowest_point; } // ------------------------------------------------------------------------ /** Enables- or disables the end animation. */ void setAnimation(AnimationFrameType type); @@ -319,15 +319,15 @@ public: // ------------------------------------------------------------------------ /** Name of the hat mesh to use. */ void setHatMeshName(const std::string &name) {m_hat_name = name; } - // ------------------------------------------------------------------------ - void attachHat(); + // ------------------------------------------------------------------------ + void attachHat(); // ------------------------------------------------------------------------ /** Returns the array of wheel nodes. */ scene::ISceneNode** getWheelNodes() { return m_wheel_node; } - // ------------------------------------------------------------------------ - scene::IAnimatedMeshSceneNode* getAnimatedNode(){ return m_animated_node; } - // ------------------------------------------------------------------------ - core::vector3df getHatOffset() { return m_hat_offset; } + // ------------------------------------------------------------------------ + scene::IAnimatedMeshSceneNode* getAnimatedNode(){ return m_animated_node; } + // ------------------------------------------------------------------------ + core::vector3df getHatOffset() { return m_hat_offset; } }; // KartModel #endif diff --git a/src/karts/kart_properties_manager.cpp b/src/karts/kart_properties_manager.cpp index b50782ac6..a1d0cbd3a 100644 --- a/src/karts/kart_properties_manager.cpp +++ b/src/karts/kart_properties_manager.cpp @@ -192,7 +192,7 @@ bool KartPropertiesManager::loadKart(const std::string &dir) { std::string config_filename=dir+"/kart.xml"; if(!file_manager->fileExists(config_filename)) - return false; + return false; KartProperties* kart_properties; try diff --git a/src/main.cpp b/src/main.cpp index 9da9112bf..79b8fe632 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1147,7 +1147,7 @@ void initUserConfig(char *argv[]) translations = new Translations(); // needs file_manager stk_config = new STKConfig(); // in case of --stk-config // command line parameters - user_config->postLoadInit(); + user_config->postLoadInit(); if (!config_ok || UserConfigParams::m_all_players.size() == 0) { user_config->addDefaultPlayer(); diff --git a/src/modes/easter_egg_hunt.cpp b/src/modes/easter_egg_hunt.cpp index 3778a2cb3..3d47bbfc5 100644 --- a/src/modes/easter_egg_hunt.cpp +++ b/src/modes/easter_egg_hunt.cpp @@ -218,6 +218,6 @@ void EasterEggHunt::checkForWrongDirection(unsigned int i) void EasterEggHunt::terminateRace() { - m_karts[0]->getControls().reset(); - WorldWithRank::terminateRace(); + m_karts[0]->getControls().reset(); + WorldWithRank::terminateRace(); } diff --git a/src/modes/easter_egg_hunt.hpp b/src/modes/easter_egg_hunt.hpp index 8ba8cb7d0..29534cdde 100755 --- a/src/modes/easter_egg_hunt.hpp +++ b/src/modes/easter_egg_hunt.hpp @@ -56,7 +56,7 @@ public: virtual bool raceHasLaps(){ return false; } virtual const std::string& getIdent() const; - virtual void terminateRace(); + virtual void terminateRace(); virtual void update(float dt); virtual void getKartsDisplayInfo( std::vector *info); diff --git a/src/modes/overworld.cpp b/src/modes/overworld.cpp index 73c718837..363b4c09c 100644 --- a/src/modes/overworld.cpp +++ b/src/modes/overworld.cpp @@ -86,10 +86,10 @@ void OverWorld::enterOverWorld() network_manager->setupPlayerKartInfo(); race_manager->startNew(false); if(race_manager->haveKartLastPositionOnOverworld()){ - OverWorld *ow = (OverWorld*)World::getWorld(); - ow->getKart(0)->setXYZ(race_manager->getKartLastPositionOnOverworld()); - ow->moveKartAfterRescue(ow->getKart(0)); - } + OverWorld *ow = (OverWorld*)World::getWorld(); + ow->getKart(0)->setXYZ(race_manager->getKartLastPositionOnOverworld()); + ow->moveKartAfterRescue(ow->getKart(0)); + } irr_driver->showPointer(); // User should be able to click on the minimap } // enterOverWorld @@ -116,7 +116,7 @@ void OverWorld::update(float dt) m_karts[0]->startEngineSFX(); } WorldWithRank::update(dt); - WorldWithRank::updateTrack(dt); + WorldWithRank::updateTrack(dt); const unsigned int kart_amount = m_karts.size(); // isn't it cool, on the overworld nitro is free! diff --git a/src/modes/soccer_world.hpp b/src/modes/soccer_world.hpp index 6c80f5ede..d28628f25 100644 --- a/src/modes/soccer_world.hpp +++ b/src/modes/soccer_world.hpp @@ -51,11 +51,11 @@ private: SFXBase *m_goal_sound; /** Timer for displaying goal text*/ float m_goal_timer; - int m_lastKartToHitBall; - std::vector m_redScorers; - std::vector m_redScoreTimes; - std::vector m_blueScorers; - std::vector m_blueScoreTimes; + int m_lastKartToHitBall; + std::vector m_redScorers; + std::vector m_redScoreTimes; + std::vector m_blueScorers; + std::vector m_blueScoreTimes; public: SoccerWorld(); @@ -83,21 +83,21 @@ public: void onCheckGoalTriggered(bool first_goal); int getTeamLeader(unsigned int i); - void setLastKartTohitBall(unsigned int kartId); - std::vector getScorers(unsigned int team) + void setLastKartTohitBall(unsigned int kartId); + std::vector getScorers(unsigned int team) { - if(team == 0) - return m_redScorers; + if(team == 0) + return m_redScorers; else - return m_blueScorers; - } - std::vector getScoreTimes(unsigned int team) + return m_blueScorers; + } + std::vector getScoreTimes(unsigned int team) { - if(team == 0) - return m_redScoreTimes; - else - return m_blueScoreTimes; - } + if(team == 0) + return m_redScoreTimes; + else + return m_blueScoreTimes; + } private: void initKartList(); diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 44b9ffa83..626f32e87 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -265,11 +265,7 @@ void World::reset() void World::createRaceGUI() { - //if(UserConfigParams::m_minimal_race_gui && - // race_manager->getTrackName() != "tutorial") - // m_race_gui = new MinimalRaceGUI(); - //else - m_race_gui = new RaceGUI(); + m_race_gui = new RaceGUI(); } //----------------------------------------------------------------------------- @@ -300,7 +296,7 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index, m_num_players ++; break; case RaceManager::KT_NETWORK_PLAYER: - break; // Avoid compiler warning about enum not handled. + break; // Avoid compiler warning about enum not handled. //controller = new NetworkController(kart_ident, position, init_pos, // global_player_id); //m_num_players++; diff --git a/src/modes/world_status.cpp b/src/modes/world_status.cpp index 0fd08ca32..2d8ec6553 100644 --- a/src/modes/world_status.cpp +++ b/src/modes/world_status.cpp @@ -146,7 +146,7 @@ void WorldStatus::update(const float dt) // long, we use the aux timer to force the next phase // after 3.5 seconds. if(m_track_intro_sound->getStatus()==SFXManager::SFX_PLAYING - && m_auxiliary_timer<3.5f) + && m_auxiliary_timer<3.5f) return; // Wait before ready phase if sounds are disabled if(!UserConfigParams::m_sfx && m_auxiliary_timer<3.0f) @@ -239,8 +239,8 @@ void WorldStatus::update(const float dt) case FINISH_PHASE: // Nothing to do here. break; - case GOAL_PHASE: - // Nothing to do here as well. + case GOAL_PHASE: + // Nothing to do here as well. default: break; } diff --git a/src/modes/world_status.hpp b/src/modes/world_status.hpp index 511b83193..bfdf30aa9 100644 --- a/src/modes/world_status.hpp +++ b/src/modes/world_status.hpp @@ -79,8 +79,8 @@ public: // Undefined, used in asserts to catch incorrect states. UNDEFINED_PHASE, - //Goal scored phase - GOAL_PHASE + //Goal scored phase + GOAL_PHASE }; protected: /** Sound to play at the beginning of a race, during which a diff --git a/src/network/network_manager.cpp b/src/network/network_manager.cpp index f3e35791d..b216dc752 100644 --- a/src/network/network_manager.cpp +++ b/src/network/network_manager.cpp @@ -653,7 +653,7 @@ void NetworkManager::receiveUpdates() { RaceResultMessage m(event.packet); m_state = NS_WAIT_FOR_RACE_RESULT; - World::getWorld()->enterRaceOverState(); + World::getWorld()->enterRaceOverState(); return; } race_state->receive(event.packet); diff --git a/src/physics/btKartRaycast.cpp b/src/physics/btKartRaycast.cpp index 781d052aa..13b310f76 100644 --- a/src/physics/btKartRaycast.cpp +++ b/src/physics/btKartRaycast.cpp @@ -37,9 +37,9 @@ void* btKartRaycaster::castRay(const btVector3& from, const btVector3& to, } // CloestWithNormal // -------------------------------------------------------------------- /** Stores the index of the triangle hit. */ - virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult, + virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult, bool normalInWorldSpace) - { + { // We don't always get a triangle index, sometimes (e.g. ray hits // other kart) we get shapePart=-1, or no localShapeInfo at all if(rayResult.m_localShapeInfo && @@ -48,7 +48,7 @@ void* btKartRaycaster::castRay(const btVector3& from, const btVector3& to, return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace); - } + } // -------------------------------------------------------------------- /** Returns the index of the triangle which was hit, or -1 if * no triangle was hit. */ @@ -57,19 +57,19 @@ void* btKartRaycaster::castRay(const btVector3& from, const btVector3& to, }; // CloestWithNormal // ======================================================================== - ClosestWithNormal rayCallback(from,to); + ClosestWithNormal rayCallback(from,to); - m_dynamicsWorld->rayTest(from, to, rayCallback); + m_dynamicsWorld->rayTest(from, to, rayCallback); - if (rayCallback.hasHit()) - { - btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject); + if (rayCallback.hasHit()) + { + btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject); if (body && body->hasContactResponse()) - { - result.m_hitPointInWorld = rayCallback.m_hitPointWorld; - result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld; - result.m_hitNormalInWorld.normalize(); - result.m_distFraction = rayCallback.m_closestHitFraction; + { + result.m_hitPointInWorld = rayCallback.m_hitPointWorld; + result.m_hitNormalInWorld = rayCallback.m_hitNormalWorld; + result.m_hitNormalInWorld.normalize(); + result.m_distFraction = rayCallback.m_closestHitFraction; const TriangleMesh &tm = World::getWorld()->getTrack()->getTriangleMesh(); if(m_smooth_normals && @@ -89,8 +89,8 @@ void* btKartRaycaster::castRay(const btVector3& from, const btVector3& to, #endif } return body; - } - } - return 0; + } + } + return 0; } diff --git a/src/physics/btKartRaycast.hpp b/src/physics/btKartRaycast.hpp index 19384218d..f9c7faa16 100644 --- a/src/physics/btKartRaycast.hpp +++ b/src/physics/btKartRaycast.hpp @@ -23,17 +23,17 @@ class btDynamicsWorld; class btKartRaycaster : public btVehicleRaycaster { private: - btDynamicsWorld* m_dynamicsWorld; + btDynamicsWorld* m_dynamicsWorld; /** True if the normals should be smoothed. Not all tracks support this, * so this flag is set depending on track when constructing this object. */ bool m_smooth_normals; public: - btKartRaycaster(btDynamicsWorld* world, bool smooth_normals=false) - :m_dynamicsWorld(world), m_smooth_normals(smooth_normals) - { - } + btKartRaycaster(btDynamicsWorld* world, bool smooth_normals=false) + :m_dynamicsWorld(world), m_smooth_normals(smooth_normals) + { + } - virtual void* castRay(const btVector3& from,const btVector3& to, + virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result); }; diff --git a/src/physics/btUprightConstraint.hpp b/src/physics/btUprightConstraint.hpp index 3b36cfd6b..a2711fa9f 100644 --- a/src/physics/btUprightConstraint.hpp +++ b/src/physics/btUprightConstraint.hpp @@ -111,7 +111,7 @@ public: timeStep); virtual void getInfo1 (btConstraintInfo1* info); virtual void getInfo2 (btConstraintInfo2* info); - virtual void setParam(int num, btScalar value, int axis = -1); + virtual void setParam(int num, btScalar value, int axis = -1); virtual btScalar getParam(int num, int axis) const; }; diff --git a/src/physics/physical_object.cpp b/src/physics/physical_object.cpp index 7aecce047..6c90b014b 100644 --- a/src/physics/physical_object.cpp +++ b/src/physics/physical_object.cpp @@ -533,7 +533,7 @@ void PhysicalObject::handleExplosion(const Vec3& pos, bool direct_hit) */ bool PhysicalObject::isSoccerBall() const { - return m_object->isSoccerBall(); + return m_object->isSoccerBall(); } // is SoccerBall // ---------------------------------------------------------------------------- diff --git a/src/physics/physics.cpp b/src/physics/physics.cpp index c5b3bcf45..fcff1f0c7 100644 --- a/src/physics/physics.cpp +++ b/src/physics/physics.cpp @@ -85,13 +85,13 @@ Physics::~Physics() */ void Physics::addKart(const AbstractKart *kart) { - const btCollisionObjectArray &all_objs = - m_dynamics_world->getCollisionObjectArray(); - for(unsigned int i=0; i<(unsigned int)all_objs.size(); i++) - { - if(btRigidBody::upcast(all_objs[i])== kart->getBody()) - return; - } + const btCollisionObjectArray &all_objs = + m_dynamics_world->getCollisionObjectArray(); + for(unsigned int i=0; i<(unsigned int)all_objs.size(); i++) + { + if(btRigidBody::upcast(all_objs[i])== kart->getBody()) + return; + } m_dynamics_world->addRigidBody(kart->getBody()); m_dynamics_world->addVehicle(kart->getVehicle()); m_dynamics_world->addConstraint(kart->getUprightConstraint()); @@ -189,12 +189,12 @@ void Physics::update(float dt) const KartProperties* kp = kart->getKartProperties(); kart->setSquash(kp->getSquashDuration(), kp->getSquashSlowdown()); } - else if(obj->isSoccerBall()) + else if(obj->isSoccerBall()) { - int kartId = p->getUserPointer(1)->getPointerKart()->getWorldKartId(); - SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld(); - soccerWorld->setLastKartTohitBall(kartId); - } + int kartId = p->getUserPointer(1)->getPointerKart()->getWorldKartId(); + SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld(); + soccerWorld->setLastKartTohitBall(kartId); + } continue; } diff --git a/src/physics/stk_dynamics_world.hpp b/src/physics/stk_dynamics_world.hpp index 0210cd5ba..d0f2f49d0 100644 --- a/src/physics/stk_dynamics_world.hpp +++ b/src/physics/stk_dynamics_world.hpp @@ -24,7 +24,7 @@ class STKDynamicsWorld : public btDiscreteDynamicsWorld { public: - /** The standard constructor which just created a btDiscreteDynamicsWorld. */ + /** The standard constructor which just created a btDiscreteDynamicsWorld. */ STKDynamicsWorld(btDispatcher* dispatcher, btBroadphaseInterface* pairCache, btConstraintSolver* constraintSolver, diff --git a/src/race/race_manager.hpp b/src/race/race_manager.hpp index 6c5ab9c4a..bd9395080 100644 --- a/src/race/race_manager.hpp +++ b/src/race/race_manager.hpp @@ -331,7 +331,7 @@ private: int m_coin_target; bool m_has_time_target; float m_time_target; - int m_goal_target; + int m_goal_target; void startNextRace(); // start a next race @@ -394,9 +394,9 @@ public: bool hasTimeTarget() const { return m_has_time_target; } - void setMaxGoal(int maxGoal){ m_goal_target = maxGoal; } + void setMaxGoal(int maxGoal){ m_goal_target = maxGoal; } - int getMaxGoal(){ return m_goal_target; } + int getMaxGoal(){ return m_goal_target; } /** Sort karts and update the m_gp_rank KartStatus member, in preparation * for future calls to RaceManager::getKartGPRank or diff --git a/src/states_screens/addons_screen.cpp b/src/states_screens/addons_screen.cpp index 94c2ef1c0..9afc48972 100644 --- a/src/states_screens/addons_screen.cpp +++ b/src/states_screens/addons_screen.cpp @@ -140,7 +140,7 @@ void AddonsScreen::init() m_sort_default = true; m_sort_col = 0; - getWidget("category")->setDeactivated(); + getWidget("category")->setDeactivated(); GUIEngine::getFont()->setTabStop(0.66f); @@ -273,8 +273,8 @@ void AddonsScreen::loadList() if(addon->isInstalled()) icon = addon->needsUpdate() ? m_icon_needs_update : m_icon_installed; - else - icon = m_icon_not_installed; + else + icon = m_icon_not_installed; core::stringw s; if (addon->getDesigner().size()==0) @@ -367,15 +367,15 @@ void AddonsScreen::loadList() } } - getWidget("category")->setActivated(); - if(m_type == "kart") - getWidget("category")->select("tab_kart", + getWidget("category")->setActivated(); + if(m_type == "kart") + getWidget("category")->select("tab_kart", PLAYER_ID_GAME_MASTER); - else if(m_type == "track") - getWidget("category")->select("tab_track", + else if(m_type == "track") + getWidget("category")->select("tab_track", PLAYER_ID_GAME_MASTER); else - getWidget("category")->select("tab_update", + getWidget("category")->select("tab_update", PLAYER_ID_GAME_MASTER); } // loadList diff --git a/src/states_screens/dialogs/add_device_dialog.cpp b/src/states_screens/dialogs/add_device_dialog.cpp index 7c23d72ad..1a3226545 100644 --- a/src/states_screens/dialogs/add_device_dialog.cpp +++ b/src/states_screens/dialogs/add_device_dialog.cpp @@ -178,7 +178,7 @@ GUIEngine::EventPropagation AddDeviceDialog::processEvent { // Remove the previous modal dialog to avoid a warning GUIEngine::ModalDialog::dismiss(); - if(wiimote_manager->askUserToConnectWiimotes() > 0) + if(wiimote_manager->askUserToConnectWiimotes() > 0) ((OptionsScreenInput*)GUIEngine::getCurrentScreen())->rebuildDeviceList(); return GUIEngine::EVENT_BLOCK; diff --git a/src/states_screens/dialogs/track_info_dialog.cpp b/src/states_screens/dialogs/track_info_dialog.cpp index 823cc7d69..e49264bde 100644 --- a/src/states_screens/dialogs/track_info_dialog.cpp +++ b/src/states_screens/dialogs/track_info_dialog.cpp @@ -122,7 +122,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& ribbonItem, const std::strin // Reverse track const bool reverse_available = track->reverseAvailable() && - race_manager->getMinorMode() != RaceManager::MINOR_MODE_EASTER_EGG; + race_manager->getMinorMode() != RaceManager::MINOR_MODE_EASTER_EGG; if (reverse_available) { m_checkbox = getWidget("reverse"); diff --git a/src/states_screens/help_screen_1.cpp b/src/states_screens/help_screen_1.cpp index 7b2152fe6..035f3c73c 100644 --- a/src/states_screens/help_screen_1.cpp +++ b/src/states_screens/help_screen_1.cpp @@ -108,16 +108,16 @@ void HelpScreen1::init() { Screen::init(); RibbonWidget* w = this->getWidget("category"); - ButtonWidget* tutorial = getWidget("startTutorial"); + ButtonWidget* tutorial = getWidget("startTutorial"); - if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) - { - tutorial->setDeactivated(); - } - else - { - tutorial->setActivated(); - } + if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU) + { + tutorial->setDeactivated(); + } + else + { + tutorial->setActivated(); + } if (w != NULL) w->select( "page1", PLAYER_ID_GAME_MASTER ); } //init diff --git a/src/states_screens/race_gui.hpp b/src/states_screens/race_gui.hpp index 078dfa015..12142b1eb 100644 --- a/src/states_screens/race_gui.hpp +++ b/src/states_screens/race_gui.hpp @@ -105,7 +105,7 @@ private: /** Display items that are shown once only (for all karts). */ void drawGlobalMiniMap (); void drawGlobalTimer (); - void drawScores(); + void drawScores(); public: diff --git a/src/states_screens/race_gui_base.cpp b/src/states_screens/race_gui_base.cpp index 1f30c987b..3b00b9020 100644 --- a/src/states_screens/race_gui_base.cpp +++ b/src/states_screens/race_gui_base.cpp @@ -70,7 +70,7 @@ RaceGUIBase::RaceGUIBase() //I18N: as in "ready, set, go", shown at the beginning of the race m_string_go = _("Go!"); //I18N: Shown when a goal is scored - m_string_goal = _("GOAL!"); + m_string_goal = _("GOAL!"); // Make the two materials permanent (in case that they are not listed // in the textures/materials.xml file). m_music_icon = material_manager->getMaterial("notes.png", @@ -678,14 +678,15 @@ void RaceGUIBase::drawGlobalMusicDescription() } // drawGlobalMusicDescription //----------------------------------------------------------------------------- -void RaceGUIBase::drawGlobalGoal(){ - static video::SColor color = video::SColor(255, 255, 255, 255); - core::rect pos(UserConfigParams::m_width>>1, - UserConfigParams::m_height>>1, - UserConfigParams::m_width>>1, - UserConfigParams::m_height>>1); - gui::IGUIFont* font = GUIEngine::getTitleFont(); - font->draw(m_string_goal.c_str(), pos, color, true, true); +void RaceGUIBase::drawGlobalGoal() +{ + static video::SColor color = video::SColor(255, 255, 255, 255); + core::rect pos(UserConfigParams::m_width>>1, + UserConfigParams::m_height>>1, + UserConfigParams::m_width>>1, + UserConfigParams::m_height>>1); + gui::IGUIFont* font = GUIEngine::getTitleFont(); + font->draw(m_string_goal.c_str(), pos, color, true, true); } // ---------------------------------------------------------------------------- /** Draws the ready-set-go message on the screen. diff --git a/src/states_screens/race_gui_base.hpp b/src/states_screens/race_gui_base.hpp index 7c13675fb..55bce3039 100644 --- a/src/states_screens/race_gui_base.hpp +++ b/src/states_screens/race_gui_base.hpp @@ -198,8 +198,8 @@ protected: const core::recti &viewport, const core::vector2df &scaling); void drawGlobalMusicDescription(); - void drawGlobalReadySetGo (); - void drawGlobalGoal (); + void drawGlobalReadySetGo(); + void drawGlobalGoal(); void drawPlungerInFace(const Camera *camera, float dt); /** Instructs the base gui to ignore unimportant messages (like * item messages). diff --git a/src/states_screens/state_manager.hpp b/src/states_screens/state_manager.hpp index 7a38c08d7..6e01f56d6 100644 --- a/src/states_screens/state_manager.hpp +++ b/src/states_screens/state_manager.hpp @@ -102,9 +102,9 @@ public: PlayerProfile* getProfile() { #ifdef DEBUG - assert(m_magic_number == 0xAC1EF1AE); + assert(m_magic_number == 0xAC1EF1AE); #endif - return m_player; + return m_player; } // getProfile // -------------------------------------------------------------------- @@ -112,9 +112,9 @@ public: const PlayerProfile* getConstProfile() const { #ifdef DEBUG - assert(m_magic_number == 0xAC1EF1AE); + assert(m_magic_number == 0xAC1EF1AE); #endif - return m_player; + return m_player; } // getConstProfile // -------------------------------------------------------------------- @@ -127,9 +127,9 @@ public: int getID() const { #ifdef DEBUG - assert(m_magic_number == 0xAC1EF1AE); + assert(m_magic_number == 0xAC1EF1AE); #endif - return m_id; + return m_id; } // getID // -------------------------------------------------------------------- @@ -138,9 +138,9 @@ public: InputDevice* getDevice() const { #ifdef DEBUG - assert(m_magic_number == 0xAC1EF1AE); + assert(m_magic_number == 0xAC1EF1AE); #endif - return m_device; + return m_device; } // getDevice // -------------------------------------------------------------------- @@ -151,9 +151,9 @@ public: void setKart(AbstractKart *kart) { #ifdef DEBUG - assert(m_magic_number == 0xAC1EF1AE); + assert(m_magic_number == 0xAC1EF1AE); #endif - m_kart = kart; + m_kart = kart; } // setKart // -------------------------------------------------------------------- @@ -161,7 +161,7 @@ public: AbstractKart* getKart() { #ifdef DEBUG - assert(m_magic_number == 0xAC1EF1AE); + assert(m_magic_number == 0xAC1EF1AE); #endif return m_kart; } // getKart diff --git a/src/tinygettext/po_parser.cpp b/src/tinygettext/po_parser.cpp index 703d42649..2a6bbb3c0 100644 --- a/src/tinygettext/po_parser.cpp +++ b/src/tinygettext/po_parser.cpp @@ -382,7 +382,7 @@ POParser::parse() { std::string msgid_plural = get_string(12); std::vector msgstr_num; - bool saw_nonempty_msgstr = false; + bool saw_nonempty_msgstr = false; next: if (is_empty_line()) @@ -395,10 +395,10 @@ POParser::parse() isdigit(current_line[7]) && current_line[8] == ']') { unsigned int number = static_cast(current_line[7] - '0'); - std::string msgstr = get_string(9); + std::string msgstr = get_string(9); - if(!msgstr.empty()) - saw_nonempty_msgstr = true; + if(!msgstr.empty()) + saw_nonempty_msgstr = true; if (number >= msgstr_num.size()) msgstr_num.resize(number+1); @@ -414,38 +414,38 @@ POParser::parse() if (!is_empty_line()) error("expected 'msgstr[N]' or empty line"); - if (saw_nonempty_msgstr) - { - if (use_fuzzy || !fuzzy) + if (saw_nonempty_msgstr) + { + if (use_fuzzy || !fuzzy) { - if (!dict.get_plural_forms()) - { - warning("msgstr[N] seen, but no Plural-Forms given"); - } - else - { - if (msgstr_num.size() != dict.get_plural_forms().get_nplural()) - { - warning("msgstr[N] count doesn't match Plural-Forms.nplural"); - } - } + if (!dict.get_plural_forms()) + { + warning("msgstr[N] seen, but no Plural-Forms given"); + } + else + { + if (msgstr_num.size() != dict.get_plural_forms().get_nplural()) + { + warning("msgstr[N] count doesn't match Plural-Forms.nplural"); + } + } - if (has_msgctxt) - dict.add_translation(msgctxt, msgid, msgid_plural, msgstr_num); - else - dict.add_translation(msgid, msgid_plural, msgstr_num); - } + if (has_msgctxt) + dict.add_translation(msgctxt, msgid, msgid_plural, msgstr_num); + else + dict.add_translation(msgid, msgid_plural, msgstr_num); + } - if (0) - { - std::cout << (fuzzy?"fuzzy":"not-fuzzy") << std::endl; - std::cout << "msgid \"" << msgid << "\"" << std::endl; - std::cout << "msgid_plural \"" << msgid_plural << "\"" << std::endl; - for(std::vector::size_type i = 0; i < msgstr_num.size(); ++i) - std::cout << "msgstr[" << i << "] \"" << msgstr_num[i] /*conv.convert(msgstr_num[i])*/ << "\"" << std::endl; - std::cout << std::endl; - } - } + if (0) + { + std::cout << (fuzzy?"fuzzy":"not-fuzzy") << std::endl; + std::cout << "msgid \"" << msgid << "\"" << std::endl; + std::cout << "msgid_plural \"" << msgid_plural << "\"" << std::endl; + for(std::vector::size_type i = 0; i < msgstr_num.size(); ++i) + std::cout << "msgstr[" << i << "] \"" << msgstr_num[i] /*conv.convert(msgstr_num[i])*/ << "\"" << std::endl; + std::cout << std::endl; + } + } } else if (prefix("msgstr")) { diff --git a/src/tracks/check_cannon.hpp b/src/tracks/check_cannon.hpp index 1b8b70624..9e3a62dea 100644 --- a/src/tracks/check_cannon.hpp +++ b/src/tracks/check_cannon.hpp @@ -36,7 +36,7 @@ class XMLNode; class CheckCannon : public CheckLine { private: - /** The target point the kart will fly to. */ + /** The target point the kart will fly to. */ core::line3df m_target; /** Stores the cannon curve data. */ diff --git a/src/tracks/check_structure.cpp b/src/tracks/check_structure.cpp index dba714639..be36cc64a 100644 --- a/src/tracks/check_structure.cpp +++ b/src/tracks/check_structure.cpp @@ -49,8 +49,8 @@ CheckStructure::CheckStructure(const XMLNode &node, unsigned int index) else if(kind=="ambient-light") m_check_type = CT_AMBIENT_SPHERE; // Cannons don't have a kind specified, so test for the name in this case - else if(node.getName()=="cannon") - m_check_type = CT_CANNON; + else if(node.getName()=="cannon") + m_check_type = CT_CANNON; else { printf("Unknown check structure '%s' - ignored.\n", kind.c_str()); diff --git a/src/tracks/check_structure.hpp b/src/tracks/check_structure.hpp index 3bab7f8d7..e9da8b307 100644 --- a/src/tracks/check_structure.hpp +++ b/src/tracks/check_structure.hpp @@ -64,7 +64,7 @@ public: * enabling you to count the lap again. */ enum CheckType {CT_NEW_LAP, CT_ACTIVATE, CT_TOGGLE, CT_CANNON, - CT_GOAL, CT_AMBIENT_SPHERE}; + CT_GOAL, CT_AMBIENT_SPHERE}; protected: /** Stores the previous position of all karts. This is needed to detect diff --git a/src/utils/log.cpp b/src/utils/log.cpp index 4e9ef311c..98e58a8e3 100644 --- a/src/utils/log.cpp +++ b/src/utils/log.cpp @@ -67,9 +67,9 @@ void Log::setTerminalColor(LogLevel level) #else enum TermAttr { - TERM_RESET = 0, // "normal" mode + TERM_RESET = 0, // "normal" mode TERM_BRIGHT = 1,// more luminosity for the foreground - TERM_DIM = 2, // less luminosity for the foreground + TERM_DIM = 2, // less luminosity for the foreground }; enum TermColor diff --git a/src/utils/profiler.cpp b/src/utils/profiler.cpp index 634b6385a..0d5a10e28 100644 --- a/src/utils/profiler.cpp +++ b/src/utils/profiler.cpp @@ -64,7 +64,7 @@ Profiler profiler; //----------------------------------------------------------------------------- Profiler::Profiler() { - m_thread_infos.resize(1); // TODO: monothread now, should support multithreading + m_thread_infos.resize(1); // TODO: monothread now, should support multithreading m_write_id = 0; m_time_last_sync = _getTimeMilliseconds(); m_time_between_sync = 0.0; @@ -101,7 +101,7 @@ void Profiler::popCpuMarker() if(m_freeze_state == FROZEN || m_freeze_state == WAITING_FOR_UNFREEZE) return; - ThreadInfo& ti = getThreadInfo(); + ThreadInfo& ti = getThreadInfo(); assert(ti.markers_stack[m_write_id].size() > 0); MarkerStack& markers_stack = ti.markers_stack[m_write_id]; @@ -195,7 +195,7 @@ void Profiler::draw() int read_id = !m_write_id; // Compute some values for drawing (unit: pixels, but we keep floats for reducing errors accumulation) - core::dimension2d screen_size = driver->getScreenSize(); + core::dimension2d screen_size = driver->getScreenSize(); const double profiler_width = (1.0 - 2.0*MARGIN_X) * screen_size.Width; const double x_offset = MARGIN_X*screen_size.Width; const double y_offset = (MARGIN_Y + LINE_HEIGHT)*screen_size.Height; @@ -220,12 +220,12 @@ void Profiler::draw() MarkerList::const_iterator it_end = markers.end(); for(MarkerList::const_iterator it = markers.begin() ; it != it_end ; it++) { - const Marker& m = *it; + const Marker& m = *it; assert(m.end >= 0.0); - core::rect pos((s32)( x_offset + factor*m.start ), - (s32)( y_offset + i*line_height ), - (s32)( x_offset + factor*m.end ), - (s32)( y_offset + (i+1)*line_height )); + core::rect pos((s32)( x_offset + factor*m.start ), + (s32)( y_offset + i*line_height ), + (s32)( x_offset + factor*m.end ), + (s32)( y_offset + (i+1)*line_height )); // Reduce vertically the size of the markers according to their layer pos.UpperLeftCorner.Y += m.layer; diff --git a/src/utils/profiler.hpp b/src/utils/profiler.hpp index cede745cf..738e2e633 100644 --- a/src/utils/profiler.hpp +++ b/src/utils/profiler.hpp @@ -77,8 +77,8 @@ private: } }; - typedef std::list MarkerList; - typedef std::stack MarkerStack; + typedef std::list MarkerList; + typedef std::stack MarkerStack; struct ThreadInfo { @@ -86,7 +86,7 @@ private: MarkerStack markers_stack[2]; }; - typedef std::vector ThreadInfoList; + typedef std::vector ThreadInfoList; ThreadInfoList m_thread_infos; int m_write_id; diff --git a/src/utils/string_utils.cpp b/src/utils/string_utils.cpp index eed8955ae..0465fe57c 100644 --- a/src/utils/string_utils.cpp +++ b/src/utils/string_utils.cpp @@ -644,54 +644,56 @@ namespace StringUtils // ------------------------------------------------------------------------ /** Converts a version string (in the form of 'X.Y.Za-rcU' into an - * integer number. - * \param s The version string to convert. - */ + * integer number. + * \param s The version string to convert. + */ int versionToInt(const std::string &version_string) { - // Special case: SVN - if(version_string=="SVN" || version_string=="svn") - // SVN version will be version 99.99.99i-rcJ - return 1000000*99 - + 10000*99 - + 100*99 - + 10* 9 - + 9; + // Special case: SVN + if(version_string=="SVN" || version_string=="svn") + { + // SVN version will be version 99.99.99i-rcJ + return 1000000*99 + + 10000*99 + + 100*99 + + 10* 9 + + 9; + } - std::string s=version_string; - // To guarantee that a release gets a higher version number than - // a release candidate, we assign a 'release_candidate' number - // of 9 to versions which are not a RC. We assert that any RC - // is less than 9 to guarantee the ordering. - int release_candidate=9; - if(s.length()>4 && sscanf(s.substr(s.length()-4, 4).c_str(), "-rc%d", - &release_candidate)==1) - { - s = s.substr(0, s.length()-4); - // Otherwise a RC can get a higher version number than - // the corresponding release! If this should ever get - // triggered, multiply all scaling factors above and - // below by 10, to get two digits for RC numbers. - assert(release_candidate<9); - } - int very_minor=0; - if(s.length()>0 && s[s.size()-1]>='a' && s[s.size()-1]<='z') - { - very_minor = s[s.size()-1]-'a'+1; - s = s.substr(0, s.size()-1); - } - std::vector l = StringUtils::split(s, '.'); - while(l.size()<3) - l.push_back("0"); - int version = 1000000*atoi(l[0].c_str()) - + 10000*atoi(l[1].c_str()) - + 100*atoi(l[2].c_str()) - + 10*very_minor - + release_candidate; + std::string s=version_string; + // To guarantee that a release gets a higher version number than + // a release candidate, we assign a 'release_candidate' number + // of 9 to versions which are not a RC. We assert that any RC + // is less than 9 to guarantee the ordering. + int release_candidate=9; + if(s.length()>4 && sscanf(s.substr(s.length()-4, 4).c_str(), "-rc%d", + &release_candidate)==1) + { + s = s.substr(0, s.length()-4); + // Otherwise a RC can get a higher version number than + // the corresponding release! If this should ever get + // triggered, multiply all scaling factors above and + // below by 10, to get two digits for RC numbers. + assert(release_candidate<9); + } + int very_minor=0; + if(s.length()>0 && s[s.size()-1]>='a' && s[s.size()-1]<='z') + { + very_minor = s[s.size()-1]-'a'+1; + s = s.substr(0, s.size()-1); + } + std::vector l = StringUtils::split(s, '.'); + while(l.size()<3) + l.push_back("0"); + int version = 1000000*atoi(l[0].c_str()) + + 10000*atoi(l[1].c_str()) + + 100*atoi(l[2].c_str()) + + 10*very_minor + + release_candidate; - if(version<=0) - printf("Invalid version string '%s'.\n", s.c_str()); - return version; + if(version<=0) + printf("Invalid version string '%s'.\n", s.c_str()); + return version; } // versionToInt } // namespace StringUtils