From: <hik...@us...> - 2009-12-16 21:37:46
|
Revision: 4306 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4306&view=rev Author: hikerstk Date: 2009-12-16 21:37:33 +0000 (Wed, 16 Dec 2009) Log Message: ----------- Simplified camera code somewhat, added support for final-camera, and made reverse faster. Modified Paths: -------------- main/trunk/src/graphics/camera.cpp main/trunk/src/graphics/camera.hpp main/trunk/src/karts/player_kart.cpp main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track.hpp Modified: main/trunk/src/graphics/camera.cpp =================================================================== --- main/trunk/src/graphics/camera.cpp 2009-12-16 04:04:52 UTC (rev 4305) +++ main/trunk/src/graphics/camera.cpp 2009-12-16 21:37:33 UTC (rev 4306) @@ -38,8 +38,6 @@ setupCamera(); m_distance = kart->getKartProperties()->getCameraDistance() * 0.5f; m_kart = kart; - m_angle_up = 0.0f; - m_angle_around = 0.0f; m_ambient_light = RaceManager::getTrack()->getDefaultAmbientColor(); // TODO: Put these values into a config file @@ -136,12 +134,49 @@ } // setupCamera // ---------------------------------------------------------------------------- +/** Sets the mode of the camera. + * \param mode Mode the camera should be switched to. + */ void Camera::setMode(Mode mode) { - m_mode = mode; + // If we switch from reverse view, move the camera immediately to the + // correct position. + if(m_mode==CM_REVERSE && mode==CM_NORMAL) + { + Vec3 wanted_position, wanted_target; + computeNormalCameraPosition(&wanted_position, &wanted_target); + m_camera->setPosition(wanted_position.toIrrVector()); + m_camera->setTarget(wanted_target.toIrrVector()); + } + if(mode==CM_FINAL) + { + const Track* track = RaceManager::getTrack(); + core::vector3df wanted_position(track->getCameraPosition().toIrrVector()); + core::vector3df curr_position(m_camera->getPosition()); + m_lin_velocity = (wanted_position-curr_position) + / stk_config->m_final_camera_time; + float distance = (m_kart->getXYZ() - curr_position).length(); + core::vector3df hpr = track->getCameraHPR().toIrrHPR(); + core::vector3df target = hpr.rotationToDirection(core::vector3df(0, 0, 1)*distance) + + wanted_position; + core::vector3df curr_hpr = m_camera->getRotation(); + m_target_velocity = (target - m_camera->getTarget()) + / stk_config->m_final_camera_time; + m_final_time = 0.0f; + } + + // If the camera is set to final mode but there is no camera + // end position defined, ignore this request and leave the camera + // in normal mode. + if(mode!=CM_FINAL || RaceManager::getTrack()->hasFinalCamera()) + { + m_mode = mode; + } } // setMode // ---------------------------------------------------------------------------- +/** Returns the current mode of the camera. + */ Camera::Mode Camera::getMode() { return m_mode; @@ -154,9 +189,6 @@ void Camera::reset() { setMode(CM_NORMAL); - // m_position, m_target etc. are set when the worlds has computed the right starting - // position of all karts and calls setInitialTransform for each camera. - } // reset //----------------------------------------------------------------------------- @@ -165,120 +197,154 @@ */ void Camera::setInitialTransform() { - m_target = m_kart->getXYZ(); - m_position = m_target - Vec3(0,50,-25); - m_temp_position = m_position; - m_temp_target = m_target; -} // updateKartPosition + m_camera->setPosition( m_kart->getXYZ().toIrrVector() - core::vector3df(0, -25, 50) ); +} // setInitialTransform //----------------------------------------------------------------------------- +/** Moves the camera smoothly from the current camera position (and target) + * to the new position and target. + * \param wanted_position The position the camera wanted to reach. + * \param wanted_target The point the camera wants to point to. + */ +void Camera::smoothMoveCamera(float dt, const Vec3 &wanted_position, + const Vec3 &wanted_target) +{ + // Smoothly interpolate towards the position and target + core::vector3df current_position = m_camera->getPosition(); + core::vector3df current_target = m_camera->getTarget(); + current_target += ((wanted_target.toIrrVector() - current_target ) * m_target_speed ) * dt; + current_position += ((wanted_position.toIrrVector() - current_position) * m_position_speed) * dt; + m_camera->setPosition(current_position); + m_camera->setTarget(current_target); + + if(race_manager->getNumLocalPlayers() < 2) + sound_manager->positionListener(current_position, + current_target - current_position); + + // The following settings give a debug camera which shows the track from + // high above the kart straight down. +#undef DEBUG_CAMERA +#ifdef DEBUG_CAMERA + core::vector3df xyz = RaceManager::getKart(0)->getXYZ().toIrrVector(); + m_camera->setTarget(xyz); + xyz.Y = xyz.Y+30; + m_camera->setPosition(xyz); +#endif +} // smoothMoveCamera + +//----------------------------------------------------------------------------- +/** Computes the wanted camera position and target for normal camera mode. + * Besides being used in update(dt), it is also used when switching the + * camera from reverse mode to normal mode - in which case we don't want + * to have a smooth camera. + * \param wanted_position The position the camera should be. + * \param wanted_target The target position the camera should target. + */ +void Camera::computeNormalCameraPosition(Vec3 *wanted_position, + Vec3 *wanted_target) +{ + *wanted_target = m_kart->getXYZ(); + wanted_target->setZ(wanted_target->getZ()+ 0.75f); + // This first line moves the camera around behind the kart, pointing it + // towards where the kart is turning (and turning even more while skidding). + float steering = m_kart->getSteerPercent() * (1.0f + (m_kart->getSkidding() - 1.0f)/2.3f ); // dampen skidding effect + float dampened_steer = fabsf(steering) * steering; // quadratically to dampen small variations (but keep sign) + float angle_around = m_kart->getHPR().getX() + m_rotation_range * dampened_steer * 0.5f; + float angle_up = m_kart->getHPR().getY() - 30.0f*DEGREE_TO_RAD; + wanted_position->setX( sin(angle_around)); + wanted_position->setY(-cos(angle_around)); + wanted_position->setZ(-sin(angle_up) ); + *wanted_position *= m_distance; + *wanted_position += *wanted_target; +} // computeNormalCameraPosition + +//----------------------------------------------------------------------------- +/** Called once per time frame to move the camera to the right position. + * \param dt Time step. + */ void Camera::update(float dt) { - const Track* track=RaceManager::getTrack(); - float steering; - float dampened_steer; + printf("cam: %f %f %f\n", + m_camera->getRotation().X, + m_camera->getRotation().Y, + m_camera->getRotation().Z); - // Each case should set m_target and m_position according to what is needed for that mode. - // Yes, there is a lot of duplicate code but it is (IMHO) much easier to follow this way. + Vec3 wanted_position; + Vec3 wanted_target = m_kart->getXYZ(); + + // Each case should set wanted_position and wanted_target according to + // what is needed for that mode. Yes, there is a lot of duplicate code + // but it is (IMHO) much easier to follow this way. switch(m_mode) { case CM_NORMAL: - // This first line moves the camera around behind the kart, pointing it - // towards where the kart is turning (and turning even more while skidding). - steering = m_kart->getSteerPercent() * (1.0f + (m_kart->getSkidding() - 1.0f)/2.3f ); // dampen skidding effect - dampened_steer = fabsf(steering) * steering; // quadratically to dampen small variations (but keep sign) - m_angle_around = m_kart->getHPR().getX() + m_rotation_range * dampened_steer * 0.5f; - m_angle_up = m_kart->getHPR().getY() - 30.0f*DEGREE_TO_RAD; - - m_target = m_kart->getXYZ(); - m_target.setZ(m_target.getZ()+0.75f); - - m_position.setX( sin(m_angle_around)); - m_position.setY(-cos(m_angle_around)); - m_position.setZ(-sin(m_angle_up)); - m_position *= m_distance; - m_position += m_target; - - break; + { + computeNormalCameraPosition(&wanted_position, &wanted_target); + smoothMoveCamera(dt, wanted_position, wanted_target); + break; + } case CM_REVERSE: // Same as CM_NORMAL except it looks backwards - m_angle_around = m_kart->getHPR().getX() - m_rotation_range * m_kart->getSteerPercent() * m_kart->getSkidding(); - m_angle_up = m_kart->getHPR().getY() + 30.0f*DEGREE_TO_RAD; - - m_target = m_kart->getXYZ(); - m_target.setZ(m_target.getZ()+0.75f); - - m_position.setX(-sin(m_angle_around)); - m_position.setY( cos(m_angle_around)); - m_position.setZ( sin(m_angle_up)); - m_position *= m_distance * 2.0f; - m_position += m_target; - - break; + { + wanted_target.setZ(wanted_target.getZ()+ 0.75f); + float angle_around = m_kart->getHPR().getX() - m_rotation_range * m_kart->getSteerPercent() * m_kart->getSkidding(); + float angle_up = m_kart->getHPR().getY() + 30.0f*DEGREE_TO_RAD; + wanted_position.setX(-sin(angle_around)); + wanted_position.setY( cos(angle_around)); + wanted_position.setZ( sin(angle_up) ); + wanted_position *= m_distance * 2.0f; + wanted_position += wanted_target; + smoothMoveCamera(dt, wanted_position, wanted_target); + m_camera->setPosition(wanted_position.toIrrVector()); + m_camera->setTarget(wanted_target.toIrrVector()); + break; + } case CM_CLOSEUP: // Lower to the ground and closer to the kart - m_angle_around = m_kart->getHPR().getX() + m_rotation_range * m_kart->getSteerPercent() * m_kart->getSkidding(); - m_angle_up = m_kart->getHPR().getY() - 20.0f*DEGREE_TO_RAD; - - m_target = m_kart->getXYZ(); - m_target.setZ(m_target.getZ()+0.75f); - - m_position.setX( sin(m_angle_around)); - m_position.setY(-cos(m_angle_around)); - m_position.setZ(-sin(m_angle_up)); - m_position *= m_distance * 0.5f; - m_position += m_target; - - break; - case CM_LEADER_MODE: // Follows the leader kart, higher off of the ground, further from the kart, - // and turns in the opposite direction from the kart for a nice effect. :) - m_angle_around = RaceManager::getKart(0)->getHPR().getX(); - m_angle_up = RaceManager::getKart(0)->getHPR().getY() + 40.0f*DEGREE_TO_RAD; - - m_target = RaceManager::getKart(0)->getXYZ(); - - m_position.setX(sin(m_angle_around)); - m_position.setY(cos(m_angle_around)); - m_position.setZ(sin(m_angle_up)); - m_position *= m_distance * 2.0f; - m_position += m_target; - - break; + { + wanted_target.setZ(wanted_target.getZ()+0.75f); + float angle_around = m_kart->getHPR().getX() + m_rotation_range * m_kart->getSteerPercent() * m_kart->getSkidding(); + float angle_up = m_kart->getHPR().getY() - 20.0f*DEGREE_TO_RAD; + wanted_position.setX( sin(angle_around)); + wanted_position.setY(-cos(angle_around)); + wanted_position.setZ(-sin(angle_up) ); + wanted_position *= m_distance * 0.5f; + wanted_position += wanted_target; + smoothMoveCamera(dt, wanted_position, wanted_target); + break; + } + case CM_LEADER_MODE: + { + wanted_target = RaceManager::getKart(0)->getXYZ().toIrrVector(); + // Follows the leader kart, higher off of the ground, further from the kart, + // and turns in the opposite direction from the kart for a nice effect. :) + float angle_around = RaceManager::getKart(0)->getHPR().getX(); + float angle_up = RaceManager::getKart(0)->getHPR().getY() + 40.0f*DEGREE_TO_RAD; + wanted_position.setX(sin(angle_around)); + wanted_position.setY(cos(angle_around)); + wanted_position.setZ(sin(angle_up) ); + wanted_position *= m_distance * 2.0f; + wanted_position += wanted_target; + smoothMoveCamera(dt, wanted_position, wanted_target); + break; + } case CM_FINAL: - if(!track->hasFinalCamera()) { - m_mode = CM_NORMAL; + m_final_time +=dt; + if(m_final_time < stk_config->m_final_camera_time) + { + const Track* track=RaceManager::getTrack(); + core::vector3df new_pos = m_camera->getPosition()+m_lin_velocity*dt; + m_camera->setPosition(new_pos); + core::vector3df new_target = m_camera->getTarget()+m_target_velocity*dt; + m_camera->setTarget(new_target); + } + return; break; } - m_position = track->getCameraPosition(); - m_target.setX(-sin( track->getCameraHPR().getX() ) ); - m_target.setY( cos( track->getCameraHPR().getX() ) ); - m_target.setZ( sin( track->getCameraHPR().getY() ) ); - m_target *= 10.0f; - m_target += m_position; - break; case CM_SIMPLE_REPLAY: // TODO: Implement break; } - // Smoothly interpolate towards the position and target - m_temp_target += ((m_target - m_temp_target) * m_target_speed) * dt; - m_temp_position += ((m_position - m_temp_position) * m_position_speed) * dt; - - m_camera->setPosition(m_temp_position.toIrrVector()); - m_camera->setTarget(m_temp_target.toIrrVector()); - // The following settings give a debug camera which shows the track from - // high above the kart straight down. -#undef DEBUG_CAMERA -#ifdef DEBUG_CAMERA - core::vector3df xyz = RaceManager::getKart(0)->getXYZ().toIrrVector(); - m_camera->setTarget(xyz); - xyz.Y = xyz.Y+30; - m_camera->setPosition(xyz); -#endif - - if(race_manager->getNumLocalPlayers() < 2) - sound_manager->positionListener(m_temp_position, m_temp_target - m_temp_position); - } // update // ---------------------------------------------------------------------------- Modified: main/trunk/src/graphics/camera.hpp =================================================================== --- main/trunk/src/graphics/camera.hpp 2009-12-16 04:04:52 UTC (rev 4305) +++ main/trunk/src/graphics/camera.hpp 2009-12-16 21:37:33 UTC (rev 4306) @@ -51,35 +51,16 @@ * attached to. */ unsigned int m_index; - /** The ultimate position which the camera wants to obtain. */ - Vec3 m_position; - - /** The position the camera currently has. */ - Vec3 m_temp_position; - - /** The ultimate target which the camera wants to obtain. */ - Vec3 m_target; - - /** The target the camera currently has. */ - Vec3 m_temp_target; - /** Current ambient light for this camera. */ video::SColor m_ambient_light; /** Distance between the camera and the kart. */ float m_distance; - /** Angle between the ground and the camera (with the kart as the - * vertex of the angle). */ - float m_angle_up; - - /** Angle around the kart (should actually match the rotation of the kart). */ - float m_angle_around; - /** The speed at which the camera changes position. */ float m_position_speed; - /** The speed at which the camera changes targets. */ + /** The speed at which the camera target changes position. */ float m_target_speed; /** Factor of the effects of steering in camera aim. */ @@ -100,8 +81,21 @@ /** Aspect ratio for camera. */ float m_aspect; - void setupCamera(); + /** Linear velocity of the camera, only used for end camera. */ + core::vector3df m_lin_velocity; + /** Velocity of the target of the camera, only used for end camera. */ + core::vector3df m_target_velocity; + + /** Counts the time for the end camera only, to indicate when + * the end camera should stop moving. */ + float m_final_time; + + void setupCamera(); + void smoothMoveCamera(float dt, const Vec3 &wanted_position, + const Vec3 &wanted_target); + void computeNormalCameraPosition(Vec3 *wanted_position, + Vec3 *wanted_target); public: Camera (int camera_index, const Kart* kart); ~Camera (); Modified: main/trunk/src/karts/player_kart.cpp =================================================================== --- main/trunk/src/karts/player_kart.cpp 2009-12-16 04:04:52 UTC (rev 4305) +++ main/trunk/src/karts/player_kart.cpp 2009-12-16 21:37:33 UTC (rev 4306) @@ -278,10 +278,10 @@ if (m_powerup.getType()==POWERUP_NOTHING) Kart::beep(); } + if(m_camera->getMode()!=Camera::CM_FINAL) + m_camera->setMode(m_controls.m_look_back ? Camera::CM_REVERSE + : Camera::CM_NORMAL); - m_camera->setMode(m_controls.m_look_back ? Camera::CM_REVERSE - : Camera::CM_NORMAL); - // We can't restrict rescue to fulfil isOnGround() (which would be more like // MK), since e.g. in the City track it is possible for the kart to end // up sitting on a brick wall, with all wheels in the air :(( Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2009-12-16 04:04:52 UTC (rev 4305) +++ main/trunk/src/tracks/track.cpp 2009-12-16 21:37:33 UTC (rev 4306) @@ -237,14 +237,6 @@ if(m_groups.size()==0) m_groups.push_back("standard"); - // if both camera position and rotation are defined, - // set the flag that the track has final camera position - m_has_final_camera = root->get("camera-final-position", - &m_camera_final_position)!=1; - m_has_final_camera &= root->get("camera-final-hpr", - &m_camera_final_hpr) !=1; - m_camera_final_hpr.degreeToRad(); - const XMLNode *xml_node = root->getNode("curves"); if(xml_node) loadCurves(*xml_node); @@ -614,9 +606,13 @@ * animations, items, ... It is called from world during initialisation. * Track is the first model to be loaded, so at this stage the root scene node * is empty. + * \param mode_id Which of the modes of a track to use. This determines which + * scene, quad, and graph file to load. */ void Track::loadTrackModel(unsigned int mode_id) { + m_has_final_camera = false; + m_is_arena = false; item_manager->setStyle(); // Load the graph only now: this function is called from world, after @@ -740,6 +736,10 @@ { handleSky(*node, path); } + else if (name=="camera") + { + handleCamera(*node); + } else { fprintf(stderr, "Warning: element '%s' not found.\n", @@ -862,8 +862,26 @@ } // handleSky //----------------------------------------------------------------------------- +/** Reads the final camera position. + * \param root The XML node with the camera node. + */ +void Track::handleCamera(const XMLNode &root) +{ + m_has_final_camera = true; + root.get("final-position", &m_camera_final_position); + root.get("final-hpr", &m_camera_final_hpr ); + m_camera_final_hpr.degreeToRad(); +} // handleCamera + +//----------------------------------------------------------------------------- +/** Handle creation and placement of an item. + * \param xyz The position of the item. + * \param type The item type. + * \param need_height True if the item Z position should be determined based on + * the track topology. + */ void Track::itemCommand(const Vec3 &xyz, Item::ItemType type, - int bNeedHeight) + int need_height) { // Some modes (e.g. time trial) don't have any bonus boxes if(type==Item::ITEM_BONUS_BOX && @@ -872,7 +890,7 @@ Vec3 loc(xyz); // if only 2d coordinates are given, let the item fall from very high - if(bNeedHeight) + if(need_height) { loc.setZ(1000); loc.setZ(getTerrainHeight(loc)); Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2009-12-16 04:04:52 UTC (rev 4305) +++ main/trunk/src/tracks/track.hpp 2009-12-16 21:37:33 UTC (rev 4306) @@ -73,14 +73,20 @@ scene::ILightSceneNode *m_sun; TriangleMesh* m_track_mesh; TriangleMesh* m_non_collision_mesh; + /** True if the track/scene has a final camera position. */ bool m_has_final_camera; + /** The final xyz coordinates of the camera. */ Vec3 m_camera_final_position; + /** The final hpr rotation of the camera. */ Vec3 m_camera_final_hpr; /** Minimum coordinates of this track. */ Vec3 m_aabb_min; /** Maximum coordinates of this track. */ Vec3 m_aabb_max; + /** True if this track is an arena. */ bool m_is_arena; + /** The version of this track. A certain STK version will only support + * certain track versions. */ int m_version; /** The graph used to connect the quads. */ @@ -166,6 +172,7 @@ void loadCurves(const XMLNode &node); void handleAnimatedTextures(scene::ISceneNode *node, const XMLNode &xml); void handleSky(const XMLNode &root, const std::string &filename); + void handleCamera(const XMLNode &root); public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-17 21:36:52
|
Revision: 4313 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4313&view=rev Author: auria Date: 2009-12-17 21:36:45 +0000 (Thu, 17 Dec 2009) Log Message: ----------- Use new badging facility to show the green check on selected karts, simplifying code and fixing bugs Modified Paths: -------------- main/trunk/src/guiengine/skin.cpp main/trunk/src/guiengine/skin.hpp main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp main/trunk/src/guiengine/widgets/model_view_widget.cpp main/trunk/src/guiengine/widgets/model_view_widget.hpp main/trunk/src/states_screens/kart_selection.cpp Modified: main/trunk/src/guiengine/skin.cpp =================================================================== --- main/trunk/src/guiengine/skin.cpp 2009-12-17 03:21:41 UTC (rev 4312) +++ main/trunk/src/guiengine/skin.cpp 2009-12-17 21:36:45 UTC (rev 4313) @@ -1101,7 +1101,7 @@ { drawSpinnerChild(rect, widget, pressed, focused); } - else if (type == WTYPE_ICON_BUTTON) + else if (type == WTYPE_ICON_BUTTON || type == WTYPE_MODEL_VIEW) { drawIconButton(rect, widget, pressed, focused); } @@ -1121,6 +1121,7 @@ { drawCheckBox(rect, widget, focused); } + if (ID_DEBUG && id != -1) { @@ -1132,29 +1133,45 @@ if (widget->m_lock_badge || widget->m_okay_badge) { - // TODO - video::ITexture* texture = NULL; - - if (widget->m_lock_badge) texture = irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png")); - else if (widget->m_okay_badge) texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png")); - else { assert(false); return; } - const core::dimension2d<u32>& texture_size = texture->getSize(); - const float aspectRatio = (float)texture_size.Width / (float)texture_size.Height; - const int h = std::min( rect.getHeight()/2 , (int)(texture_size.Height) ); - int w = (int)(aspectRatio*h); - - const core::rect<s32> source_area = core::rect<s32>(0, 0, texture_size.Width, texture_size.Height); - - const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X, - rect.LowerRightCorner.Y - h, - rect.UpperLeftCorner.X + w, - rect.LowerRightCorner.Y); - - GUIEngine::getDriver()->draw2DImage(texture, rect2, source_area, - 0 /* no clipping */, 0, true /* alpha */); + drawBadgeOn(widget, rect); } } +void Skin::drawBadgeOn(const Widget* widget, const core::rect<s32>& rect) +{ + video::ITexture* texture = NULL; + float max_icon_size = 0.35f; + + if (widget->m_lock_badge) + { + texture = irr_driver->getTexture(file_manager->getTextureFile("gui_lock.png")); + max_icon_size = 0.5f; // Lock badge can be quite big + } + else if (widget->m_okay_badge) + { + texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png")); + } + else + { + assert(false); + return; + } + const core::dimension2d<u32>& texture_size = texture->getSize(); + const float aspectRatio = (float)texture_size.Width / (float)texture_size.Height; + const int h = std::min( (int)(rect.getHeight()*max_icon_size), (int)(texture_size.Height) ); + int w = (int)(aspectRatio*h); + + const core::rect<s32> source_area = core::rect<s32>(0, 0, texture_size.Width, texture_size.Height); + + const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X, + rect.LowerRightCorner.Y - h, + rect.UpperLeftCorner.X + w, + rect.LowerRightCorner.Y); + + GUIEngine::getDriver()->draw2DImage(texture, rect2, source_area, + 0 /* no clipping */, 0, true /* alpha */); +} + void Skin::draw3DButtonPanePressed (IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip) { process3DPane(element, rect, true /* pressed */ ); Modified: main/trunk/src/guiengine/skin.hpp =================================================================== --- main/trunk/src/guiengine/skin.hpp 2009-12-17 03:21:41 UTC (rev 4312) +++ main/trunk/src/guiengine/skin.hpp 2009-12-17 21:36:45 UTC (rev 4313) @@ -243,7 +243,8 @@ void renderSections(ptr_vector<Widget>* within_vector=NULL); void drawBgImage(); void drawBGFadeColor(); - + void drawBadgeOn(const Widget* widget, const irr::core::rect<irr::s32>& rect); + // irrlicht's callbacks virtual void draw2DRectangle (irr::gui::IGUIElement *element, const irr::video::SColor &color, const irr::core::rect< irr::s32 > &pos, const irr::core::rect< irr::s32 > *clip); virtual void draw3DButtonPanePressed (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2009-12-17 03:21:41 UTC (rev 4312) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2009-12-17 21:36:45 UTC (rev 4313) @@ -584,7 +584,7 @@ icon->m_text = m_items[icon_id].m_user_name; icon->m_lock_badge = m_items[icon_id].m_locked; - 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); Modified: main/trunk/src/guiengine/widgets/model_view_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/model_view_widget.cpp 2009-12-17 03:21:41 UTC (rev 4312) +++ main/trunk/src/guiengine/widgets/model_view_widget.cpp 2009-12-17 21:36:45 UTC (rev 4313) @@ -22,11 +22,14 @@ using namespace irr::core; using namespace irr::gui; -ModelViewWidget::ModelViewWidget() +ModelViewWidget::ModelViewWidget() : IconButtonWidget(false, false) { m_type = WTYPE_MODEL_VIEW; m_rtt_provider = NULL; m_rotation_mode = ROTATE_OFF; + + // so that the base class doesn't complain there is no icon defined + m_properties[PROP_ICON]="gui/main_help.png"; } // ----------------------------------------------------------------------------- ModelViewWidget::~ModelViewWidget() @@ -39,17 +42,11 @@ // ----------------------------------------------------------------------------- void ModelViewWidget::add() { - rect<s32> widget_size = rect<s32>(x, y, x + w, y + h); - //stringw& message = m_text; + // so that the base class doesn't complain there is no icon defined + m_properties[PROP_ICON]="gui/main_help.png"; - IGUIImage* btn = GUIEngine::getGUIEnv()->addImage(widget_size, m_parent, getNewNoFocusID()); - m_element = btn; - btn->setUseAlphaChannel(true); - btn->setTabStop(false); - btn->setScaleImage(true); - - //m_element = GUIEngine::getGUIEnv()->addMeshViewer(widget_size, NULL, ++id_counter_2); - + IconButtonWidget::add(); + /* TODO: remove this unclean thing, I think irrlicht provides this feature: virtual void IGUIElement::OnPostRender (u32 timeMs) @@ -59,10 +56,6 @@ angle = 0; - id = m_element->getID(); - //m_element->setTabOrder(id); - m_element->setTabGroup(false); - m_element->setTabStop(false); } // add // ----------------------------------------------------------------------------- @@ -149,7 +142,9 @@ } m_texture = m_rtt_provider->renderToTexture(angle); - ((IGUIImage*)m_element)->setImage(m_texture); + setImage(m_texture); + //getIrrlichtElement<IGUIButton>()->setImage(m_texture); + //getIrrlichtElement<IGUIButton>()->setPressedImage(m_texture); } Modified: main/trunk/src/guiengine/widgets/model_view_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/model_view_widget.hpp 2009-12-17 03:21:41 UTC (rev 4312) +++ main/trunk/src/guiengine/widgets/model_view_widget.hpp 2009-12-17 21:36:45 UTC (rev 4313) @@ -23,13 +23,13 @@ #include <irrlicht.h> #include "graphics/irr_driver.hpp" -#include "guiengine/widget.hpp" +#include "guiengine/widgets/icon_button_widget.hpp" #include "utils/ptr_vector.hpp" namespace GUIEngine { /** A model view widget. See guiengine/engine.hpp for a detailed overview */ - class ModelViewWidget : public Widget + class ModelViewWidget : public IconButtonWidget { enum RotationMode { Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2009-12-17 03:21:41 UTC (rev 4312) +++ main/trunk/src/states_screens/kart_selection.cpp 2009-12-17 21:36:45 UTC (rev 4313) @@ -426,6 +426,8 @@ player_id_w *= 2; player_name_w = 0; + modelView->m_okay_badge = true; + /* irr::video::ITexture* texture = irr_driver->getTexture( file_manager->getTextureFile("green_check.png").c_str() ) ; const int check_size = 128; // TODO: reduce size on smaller resolutions? const int check_x = model_x + model_w - check_size; @@ -436,6 +438,7 @@ greenCheckWidget->setScaleImage(true); greenCheckWidget->setTabStop(false); greenCheckWidget->setUseAlphaChannel(true); + */ } /** \return Whether this player confirmed his kart and indent selection */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-17 22:06:33
|
Revision: 4315 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4315&view=rev Author: auria Date: 2009-12-17 22:06:23 +0000 (Thu, 17 Dec 2009) Log Message: ----------- Fixed one aspect ratio problem (when using child_width/height properties and DynamicRibbon) Modified Paths: -------------- main/trunk/src/guiengine/screen_loader.cpp main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp main/trunk/src/guiengine/widgets/icon_button_widget.cpp main/trunk/src/guiengine/widgets/icon_button_widget.hpp main/trunk/src/guiengine/widgets/model_view_widget.cpp main/trunk/src/guiengine/widgets/ribbon_widget.cpp main/trunk/src/states_screens/dialogs/track_info_dialog.cpp Modified: main/trunk/src/guiengine/screen_loader.cpp =================================================================== --- main/trunk/src/guiengine/screen_loader.cpp 2009-12-17 21:42:45 UTC (rev 4314) +++ main/trunk/src/guiengine/screen_loader.cpp 2009-12-17 22:06:23 UTC (rev 4315) @@ -109,7 +109,8 @@ } else if (!strcmp("icon", xml->getNodeName())) { - append_to.push_back(new IconButtonWidget(false, false)); + append_to.push_back(new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_ASPECT_RATIO, + false, false)); } else if (!strcmp("checkbox", xml->getNodeName())) { Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2009-12-17 21:42:45 UTC (rev 4314) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2009-12-17 22:06:23 UTC (rev 4315) @@ -214,13 +214,17 @@ // add columns for (int i=0; i<m_col_amount; i++) { - IconButtonWidget* icon = new IconButtonWidget(false, true); + // stretch the *texture* within the widget (and the widget has the right aspect ratio) + // (Yeah, that's complicated, but screenshots are saved compressed horizontally so it's hard to be clean) + IconButtonWidget* icon = new IconButtonWidget(IconButtonWidget::SCALE_MODE_STRETCH, false, true); icon->m_properties[PROP_ICON]="gui/main_help.png"; // set size to get proper ratio (as most textures are saved scaled down to 256x256) icon->m_properties[PROP_WIDTH] = m_properties[PROP_CHILD_WIDTH]; icon->m_properties[PROP_HEIGHT] = m_properties[PROP_CHILD_HEIGHT]; - + icon->w = atoi(icon->m_properties[PROP_WIDTH].c_str()); + icon->h = atoi(icon->m_properties[PROP_HEIGHT].c_str()); + if (m_text == "all") icon->m_text = " "; // FIXME: what's that?? // std::cout << "ribbon text = " << m_properties[PROP_TEXT].c_str() << std::endl; Modified: main/trunk/src/guiengine/widgets/icon_button_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2009-12-17 21:42:45 UTC (rev 4314) +++ main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2009-12-17 22:06:23 UTC (rev 4315) @@ -24,13 +24,14 @@ using namespace irr::gui; // ----------------------------------------------------------------------------- -IconButtonWidget::IconButtonWidget(const bool tab_stop, const bool focusable) +IconButtonWidget::IconButtonWidget(ScaleMode scale_mode, const bool tab_stop, const bool focusable) { m_tab_stop = tab_stop; m_label = NULL; m_type = WTYPE_ICON_BUTTON; m_texture = NULL; m_focusable = focusable; + m_scale_mode = scale_mode; } // ----------------------------------------------------------------------------- void IconButtonWidget::add() @@ -43,8 +44,13 @@ // irrlicht widgets don't support scaling while keeping aspect ratio // so, happily, let's implement it ourselves - const int x_gap = (int)((float)w - (float)m_texture_w * (float)h / m_texture_h); + int x_gap = 0; + if (m_scale_mode == SCALE_MODE_KEEP_ASPECT_RATIO) + { + x_gap = (int)((float)w - (float)m_texture_w * (float)h / m_texture_h); + } + rect<s32> widget_size = rect<s32>(x + x_gap/2, y, x + w - x_gap/2, y + h); //std::cout << "Creating a IGUIButton " << widget_size.UpperLeftCorner.X << ", " << widget_size.UpperLeftCorner.Y << //" : " << widget_size.getWidth() << "x" << widget_size.getHeight() << std::endl; Modified: main/trunk/src/guiengine/widgets/icon_button_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/icon_button_widget.hpp 2009-12-17 21:42:45 UTC (rev 4314) +++ main/trunk/src/guiengine/widgets/icon_button_widget.hpp 2009-12-17 22:06:23 UTC (rev 4315) @@ -31,16 +31,29 @@ See guiengine/engine.hpp for a detailed overview */ class IconButtonWidget : public Widget { + public: + enum ScaleMode + { + SCALE_MODE_STRETCH, + SCALE_MODE_KEEP_ASPECT_RATIO + }; + + protected: friend class Skin; irr::gui::IGUIStaticText* m_label; irr::video::ITexture* m_texture; int m_texture_w, m_texture_h; + + ScaleMode m_scale_mode; public: + + + /** Whether to make the widget included in keyboard navigation order when adding */ bool m_tab_stop; - IconButtonWidget(const bool tab_stop=true, const bool focusable=true); + IconButtonWidget(ScaleMode scale_mode=SCALE_MODE_KEEP_ASPECT_RATIO, const bool tab_stop=true, const bool focusable=true); virtual ~IconButtonWidget() {} /** Callback called when this widget needs to be added (see base class Widget) */ Modified: main/trunk/src/guiengine/widgets/model_view_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/model_view_widget.cpp 2009-12-17 21:42:45 UTC (rev 4314) +++ main/trunk/src/guiengine/widgets/model_view_widget.cpp 2009-12-17 22:06:23 UTC (rev 4315) @@ -22,7 +22,7 @@ using namespace irr::core; using namespace irr::gui; -ModelViewWidget::ModelViewWidget() : IconButtonWidget(false, false) +ModelViewWidget::ModelViewWidget() : IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_ASPECT_RATIO, false, false) { m_type = WTYPE_MODEL_VIEW; m_rtt_provider = NULL; Modified: main/trunk/src/guiengine/widgets/ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2009-12-17 21:42:45 UTC (rev 4314) +++ main/trunk/src/guiengine/widgets/ribbon_widget.cpp 2009-12-17 22:06:23 UTC (rev 4315) @@ -158,13 +158,13 @@ const int needed_space_under_button = has_label ? 30 : 10; // quite arbitrary for now // For now, the image stretches to keep the aspect ratio of the widget (FIXME, doesn't work) - //float imageRatio = (float)m_children[i].w/(float)m_children[i].h; + float imageRatio = (float)m_children[i].w/(float)m_children[i].h; // size of the image video::ITexture* image = GUIEngine::getDriver()->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str()); float image_h = (float)image->getSize().Height; - float image_w = (float)image->getSize().Width; - //float image_w = image_h*imageRatio; + //float image_w = (float)image->getSize().Width; + float image_w = image_h*imageRatio; // if button too high to fit, scale down float zoom = global_zoom; @@ -174,19 +174,30 @@ //rect<s32> subsize = rect<s32>(widget_x - (int)(image_w/2.0f), button_y, // widget_x + (int)(image_w/2.0f), button_y + (int)(m_children[i].h*zoom)); + // backup and restore position in case the same object is added multiple times (FIXME: unclean) + int old_x = m_children[i].x; + int old_y = m_children[i].y; + int old_w = m_children[i].w; + int old_h = m_children[i].h; + m_children[i].x = widget_x - (int)(image_w*zoom/2.0f); m_children[i].y = button_y; m_children[i].w = (int)(image_w*zoom); m_children[i].h = (int)(image_h*zoom); + //std::wcout << L"Widget has text '" << m_children[i].m_text.c_str() << "'\n"; - - + m_children.get(i)->m_parent = btn; m_children.get(i)->add(); //subbtn->setUseAlphaChannel(true); //subbtn->setImage( GUIEngine::getDriver()->getTexture((file_manager->getDataDir() + "/" + m_children[i].m_properties[PROP_ICON]).c_str()) ); + m_children[i].x = old_x; + m_children[i].y = old_y; + m_children[i].w = old_w; + m_children[i].h = old_h; + // ---- label part /* if (has_label) Modified: main/trunk/src/states_screens/dialogs/track_info_dialog.cpp =================================================================== --- main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-17 21:42:45 UTC (rev 4314) +++ main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-17 22:06:23 UTC (rev 4315) @@ -187,7 +187,9 @@ // ---- Track screenshot - IconButtonWidget* screenshotWidget = new IconButtonWidget(false, false); + // stretch the *texture* within the widget (and the widget has the right aspect ratio) + // (Yeah, that's complicated, but screenshots are saved compressed horizontally so it's hard to be clean) + IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_STRETCH, false, false); core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y2-10); screenshotWidget->x = area_right.UpperLeftCorner.X; screenshotWidget->y = area_right.UpperLeftCorner.Y; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mbj...@us...> - 2009-12-18 00:36:44
|
Revision: 4320 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4320&view=rev Author: mbjornstk Date: 2009-12-18 00:36:35 +0000 (Fri, 18 Dec 2009) Log Message: ----------- Run expand -t4 to convert tabs to spaces. No other whitespace fixes, but there are still trailing spaces and lines with 5 spaces as indent (fix them as the files are changed for other reasons). src/guiengine/CGUIFont.* and src/bullet/ not processed to allow cleaner updates from upstream. Modified Paths: -------------- main/trunk/src/animations/animation_base.cpp main/trunk/src/animations/animation_manager.cpp main/trunk/src/animations/billboard_animation.cpp main/trunk/src/audio/music_information.cpp main/trunk/src/audio/music_ogg.cpp main/trunk/src/audio/sfx_manager.cpp main/trunk/src/audio/sfx_manager.hpp main/trunk/src/audio/sfx_openal.cpp main/trunk/src/audio/sfx_openal.hpp main/trunk/src/audio/sound_manager.hpp main/trunk/src/graphics/irr_driver.cpp main/trunk/src/graphics/irr_driver.hpp main/trunk/src/graphics/material_manager.hpp main/trunk/src/guiengine/engine.cpp main/trunk/src/guiengine/modaldialog.cpp main/trunk/src/guiengine/skin.cpp main/trunk/src/guiengine/skin.hpp main/trunk/src/guiengine/widgets/label_widget.cpp main/trunk/src/input/device_manager.cpp main/trunk/src/input/input.cpp main/trunk/src/input/input.hpp main/trunk/src/input/input_manager.cpp main/trunk/src/input/input_manager.hpp main/trunk/src/io/xml_node.hpp main/trunk/src/items/bowling.cpp main/trunk/src/items/bowling.hpp main/trunk/src/items/cake.cpp main/trunk/src/items/flyable.cpp main/trunk/src/items/flyable.hpp main/trunk/src/items/item.cpp main/trunk/src/items/item.hpp main/trunk/src/items/powerup.cpp main/trunk/src/items/powerup.hpp main/trunk/src/karts/kart_properties.hpp main/trunk/src/karts/kart_properties_manager.cpp main/trunk/src/karts/kart_properties_manager.hpp main/trunk/src/lisp/lexer.cpp main/trunk/src/lisp/lexer.hpp main/trunk/src/lisp/parser.cpp main/trunk/src/lisp/writer.cpp main/trunk/src/main.cpp main/trunk/src/modes/follow_the_leader.cpp main/trunk/src/modes/world.cpp main/trunk/src/network/network_manager.cpp main/trunk/src/physics/btKart.cpp main/trunk/src/physics/btUprightConstraint.cpp main/trunk/src/race/highscore_manager.cpp main/trunk/src/replay/replay_recorder.cpp main/trunk/src/states_screens/feature_unlocked.cpp main/trunk/src/states_screens/main_menu_screen.cpp main/trunk/src/states_screens/options_screen_input.cpp main/trunk/src/states_screens/race_gui.cpp main/trunk/src/tracks/ambient_light_sphere.cpp main/trunk/src/tracks/bezier_curve.cpp main/trunk/src/tracks/check_line.cpp main/trunk/src/tracks/check_manager.cpp main/trunk/src/tracks/check_sphere.cpp Modified: main/trunk/src/animations/animation_base.cpp =================================================================== --- main/trunk/src/animations/animation_base.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/animations/animation_base.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -26,12 +26,12 @@ AnimationBase::AnimationBase(const XMLNode &node, float fps) { - for(unsigned int i=0; i<node.getNumNodes(); i++) - { - Ipo *ipo = new Ipo(*node.getNode(i), fps); - m_all_ipos.push_back(ipo); - } // for i<getNumNodes() - m_playing = true; + for(unsigned int i=0; i<node.getNumNodes(); i++) + { + Ipo *ipo = new Ipo(*node.getNode(i), fps); + m_all_ipos.push_back(ipo); + } // for i<getNumNodes() + m_playing = true; } // AnimationBase // ---------------------------------------------------------------------------- @@ -39,8 +39,8 @@ */ AnimationBase::~AnimationBase() { - std::vector<Ipo*>::iterator i; - for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++) + std::vector<Ipo*>::iterator i; + for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++) delete *i; m_all_ipos.clear(); } // ~AnimationBase @@ -52,13 +52,13 @@ * \param hpr Rotation of the object. */ void AnimationBase::setInitialTransform(const core::vector3df &xyz, - const core::vector3df &hpr) + const core::vector3df &hpr) { - std::vector<Ipo*>::iterator i; - for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++) - { - (*i)->setInitialTransform(xyz, hpr); - } // for i in m_all_ipos + std::vector<Ipo*>::iterator i; + for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++) + { + (*i)->setInitialTransform(xyz, hpr); + } // for i in m_all_ipos } // setTransform // ---------------------------------------------------------------------------- @@ -66,11 +66,11 @@ */ void AnimationBase::reset() { - std::vector<Ipo*>::iterator i; - for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++) - { - (*i)->reset(); - } // for i in m_all_ipos + std::vector<Ipo*>::iterator i; + for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++) + { + (*i)->reset(); + } // for i in m_all_ipos } // reset // ---------------------------------------------------------------------------- @@ -80,12 +80,12 @@ * \param hpr Rotation to be updated. */ void AnimationBase::update(float dt, core::vector3df *xyz, - core::vector3df *hpr) + core::vector3df *hpr) { - std::vector<Ipo*>::iterator i; - for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++) - { - (*i)->update(dt, xyz, hpr); - } // for i in m_all_ipos + std::vector<Ipo*>::iterator i; + for(i=m_all_ipos.begin(); i<m_all_ipos.end(); i++) + { + (*i)->update(dt, xyz, hpr); + } // for i in m_all_ipos } // float dt Modified: main/trunk/src/animations/animation_manager.cpp =================================================================== --- main/trunk/src/animations/animation_manager.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/animations/animation_manager.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -27,20 +27,20 @@ AnimationManager::AnimationManager(const Track &track, const XMLNode &node) { - for(unsigned int i=0; i<node.getNumNodes(); i++) - { - const XMLNode *anim_node = node.getNode(i); - std::string type = anim_node->getName(); - float fps=25; - anim_node->get("fps", &fps); - if(type=="anim_billboard") - m_all_animations.push_back(new BillboardAnimation(track, *anim_node, fps)); - else if(type=="animations-IPO") - m_all_animations.push_back(new ThreeDAnimation(track, *anim_node, fps)); - else - fprintf(stderr, "Unknown animation type '%s' - ignored.\n", - type.c_str()); - } // for i<node.getNumNodes + for(unsigned int i=0; i<node.getNumNodes(); i++) + { + const XMLNode *anim_node = node.getNode(i); + std::string type = anim_node->getName(); + float fps=25; + anim_node->get("fps", &fps); + if(type=="anim_billboard") + m_all_animations.push_back(new BillboardAnimation(track, *anim_node, fps)); + else if(type=="animations-IPO") + m_all_animations.push_back(new ThreeDAnimation(track, *anim_node, fps)); + else + fprintf(stderr, "Unknown animation type '%s' - ignored.\n", + type.c_str()); + } // for i<node.getNumNodes } // AnimationManager // ---------------------------------------------------------------------------- @@ -49,9 +49,9 @@ */ AnimationManager::~AnimationManager() { - std::vector<AnimationBase*>::iterator i; - for(i=m_all_animations.begin(); i!=m_all_animations.end(); i++) - delete *i; + std::vector<AnimationBase*>::iterator i; + for(i=m_all_animations.begin(); i!=m_all_animations.end(); i++) + delete *i; m_all_animations.clear(); } // ~AnimationManager @@ -60,9 +60,9 @@ */ void AnimationManager::reset() { - std::vector<AnimationBase*>::iterator i; - for(i=m_all_animations.begin(); i!=m_all_animations.end(); i++) - (*i)->reset(); + std::vector<AnimationBase*>::iterator i; + for(i=m_all_animations.begin(); i!=m_all_animations.end(); i++) + (*i)->reset(); } // reset // ---------------------------------------------------------------------------- @@ -71,7 +71,7 @@ */ void AnimationManager::update(float dt) { - std::vector<AnimationBase*>::iterator i; - for(i=m_all_animations.begin(); i!=m_all_animations.end(); i++) - (*i)->update(dt); + std::vector<AnimationBase*>::iterator i; + for(i=m_all_animations.begin(); i!=m_all_animations.end(); i++) + (*i)->update(dt); } // update Modified: main/trunk/src/animations/billboard_animation.cpp =================================================================== --- main/trunk/src/animations/billboard_animation.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/animations/billboard_animation.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -23,7 +23,7 @@ /** A 2d billboard animation. */ BillboardAnimation::BillboardAnimation(const Track &track_name, - const XMLNode &node, float fps) + const XMLNode &node, float fps) : AnimationBase(node, fps) { } // BillboardAnimation @@ -33,9 +33,9 @@ * \param dt Time since last call. */ void BillboardAnimation::update(float dt) { - // FIXME: not implemented yet. - core::vector3df xyz(0, 0, 0); - core::vector3df hpr(0, 0, 0); - AnimationBase::update(dt, &xyz, &hpr); + // FIXME: not implemented yet. + core::vector3df xyz(0, 0, 0); + core::vector3df hpr(0, 0, 0); + AnimationBase::update(dt, &xyz, &hpr); } // update Modified: main/trunk/src/audio/music_information.cpp =================================================================== --- main/trunk/src/audio/music_information.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/audio/music_information.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -132,7 +132,7 @@ { delete m_normal_music; m_normal_music=0; - fprintf(stderr, "WARNING: Unabled to load music %s, not supported or not found.\n", + fprintf(stderr, "WARNING: Unabled to load music %s, not supported or not found.\n", m_normal_filename.c_str()); return; } @@ -160,7 +160,7 @@ { delete m_fast_music; m_fast_music=0; - fprintf(stderr, "WARNING: Unabled to load fast music %s, not supported or not found.\n", + fprintf(stderr, "WARNING: Unabled to load fast music %s, not supported or not found.\n", m_fast_filename.c_str()); return; } Modified: main/trunk/src/audio/music_ogg.cpp =================================================================== --- main/trunk/src/audio/music_ogg.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/audio/music_ogg.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -43,7 +43,7 @@ MusicOggStream::~MusicOggStream() { if(stopMusic() == false) - fprintf(stderr, "WARNING: problems while stopping music.\n"); + fprintf(stderr, "WARNING: problems while stopping music.\n"); } // ~MusicOggStream //----------------------------------------------------------------------------- @@ -250,7 +250,7 @@ if(!active) { // no more data. Seek to beginning (causes the sound to loop) - ov_time_seek(&m_oggStream, 0); + ov_time_seek(&m_oggStream, 0); active = streamIntoBuffer(buffer);//now there really should be data //fprintf(stdout,"Music buffer under-run.\n"); } @@ -266,7 +266,7 @@ alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state); if (state != AL_PLAYING) { - fprintf(stderr,"WARNING: Music not playing when it should be. Source state: %d\n", state); + fprintf(stderr,"WARNING: Music not playing when it should be. Source state: %d\n", state); alGetSourcei(m_soundSource, AL_BUFFERS_PROCESSED, &processed); alSourcePlay(m_soundSource); } Modified: main/trunk/src/audio/sfx_manager.cpp =================================================================== --- main/trunk/src/audio/sfx_manager.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/audio/sfx_manager.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -122,8 +122,8 @@ loadSingleSfx(lisp, "ugh", SOUND_UGH ); loadSingleSfx(lisp, "skid", SOUND_SKID ); loadSingleSfx(lisp, "locked", SOUND_LOCKED ); - loadSingleSfx(lisp, "bowling_roll", SOUND_BOWLING_ROLL ); - loadSingleSfx(lisp, "bowling_strike",SOUND_BOWLING_STRIKE ); + loadSingleSfx(lisp, "bowling_roll", SOUND_BOWLING_ROLL ); + loadSingleSfx(lisp, "bowling_strike",SOUND_BOWLING_STRIKE ); loadSingleSfx(lisp, "winner", SOUND_WINNER ); loadSingleSfx(lisp, "crash", SOUND_CRASH ); loadSingleSfx(lisp, "grab", SOUND_GRAB ); Modified: main/trunk/src/audio/sfx_manager.hpp =================================================================== --- main/trunk/src/audio/sfx_manager.hpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/audio/sfx_manager.hpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -44,7 +44,7 @@ enum SFXType { SOUND_UGH, SOUND_SKID, SOUND_BOWLING_ROLL, SOUND_BOWLING_STRIKE, SOUND_WINNER, SOUND_CRASH, SOUND_GRAB, - SOUND_SHOT, SOUND_GOO, SOUND_WEE, SOUND_EXPLOSION, SOUND_BZZT, SOUND_BEEP, SOUND_BACK_MENU, SOUND_USE_ANVIL, + SOUND_SHOT, SOUND_GOO, SOUND_WEE, SOUND_EXPLOSION, SOUND_BZZT, SOUND_BEEP, SOUND_BACK_MENU, SOUND_USE_ANVIL, SOUND_USE_PARACHUTE, SOUND_SELECT_MENU, SOUND_MOVE_MENU, SOUND_FULL, SOUND_LOCKED, SOUND_PRESTART, SOUND_START, SOUND_ENGINE_SMALL, SOUND_ENGINE_LARGE, NUM_SOUNDS @@ -81,7 +81,7 @@ SFX_INITIAL = 3 }; -private: +private: /** The buffers for all sound effects. These are shared among all * instances of SFXOpenal. */ std::vector<ALuint> m_sfx_buffers; Modified: main/trunk/src/audio/sfx_openal.cpp =================================================================== --- main/trunk/src/audio/sfx_openal.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/audio/sfx_openal.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -174,7 +174,7 @@ { if(!sfx_manager->sfxAllowed()||!m_ok) return SFXManager::SFX_UNKNOWN; - int state = 0; + int state = 0; alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state); switch(state) { Modified: main/trunk/src/audio/sfx_openal.hpp =================================================================== --- main/trunk/src/audio/sfx_openal.hpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/audio/sfx_openal.hpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -49,7 +49,7 @@ virtual void position(const Vec3 &position); virtual void volume(float gain); virtual SFXManager::SFXStatus getStatus(); - + }; // SFXOpenAL #endif // HEADER_SFX_OPENAL_HPP Modified: main/trunk/src/audio/sound_manager.hpp =================================================================== --- main/trunk/src/audio/sound_manager.hpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/audio/sound_manager.hpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -35,7 +35,7 @@ class SoundManager { -private: +private: MusicInformation *m_current_music; /** If the sound could not be initialized, e.g. if the player doesn't has Modified: main/trunk/src/graphics/irr_driver.cpp =================================================================== --- main/trunk/src/graphics/irr_driver.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/graphics/irr_driver.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -586,7 +586,7 @@ GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; - /* light_position is NOT default value */ + /* light_position is NOT default value */ GLfloat light_position0[] = { 1.0, 1.0, 1.0, 0.0 }; GLfloat light_position1[] = { -1.0, -1.0, -1.0, 0.0 }; @@ -856,7 +856,7 @@ m_rtt_main_node->getMaterial(n).setFlag(EMF_GOURAUD_SHADING , true); } - m_camera = irr_driver->getSceneManager()->addCameraSceneNode(); + m_camera = irr_driver->getSceneManager()->addCameraSceneNode(); m_camera->setPosition( core::vector3df(0.0, 20.0f, 70.0f) ); m_camera->setUpVector( core::vector3df(0.0, 1.0, 0.0) ); Modified: main/trunk/src/graphics/irr_driver.hpp =================================================================== --- main/trunk/src/graphics/irr_driver.hpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/graphics/irr_driver.hpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -84,7 +84,7 @@ video::ITexture *getTexture(const std::string &filename); scene::IMesh *createQuadMesh(const video::SMaterial *material=NULL, bool create_one_quad=false); - scene::IMesh *createTexturedQuadMesh(const video::SMaterial *material, const double w, const double h); + scene::IMesh *createTexturedQuadMesh(const video::SMaterial *material, const double w, const double h); scene::ISceneNode *addWaterNode(scene::IMesh *mesh, float wave_height, float wave_speed, float wave_length); scene::ISceneNode *addOctTree(scene::IMesh *mesh); Modified: main/trunk/src/graphics/material_manager.hpp =================================================================== --- main/trunk/src/graphics/material_manager.hpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/graphics/material_manager.hpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -43,7 +43,7 @@ void reInit (); void setAllMaterialFlags(video::ITexture* t, scene::IMeshBuffer *mb) const; - void setAllUntexturedMaterialFlags(scene::IMeshBuffer *mb) const; + void setAllUntexturedMaterialFlags(scene::IMeshBuffer *mb) const; int addEntity (Material *m); Material *getMaterial (const std::string& t, bool is_full_path=false, bool make_permanent=false); Modified: main/trunk/src/guiengine/engine.cpp =================================================================== --- main/trunk/src/guiengine/engine.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/guiengine/engine.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -179,7 +179,7 @@ g_focus_for_player[n] = NULL; } - /* + /* To make the g_font a little bit nicer, we load an external g_font and set it as the new default g_font in the g_skin. To keep the standard g_font for tool tip text, we set it to @@ -187,7 +187,7 @@ */ g_skin = new Skin(g_env->getSkin()); g_env->setSkin(g_skin); - //g_skin = g_env->getSkin(); + //g_skin = g_env->getSkin(); // font size is resolution-dependent. // normal text will range from 0.8, in 640x* resolutions (won't scale below that) to @@ -204,14 +204,14 @@ g_font = sfont; ScalableFont* sfont2 = new ScalableFont(g_env, (file_manager->getGUIDir() + "/title_font.xml").c_str()); - sfont2->setScale(title_text_scale); + sfont2->setScale(title_text_scale); sfont2->setKerningWidth(-18); g_title_font = sfont2; - if (g_font != NULL) g_skin->setFont(g_font); + if (g_font != NULL) g_skin->setFont(g_font); - //g_skin->setFont(g_env->getBuiltInFont(), EGDF_TOOLTIP); + //g_skin->setFont(g_env->getBuiltInFont(), EGDF_TOOLTIP); // set event receiver g_device->setEventReceiver(EventHandler::get()); Modified: main/trunk/src/guiengine/modaldialog.cpp =================================================================== --- main/trunk/src/guiengine/modaldialog.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/guiengine/modaldialog.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -49,7 +49,7 @@ if (modalWindow != NULL) delete modalWindow; modalWindow = this; - m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow ( m_area, true /* modal */ ); + m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow ( m_area, true /* modal */ ); GUIEngine::getSkin()->m_dialog = true; GUIEngine::getSkin()->m_dialog_size = 0.0f; @@ -79,7 +79,7 @@ m_children.clearAndDeleteAll(); m_irrlicht_window->remove(); - m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow ( m_area, true /* modal */ ); + m_irrlicht_window = GUIEngine::getGUIEnv()->addWindow ( m_area, true /* modal */ ); /* const core::list<IGUIElement*>& remainingChildren = m_irrlicht_window->getChildren(); Modified: main/trunk/src/guiengine/skin.cpp =================================================================== --- main/trunk/src/guiengine/skin.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/guiengine/skin.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -946,16 +946,16 @@ sized_rect.UpperLeftCorner.Y = center.Y + (int)(((int)rect.UpperLeftCorner.Y - (int)center.Y)*texture_size); //std::cout << "y is " << center.Y << " + (" << rect.UpperLeftCorner.Y << " - " << center.Y << ")*" << texture_size << " = " - // << center.Y + (int)((rect.UpperLeftCorner.Y - center.Y)*texture_size) << std::endl; + // << center.Y + (int)((rect.UpperLeftCorner.Y - center.Y)*texture_size) << std::endl; sized_rect.LowerRightCorner.X = center.X + (int)(((int)rect.LowerRightCorner.X - (int)center.X)*texture_size); sized_rect.LowerRightCorner.Y = center.Y + (int)(((int)rect.LowerRightCorner.Y - (int)center.Y)*texture_size); /* std::cout << texture_size << " : " << rect.UpperLeftCorner.X << ", " << rect.UpperLeftCorner.Y << " : " << - rect.LowerRightCorner.X << ", " << rect.LowerRightCorner.Y << " ---> " << - sized_rect.UpperLeftCorner.X << ", " << sized_rect.UpperLeftCorner.Y << " : " << - sized_rect.LowerRightCorner.X << ", " << sized_rect.LowerRightCorner.Y << std::endl; + rect.LowerRightCorner.X << ", " << rect.LowerRightCorner.Y << " ---> " << + sized_rect.UpperLeftCorner.X << ", " << sized_rect.UpperLeftCorner.Y << " : " << + sized_rect.LowerRightCorner.X << ", " << sized_rect.LowerRightCorner.Y << std::endl; */ } @@ -1246,7 +1246,7 @@ } else { - GUIEngine::getDriver()->draw2DRectangle( color, rect ); + GUIEngine::getDriver()->draw2DRectangle( color, rect ); } } return; @@ -1294,7 +1294,7 @@ } else { - drawBoxFromStretchableTexture( ModalDialog::getCurrent(), rect, SkinConfig::m_render_params["window::neutral"]); + drawBoxFromStretchableTexture( ModalDialog::getCurrent(), rect, SkinConfig::m_render_params["window::neutral"]); } return rect; @@ -1327,27 +1327,27 @@ video::SColor Skin::getColor (EGUI_DEFAULT_COLOR color) const { /* - EGDC_3D_DARK_SHADOW Dark shadow for three-dimensional display elements. - EGDC_3D_SHADOW Shadow color for three-dimensional display elements (for edges facing away from the light source). - EGDC_3D_FACE Face color for three-dimensional display elements and for dialog box backgrounds. - EGDC_3D_HIGH_LIGHT Highlight color for three-dimensional display elements (for edges facing the light source.). - EGDC_3D_LIGHT Light color for three-dimensional display elements (for edges facing the light source.). - EGDC_ACTIVE_BORDER Active window border. - EGDC_ACTIVE_CAPTION Active window title bar text. - EGDC_APP_WORKSPACE Background color of multiple document interface (MDI) applications. - EGDC_BUTTON_TEXT Text on a button. - EGDC_GRAY_TEXT Grayed (disabled) text. - EGDC_HIGH_LIGHT Item(s) selected in a control. - EGDC_HIGH_LIGHT_TEXT Text of item(s) selected in a control. - EGDC_INACTIVE_BORDER Inactive window border. - EGDC_INACTIVE_CAPTION Inactive window caption. - EGDC_TOOLTIP Tool tip text color. - EGDC_TOOLTIP_BACKGROUND Tool tip background color. - EGDC_SCROLLBAR Scrollbar gray area. - EGDC_WINDOW Window background. - EGDC_WINDOW_SYMBOL Window symbols like on close buttons, scroll bars and check boxes. - EGDC_ICON Icons in a list or tree. - EGDC_ICON_HIGH_LIGHT Selected icons in a list or tree. + EGDC_3D_DARK_SHADOW Dark shadow for three-dimensional display elements. + EGDC_3D_SHADOW Shadow color for three-dimensional display elements (for edges facing away from the light source). + EGDC_3D_FACE Face color for three-dimensional display elements and for dialog box backgrounds. + EGDC_3D_HIGH_LIGHT Highlight color for three-dimensional display elements (for edges facing the light source.). + EGDC_3D_LIGHT Light color for three-dimensional display elements (for edges facing the light source.). + EGDC_ACTIVE_BORDER Active window border. + EGDC_ACTIVE_CAPTION Active window title bar text. + EGDC_APP_WORKSPACE Background color of multiple document interface (MDI) applications. + EGDC_BUTTON_TEXT Text on a button. + EGDC_GRAY_TEXT Grayed (disabled) text. + EGDC_HIGH_LIGHT Item(s) selected in a control. + EGDC_HIGH_LIGHT_TEXT Text of item(s) selected in a control. + EGDC_INACTIVE_BORDER Inactive window border. + EGDC_INACTIVE_CAPTION Inactive window caption. + EGDC_TOOLTIP Tool tip text color. + EGDC_TOOLTIP_BACKGROUND Tool tip background color. + EGDC_SCROLLBAR Scrollbar gray area. + EGDC_WINDOW Window background. + EGDC_WINDOW_SYMBOL Window symbols like on close buttons, scroll bars and check boxes. + EGDC_ICON Icons in a list or tree. + EGDC_ICON_HIGH_LIGHT Selected icons in a list or tree. */ switch(color) @@ -1368,7 +1368,7 @@ } -const wchar_t* Skin::getDefaultText (EGUI_DEFAULT_TEXT text) const +const wchar_t* Skin::getDefaultText (EGUI_DEFAULT_TEXT text) const { return L"SuperTuxKart"; } @@ -1395,7 +1395,7 @@ return m_fallback_skin->getSpriteBank(); } -//EGUI_SKIN_TYPE getType () const +//EGUI_SKIN_TYPE getType () const void Skin::setColor (EGUI_DEFAULT_COLOR which, video::SColor newColor) { Modified: main/trunk/src/guiengine/skin.hpp =================================================================== --- main/trunk/src/guiengine/skin.hpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/guiengine/skin.hpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -246,29 +246,29 @@ void drawBadgeOn(const Widget* widget, const irr::core::rect<irr::s32>& rect); // irrlicht's callbacks - virtual void draw2DRectangle (irr::gui::IGUIElement *element, const irr::video::SColor &color, const irr::core::rect< irr::s32 > &pos, const irr::core::rect< irr::s32 > *clip); - virtual void draw3DButtonPanePressed (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); - virtual void draw3DButtonPaneStandard (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); - virtual void draw3DMenuPane (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); - virtual void draw3DSunkenPane (irr::gui::IGUIElement *element, irr::video::SColor bgcolor, bool flat, bool fillBackGround, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); - virtual void draw3DTabBody (irr::gui::IGUIElement *element, bool border, bool background, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip, irr::s32 tabHeight=-1, irr::gui::EGUI_ALIGNMENT alignment=irr::gui::EGUIA_UPPERLEFT); - virtual void draw3DTabButton (irr::gui::IGUIElement *element, bool active, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip, irr::gui::EGUI_ALIGNMENT alignment=irr::gui::EGUIA_UPPERLEFT); - virtual void draw3DToolBar (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); - virtual irr::core::rect< irr::s32 > draw3DWindowBackground (irr::gui::IGUIElement *element, bool drawTitleBar, irr::video::SColor titleBarColor, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); - virtual void drawIcon (irr::gui::IGUIElement *element, irr::gui::EGUI_DEFAULT_ICON icon, const irr::core::position2di position, irr::u32 starttime, irr::u32 currenttime, bool loop=false, const irr::core::rect< irr::s32 > *clip=NULL); - virtual irr::video::SColor getColor (irr::gui::EGUI_DEFAULT_COLOR color) const; - virtual const wchar_t* getDefaultText (irr::gui::EGUI_DEFAULT_TEXT text) const; - virtual irr::gui::IGUIFont* getFont (irr::gui::EGUI_DEFAULT_FONT which=irr::gui::EGDF_DEFAULT) const ; - virtual irr::u32 getIcon (irr::gui::EGUI_DEFAULT_ICON icon) const ; - virtual irr::s32 getSize (irr::gui::EGUI_DEFAULT_SIZE size) const ; - virtual irr::gui::IGUISpriteBank * getSpriteBank () const ; - //virtual EGUI_SKIN_TYPE getType () const; - virtual void setColor (irr::gui::EGUI_DEFAULT_COLOR which, irr::video::SColor newColor); - virtual void setDefaultText (irr::gui::EGUI_DEFAULT_TEXT which, const wchar_t* newText); - virtual void setFont (irr::gui::IGUIFont *font, irr::gui::EGUI_DEFAULT_FONT which=irr::gui::EGDF_DEFAULT); - virtual void setIcon (irr::gui::EGUI_DEFAULT_ICON icon, irr::u32 index); - virtual void setSize (irr::gui::EGUI_DEFAULT_SIZE which, irr::s32 size); - virtual void setSpriteBank (irr::gui::IGUISpriteBank *bank); + virtual void draw2DRectangle (irr::gui::IGUIElement *element, const irr::video::SColor &color, const irr::core::rect< irr::s32 > &pos, const irr::core::rect< irr::s32 > *clip); + virtual void draw3DButtonPanePressed (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); + virtual void draw3DButtonPaneStandard (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); + virtual void draw3DMenuPane (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); + virtual void draw3DSunkenPane (irr::gui::IGUIElement *element, irr::video::SColor bgcolor, bool flat, bool fillBackGround, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); + virtual void draw3DTabBody (irr::gui::IGUIElement *element, bool border, bool background, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip, irr::s32 tabHeight=-1, irr::gui::EGUI_ALIGNMENT alignment=irr::gui::EGUIA_UPPERLEFT); + virtual void draw3DTabButton (irr::gui::IGUIElement *element, bool active, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip, irr::gui::EGUI_ALIGNMENT alignment=irr::gui::EGUIA_UPPERLEFT); + virtual void draw3DToolBar (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); + virtual irr::core::rect< irr::s32 > draw3DWindowBackground (irr::gui::IGUIElement *element, bool drawTitleBar, irr::video::SColor titleBarColor, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); + virtual void drawIcon (irr::gui::IGUIElement *element, irr::gui::EGUI_DEFAULT_ICON icon, const irr::core::position2di position, irr::u32 starttime, irr::u32 currenttime, bool loop=false, const irr::core::rect< irr::s32 > *clip=NULL); + virtual irr::video::SColor getColor (irr::gui::EGUI_DEFAULT_COLOR color) const; + virtual const wchar_t* getDefaultText (irr::gui::EGUI_DEFAULT_TEXT text) const; + virtual irr::gui::IGUIFont* getFont (irr::gui::EGUI_DEFAULT_FONT which=irr::gui::EGDF_DEFAULT) const ; + virtual irr::u32 getIcon (irr::gui::EGUI_DEFAULT_ICON icon) const ; + virtual irr::s32 getSize (irr::gui::EGUI_DEFAULT_SIZE size) const ; + virtual irr::gui::IGUISpriteBank * getSpriteBank () const ; + //virtual EGUI_SKIN_TYPE getType () const; + virtual void setColor (irr::gui::EGUI_DEFAULT_COLOR which, irr::video::SColor newColor); + virtual void setDefaultText (irr::gui::EGUI_DEFAULT_TEXT which, const wchar_t* newText); + virtual void setFont (irr::gui::IGUIFont *font, irr::gui::EGUI_DEFAULT_FONT which=irr::gui::EGDF_DEFAULT); + virtual void setIcon (irr::gui::EGUI_DEFAULT_ICON icon, irr::u32 index); + virtual void setSize (irr::gui::EGUI_DEFAULT_SIZE which, irr::s32 size); + virtual void setSpriteBank (irr::gui::IGUISpriteBank *bank); }; } Modified: main/trunk/src/guiengine/widgets/label_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/label_widget.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/guiengine/widgets/label_widget.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -48,7 +48,7 @@ irrwidget->setOverrideFont( GUIEngine::getTitleFont() ); } //irrwidget->setBackgroundColor( video::SColor(255,255,0,0) ); - //irrwidget->setDrawBackground(true); + //irrwidget->setDrawBackground(true); id = m_element->getID(); //m_element->setTabOrder(id); Modified: main/trunk/src/input/device_manager.cpp =================================================================== --- main/trunk/src/input/device_manager.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/input/device_manager.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -249,7 +249,7 @@ if (device != NULL && abs(value) > Input::MAX_VALUE/2) { //std::cout<< "========== Setting latest device " << (device->getType() == DT_KEYBOARD ? "keyboard" : "gamepad") - // << " #" << deviceID << " button=" << btnID << " value=" << value << " ==========\n"; + // << " #" << deviceID << " button=" << btnID << " value=" << value << " ==========\n"; m_latest_used_device = device; } Modified: main/trunk/src/input/input.cpp =================================================================== --- main/trunk/src/input/input.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/input/input.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -49,113 +49,113 @@ case KEY_RBUTTON : s = "right mouse button"; break; - case KEY_CANCEL : + case KEY_CANCEL : s = "cancel"; break; - case KEY_MBUTTON : + case KEY_MBUTTON : s = "middle mouse button"; break; - case KEY_XBUTTON1 : + case KEY_XBUTTON1 : s = "X1 mouse button"; break; - case KEY_XBUTTON2 : + case KEY_XBUTTON2 : s = "X2 mouse button"; break; - case KEY_BACK : + case KEY_BACK : s = "backspace"; break; - case KEY_TAB : + case KEY_TAB : s = "tab"; break; - case KEY_CLEAR : + case KEY_CLEAR : s = "clear"; break; - case KEY_RETURN : + case KEY_RETURN : s = "return"; break; case KEY_SHIFT : s = "shift"; break; - case KEY_CONTROL : + case KEY_CONTROL : s = "control"; break; - case KEY_MENU : + case KEY_MENU : s = "alt/menu"; break; case KEY_PAUSE : s = "pause"; break; - case KEY_CAPITAL : + case KEY_CAPITAL : s = "caps lock"; break; - case KEY_KANA : + case KEY_KANA : s = "kana"; break; - //case KEY_HANGUEL : + //case KEY_HANGUEL : //case KEY_HANGUL : // s = "hangul"; break; - case KEY_JUNJA : + case KEY_JUNJA : s = "junja"; break; - case KEY_FINAL : + case KEY_FINAL : s = "final"; break; - //case KEY_HANJA : + //case KEY_HANJA : // s = "hanja"; // break; - //case KEY_KANJI : + //case KEY_KANJI : // s = "kanji"; // break; - case KEY_ESCAPE : + case KEY_ESCAPE : s = "escape"; break; - case KEY_CONVERT : + case KEY_CONVERT : s = "convert"; break; - case KEY_NONCONVERT : + case KEY_NONCONVERT : s = "nonconvert"; break; - case KEY_ACCEPT : + case KEY_ACCEPT : s = "accept"; break; - case KEY_MODECHANGE : + case KEY_MODECHANGE : s = "modechange"; break; - case KEY_SPACE : + case KEY_SPACE : s = "space"; break; - case KEY_PRIOR : + case KEY_PRIOR : s = "page up"; break; - case KEY_NEXT : + case KEY_NEXT : s = "page down"; break; case KEY_END : s = "end"; break; - case KEY_HOME : + case KEY_HOME : s = "home"; break; - case KEY_LEFT : + case KEY_LEFT : s = "left"; break; - case KEY_UP : + case KEY_UP : s = "up"; break; case KEY_RIGHT : s = "right"; break; - case KEY_DOWN : + case KEY_DOWN : s = "down"; break; - case KEY_SELECT : + case KEY_SELECT : s = "select"; break; - case KEY_PRINT : + case KEY_PRINT : s = "print"; break; - case KEY_EXECUT : + case KEY_EXECUT : s = "exec"; break; case KEY_SNAPSHOT : @@ -164,142 +164,142 @@ case KEY_INSERT : s = "insert"; break; - case KEY_DELETE : + case KEY_DELETE : s = "delete"; break; - case KEY_HELP : + case KEY_HELP : s = "help"; break; - case KEY_KEY_0 : + case KEY_KEY_0 : s = "0"; break; - case KEY_KEY_1 : + case KEY_KEY_1 : s = "1"; break; case KEY_KEY_2 : s = "2"; break; - case KEY_KEY_3 : + case KEY_KEY_3 : s = "3"; break; case KEY_KEY_4 : s = "4"; break; - case KEY_KEY_5 : + case KEY_KEY_5 : s = "5"; break; - case KEY_KEY_6 : + case KEY_KEY_6 : s = "6"; break; - case KEY_KEY_7 : + case KEY_KEY_7 : s = "7"; break; - case KEY_KEY_8 : + case KEY_KEY_8 : s = "8"; break; - case KEY_KEY_9 : + case KEY_KEY_9 : s = "9"; break; - case KEY_KEY_A : + case KEY_KEY_A : s = "A"; break; - case KEY_KEY_B : + case KEY_KEY_B : s = "B"; break; - case KEY_KEY_C : + case KEY_KEY_C : s = "C"; break; - case KEY_KEY_D : + case KEY_KEY_D : s = "D"; break; - case KEY_KEY_E : + case KEY_KEY_E : s = "E"; break; - case KEY_KEY_F : + case KEY_KEY_F : s = "F"; break; - case KEY_KEY_G : + case KEY_KEY_G : s = "G"; break; case KEY_KEY_H : s = "H"; break; - case KEY_KEY_I : + case KEY_KEY_I : s = "I"; break; - case KEY_KEY_J : + case KEY_KEY_J : s = "J"; break; - case KEY_KEY_K : + case KEY_KEY_K : s = "K"; break; - case KEY_KEY_L : + case KEY_KEY_L : s = "L"; break; - case KEY_KEY_M : + case KEY_KEY_M : s = "M"; break; - case KEY_KEY_N : + case KEY_KEY_N : s = "N"; break; - case KEY_KEY_O : + case KEY_KEY_O : s = "O"; break; - case KEY_KEY_P : + case KEY_KEY_P : s = "P"; break; - case KEY_KEY_Q : + case KEY_KEY_Q : s = "Q"; break; - case KEY_KEY_R : + case KEY_KEY_R : s = "R"; break; - case KEY_KEY_S : + case KEY_KEY_S : s = "S"; break; - case KEY_KEY_T : + case KEY_KEY_T : s = "T"; break; - case KEY_KEY_U : + case KEY_KEY_U : s = "U"; break; - case KEY_KEY_V : + case KEY_KEY_V : s = "V"; break; - case KEY_KEY_W : + case KEY_KEY_W : s = "W"; break; case KEY_KEY_X : s = "X"; break; - case KEY_KEY_Y : + case KEY_KEY_Y : s = "Y"; break; - case KEY_KEY_Z : + case KEY_KEY_Z : s = "Z"; break; - case KEY_LWIN : + case KEY_LWIN : s = "Left Logo"; break; - case KEY_RWIN : + case KEY_RWIN : s = "Right Logo"; break; - case KEY_APPS : + case KEY_APPS : s = "apps"; break; - case KEY_SLEEP : + case KEY_SLEEP : s = "sleep"; break; - case KEY_NUMPAD0 : + case KEY_NUMPAD0 : s = "numpad 0"; break; - case KEY_NUMPAD1 : + case KEY_NUMPAD1 : s = "numpad 1"; break; - case KEY_NUMPAD2 : + case KEY_NUMPAD2 : s = "numpad 2"; break; - case KEY_NUMPAD3 : + case KEY_NUMPAD3 : s = "numpad 3"; break; case KEY_NUMPAD4 : @@ -308,133 +308,133 @@ case KEY_NUMPAD5 : s = "numpad 5"; break; - case KEY_NUMPAD6 : + case KEY_NUMPAD6 : s = "numpad 6"; break; - case KEY_NUMPAD7 : + case KEY_NUMPAD7 : s = "numpad 7"; break; - case KEY_NUMPAD8 : + case KEY_NUMPAD8 : s = "numpad 8"; break; - case KEY_NUMPAD9 : + case KEY_NUMPAD9 : s = "numpad 9"; break; - case KEY_MULTIPLY : + case KEY_MULTIPLY : s = "*"; break; - case KEY_ADD : + case KEY_ADD : s = "+"; break; - case KEY_SEPARATOR : + case KEY_SEPARATOR : s = "separator"; break; - case KEY_SUBTRACT : + case KEY_SUBTRACT : s = "- (subtract)"; break; - case KEY_DECIMAL : + case KEY_DECIMAL : s = "decimal"; break; - case KEY_DIVIDE : + case KEY_DIVIDE : s = "/ (divide)"; break; - case KEY_F1 : + case KEY_F1 : s = "F1"; break; - case KEY_F2 : + case KEY_F2 : s = "F2"; break; - case KEY_F3 : + case KEY_F3 : s = "F3"; break; - case KEY_F4 : + case KEY_F4 : s = "F4"; break; - case KEY_F5 : + case KEY_F5 : s = "F5"; break; - case KEY_F6 : + case KEY_F6 : s = "F6"; break; - case KEY_F7 : + case KEY_F7 : s = "F7"; break; - case KEY_F8 : + case KEY_F8 : s = "F8"; break; case KEY_F9 : s = "F9"; break; - case KEY_F10 : + case KEY_F10 : s = "F10"; break; - case KEY_F11 : + case KEY_F11 : s = "F11"; break; - case KEY_F12 : + case KEY_F12 : s = "F12"; break; - case KEY_F13 : + case KEY_F13 : s = "F13"; break; - case KEY_F14 : + case KEY_F14 : s = "F14"; break; - case KEY_F15 : + case KEY_F15 : s = "F15"; break; - case KEY_F16 : + case KEY_F16 : s = "F16"; break; - case KEY_F17 : + case KEY_F17 : s = "F17"; break; - case KEY_F18 : + case KEY_F18 : s = "F18"; break; - case KEY_F19 : + case KEY_F19 : s = "F19"; break; - case KEY_F20 : + case KEY_F20 : s = "F20"; break; - case KEY_F21 : + case KEY_F21 : s = "F21"; break; case KEY_F22 : s = "F22"; break; - case KEY_F23 : + case KEY_F23 : s = "F23"; break; - case KEY_F24 : + case KEY_F24 : s = "F24"; break; - case KEY_NUMLOCK : + case KEY_NUMLOCK : s = "num lock"; break; - case KEY_SCROLL : + case KEY_SCROLL : s = "scroll lock"; break; case KEY_LSHIFT : s = "left shift"; break; - case KEY_RSHIFT : + case KEY_RSHIFT : s = "right shift"; break; - case KEY_LCONTROL : + case KEY_LCONTROL : s = "left control"; break; - case KEY_RCONTROL : + case KEY_RCONTROL : s = "right control"; break; - case KEY_LMENU : + case KEY_LMENU : s = "left menu"; break; - case KEY_RMENU : + case KEY_RMENU : s = "right menu"; break; - case KEY_PLUS : + case KEY_PLUS : s = "+"; break; case KEY_COMMA : @@ -446,7 +446,7 @@ case KEY_PERIOD : s = "."; break; - case KEY_ATTN : + case KEY_ATTN : s = "attn"; break; case KEY_CRSEL : @@ -455,16 +455,16 @@ case KEY_EXSEL : s = "exsel"; break; - case KEY_EREOF : + case KEY_EREOF : s = "ereof"; break; - case KEY_PLAY : + case KEY_PLAY : s = "play"; break; case KEY_ZOOM : s = "zoom"; break; - case KEY_PA1 : + case KEY_PA1 : s = "pa1"; break; case KEY_OEM_CLEAR: Modified: main/trunk/src/input/input.hpp =================================================================== --- main/trunk/src/input/input.hpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/input/input.hpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -54,40 +54,40 @@ int btnID; // or axis ID for gamepads axes int axisDirection; - Input() - : type(IT_NONE), deviceID(0), btnID(0), axisDirection(0) - { - // Nothing to do. - } - - /** Creates an Input instance which represents an arbitrary way of getting - * game input using a type specifier and 3 integers. - * - * Meaning of the 3 integers for each InputType: - * IT_NONE: This means nothing. In certain cases this is regarded as an - * unset binding. - * IT_KEYBOARD: id0 is a irrLicht value. - * IT_STICKMOTION: id0 - stick index, id1 - axis index, id2 - axis direction - * (negative, positive). You can assume that axis 0 is the X-Axis where the + Input() + : type(IT_NONE), deviceID(0), btnID(0), axisDirection(0) + { + // Nothing to do. + } + + /** Creates an Input instance which represents an arbitrary way of getting + * game input using a type specifier and 3 integers. + * + * Meaning of the 3 integers for each InputType: + * IT_NONE: This means nothing. In certain cases this is regarded as an + * unset binding. + * IT_KEYBOARD: id0 is a irrLicht value. + * IT_STICKMOTION: id0 - stick index, id1 - axis index, id2 - axis direction + * (negative, positive). You can assume that axis 0 is the X-Axis where the * negative direction is to the left and that axis 1 is the Y-Axis with the - * negative direction being upwards. - * IT_STICKBUTTON: id0 - stick index, id1 - button index. Button 0 and 1 are - * usually reached most easily. - * IT_STICKHAT: This is not yet implemented. - * IT_MOUSEMOTION: id0 - axis index (0 -> X, 1 -> Y). Mouse wheel is - * represented as buttons! - * IT_MOUSEBUTTON: id0 - button number (1 -> left, 2 -> middle, 3 -> right, - * ...) - * - * Note: For joystick bindings that are actice in the menu the joystick's - * index should be zero. The binding will react to all joysticks connected - * to the system. - */ - Input(InputType ntype, int deviceID , int btnID = 0, int axisDirection= 0) - : type(ntype), deviceID(deviceID), btnID(btnID), axisDirection(axisDirection) - { - // Nothing to do. - } + * negative direction being upwards. + * IT_STICKBUTTON: id0 - stick index, id1 - button index. Button 0 and 1 are + * usually reached most easily. + * IT_STICKHAT: This is not yet implemented. + * IT_MOUSEMOTION: id0 - axis index (0 -> X, 1 -> Y). Mouse wheel is + * represented as buttons! + * IT_MOUSEBUTTON: id0 - button number (1 -> left, 2 -> middle, 3 -> right, + * ...) + * + * Note: For joystick bindings that are actice in the menu the joystick's + * index should be zero. The binding will react to all joysticks connected + * to the system. + */ + Input(InputType ntype, int deviceID , int btnID = 0, int axisDirection= 0) + : type(ntype), deviceID(deviceID), btnID(btnID), axisDirection(axisDirection) + { + // Nothing to do. + } static irr::core::stringw getInputAsString(const Input::InputType type, const int id, const Input::AxisDirection dir=AD_NEUTRAL); @@ -97,15 +97,15 @@ { PA_FIRST = -1, - PA_LEFT = 0, - PA_RIGHT, - PA_ACCEL, - PA_BRAKE, - PA_NITRO, - PA_DRIFT, - PA_RESCUE, - PA_FIRE, - PA_LOOK_BACK, + PA_LEFT = 0, + PA_RIGHT, + PA_ACCEL, + PA_BRAKE, + PA_NITRO, + PA_DRIFT, + PA_RESCUE, + PA_FIRE, + PA_LOOK_BACK, PA_COUNT }; @@ -122,41 +122,41 @@ enum StaticAction { - // Below this are synthetic game actions which are never triggered through - // an input device. - GA_NULL, // Nothing dummy entry. - GA_SENSE_CANCEL, // Input sensing canceled. - GA_SENSE_COMPLETE, // Input sensing successfully finished. - - // Below this point are the game actions which can happen while in menu - // mode. - - GA_ENTER, // Enter menu, acknowledge, ... - GA_LEAVE, // Leave a menu. - - GA_CLEAR_MAPPING, // Clear an input mapping. - - GA_INC_SCROLL_SPEED, - GA_INC_SCROLL_SPEED_FAST, - GA_DEC_SCROLL_SPEED, - GA_DEC_SCROLL_SPEED_FAST, - - GA_CURSOR_UP, - GA_CURSOR_DOWN, - GA_CURSOR_LEFT, - GA_CURSOR_RIGHT, - + // Below this are synthetic game actions which are never triggered through + // an input device. + GA_NULL, // Nothing dummy entry. + GA_SENSE_CANCEL, // Input sensing canceled. + GA_SENSE_COMPLETE, // Input sensing successfully finished. + + // Below this point are the game actions which can happen while in menu + // mode. + + GA_ENTER, // Enter menu, acknowledge, ... + GA_LEAVE, // Leave a menu. + + GA_CLEAR_MAPPING, // Clear an input mapping. + + GA_INC_SCROLL_SPEED, + GA_INC_SCROLL_SPEED_FAST, + GA_DEC_SCROLL_SPEED, + GA_DEC_SCROLL_SPEED_FAST, + + GA_CURSOR_UP, + GA_CURSOR_DOWN, + GA_CURSOR_LEFT, + GA_CURSOR_RIGHT, + - GA_TOGGLE_FULLSCREEN, // Switch between windowed/fullscreen mode - GA_LEAVE_RACE, // Switch from race to menu. - - GA_DEBUG_ADD_MISSILE, - GA_DEBUG_ADD_BOWLING, - GA_DEBUG_ADD_HOMING, - GA_DEBUG_TOGGLE_FPS, - GA_DEBUG_TOGGLE_WIREFRAME, - GA_DEBUG_HISTORY - + GA_TOGGLE_FULLSCREEN, // Switch between windowed/fullscreen mode + GA_LEAVE_RACE, // Switch from race to menu. + + GA_DEBUG_ADD_MISSILE, + GA_DEBUG_ADD_BOWLING, + GA_DEBUG_ADD_HOMING, + GA_DEBUG_TOGGLE_FPS, + GA_DEBUG_TOGGLE_WIREFRAME, + GA_DEBUG_HISTORY + }; Modified: main/trunk/src/input/input_manager.cpp =================================================================== --- main/trunk/src/input/input_manager.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/input/input_manager.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -402,7 +402,7 @@ /** Returns whether only the master player should be allowed to perform changes in menus */ bool InputManager::masterPlayerOnly() const { - return m_device_manager->getAssignMode() == ASSIGN && m_master_player_only; + return m_device_manager->getAssignMode() == ASSIGN && m_master_player_only; } //----------------------------------------------------------------------------- /** Modified: main/trunk/src/input/input_manager.hpp =================================================================== --- main/trunk/src/input/input_manager.hpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/input/input_manager.hpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -53,7 +53,7 @@ private: - Input *m_sensed_input; + Input *m_sensed_input; DeviceManager *m_device_manager; /** Stores the maximum sensed input values. This allows to select the @@ -61,39 +61,39 @@ int m_max_sensed_input; Input::InputType m_max_sensed_type; - InputDriverMode m_mode; - + InputDriverMode m_mode; + /** When at true, only the master player can play with menus */ bool m_master_player_only; - /* Helper values to store and track the relative mouse movements. If these - * values exceed the deadzone value the input is reported to the game. This - * makes the mouse behave like an analog axis on a gamepad/joystick. - */ - int m_mouse_val_x, m_mouse_val_y; + /* Helper values to store and track the relative mouse movements. If these + * values exceed the deadzone value the input is reported to the game. This + * makes the mouse behave like an analog axis on a gamepad/joystick. + */ + int m_mouse_val_x, m_mouse_val_y; void dispatchInput(Input::InputType, int, int, int, int); void handleStaticAction(int id0, int value); void handlePlayerAction(PlayerAction pa, const int playerNo, int value); void inputSensing(Input::InputType type, int deviceID, int btnID, int axisDirection, int value); public: - InputManager(); + InputManager(); ~InputManager(); - // void initGamePadDevices(); + // void initGamePadDevices(); - //void input(); + //void input(); GUIEngine::EventPropagation input(const irr::SEvent& event); DeviceManager* getDeviceList() { return m_device_manager; } - void setMode(InputDriverMode); - bool isInMode(InputDriverMode); + void setMode(InputDriverMode); + bool isInMode(InputDriverMode); /** When this mode is enabled, only the master player will be able to play with menus (only works in 'assign' mode) */ void setMasterPlayerOnly(bool enabled); /** Returns whether only the master player should be allowed to perform changes in menus */ - bool masterPlayerOnly() const; + bool masterPlayerOnly() const; void update(float dt); Modified: main/trunk/src/io/xml_node.hpp =================================================================== --- main/trunk/src/io/xml_node.hpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/io/xml_node.hpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -53,7 +53,7 @@ int get(const std::string &attribute, float *value) const; int get(const std::string &attribute, bool *value) const; int get(const std::string &attribute, Vec3 *value) const; - int get(const std::string &attribute, core::vector2df *value) const; + int get(const std::string &attribute, core::vector2df *value) const; int get(const std::string &attribute, core::vector3df *value) const; int get(const std::string &attribute, video::SColorf *value) const; int get(const std::string &attribute, video::SColor *value) const; Modified: main/trunk/src/items/bowling.cpp =================================================================== --- main/trunk/src/items/bowling.cpp 2009-12-17 23:45:42 UTC (rev 4319) +++ main/trunk/src/items/bowling.cpp 2009-12-18 00:36:35 UTC (rev 4320) @@ -62,10 +62,10 @@ int flag = getBody()->getCollisionFlags(); flag = flag & (... [truncated message content] |
From: <au...@us...> - 2009-12-19 19:26:10
|
Revision: 4324 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4324&view=rev Author: auria Date: 2009-12-19 19:25:12 +0000 (Sat, 19 Dec 2009) Log Message: ----------- Started adding back support for 3 strikes mode (which doesn't work since no arena was converted yet) Modified Paths: -------------- main/trunk/src/Makefile.am main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj main/trunk/src/states_screens/race_setup_screen.cpp main/trunk/src/states_screens/tracks_screen.cpp Added Paths: ----------- main/trunk/src/states_screens/arenas_screen.cpp main/trunk/src/states_screens/arenas_screen.hpp Modified: main/trunk/src/Makefile.am =================================================================== --- main/trunk/src/Makefile.am 2009-12-19 19:09:07 UTC (rev 4323) +++ main/trunk/src/Makefile.am 2009-12-19 19:25:12 UTC (rev 4324) @@ -266,6 +266,8 @@ states_screens/dialogs/race_over_dialog.hpp \ states_screens/dialogs/race_paused_dialog.hpp \ states_screens/dialogs/race_paused_dialog.cpp \ + states_screens/arenas_screen.cpp \ + states_screens/arenas_screen.hpp \ states_screens/feature_unlocked.cpp \ states_screens/feature_unlocked.hpp \ states_screens/help_screen_1.cpp \ Modified: main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj =================================================================== --- main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj 2009-12-19 19:09:07 UTC (rev 4323) +++ main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj 2009-12-19 19:25:12 UTC (rev 4324) @@ -245,6 +245,7 @@ 9551DB34104CABFC001C53E5 /* race_over_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9551DB33104CABFC001C53E5 /* race_over_dialog.cpp */; }; 955DE88310042701006A4F3C /* check_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE88110042701006A4F3C /* check_manager.cpp */; }; 955DE88C1004273B006A4F3C /* check_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE8871004273B006A4F3C /* check_structure.cpp */; }; + 956541BB10DD5F0A00C83E99 /* arenas_screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956541B910DD5F0A00C83E99 /* arenas_screen.cpp */; }; 956D36A710095035007FCB95 /* player.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956D36A610095035007FCB95 /* player.cpp */; }; 958330CC10122B4A00C5137E /* engine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 958330B210122B4A00C5137E /* engine.cpp */; }; 958330CD10122B4A00C5137E /* event_handler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 958330B410122B4A00C5137E /* event_handler.cpp */; }; @@ -432,6 +433,8 @@ 955DE88210042701006A4F3C /* check_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = check_manager.hpp; path = ../../tracks/check_manager.hpp; sourceTree = SOURCE_ROOT; }; 955DE8871004273B006A4F3C /* check_structure.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = check_structure.cpp; path = ../../tracks/check_structure.cpp; sourceTree = SOURCE_ROOT; }; 955DE8881004273B006A4F3C /* check_structure.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = check_structure.hpp; path = ../../tracks/check_structure.hpp; sourceTree = SOURCE_ROOT; }; + 956541B910DD5F0A00C83E99 /* arenas_screen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = arenas_screen.cpp; path = games/supertuxkart/src/states_screens/arenas_screen.cpp; sourceTree = SYSTEM_DEVELOPER_DIR; }; + 956541BA10DD5F0A00C83E99 /* arenas_screen.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = arenas_screen.hpp; path = games/supertuxkart/src/states_screens/arenas_screen.hpp; sourceTree = SYSTEM_DEVELOPER_DIR; }; 956D36A610095035007FCB95 /* player.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = player.cpp; path = ../../config/player.cpp; sourceTree = SOURCE_ROOT; }; 958330B210122B4A00C5137E /* engine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = engine.cpp; path = ../../guiengine/engine.cpp; sourceTree = SOURCE_ROOT; }; 958330B310122B4A00C5137E /* engine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = engine.hpp; path = ../../guiengine/engine.hpp; sourceTree = SOURCE_ROOT; }; @@ -1261,6 +1264,8 @@ isa = PBXGroup; children = ( 95833236101243ED00C5137E /* dialogs */, + 956541B910DD5F0A00C83E99 /* arenas_screen.cpp */, + 956541BA10DD5F0A00C83E99 /* arenas_screen.hpp */, 951B7D18108E52C900BC03AE /* challenges.cpp */, 951B7D17108E52C900BC03AE /* challenges.hpp */, 958330C210122B4A00C5137E /* credits.cpp */, @@ -2564,6 +2569,7 @@ 951B7D19108E52C900BC03AE /* challenges.cpp in Sources */, 95FB16DB10A7796800645974 /* new_ai.cpp in Sources */, 953C3CCA10CAF3EE0025F78A /* CGUIFont.cpp in Sources */, + 956541BB10DD5F0A00C83E99 /* arenas_screen.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Added: main/trunk/src/states_screens/arenas_screen.cpp =================================================================== --- main/trunk/src/states_screens/arenas_screen.cpp (rev 0) +++ main/trunk/src/states_screens/arenas_screen.cpp 2009-12-19 19:25:12 UTC (rev 4324) @@ -0,0 +1,105 @@ +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2009 Marianne Gagnon +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "challenges/unlock_manager.hpp" +#include "guiengine/widget.hpp" +#include "io/file_manager.hpp" +#include "states_screens/state_manager.hpp" +#include "states_screens/arenas_screen.hpp" +#include "states_screens/dialogs/track_info_dialog.hpp" +#include "tracks/track.hpp" +#include "tracks/track_manager.hpp" +#include "utils/translation.hpp" + +using namespace GUIEngine; +using namespace irr::core; +using namespace irr::video; + +ArenasScreen::ArenasScreen() : Screen("arenas.stkgui") +{ +} + + +void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) +{ + if (name == "tracks") + { + DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget); + if (w2 != NULL) + { + const std::string selection = w2->getSelectionIDString(GUI_PLAYER_ID); + std::cout << "Clicked on arena " << selection.c_str() << std::endl; + + if (selection == "random_track") + { + // TODO + } + else + { + Track* clickedTrack = track_manager->getTrack(selection); + if (clickedTrack != NULL) + { + ITexture* screenshot = GUIEngine::getDriver()->getTexture( clickedTrack->getScreenshotFile().c_str() ); + + new TrackInfoDialog( clickedTrack->getIdent(), clickedTrack->getName().c_str(), screenshot, 0.8f, 0.7f); + } + } + } + } + +} + +void ArenasScreen::init() +{ + DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks"); + assert( w != NULL ); + + // Re-build track list everytime (accounts for locking changes, etc.) + w->clearItems(); + + const int trackAmount = track_manager->getNumberOfTracks(); + //bool hasLockedTracks = false; + for (int n=0; n<trackAmount; n++) + { + Track* curr = track_manager->getTrack(n); + if (!curr->isArena()) continue; + + if (unlock_manager->isLocked(curr->getIdent())) + { + w->addItem( _("Locked : solve active challenges to gain access to more!"), "locked", curr->getScreenshotFile(), true ); + } + else + { + w->addItem( curr->getName(), curr->getIdent(), curr->getScreenshotFile(), false ); + } + } + w->addItem(_("Random Arena"), "random_track", "/gui/track_random.png"); + w->updateItemDisplay(); +} + +void ArenasScreen::tearDown() +{ +} + +void ArenasScreen::setFocusOnTrack(const std::string& trackName) +{ + DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("tracks"); + assert( w != NULL ); + + // FIXME: don't hardcode player 0? + w->setSelection(trackName, 0, true); +} Property changes on: main/trunk/src/states_screens/arenas_screen.cpp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: main/trunk/src/states_screens/arenas_screen.hpp =================================================================== --- main/trunk/src/states_screens/arenas_screen.hpp (rev 0) +++ main/trunk/src/states_screens/arenas_screen.hpp 2009-12-19 19:25:12 UTC (rev 4324) @@ -0,0 +1,40 @@ +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2009 Marianne Gagnon +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef HEADER_ARENAS_SCREEN_HPP +#define HEADER_ARENAS_SCREEN_HPP + +#include "guiengine/screen.hpp" + + +namespace GUIEngine { class Widget; } + +class ArenasScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<ArenasScreen> +{ + friend class GUIEngine::ScreenSingleton<ArenasScreen>; + + ArenasScreen(); + +public: + void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); + void init(); + void tearDown(); + + void setFocusOnTrack(const std::string& trackName); +}; + +#endif Property changes on: main/trunk/src/states_screens/arenas_screen.hpp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: main/trunk/src/states_screens/race_setup_screen.cpp =================================================================== --- main/trunk/src/states_screens/race_setup_screen.cpp 2009-12-19 19:09:07 UTC (rev 4323) +++ main/trunk/src/states_screens/race_setup_screen.cpp 2009-12-19 19:25:12 UTC (rev 4324) @@ -19,6 +19,7 @@ #include "guiengine/widget.hpp" #include "io/file_manager.hpp" #include "race/race_manager.hpp" +#include "states_screens/arenas_screen.hpp" #include "states_screens/race_setup_screen.hpp" #include "states_screens/state_manager.hpp" #include "states_screens/tracks_screen.hpp" @@ -77,8 +78,8 @@ } else if (selectedMode == "3strikes") { - // TODO - 3 strikes battle track selection race_manager->setMinorMode(RaceManager::MINOR_MODE_3_STRIKES); + StateManager::get()->pushScreen( ArenasScreen::getInstance() ); } else if (selectedMode == "locked") { Modified: main/trunk/src/states_screens/tracks_screen.cpp =================================================================== --- main/trunk/src/states_screens/tracks_screen.cpp 2009-12-19 19:09:07 UTC (rev 4323) +++ main/trunk/src/states_screens/tracks_screen.cpp 2009-12-19 19:25:12 UTC (rev 4324) @@ -83,6 +83,8 @@ for (int n=0; n<trackAmount; n++) { Track* curr = track_manager->getTrack(n); + if (curr->isArena()) continue; + /* if (unlock_manager->isLocked(curr->getIdent())) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-22 18:40:03
|
Revision: 4328 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4328&view=rev Author: auria Date: 2009-12-22 18:39:55 +0000 (Tue, 22 Dec 2009) Log Message: ----------- Started dealing with [?] squares in ribbons Modified Paths: -------------- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp main/trunk/src/states_screens/challenges.cpp Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2009-12-19 20:56:41 UTC (rev 4327) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.cpp 2009-12-22 18:39:55 UTC (rev 4328) @@ -187,6 +187,7 @@ } // ---- add rows + int added_item_count = 0; for (int n=0; n<m_row_amount; n++) { RibbonWidget* ribbon; @@ -230,6 +231,10 @@ // std::cout << "ribbon text = " << m_properties[PROP_TEXT].c_str() << std::endl; ribbon->m_children.push_back( icon ); + added_item_count++; + + // stop adding columns when we have enough items + if (added_item_count >= item_count) break; } m_children.push_back( ribbon ); m_rows.push_back( ribbon ); @@ -444,6 +449,11 @@ // ----------------------------------------------------------------------------- void DynamicRibbonWidget::onRowChange(RibbonWidget* row, const int playerID) { + if (row->m_selection[playerID] >= row->m_children.size()) + { + row->m_selection[playerID] = row->m_children.size()-1; + } + updateLabel(row); const int listenerAmount = m_hover_listeners.size(); @@ -513,7 +523,7 @@ RibbonWidget* ribbon = m_rows.get(n); if (ribbon != selected_ribbon) { - ribbon->m_selection[p] = relative_selection; + ribbon->m_selection[p] = std::min(relative_selection, ribbon->m_children.size()-1); ribbon->updateSelection(); } } @@ -568,7 +578,8 @@ { RibbonWidget& row = m_rows[n]; - for (int i=0; i<m_col_amount; i++) + const int items_in_row = row.m_children.size(); + for (int i=0; i<items_in_row; i++) { IconButtonWidget* icon = dynamic_cast<IconButtonWidget*>(&row.m_children[i]); assert(icon != NULL); Modified: main/trunk/src/states_screens/challenges.cpp =================================================================== --- main/trunk/src/states_screens/challenges.cpp 2009-12-19 20:56:41 UTC (rev 4327) +++ main/trunk/src/states_screens/challenges.cpp 2009-12-22 18:39:55 UTC (rev 4328) @@ -78,7 +78,7 @@ for (int n=0; n<lockedChallengeAmount; n++) { w->addItem( _("Locked : solve active challenges to gain access to more!"), "locked", - file_manager->getTextureFile("gui_lock.png")); + file_manager->getGUIDir() + "/challenge.png", true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-27 18:41:26
|
Revision: 4354 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4354&view=rev Author: auria Date: 2009-12-27 18:41:19 +0000 (Sun, 27 Dec 2009) Log Message: ----------- Fixed input bug that occurred when going back in menus Modified Paths: -------------- main/trunk/src/guiengine/abstract_state_manager.cpp main/trunk/src/input/device_manager.cpp main/trunk/src/input/input_manager.cpp Modified: main/trunk/src/guiengine/abstract_state_manager.cpp =================================================================== --- main/trunk/src/guiengine/abstract_state_manager.cpp 2009-12-27 17:02:15 UTC (rev 4353) +++ main/trunk/src/guiengine/abstract_state_manager.cpp 2009-12-27 18:41:19 UTC (rev 4354) @@ -165,7 +165,6 @@ { m_game_mode = MENU; switchToScreen(m_menu_stack[m_menu_stack.size()-1].c_str()); - input_manager->getDeviceList()->setAssignMode(NO_ASSIGN); // No assign mode on menus by default getCurrentScreen()->init(); } } Modified: main/trunk/src/input/device_manager.cpp =================================================================== --- main/trunk/src/input/device_manager.cpp 2009-12-27 17:02:15 UTC (rev 4353) +++ main/trunk/src/input/device_manager.cpp 2009-12-27 18:41:19 UTC (rev 4354) @@ -10,6 +10,8 @@ #include "states_screens/state_manager.hpp" #include "io/file_manager.hpp" +#define INPUT_MODE_DEBUG 0 + DeviceManager::DeviceManager() { m_latest_used_device = NULL; @@ -89,6 +91,12 @@ { m_assign_mode = assignMode; +#if INPUT_MODE_DEBUG + if (assignMode == NO_ASSIGN) std::cout << "====== DeviceManager::setAssignMode(NO_ASSIGN) ======\n"; + if (assignMode == ASSIGN) std::cout << "====== DeviceManager::setAssignMode(ASSIGN) ======\n"; + if (assignMode == DETECT_NEW) std::cout << "====== DeviceManager::setAssignMode(DETECT_NEW) ======\n"; +#endif + // when going back to no-assign mode, do some cleanup if (assignMode == NO_ASSIGN) { @@ -262,7 +270,7 @@ if (m_latest_used_device == NULL) { - std::cout<< "========== No latest device, returning keyboard ==========\n"; + //std::cout<< "========== No latest device, returning keyboard ==========\n"; return m_keyboards.get(0); // FIXME: is this right? } Modified: main/trunk/src/input/input_manager.cpp =================================================================== --- main/trunk/src/input/input_manager.cpp 2009-12-27 17:02:15 UTC (rev 4353) +++ main/trunk/src/input/input_manager.cpp 2009-12-27 18:41:19 UTC (rev 4354) @@ -49,6 +49,8 @@ using GUIEngine::EVENT_LET; using GUIEngine::EVENT_BLOCK; +#define INPUT_MODE_DEBUG 0 + //----------------------------------------------------------------------------- /** Initialise input */ @@ -397,6 +399,9 @@ //----------------------------------------------------------------------------- void InputManager::setMasterPlayerOnly(bool enabled) { +#if INPUT_MODE_DEBUG + std::cout << "====== InputManager::setMasterPlayerOnly(" << enabled << ") ======\n"; +#endif m_master_player_only = enabled; } /** Returns whether only the master player should be allowed to perform changes in menus */ @@ -616,6 +621,9 @@ switch (new_mode) { case MENU: +#if INPUT_MODE_DEBUG + std::cout << "====== InputManager::setMode(MENU) ======\n"; +#endif switch (m_mode) { case INGAME: @@ -673,6 +681,9 @@ break; case INGAME: +#if INPUT_MODE_DEBUG + std::cout << "====== InputManager::setMode(INGAME) ======\n"; +#endif // We must be in menu mode now in order to switch. assert (m_mode == MENU); @@ -689,6 +700,9 @@ break; case INPUT_SENSE_KEYBOARD: case INPUT_SENSE_GAMEPAD: +#if INPUT_MODE_DEBUG + std::cout << "====== InputManager::setMode(INPUT_SENSE_*) ======\n"; +#endif // We must be in menu mode now in order to switch. assert (m_mode == MENU); @@ -705,6 +719,9 @@ break; case LOWLEVEL: +#if INPUT_MODE_DEBUG + std::cout << "====== InputManager::setMode(LOWLEVEL) ======\n"; +#endif // We must be in menu mode now in order to switch. assert (m_mode == MENU); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-27 19:12:54
|
Revision: 4355 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4355&view=rev Author: auria Date: 2009-12-27 19:12:44 +0000 (Sun, 27 Dec 2009) Log Message: ----------- Much cleanup and documentation in input code, which was done on the way of fixing a bug that dealt with multiple and/or custom keyboard configs and menu navigation Modified Paths: -------------- main/trunk/src/config/device_config.cpp main/trunk/src/config/device_config.hpp main/trunk/src/input/device_manager.cpp main/trunk/src/input/device_manager.hpp main/trunk/src/input/input_device.cpp main/trunk/src/input/input_device.hpp main/trunk/src/input/input_manager.cpp Modified: main/trunk/src/config/device_config.cpp =================================================================== --- main/trunk/src/config/device_config.cpp 2009-12-27 18:41:19 UTC (rev 4354) +++ main/trunk/src/config/device_config.cpp 2009-12-27 19:12:44 UTC (rev 4355) @@ -51,7 +51,7 @@ bool DeviceConfig::getAction ( Input::InputType type, const int id, const int value, - PlayerAction* action ) + PlayerAction* action /* out */ ) { bool success = false; int n; Modified: main/trunk/src/config/device_config.hpp =================================================================== --- main/trunk/src/config/device_config.hpp 2009-12-27 18:41:19 UTC (rev 4354) +++ main/trunk/src/config/device_config.hpp 2009-12-27 19:12:44 UTC (rev 4355) @@ -53,7 +53,7 @@ bool getAction (Input::InputType type, const int id, const int value, - PlayerAction* action); + PlayerAction* action /* out */); KeyBinding getBinding (int i) {return m_bindings[i];} bool hasBindingFor(const int buttonID) const; Modified: main/trunk/src/input/device_manager.cpp =================================================================== --- main/trunk/src/input/device_manager.cpp 2009-12-27 18:41:19 UTC (rev 4354) +++ main/trunk/src/input/device_manager.cpp 2009-12-27 19:12:44 UTC (rev 4355) @@ -172,23 +172,29 @@ } // ----------------------------------------------------------------------------- -InputDevice* DeviceManager::mapKeyboardInput( int deviceID, - int btnID, - ActivePlayer **player, - PlayerAction *action ) +InputDevice* DeviceManager::mapKeyboardInput( int btnID, + ActivePlayer **player /* out */, + PlayerAction *action /* out */ ) { const int keyboard_amount = m_keyboards.size(); + + //std::cout << "mapKeyboardInput " << btnID << " to " << keyboard_amount << " keyboards\n"; + for (int n=0; n<keyboard_amount; n++) { KeyboardDevice *keyboard = m_keyboards.get(n); if (keyboard->hasBinding(btnID, action)) { + //std::cout << " binding found in keyboard #" << (n+1) << "; action is " << KartActionStrings[*action] << "\n"; if (m_assign_mode == NO_ASSIGN) // Don't set the player in NO_ASSIGN mode { *player = NULL; } - else *player = keyboard->m_player; + else + { + *player = keyboard->m_player; + } return keyboard; } } @@ -202,8 +208,8 @@ int btnID, int axisDir, int value, - ActivePlayer **player, - PlayerAction *action ) + ActivePlayer **player /* out */, + PlayerAction *action /* out */) { GamePadDevice *gPad = getGamePadFromIrrID(deviceID); @@ -227,8 +233,6 @@ } //----------------------------------------------------------------------------- -// Formerly mapInputToPlayerAndAction(), broken down to be more readable - bool DeviceManager::translateInput( Input::InputType type, int deviceID, int btnID, @@ -243,7 +247,7 @@ switch (type) { case Input::IT_KEYBOARD: - device = mapKeyboardInput(deviceID, btnID, player, action); + device = mapKeyboardInput(btnID, player, action); break; case Input::IT_STICKBUTTON: case Input::IT_STICKMOTION: @@ -253,6 +257,12 @@ break; }; + /* + if (device != NULL) + { + std::cout << " binding found; action is " << KartActionStrings[*action] << "\n"; + }*/ + // Return true if input was successfully translated to an action and player if (device != NULL && abs(value) > Input::MAX_VALUE/2) { Modified: main/trunk/src/input/device_manager.hpp =================================================================== --- main/trunk/src/input/device_manager.hpp 2009-12-27 18:41:19 UTC (rev 4354) +++ main/trunk/src/input/device_manager.hpp 2009-12-27 19:12:44 UTC (rev 4355) @@ -7,11 +7,23 @@ enum PlayerAssignMode { - NO_ASSIGN, // react to all devices - DETECT_NEW, // notify the manager when an inactive device is being asked to activate with fire - ASSIGN // only react to assigned devices + NO_ASSIGN, //!< react to all devices + DETECT_NEW, //!< notify the manager when an inactive device is being asked to activate with fire + ASSIGN //!< only react to assigned devices }; +/** + * This class holds the list of all known devices (ands their configurations), as well as the list + * of currently plugged (used) devices. It thus takes care of finding to which device any given + * input belongs, and what action each keypress is bound to, if any (and, since each device is associated + * to a player, it also finds which player triggered this action) + * These input mapping capabilities should *only* be used through the InputManager, not directly. + * + * The device manager starts in "no-assign" mode, which means no input configuration is associated + * to any player. So all devices will react. This is used in menus before player set-up is done. + * Switching back to no-assign mode will also clear anything in devices that was associated with + * players in assign mode. + */ class DeviceManager { private: @@ -24,67 +36,71 @@ InputDevice* m_latest_used_device; PlayerAssignMode m_assign_mode; - // Helper functions, only used internally + /** + * Helper method, only used internally. Takes care of analyzing gamepad input. + * + * \param[out] player Which player this input belongs to (only set in ASSIGN mode) + * \param[out] action Which action is related to this input trigger + * \return The device to which this input belongs + */ InputDevice *mapGamepadInput ( Input::InputType type, int deviceID, int btnID, int axisDir, int value, - ActivePlayer **player, - PlayerAction *action ); + ActivePlayer **player /* out */, + PlayerAction *action /* out */); - InputDevice *mapKeyboardInput ( int deviceID, - int btnID, - ActivePlayer **player, - PlayerAction *action ); + /** + * Helper method, only used internally. Takes care of analyzing keyboard input. + * + * \param[out] player Which player this input belongs to (only set in ASSIGN mode) + * \param[out] action Which action is related to this input trigger + * \return The device to which this input belongs + */ + InputDevice *mapKeyboardInput ( int btnID, + ActivePlayer **player /* out */, + PlayerAction *action /* out */); bool deserialize(); void shutdown(); public: - /** - * The device manager starts in "no-assign" mode, which means no input configuration is associated - * to any player. So all devices will react. This is used in menus before player set-up is done. - * Switching back to no-assign mode will also clear anything in devices that was associated with - * players in assign mode. - */ - DeviceManager(); + // ---- Assign mode ---- + PlayerAssignMode getAssignMode() const { return m_assign_mode; } + void setAssignMode(const PlayerAssignMode assignMode); + // ---- Gamepads ---- void addGamepad(GamePadDevice* d); int getGamePadAmount() const { return m_gamepads.size(); } int getGamePadConfigAmount() const { return m_gamepad_configs.size(); } GamePadDevice* getGamePad(const int i) { return m_gamepads.get(i); } GamepadConfig* getGamepadConfig(const int i) { return m_gamepad_configs.get(i); } - void clearGamepads() { m_gamepads.clearAndDeleteAll(); } - + GamePadDevice* getGamePadFromIrrID(const int i); + void clearGamepads() { m_gamepads.clearAndDeleteAll(); } + /** Returns the keyboard that has a binding for this button, or NULL if none */ + bool getConfigForGamepad(const int sdl_id, GamepadConfig **config); + // ---- Keyboard(s) ---- void addKeyboard(KeyboardDevice* d); int getKeyboardConfigAmount() const { return m_keyboard_configs.size(); } KeyboardDevice* getKeyboard(const int i) { return m_keyboards.get(i); } KeyboardConfig* getKeyboardConfig(const int i) { return m_keyboard_configs.get(i); } - void clearKeyboard() { m_keyboards.clearAndDeleteAll(); } + void clearKeyboard() { m_keyboards.clearAndDeleteAll(); } + KeyboardDevice* getKeyboardFromBtnID(const int btnID); - PlayerAssignMode playerAssignMode() const { return m_assign_mode; } - /** Returns the keyboard that has a binding for this button, or NULL if none */ - KeyboardDevice* getKeyboardFromBtnID(const int btnID); - PlayerAssignMode getAssignMode() { return m_assign_mode; } - GamePadDevice* getGamePadFromIrrID(const int i); - InputDevice* getLatestUsedDevice(); - void setAssignMode(const PlayerAssignMode assignMode); - bool getConfigForGamepad(const int sdl_id, GamepadConfig **config); /** Given some input, finds to which device it belongs and, using the corresponding device object, * maps this input to the corresponding player and game action. returns false if player/action could not be set. * Special case : can return true but set action to PA_FIRST if the input was used but is not associated to an * action and a player */ - bool translateInput( Input::InputType type, int deviceID, int btnID, @@ -93,7 +109,7 @@ ActivePlayer** player /* out */, PlayerAction* action /* out */ ); - /* returns whether a new gamepad was detected */ + InputDevice* getLatestUsedDevice(); bool initialize(); void serialize(); }; Modified: main/trunk/src/input/input_device.cpp =================================================================== --- main/trunk/src/input/input_device.cpp 2009-12-27 18:41:19 UTC (rev 4354) +++ main/trunk/src/input/input_device.cpp 2009-12-27 19:12:44 UTC (rev 4355) @@ -44,7 +44,7 @@ } // ----------------------------------------------------------------------------- -bool KeyboardDevice::hasBinding(const int id, PlayerAction* action) +bool KeyboardDevice::hasBinding(const int id, PlayerAction* action /* out */) { return m_configuration->getAction(Input::IT_KEYBOARD, id, 0, action); } Modified: main/trunk/src/input/input_device.hpp =================================================================== --- main/trunk/src/input/input_device.hpp 2009-12-27 18:41:19 UTC (rev 4354) +++ main/trunk/src/input/input_device.hpp 2009-12-27 19:12:44 UTC (rev 4355) @@ -44,11 +44,19 @@ class KeyboardDevice : public InputDevice { public: - bool hasBinding(const int id, PlayerAction* action); + + KeyboardDevice(); KeyboardDevice(KeyboardConfig *configuration); - /** checks if this key belongs to this belongs. if yes, sets action and returns true; otherwise returns false */ + /** + * Checks if this key belongs to this device. if yes, sets action and returns true; otherwise returns false + * + * \param id ID of the key that was pressed + * \param[out] action The action associated to this input (only check this value if method returned true) + */ + bool hasBinding(const int id, PlayerAction* action); + }; class GamePadDevice : public InputDevice @@ -63,17 +71,22 @@ int m_axis_count; int m_button_count; - - /** checks if this key belongs to this belongs. if yes, sets action and returns true; otherwise returns false. - The 'player' id passed is simply to know where to send 'axis reset's when necessary*/ - bool hasBinding(Input::InputType type, const int id, const int value, ActivePlayer* player, PlayerAction* action); - GamePadDevice(const int irrIndex, const std::string name, const int axis_number, const int btnAmount, GamepadConfig *configuration); + ~GamePadDevice(); bool isButtonPressed(const int i); void setButtonPressed(const int i, bool isButtonPressed); - ~GamePadDevice(); + /** + * Checks if this key belongs to this device. if yes, sets action and returns true; otherwise returns false. + * + * \param player Only passed to know where to send 'axis reset's when necessary + * \param id ID of the key that was pressed or of the axis that was triggered (depending on + * the value of the 'type' parameter) + * \param[out] action The action associated to this input (only check this value if method returned true) + */ + bool hasBinding(Input::InputType type, const int id, const int value, ActivePlayer* player, PlayerAction* action); + }; Modified: main/trunk/src/input/input_manager.cpp =================================================================== --- main/trunk/src/input/input_manager.cpp 2009-12-27 18:41:19 UTC (rev 4354) +++ main/trunk/src/input/input_manager.cpp 2009-12-27 19:12:44 UTC (rev 4355) @@ -228,7 +228,7 @@ int InputManager::getPlayerKeyboardID() const { // In no-assign mode, just return the GUI player ID (devices not assigned yet) - if (m_device_manager->playerAssignMode() == NO_ASSIGN) return GUI_PLAYER_ID; + if (m_device_manager->getAssignMode() == NO_ASSIGN) return GUI_PLAYER_ID; // Otherwise, after devices are assigned, we can check the ID // FIXME: don't hardcode keyboard 0, there may be multiple keyboard configs @@ -262,8 +262,8 @@ // in menus, some keyboard keys are standard (before each player selected his device) // FIXME: should enter always work to accept for a player using keyboard? - if (StateManager::get()->getGameState() != GUIEngine::GAME && type == Input::IT_KEYBOARD && m_mode == MENU && - m_device_manager->playerAssignMode() == NO_ASSIGN) + if (!action_found && StateManager::get()->getGameState() != GUIEngine::GAME && type == Input::IT_KEYBOARD && + m_mode == MENU && m_device_manager->getAssignMode() == NO_ASSIGN) { action = PA_FIRST; @@ -273,7 +273,10 @@ else if (btnID == KEY_RIGHT) action = PA_RIGHT; else if (btnID == KEY_SPACE) action = PA_FIRE; - if(btnID == KEY_RETURN && GUIEngine::ModalDialog::isADialogActive()) GUIEngine::ModalDialog::onEnterPressed(); + if (btnID == KEY_RETURN && GUIEngine::ModalDialog::isADialogActive()) + { + GUIEngine::ModalDialog::onEnterPressed(); + } if (action != PA_FIRST) { @@ -364,6 +367,7 @@ // ... when in menus else { + // reset timer when released if (abs(value) == 0 && (/*type == Input::IT_KEYBOARD ||*/ type == Input::IT_STICKBUTTON)) { @@ -390,7 +394,7 @@ } } } - else if(type == Input::IT_KEYBOARD) + else if (type == Input::IT_KEYBOARD) { // keyboard press not handled by device manager / bindings. Check static bindings... handleStaticAction( btnID, value ); @@ -557,7 +561,7 @@ #endif // block events in all modes but initial menus (except in text boxes to allow typing, and except in modal dialogs in-game) - if (getDeviceList()->playerAssignMode() != NO_ASSIGN && !GUIEngine::isWithinATextBox() && + if (getDeviceList()->getAssignMode() != NO_ASSIGN && !GUIEngine::isWithinATextBox() && (!GUIEngine::ModalDialog::isADialogActive() && StateManager::get()->getGameState() == GUIEngine::GAME)) { return EVENT_BLOCK; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-28 18:13:32
|
Revision: 4357 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4357&view=rev Author: auria Date: 2009-12-28 18:13:24 +0000 (Mon, 28 Dec 2009) Log Message: ----------- Implemented adding keyboard configs through the GUI Modified Paths: -------------- main/trunk/src/input/device_manager.cpp main/trunk/src/input/device_manager.hpp main/trunk/src/states_screens/dialogs/add_device_dialog.cpp main/trunk/src/states_screens/options_screen_input.cpp main/trunk/src/states_screens/options_screen_input.hpp Modified: main/trunk/src/input/device_manager.cpp =================================================================== --- main/trunk/src/input/device_manager.cpp 2009-12-27 19:25:41 UTC (rev 4356) +++ main/trunk/src/input/device_manager.cpp 2009-12-28 18:13:24 UTC (rev 4357) @@ -166,6 +166,14 @@ m_keyboards.push_back(d); } // ----------------------------------------------------------------------------- +void DeviceManager::addEmptyKeyboard() +{ + KeyboardConfig* newConf = new KeyboardConfig(); + m_keyboard_configs.push_back(newConf); + m_keyboards.push_back( new KeyboardDevice(newConf) ); +} + +// ----------------------------------------------------------------------------- void DeviceManager::addGamepad(GamePadDevice* d) { m_gamepads.push_back(d); Modified: main/trunk/src/input/device_manager.hpp =================================================================== --- main/trunk/src/input/device_manager.hpp 2009-12-27 19:25:41 UTC (rev 4356) +++ main/trunk/src/input/device_manager.hpp 2009-12-28 18:13:24 UTC (rev 4357) @@ -86,6 +86,7 @@ bool getConfigForGamepad(const int sdl_id, GamepadConfig **config); // ---- Keyboard(s) ---- + void addEmptyKeyboard(); void addKeyboard(KeyboardDevice* d); int getKeyboardConfigAmount() const { return m_keyboard_configs.size(); } KeyboardDevice* getKeyboard(const int i) { return m_keyboards.get(i); } Modified: main/trunk/src/states_screens/dialogs/add_device_dialog.cpp =================================================================== --- main/trunk/src/states_screens/dialogs/add_device_dialog.cpp 2009-12-27 19:25:41 UTC (rev 4356) +++ main/trunk/src/states_screens/dialogs/add_device_dialog.cpp 2009-12-28 18:13:24 UTC (rev 4357) @@ -19,8 +19,11 @@ #include "config/player.hpp" #include "guiengine/engine.hpp" #include "guiengine/widget.hpp" +#include "input/device_manager.hpp" +#include "input/input_manager.hpp" #include "states_screens/dialogs/add_device_dialog.hpp" #include "states_screens/options_screen_players.hpp" +#include "states_screens/options_screen_input.hpp" #include "states_screens/state_manager.hpp" #include "utils/string_utils.hpp" #include "utils/translation.hpp" @@ -92,17 +95,18 @@ if (eventSource == "cancel") { - // irrLicht is too stupid to remove focus from deleted widgets - // so do it by hand - //GUIEngine::getGUIEnv()->removeFocus( textCtrl->getIrrlichtElement() ); - //GUIEngine::getGUIEnv()->removeFocus( m_irrlicht_window ); - ModalDialog::dismiss(); return GUIEngine::EVENT_BLOCK; } else if (eventSource == "addkeyboard") { - // TODO + input_manager->getDeviceList()->addEmptyKeyboard(); + input_manager->getDeviceList()->serialize(); + ModalDialog::dismiss(); + + ((OptionsScreenInput*)GUIEngine::getCurrentScreen())->rebuildDeviceList(); + + return GUIEngine::EVENT_BLOCK; } return GUIEngine::EVENT_LET; Modified: main/trunk/src/states_screens/options_screen_input.cpp =================================================================== --- main/trunk/src/states_screens/options_screen_input.cpp 2009-12-27 19:25:41 UTC (rev 4356) +++ main/trunk/src/states_screens/options_screen_input.cpp 2009-12-28 18:13:24 UTC (rev 4357) @@ -89,6 +89,46 @@ } // ----------------------------------------------------------------------------- + +void OptionsScreenInput::buildDeviceList() +{ + DynamicRibbonWidget* devices = this->getWidget<DynamicRibbonWidget>("devices"); + assert( devices != NULL ); + + const int keyboard_config_count = input_manager->getDeviceList()->getKeyboardConfigAmount(); + + for (int i=0; i<keyboard_config_count; i++) + { + //KeyboardConfig *config = input_manager->getDeviceList()->getKeyboardConfig(i); + + std::ostringstream kbname; + kbname << "keyboard" << i; + const std::string internal_name = kbname.str(); + + + devices->addItem(StringUtils::insertValues(_("Keyboard %i"), i), internal_name, "/gui/keyboard.png"); + } + + const int gpad_config_count = input_manager->getDeviceList()->getGamePadConfigAmount(); + + for (int i = 0; i < gpad_config_count; i++) + { + GamepadConfig *config = input_manager->getDeviceList()->getGamepadConfig(i); + // Don't display the configuration if a matching device is not available + if (config->isInUse()) + { + const irr::core::stringw name = config->getName().c_str(); + + std::ostringstream gpname; + gpname << "gamepad" << i; + const std::string internal_name = gpname.str(); + + devices->addItem(name, internal_name, "/gui/gamepad.png"); + } + } +} + +// ----------------------------------------------------------------------------- void OptionsScreenInput::init() { RibbonWidget* ribbon = this->getWidget<RibbonWidget>("options_choice"); @@ -100,40 +140,8 @@ if (!this->m_inited) { - const int keyboard_config_count = input_manager->getDeviceList()->getKeyboardConfigAmount(); - - for (int i=0; i<keyboard_config_count; i++) - { - //KeyboardConfig *config = input_manager->getDeviceList()->getKeyboardConfig(i); - - std::ostringstream kbname; - kbname << "keyboard" << i; - const std::string internal_name = kbname.str(); - - - devices->addItem(StringUtils::insertValues(_("Keyboard %i"), i), internal_name, "/gui/keyboard.png"); - } - - const int gpad_config_count = input_manager->getDeviceList()->getGamePadConfigAmount(); - - for (int i = 0; i < gpad_config_count; i++) - { - GamepadConfig *config = input_manager->getDeviceList()->getGamepadConfig(i); - // Don't display the configuration if a matching device is not available - if (config->isInUse()) - { - const irr::core::stringw name = config->getName().c_str(); - - std::ostringstream gpname; - gpname << "gamepad" << i; - const std::string internal_name = gpname.str(); - - devices->addItem(name, internal_name, "/gui/gamepad.png"); - } - } - + buildDeviceList(); this->m_inited = true; - } devices->updateItemDisplay(); @@ -143,6 +151,18 @@ } // ----------------------------------------------------------------------------- + +void OptionsScreenInput::rebuildDeviceList() +{ + DynamicRibbonWidget* devices = this->getWidget<DynamicRibbonWidget>("devices"); + assert( devices != NULL ); + + devices->clearItems(); + buildDeviceList(); + devices->updateItemDisplay(); +} + +// ----------------------------------------------------------------------------- static PlayerAction binding_to_set; static std::string binding_to_set_button; Modified: main/trunk/src/states_screens/options_screen_input.hpp =================================================================== --- main/trunk/src/states_screens/options_screen_input.hpp 2009-12-27 19:25:41 UTC (rev 4356) +++ main/trunk/src/states_screens/options_screen_input.hpp 2009-12-28 18:13:24 UTC (rev 4357) @@ -31,9 +31,10 @@ class OptionsScreenInput : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OptionsScreenInput> { + OptionsScreenInput(); + void updateInputButtons(DeviceConfig* config); - - OptionsScreenInput(); + void buildDeviceList(); public: friend class GUIEngine::ScreenSingleton<OptionsScreenInput>; @@ -41,7 +42,8 @@ void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); void gotSensedInput(Input* sensedInput); - + void rebuildDeviceList(); + void init(); void tearDown(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2009-12-30 00:27:39
|
Revision: 4362 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4362&view=rev Author: hikerstk Date: 2009-12-30 00:08:20 +0000 (Wed, 30 Dec 2009) Log Message: ----------- First version of improved track object support - not fully functional yet, but should allow for movable and static track objects. Also fixes problems with incorrect radius for spheres. Modified Paths: -------------- main/trunk/src/Makefile.am main/trunk/src/animations/animation_base.cpp main/trunk/src/animations/animation_base.hpp main/trunk/src/animations/animation_manager.cpp main/trunk/src/animations/billboard_animation.cpp main/trunk/src/animations/billboard_animation.hpp main/trunk/src/animations/three_d_animation.cpp main/trunk/src/animations/three_d_animation.hpp main/trunk/src/ide/vc9/supertuxkart.vcproj main/trunk/src/io/xml_node.cpp main/trunk/src/physics/physical_object.cpp main/trunk/src/physics/physical_object.hpp main/trunk/src/tracks/track.cpp main/trunk/src/tracks/track.hpp Added Paths: ----------- main/trunk/src/tracks/track_object.cpp main/trunk/src/tracks/track_object.hpp main/trunk/src/tracks/track_object_manager.cpp main/trunk/src/tracks/track_object_manager.hpp Modified: main/trunk/src/Makefile.am =================================================================== --- main/trunk/src/Makefile.am 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/Makefile.am 2009-12-30 00:08:20 UTC (rev 4362) @@ -324,6 +324,10 @@ tracks/track.hpp \ tracks/track_manager.cpp \ tracks/track_manager.hpp \ + tracks/track_object.cpp \ + tracks/track_object.hpp \ + tracks/track_object_manager.cpp \ + tracks/track_object_manager.hpp \ utils/constants.hpp \ utils/coord.hpp \ utils/no_copy.hpp \ Modified: main/trunk/src/animations/animation_base.cpp =================================================================== --- main/trunk/src/animations/animation_base.cpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/animations/animation_base.cpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -24,8 +24,11 @@ #include "io/file_manager.hpp" #include "io/xml_node.hpp" -AnimationBase::AnimationBase(const XMLNode &node, float fps) +AnimationBase::AnimationBase(const XMLNode &node) + : TrackObject(node) { + float fps=25; + node.get("fps", &fps); for(unsigned int i=0; i<node.getNumNodes(); i++) { Ipo *ipo = new Ipo(*node.getNode(i), fps); Modified: main/trunk/src/animations/animation_base.hpp =================================================================== --- main/trunk/src/animations/animation_base.hpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/animations/animation_base.hpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -25,48 +25,50 @@ #include "irrlicht.h" using namespace irr; +#include "tracks/track_object.hpp" + class XMLNode; class Ipo; /** A base class for all animations. */ -class AnimationBase +class AnimationBase : public TrackObject { private: - /** Two types of animations: cyclic ones that play all the time, and - * one time only (which might get triggered more than once). */ - enum AnimTimeType { ATT_CYCLIC, ATT_CYCLIC_ONCE } m_anim_type; + /** Two types of animations: cyclic ones that play all the time, and + * one time only (which might get triggered more than once). */ + enum AnimTimeType { ATT_CYCLIC, ATT_CYCLIC_ONCE } m_anim_type; - /** True if the animation is currently playing. */ - bool m_playing; + /** True if the animation is currently playing. */ + bool m_playing; - /** For one time animations: start time. */ - float m_start; + /** For one time animations: start time. */ + float m_start; - /** For cyclic animations: duration of the cycle. */ - float m_cycle_length; + /** For cyclic animations: duration of the cycle. */ + float m_cycle_length; - /** The current time in the cycle of a cyclic animation. */ - float m_current_time; + /** The current time in the cycle of a cyclic animation. */ + float m_current_time; - /** The inital position of this object. */ - core::vector3df m_initial_xyz; - - /** The initial rotation of this object. */ - core::vector3df m_initial_hpr; + /** The inital position of this object. */ + core::vector3df m_initial_xyz; + + /** The initial rotation of this object. */ + core::vector3df m_initial_hpr; protected: - /** All IPOs for this animation. */ - std::vector<Ipo*> m_all_ipos; + /** All IPOs for this animation. */ + std::vector<Ipo*> m_all_ipos; public: - AnimationBase(const XMLNode &node, float fps); + AnimationBase(const XMLNode &node); virtual ~AnimationBase(); - virtual void update(float dt, core::vector3df *xyz, core::vector3df *hpr); - /** This needs to be implemented by the inheriting classes. It is called - * once per frame from the track. */ - virtual void update(float dt) = 0; - void setInitialTransform(const core::vector3df &xyz, - const core::vector3df &hpr); - void reset(); + virtual void update(float dt, core::vector3df *xyz, core::vector3df *hpr); + /** This needs to be implemented by the inheriting classes. It is called + * once per frame from the track. */ + virtual void update(float dt) = 0; + void setInitialTransform(const core::vector3df &xyz, + const core::vector3df &hpr); + void reset(); }; // AnimationBase Modified: main/trunk/src/animations/animation_manager.cpp =================================================================== --- main/trunk/src/animations/animation_manager.cpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/animations/animation_manager.cpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -31,12 +31,10 @@ { const XMLNode *anim_node = node.getNode(i); std::string type = anim_node->getName(); - float fps=25; - anim_node->get("fps", &fps); if(type=="anim_billboard") - m_all_animations.push_back(new BillboardAnimation(track, *anim_node, fps)); + m_all_animations.push_back(new BillboardAnimation(track, *anim_node)); else if(type=="animations-IPO") - m_all_animations.push_back(new ThreeDAnimation(track, *anim_node, fps)); + m_all_animations.push_back(new ThreeDAnimation(track, *anim_node)); else fprintf(stderr, "Unknown animation type '%s' - ignored.\n", type.c_str()); Modified: main/trunk/src/animations/billboard_animation.cpp =================================================================== --- main/trunk/src/animations/billboard_animation.cpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/animations/billboard_animation.cpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -23,8 +23,8 @@ /** A 2d billboard animation. */ BillboardAnimation::BillboardAnimation(const Track &track_name, - const XMLNode &node, float fps) - : AnimationBase(node, fps) + const XMLNode &node) + : AnimationBase(node) { } // BillboardAnimation Modified: main/trunk/src/animations/billboard_animation.hpp =================================================================== --- main/trunk/src/animations/billboard_animation.hpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/animations/billboard_animation.hpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -33,7 +33,7 @@ private: public: - BillboardAnimation(const Track &track, const XMLNode &node, float fps); + BillboardAnimation(const Track &track, const XMLNode &node); virtual ~BillboardAnimation(){} virtual void update(float dt); Modified: main/trunk/src/animations/three_d_animation.cpp =================================================================== --- main/trunk/src/animations/three_d_animation.cpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/animations/three_d_animation.cpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -34,27 +34,9 @@ #include "utils/constants.hpp" ThreeDAnimation::ThreeDAnimation(const Track &track, - const XMLNode &node, float fps) - : AnimationBase(node, fps) + const XMLNode &node) + : AnimationBase(node) { - std::string model_name; - node.get("obj", &model_name); - - std::string full_path = track.getTrackFile(model_name); - m_mesh = irr_driver->getAnimatedMesh(full_path); - if(!m_mesh) - { - fprintf(stderr, "Warning: node '%s' animated model '%s' not found, aborting.\n", - node.getName().c_str(), model_name.c_str()); - exit(-1); - } - m_animated_node = irr_driver->addAnimatedMesh(m_mesh); - core::vector3df xyz; - node.get("xyz", &xyz); - m_animated_node->setPosition(xyz); - core::vector3df hpr(0,0,0); - node.get("hpr", &hpr); - m_animated_node->setRotation(hpr); /** Save the initial position and rotation in the base animation object. */ setInitialTransform(m_animated_node->getPosition(), m_animated_node->getRotation()); @@ -76,7 +58,7 @@ // 1. Determine size of the object // ------------------------------- Vec3 min, max; - MeshTools::minMax3D(m_mesh, &min, &max); + MeshTools::minMax3D(m_animated_mesh, &min, &max); Vec3 extend = max-min; if(shape=="box") { @@ -130,8 +112,6 @@ delete m_body; delete m_motion_state; delete m_collision_shape; - irr_driver->removeNode(m_animated_node); - irr_driver->removeMesh(m_mesh); } // ~ThreeDAnimation // ---------------------------------------------------------------------------- Modified: main/trunk/src/animations/three_d_animation.hpp =================================================================== --- main/trunk/src/animations/three_d_animation.hpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/animations/three_d_animation.hpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -38,12 +38,6 @@ class ThreeDAnimation : public AnimationBase { private: - /** Mesh of this animation. */ - scene::IAnimatedMesh *m_mesh; - - /** The scene node for the model. */ - scene::IAnimatedMeshSceneNode *m_animated_node; - /** The bullet collision shape for the physics. */ btCollisionShape *m_collision_shape; @@ -59,8 +53,7 @@ void createPhysicsBody(const std::string &shape); public: - ThreeDAnimation(const Track &track, - const XMLNode &node, float fps); + ThreeDAnimation(const Track &track, const XMLNode &node); virtual ~ThreeDAnimation(); virtual void update(float dt); Modified: main/trunk/src/ide/vc9/supertuxkart.vcproj =================================================================== --- main/trunk/src/ide/vc9/supertuxkart.vcproj 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/ide/vc9/supertuxkart.vcproj 2009-12-30 00:08:20 UTC (rev 4362) @@ -653,6 +653,10 @@ > </File> <File + RelativePath="..\..\graphics\stars.cpp" + > + </File> + <File RelativePath="..\..\graphics\water_splash.cpp" > </File> @@ -752,6 +756,14 @@ RelativePath="..\..\tracks\track_manager.cpp" > </File> + <File + RelativePath="..\..\tracks\track_object.cpp" + > + </File> + <File + RelativePath="..\..\tracks\track_object_manager.cpp" + > + </File> </Filter> <Filter Name="replay" @@ -881,6 +893,10 @@ Name="states_screen" > <File + RelativePath="..\..\states_screens\arenas_screen.cpp" + > + </File> + <File RelativePath="..\..\states_screens\challenges.cpp" > </File> @@ -944,6 +960,10 @@ Name="dialogs" > <File + RelativePath="..\..\states_screens\dialogs\add_device_dialog.cpp" + > + </File> + <File RelativePath="..\..\states_screens\dialogs\enter_player_name_dialog.cpp" > </File> @@ -1463,6 +1483,10 @@ > </File> <File + RelativePath="..\..\graphics\stars.hpp" + > + </File> + <File RelativePath="..\..\graphics\water_splash.hpp" > </File> @@ -1522,6 +1546,14 @@ RelativePath="..\..\tracks\track_manager.hpp" > </File> + <File + RelativePath="..\..\tracks\track_object.hpp" + > + </File> + <File + RelativePath="..\..\tracks\track_object_manager.hpp" + > + </File> </Filter> <Filter Name="replay" @@ -1655,6 +1687,10 @@ Name="states_screens" > <File + RelativePath="..\..\states_screens\arenas_screen.hpp" + > + </File> + <File RelativePath="..\..\states_screens\challenges.hpp" > </File> @@ -1718,6 +1754,10 @@ Name="dialogs" > <File + RelativePath="..\..\states_screens\dialogs\add_device_dialog.hpp" + > + </File> + <File RelativePath="..\..\states_screens\dialogs\enter_player_name_dialog.hpp" > </File> Modified: main/trunk/src/io/xml_node.cpp =================================================================== --- main/trunk/src/io/xml_node.cpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/io/xml_node.cpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -177,14 +177,10 @@ // ---------------------------------------------------------------------------- int XMLNode::get(const std::string &attribute, core::vector3df *value) const { - std::string s = ""; - if(!get(attribute, &s)) return 0; + Vec3 xyz; + if(!get(attribute, &xyz)) return 0; - std::vector<std::string> v = StringUtils::split(s,' '); - if(v.size()!=3) return 0; - value->X = (float)atof(v[0].c_str()); - value->Y = (float)atof(v[1].c_str()); - value->Z = (float)atof(v[2].c_str()); + *value = xyz.toIrrVector(); return 1; } // get(vector3df) Modified: main/trunk/src/physics/physical_object.cpp =================================================================== --- main/trunk/src/physics/physical_object.cpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/physics/physical_object.cpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -21,6 +21,7 @@ #include <string> #include <vector> + #include "irrlicht.h" using namespace irr; @@ -35,43 +36,9 @@ #include "utils/string_utils.hpp" // ----------------------------------------------------------------------------- -PhysicalObject::PhysicalObject(const XMLNode *xml_node) +PhysicalObject::PhysicalObject(const XMLNode &xml_node) + : TrackObject(xml_node) { - std::string model_name; - const Track *track=RaceManager::getTrack(); - xml_node->get("model", &model_name); - std::string full_path = track->getTrackFile(model_name); - scene::IAnimatedMesh *obj = irr_driver->getAnimatedMesh(full_path); - if(!obj) - { - // If the model isn't found in the track directory, look - // in STK's model directory. - full_path = file_manager->getModelFile(model_name); - obj = irr_driver->getAnimatedMesh(full_path); - if(!obj) - { - fprintf(stderr, "Warning: '%s' in '%s' not found and is ignored.\n", - xml_node->getName().c_str(), model_name.c_str()); - return; - } // if(!obj) - } - m_mesh = obj->getMesh(0); - m_node = irr_driver->addMesh(m_mesh); - //m_node->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL); - Vec3 xyz(0,0,0); - int result = xml_node->get("xyz", &xyz); - xyz.setZ(RaceManager::getTrack()->getTerrainHeight(xyz)); - Vec3 hpr(0,0,0); - result = xml_node->getHPR(&hpr); - if(!XMLNode::hasP(result) || - !XMLNode::hasR(result)) // Needs perhaps pitch and roll - { - } - m_node->setPosition(xyz.toIrrVector()); - m_node->setRotation(hpr.toIrrHPR()); - m_init_pos.setIdentity(); - m_init_pos.setOrigin(xyz); - m_node->setMaterialFlag(video::EMF_LIGHTING, false); m_shape = NULL; m_body = NULL; @@ -80,21 +47,24 @@ m_radius = -1; std::string shape; - xml_node->get("mass", &m_mass ); - xml_node->get("radius", &m_radius); - xml_node->get("shape", &shape ); + xml_node.get("mass", &m_mass ); + xml_node.get("radius", &m_radius); + xml_node.get("shape", &shape ); m_body_type = MP_NONE; if (shape=="cone" ) m_body_type = MP_CONE; else if(shape=="box" ) m_body_type = MP_BOX; else if(shape=="sphere" ) m_body_type = MP_SPHERE; + + m_init_pos.setIdentity(); + m_init_pos.setOrigin(m_init_xyz); + } // PhysicalObject // ----------------------------------------------------------------------------- PhysicalObject::~PhysicalObject() { RaceManager::getWorld()->getPhysics()->removeBody(m_body); - irr_driver->removeNode(m_node); delete m_body; delete m_motion_state; delete m_shape; @@ -105,12 +75,12 @@ */ void PhysicalObject::init() { - assert(m_mesh); + assert(m_animated_mesh); // 1. Determine size of the object // ------------------------------- Vec3 min, max; - MeshTools::minMax3D(m_mesh, &min, &max); + MeshTools::minMax3D(m_animated_mesh, &min, &max); Vec3 extend = max-min; // Adjust the mesth of the graphical object so that its center is where it // is in bullet (usually at (0,0,0)). It can be changed in the case clause @@ -128,13 +98,8 @@ case MP_SPHERE: { if(m_radius<0) { - float max_axis = std::max(extend.getX(), extend.getY()); - max_axis = std::max(max_axis, extend.getZ()); - // Worst case radius: if the actual shape is more like - // a box, the actual radius can be up to sqrt(3) larger - // than the maxium axis size: - // sqrt(x*x+y*y+z*z) <= sqrt(3*max_axis*max_axis) - m_radius = sqrt(3.0f)*max_axis; + m_radius = std::max(extend.getX(), extend.getY()); + m_radius = 0.5f*std::max(m_radius, extend.getZ()); } m_shape = new btSphereShape(m_radius); break; @@ -151,7 +116,7 @@ irr_driver->getSceneManager()->getMeshManipulator(); core::matrix4 transform(core::matrix4::EM4CONST_IDENTITY); // transform.setTranslation(offset_from_center.toIrrVector()); - mesh_manipulator->transformMesh(m_mesh, transform); + mesh_manipulator->transformMesh(m_animated_mesh, transform); // 2. Create the rigid object // -------------------------- @@ -183,12 +148,12 @@ m_body->setCenterOfMassTransform(m_init_pos); c.setXYZ(m_init_pos.getOrigin()); } - m_node->setPosition(c.getXYZ().toIrrVector()); + m_animated_node->setPosition(c.getXYZ().toIrrVector()); btQuaternion q=t.getRotation(); core::quaternion qirr(q.getX(), q.getZ(), q.getY(), -q.getW()); core::vector3df r; qirr.toEuler(r); - m_node->setRotation(r*RAD_TO_DEGREE); + m_animated_node->setRotation(r*RAD_TO_DEGREE); return; } // update Modified: main/trunk/src/physics/physical_object.hpp =================================================================== --- main/trunk/src/physics/physical_object.hpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/physics/physical_object.hpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -22,18 +22,15 @@ #include <string> -#include "irrlicht.h" -using namespace irr; - #include "btBulletDynamicsCommon.h" #include "physics/user_pointer.hpp" +#include "tracks/track_object.hpp" #include "utils/vec3.hpp" -class scene::IAnimatedMesh; class XMLNode; -class PhysicalObject +class PhysicalObject : public TrackObject { public: enum bodyTypes {MP_NONE, MP_CONE, MP_BOX, MP_SPHERE}; @@ -54,14 +51,16 @@ UserPointer m_user_pointer; /** This is the initial position of the object for the physics. */ btTransform m_init_pos; - /** The irrlicht mesh for this object. */ - scene::IMesh *m_mesh; - /** The irrlicht scene node this object is attached to. */ - scene::ISceneNode *m_node; - /** Radius of the object - this obviously depends on the actual shape. */ + + /** Radius of the object - this obviously depends on the actual shape. + * As a default the radius is being determined from the shape of the + * mesh, but in somce cases that could lead to incorrect results + * (if the mesh does not closely resemble a sphere, see init() for + * details, but is supposed to be a sphere). In this case the radius + * can be set in the scene file. */ float m_radius; public: - PhysicalObject (const XMLNode *node); + PhysicalObject (const XMLNode &node); virtual ~PhysicalObject (); void update (float dt); void init (); Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/tracks/track.cpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -50,6 +50,7 @@ #include "tracks/check_manager.hpp" #include "tracks/quad_graph.hpp" #include "tracks/quad_set.hpp" +#include "tracks/track_object_manager.hpp" #include "utils/constants.hpp" #include "utils/string_utils.hpp" #include "utils/translation.hpp" @@ -96,12 +97,12 @@ void Track::reset() { m_ambient_color = m_default_ambient_color; - if(m_animation_manager) - m_animation_manager->reset(); + if(m_animation_manager) + m_animation_manager->reset(); if(m_check_manager) m_check_manager->reset(*this); item_manager->reset(); - + m_track_object_manager->reset(); } // reset //----------------------------------------------------------------------------- @@ -138,12 +139,11 @@ m_animation_manager = NULL; } - for(unsigned int i=0; i<m_physical_objects.size(); i++) - { - delete m_physical_objects[i]; - } - m_physical_objects.clear(); + delete m_track_object_manager; + delete m_track_object_manager; + m_track_object_manager = NULL; + irr_driver->removeNode(m_sun); delete m_non_collision_mesh; @@ -435,9 +435,15 @@ for(unsigned int i=0; i<track_node->getNumNodes(); i++) { const XMLNode *n=track_node->getNode(i); - // The have already been handled + // Animated textures have already been handled if(n->getName()=="animated-texture") continue; - assert(n->getName()=="object"); + // Only "object" entries are allowed now inside of the model tag + if(n->getName()!="static-object") + { + fprintf(stderr, "Incorrect tag '%s' inside <model> of scene file - ignored\n", + n->getName().c_str()); + continue; + } model_name=""; n->get("model", &model_name); full_path = m_root+"/"+model_name; @@ -450,11 +456,12 @@ } m_all_meshes.push_back(a_mesh); scene::ISceneNode *scene_node = irr_driver->addAnimatedMesh(a_mesh); - core::vector3df xyz(0,0,0); + //core::vector3df xyz(0,0,0); + Vec3 xyz(0,0,0); n->get("xyz", &xyz); core::vector3df hpr(0,0,0); n->get("hpr", &hpr); - scene_node->setPosition(xyz); + scene_node->setPosition(xyz.toIrrVector()); scene_node->setRotation(hpr); handleAnimatedTextures(scene_node, *n); m_all_nodes.push_back(scene_node); @@ -525,18 +532,16 @@ */ void Track::update(float dt) { + m_track_object_manager->update(dt); + for(unsigned int i=0; i<m_animated_textures.size(); i++) { m_animated_textures[i]->update(dt); } - for(unsigned int i=0; i<m_physical_objects.size(); i++) - { - m_physical_objects[i]->update(dt); - } - if(m_animation_manager) - m_animation_manager->update(dt); - if(m_check_manager) - m_check_manager->update(dt); + if(m_animation_manager) + m_animation_manager->update(dt); + if(m_check_manager) + m_check_manager->update(dt); item_manager->update(dt); } // update @@ -550,11 +555,7 @@ */ void Track::handleExplosion(const Vec3 &pos, const PhysicalObject *obj) const { - for(std::vector<PhysicalObject*>::const_iterator i=m_physical_objects.begin(); - i!=m_physical_objects.end(); i++) - { - (*i)->handleExplosion(pos, obj==(*i)); - } + m_track_object_manager->handleExplosion(pos, obj); } // handleExplosion // ---------------------------------------------------------------------------- @@ -567,17 +568,7 @@ node.get("model", &model_name); std::string full_path = m_root+"/"+model_name; - //scene::IMesh *mesh = irr_driver->getMesh(full_path); scene::IAnimatedMesh *mesh = irr_driver->getSceneManager()->getMesh(full_path.c_str()); - //irr_driver->getSceneManager()->addWaterSurfaceSceneNode(mesh->getMesh(0)); - //scene::IAnimatedMesh *mesh = irr_driver->getSceneManager()->addHillPlaneMesh("myHill", - // core::dimension2d<f32>(20,20), - // core::dimension2d<u32>(40,40), 0, 0, - // core::dimension2d<f32>(0,0), - // core::dimension2d<f32>(10,10)); - - //scene::SMeshBuffer b(*(scene::SMeshBuffer*)(mesh->getMesh(0)->getMeshBuffer(0))); - //scene::SMeshBuffer* buffer = new scene::SMeshBuffer(*(scene::SMeshBuffer*)(mesh->getMeshBuffer(0))); float wave_height = 2.0f; float wave_speed = 300.0f; @@ -616,8 +607,9 @@ */ void Track::loadTrackModel(unsigned int mode_id) { - m_has_final_camera = false; - m_is_arena = false; + m_has_final_camera = false; + m_is_arena = false; + m_track_object_manager = new TrackObjectManager(); item_manager->setStyle(); // Load the graph only now: this function is called from world, after @@ -662,9 +654,9 @@ const std::string name = node->getName(); // The track object was already converted before the loop if(name=="track") continue; - if(name=="physical-object") + if(name=="object") { - m_physical_objects.push_back(new PhysicalObject(node)); + m_track_object_manager->add(*node, *this); } else if(name=="water") { @@ -754,12 +746,8 @@ } delete root; - // Init all physical objects - for(std::vector<PhysicalObject*>::const_iterator i=m_physical_objects.begin(); - i!=m_physical_objects.end(); i++) - { - (*i)->init(); - } + // Init all track objects + m_track_object_manager->init(); // Sky dome and boxes support // -------------------------- Modified: main/trunk/src/tracks/track.hpp =================================================================== --- main/trunk/src/tracks/track.hpp 2009-12-29 23:59:51 UTC (rev 4361) +++ main/trunk/src/tracks/track.hpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -41,13 +41,14 @@ #include "tracks/quad_graph.hpp" #include "utils/vec3.hpp" +class AnimationManager; +class BezierCurve; +class CheckManager; +class MovingTexture; +class PhysicalObject; +class TrackObjectManager; class TriangleMesh; -class MovingTexture; class XMLNode; -class PhysicalObject; -class BezierCurve; -class AnimationManager; -class CheckManager; class Track { @@ -103,8 +104,8 @@ /** The list of all animated textures. */ std::vector<MovingTexture*> m_animated_textures; - /** List of all physical objects. */ - std::vector<PhysicalObject*> m_physical_objects; + /** Manager for all track objects. */ + TrackObjectManager *m_track_object_manager; /** If a sky dome is used, the number of horizontal segments * the sphere should be divided in. */ Added: main/trunk/src/tracks/track_object.cpp =================================================================== --- main/trunk/src/tracks/track_object.cpp (rev 0) +++ main/trunk/src/tracks/track_object.cpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -0,0 +1,129 @@ +// $Id: track_object.cpp 4308 2009-12-17 00:22:29Z hikerstk $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2009 Joerg Henrichs +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "tracks/track_object.hpp" + +#include "graphics/irr_driver.hpp" +#include "io/file_manager.hpp" +#include "io/xml_node.hpp" +#include "tracks/track.hpp" + +/** A track object: any additional object on the track. This object implements + * a graphics-only representation, i.e. there is no physical representation. + * Derived classes can implement a physical representation (see + * physics/physical_object) or animations. + * \param xml_node The xml node from which the initial data is taken. This is + * for now: initial position, initial rotation, name of the + * model, enable/disable status, timer information. + */ +TrackObject::TrackObject(const XMLNode &xml_node) +{ + + std::string model_name; + xml_node.get("model", &model_name); + std::string full_path = RaceManager::getTrack()->getTrackFile(model_name); + m_animated_mesh = irr_driver->getAnimatedMesh(full_path); + if(!m_animated_mesh) + { + // If the model isn't found in the track directory, look + // in STK's model directory. + full_path = file_manager->getModelFile(model_name); + m_animated_mesh = irr_driver->getAnimatedMesh(full_path); + if(!m_animated_mesh) + { + fprintf(stderr, "Warning: '%s' in '%s' not found and is ignored.\n", + xml_node.getName().c_str(), model_name.c_str()); + return; + } // if(!m_animated_mesh) + } + m_animated_node = irr_driver->addAnimatedMesh(m_animated_mesh); + + // Get the information from the xml node. + m_enabled = true; + xml_node.get("enabled", &m_enabled); + + m_is_looped = false; + xml_node.get("looped", &m_is_looped); + + m_frame_start = m_animated_node->getStartFrame(); + xml_node.get("frame-start", &m_frame_start); + + m_frame_end = m_animated_node->getEndFrame(); + xml_node.get("frame-end", &m_frame_end); + + if(!m_enabled) + m_animated_node->setVisible(false); + + m_init_xyz = Vec3(0,0,0); + int result = xml_node.get("xyz", &m_init_xyz); + m_init_hpr = Vec3(0,0,0); + result = xml_node.get("hpr", &m_init_hpr); + if(!XMLNode::hasP(result) || + !XMLNode::hasR(result)) // Needs perhaps pitch and roll + { + } + m_animated_node->setPosition(m_init_xyz.toIrrVector()); + m_animated_node->setRotation(m_init_hpr.toIrrHPR() ); + m_animated_node->setMaterialFlag(video::EMF_LIGHTING, false); +} // TrackObject + +// ---------------------------------------------------------------------------- +TrackObject::~TrackObject() +{ + irr_driver->removeNode(m_animated_node); + irr_driver->removeMesh(m_animated_mesh); +} // ~TrackObject + +// ---------------------------------------------------------------------------- +/** Initialises an object before a race starts. + */ +void TrackObject::reset() +{ + m_animated_node->setPosition(m_init_xyz.toIrrVector()); + m_animated_node->setRotation(m_init_hpr.toIrrHPR()); + m_animated_node->setLoopMode(false); + + if(m_is_looped) + { + m_animated_node->setFrameLoop(m_frame_start, m_frame_end); + m_animated_node->setLoopMode(true); + } +} // reset +// ---------------------------------------------------------------------------- +/** Enables or disables this object. This affects the visibility, i.e. + * disabled objects will not be displayed anymore. + * \param mode Enable (true) or disable (false) this object. + */ +void TrackObject::setEnable(bool mode) +{ + m_enabled = mode; + m_animated_node->setVisible(m_enabled); +} // setEnable +// ---------------------------------------------------------------------------- +/** This function is called from irrlicht when a (non-looped) animation ends. + */ +void TrackObject::OnAnimationEnd(scene::IAnimatedMeshSceneNode* node) +{ +} // OnAnimationEnd + +// ---------------------------------------------------------------------------- +void TrackObject::update(float dt) +{ +} // update +// ---------------------------------------------------------------------------- Added: main/trunk/src/tracks/track_object.hpp =================================================================== --- main/trunk/src/tracks/track_object.hpp (rev 0) +++ main/trunk/src/tracks/track_object.hpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -0,0 +1,84 @@ +// $Id: track_object.hpp 4308 2009-12-17 00:22:29Z hikerstk $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2009 Joerg Henrichs +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef HEADER_TRACK_OBJECT_HPP +#define HEADER_TRACK_OBJECT_HPP + +#include "irrlicht.h" +using namespace irr; + +#include "utils/vec3.hpp" + + +class XMLNode; + +class TrackObject : public scene::IAnimationEndCallBack +{ +//public: + // The different type of track objects: physical objects, graphical + // objects (without a physical representation) - the latter might be + // eye candy (to reduce work for physics), ... + //enum TrackObjectType {TO_PHYSICAL, TO_GRAPHICAL}; + +private: + /** True if the object is currently being displayed. */ + bool m_enabled; + + /** >0 if it is active for a timer based object. */ + float m_timer; + + /** True if it is a looped animation. */ + bool m_is_looped; + + /** Start frame of the animation to be played. */ + unsigned int m_frame_start; + + /** End frame of the animation to be played. */ + unsigned int m_frame_end; + + virtual void OnAnimationEnd(scene::IAnimatedMeshSceneNode* node); + +protected: + /** The irrlicht mesh for this object. */ + scene::IAnimatedMesh *m_animated_mesh; + + /** The irrlicht scene node this object is attached to. */ + scene::IAnimatedMeshSceneNode *m_animated_node; + + /** The initial XYZ position of the object. */ + Vec3 m_init_xyz; + + /** The initial hpr of the object. */ + Vec3 m_init_hpr; + +public: + TrackObject(const XMLNode &xml_node); + ~TrackObject(); + virtual void update(float dt); + virtual void reset(); + /** To finish object constructions. Called after the track model + * is ready. */ + virtual void init() {}; + /** Called when an explosion happens. As a default does nothing, will + * e.g. be overwritten by physical objects etc. */ + virtual void handleExplosion(const Vec3& pos, bool directHit) {}; + void setEnable(bool mode); +}; // TrackObject + +#endif Property changes on: main/trunk/src/tracks/track_object.hpp ___________________________________________________________________ Added: svn:executable + * Added: main/trunk/src/tracks/track_object_manager.cpp =================================================================== --- main/trunk/src/tracks/track_object_manager.cpp (rev 0) +++ main/trunk/src/tracks/track_object_manager.cpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -0,0 +1,103 @@ +// $Id: track_object_manager.cpp 4308 2009-12-17 00:22:29Z hikerstk $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2009 Joerg Henrichs +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "tracks/track_object_manager.hpp" + +#include "animations/three_d_animation.hpp" +#include "io/xml_node.hpp" +#include "physics/physical_object.hpp" +#include "tracks/track_object.hpp" + +TrackObjectManager::TrackObjectManager() +{ +} // TrackObjectManager + +// ---------------------------------------------------------------------------- +/** Adds an object to the track object manager. The type to add is specified + * in the xml_node. + */ +void TrackObjectManager::add(const XMLNode &xml_node, const Track &track) +{ + std::string type; + xml_node.get("type", &type); + if(type=="movable") + { + m_all_objects.push_back(new PhysicalObject(xml_node)); + } + else if(type=="animation") + { + m_all_objects.push_back(new ThreeDAnimation(track, xml_node)); + } + else + { + fprintf(stderr, "Unknown track object: '%s' - ignored.\n", type.c_str()); + } +} // add + +// ---------------------------------------------------------------------------- +/** Initialises all track objects. + */ +void TrackObjectManager::init() +{ + std::vector<TrackObject*>::iterator i; + for(i=m_all_objects.begin(); i!=m_all_objects.end(); i++) + { + (*i)->init(); + } +} // reset +// ---------------------------------------------------------------------------- +/** Initialises all track objects. + */ +void TrackObjectManager::reset() +{ + std::vector<TrackObject*>::iterator i; + for(i=m_all_objects.begin(); i!=m_all_objects.end(); i++) + { + (*i)->reset(); + } +} // reset + +// ---------------------------------------------------------------------------- +/** Handles an explosion, i.e. it makes sure that all physical objects are + * affected accordingly. + * \param pos Position of the explosion. + * \param obj If the hit was a physical object, this object will be affected + * more. Otherwise this is NULL. + */ + +void TrackObjectManager::handleExplosion(const Vec3 &pos, const PhysicalObject *mp) const +{ + for(std::vector<TrackObject*>::const_iterator i=m_all_objects.begin(); + i!=m_all_objects.end(); i++) + { + (*i)->handleExplosion(pos, mp==(*i)); + } +} // handleExplosion + +// ---------------------------------------------------------------------------- +void TrackObjectManager::update(float dt) +{ + for(std::vector<TrackObject*>::const_iterator i=m_all_objects.begin(); + i!=m_all_objects.end(); i++) + { + (*i)->update(dt); + } +} // update + +// ---------------------------------------------------------------------------- Added: main/trunk/src/tracks/track_object_manager.hpp =================================================================== --- main/trunk/src/tracks/track_object_manager.hpp (rev 0) +++ main/trunk/src/tracks/track_object_manager.hpp 2009-12-30 00:08:20 UTC (rev 4362) @@ -0,0 +1,48 @@ +// $Id: track_object_manager.hpp 4308 2009-12-17 00:22:29Z hikerstk $ +// +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2009 Joerg Henrichs +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef HEADER_TRACK_OBJECT_MANAGER_HPP +#define HEADER_TRACK_OBJECT_MANAGER_HPP + +#include <vector> + +class PhysicalObject; +class Track; +class TrackObject; +class Vec3; +class XMLNode; + +class TrackObjectManager +{ +public: + // The different type of track objects: physical objects, graphical + // objects (without a physical representation) - the latter might be + // eye candy (to reduce work for physics), ... + enum TrackObjectType {TO_PHYSICAL, TO_GRAPHICAL}; + std::vector<TrackObject*> m_all_objects; +public: + TrackObjectManager(); + void add(const XMLNode &xml_node, const Track &track); + void update(float dt); + void handleExplosion(const Vec3 &pos, const PhysicalObject *mp) const; + void reset(); + void init(); +}; // class TrackObjectManager + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-30 17:43:14
|
Revision: 4365 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4365&view=rev Author: auria Date: 2009-12-30 17:43:06 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Fixed rare focus issue in modal dialogs, and generally improved code Modified Paths: -------------- main/trunk/src/guiengine/modaldialog.cpp main/trunk/src/guiengine/screen.cpp main/trunk/src/states_screens/dialogs/track_info_dialog.cpp Modified: main/trunk/src/guiengine/modaldialog.cpp =================================================================== --- main/trunk/src/guiengine/modaldialog.cpp 2009-12-30 17:09:58 UTC (rev 4364) +++ main/trunk/src/guiengine/modaldialog.cpp 2009-12-30 17:43:06 UTC (rev 4365) @@ -117,12 +117,15 @@ Widget* ModalDialog::getLastWidget() { + // FIXME: don't duplicate this code from 'Screen.cpp' const int childrenCount = m_children.size(); for (int i=childrenCount-1; i>=0; i--) { - if (m_children[i].getIrrlichtElement() == NULL || m_children[i].getIrrlichtElement()->getTabOrder() == -1 || - m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */) + if (m_children[i].getIrrlichtElement() == NULL || + m_children[i].getIrrlichtElement()->getTabOrder() == -1 || + m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */ || + !m_children[i].m_focusable) { continue; } @@ -133,12 +136,15 @@ } Widget* ModalDialog::getFirstWidget() { + // FIXME: don't duplicate this code from 'Screen.cpp' const int childrenCount = m_children.size(); for (int i=0; i<childrenCount; i++) { - if (m_children[i].getIrrlichtElement() == NULL || m_children[i].getIrrlichtElement()->getTabOrder() == -1 || - m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */) + if (m_children[i].getIrrlichtElement() == NULL || + m_children[i].getIrrlichtElement()->getTabOrder() == -1 || + m_children[i].getIrrlichtElement()->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */ || + !m_children[i].m_focusable) { continue; } Modified: main/trunk/src/guiengine/screen.cpp =================================================================== --- main/trunk/src/guiengine/screen.cpp 2009-12-30 17:09:58 UTC (rev 4364) +++ main/trunk/src/guiengine/screen.cpp 2009-12-30 17:43:06 UTC (rev 4365) @@ -406,10 +406,16 @@ if (w != NULL) return w; } - if (within_vector->get(i)->m_element == NULL || within_vector->get(i)->m_element->getTabOrder() == -1 || - within_vector->get(i)->m_element->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */) continue; + Widget* item = within_vector->get(i); + if (item->m_element == NULL || + item->m_element->getTabOrder() == -1 || + item->m_element->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */ || + !item->m_focusable) + { + continue; + } - return within_vector->get(i); + return item; } return NULL; } @@ -431,10 +437,16 @@ if (w != NULL) return w; } - if (within_vector->get(i)->m_element == NULL || within_vector->get(i)->m_element->getTabOrder() == -1 || - within_vector->get(i)->m_element->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */) continue; + Widget* item = within_vector->get(i); + if (item->m_element == NULL || + item->m_element->getTabOrder() == -1 || + item->m_element->getTabOrder() >= 1000 /* non-tabbing items are given such IDs */ || + !item->m_focusable) + { + continue; + } - return within_vector->get(i); + return item; } return NULL; } Modified: main/trunk/src/states_screens/dialogs/track_info_dialog.cpp =================================================================== --- main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-30 17:09:58 UTC (rev 4364) +++ main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-30 17:43:06 UTC (rev 4365) @@ -50,42 +50,6 @@ m_track_ident = trackIdent; - // ---- Lap count m_spinner - m_spinner = new SpinnerWidget(); - m_spinner->x = m_area.getWidth()/2 - 200; - m_spinner->y = y2; - m_spinner->w = 400; - m_spinner->h = y3 - y2 - 15; - m_spinner->setParent(m_irrlicht_window); - - m_spinner->m_properties[PROP_MIN_VALUE] = "1"; - m_spinner->m_properties[PROP_MAX_VALUE] = "99"; - - //I18N: In the track setup screen (number of laps choice, where %i is the number) - m_spinner->m_text = _("%i laps"); - - m_children.push_back(m_spinner); - m_spinner->add(); - m_spinner->setValue(3); - m_spinner->getIrrlichtElement()->setTabStop(true); - m_spinner->getIrrlichtElement()->setTabGroup(false); - - // ---- Start button - ButtonWidget* okBtn = new ButtonWidget(); - okBtn->m_properties[PROP_ID] = "start"; - okBtn->m_text = _("Start Race"); - okBtn->x = m_area.getWidth()/2 - 200; - okBtn->y = y3; - okBtn->w = 400; - okBtn->h = m_area.getHeight() - y3 - 15; - okBtn->setParent(m_irrlicht_window); - m_children.push_back(okBtn); - okBtn->add(); - okBtn->getIrrlichtElement()->setTabStop(true); - okBtn->getIrrlichtElement()->setTabGroup(false); - - okBtn->setFocusForPlayer( GUI_PLAYER_ID ); - // ---- Track title core::rect< s32 > area_top(0, 0, m_area.getWidth(), y1); IGUIStaticText* a = GUIEngine::getGUIEnv()->addStaticText( trackName.c_str(), @@ -206,6 +170,42 @@ a->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); b->setTextAlignment(EGUIA_CENTER, EGUIA_CENTER); + // ---- Lap count m_spinner + m_spinner = new SpinnerWidget(); + m_spinner->x = m_area.getWidth()/2 - 200; + m_spinner->y = y2; + m_spinner->w = 400; + m_spinner->h = y3 - y2 - 15; + m_spinner->setParent(m_irrlicht_window); + + m_spinner->m_properties[PROP_MIN_VALUE] = "1"; + m_spinner->m_properties[PROP_MAX_VALUE] = "99"; + + //I18N: In the track setup screen (number of laps choice, where %i is the number) + m_spinner->m_text = _("%i laps"); + + m_children.push_back(m_spinner); + m_spinner->add(); + m_spinner->setValue(3); + m_spinner->getIrrlichtElement()->setTabStop(true); + m_spinner->getIrrlichtElement()->setTabGroup(false); + + // ---- Start button + ButtonWidget* okBtn = new ButtonWidget(); + okBtn->m_properties[PROP_ID] = "start"; + okBtn->m_text = _("Start Race"); + okBtn->x = m_area.getWidth()/2 - 200; + okBtn->y = y3; + okBtn->w = 400; + okBtn->h = m_area.getHeight() - y3 - 15; + okBtn->setParent(m_irrlicht_window); + m_children.push_back(okBtn); + okBtn->add(); + okBtn->getIrrlichtElement()->setTabStop(true); + okBtn->getIrrlichtElement()->setTabGroup(false); + + okBtn->setFocusForPlayer( GUI_PLAYER_ID ); + } TrackInfoDialog::~TrackInfoDialog() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-30 18:43:40
|
Revision: 4371 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4371&view=rev Author: auria Date: 2009-12-30 18:43:28 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Make track screenshot keep right aspect ratio, and clarify a bit existing aspect capbilities in icon widget Modified Paths: -------------- main/trunk/src/guiengine/screen_loader.cpp main/trunk/src/guiengine/widgets/icon_button_widget.cpp main/trunk/src/guiengine/widgets/icon_button_widget.hpp main/trunk/src/guiengine/widgets/model_view_widget.cpp main/trunk/src/states_screens/dialogs/track_info_dialog.cpp Modified: main/trunk/src/guiengine/screen_loader.cpp =================================================================== --- main/trunk/src/guiengine/screen_loader.cpp 2009-12-30 18:30:13 UTC (rev 4370) +++ main/trunk/src/guiengine/screen_loader.cpp 2009-12-30 18:43:28 UTC (rev 4371) @@ -109,7 +109,7 @@ } else if (!strcmp("icon", xml->getNodeName())) { - append_to.push_back(new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_ASPECT_RATIO, + append_to.push_back(new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, false, false)); } else if (!strcmp("checkbox", xml->getNodeName())) Modified: main/trunk/src/guiengine/widgets/icon_button_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2009-12-30 18:30:13 UTC (rev 4370) +++ main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2009-12-30 18:43:28 UTC (rev 4371) @@ -46,7 +46,7 @@ // so, happily, let's implement it ourselves int x_gap = 0; - if (m_scale_mode == SCALE_MODE_KEEP_ASPECT_RATIO) + if (m_scale_mode == SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO) { x_gap = (int)((float)w - (float)m_texture_w * (float)h / m_texture_h); } Modified: main/trunk/src/guiengine/widgets/icon_button_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/icon_button_widget.hpp 2009-12-30 18:30:13 UTC (rev 4370) +++ main/trunk/src/guiengine/widgets/icon_button_widget.hpp 2009-12-30 18:43:28 UTC (rev 4371) @@ -35,7 +35,7 @@ enum ScaleMode { SCALE_MODE_STRETCH, - SCALE_MODE_KEEP_ASPECT_RATIO + SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO }; protected: @@ -53,7 +53,7 @@ /** Whether to make the widget included in keyboard navigation order when adding */ bool m_tab_stop; - IconButtonWidget(ScaleMode scale_mode=SCALE_MODE_KEEP_ASPECT_RATIO, const bool tab_stop=true, const bool focusable=true); + IconButtonWidget(ScaleMode scale_mode=SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, const bool tab_stop=true, const bool focusable=true); virtual ~IconButtonWidget() {} /** Callback called when this widget needs to be added (see base class Widget) */ Modified: main/trunk/src/guiengine/widgets/model_view_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/model_view_widget.cpp 2009-12-30 18:30:13 UTC (rev 4370) +++ main/trunk/src/guiengine/widgets/model_view_widget.cpp 2009-12-30 18:43:28 UTC (rev 4371) @@ -22,7 +22,7 @@ using namespace irr::core; using namespace irr::gui; -ModelViewWidget::ModelViewWidget() : IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_ASPECT_RATIO, false, false) +ModelViewWidget::ModelViewWidget() : IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, false, false) { m_type = WTYPE_MODEL_VIEW; m_rtt_provider = NULL; Modified: main/trunk/src/states_screens/dialogs/track_info_dialog.cpp =================================================================== --- main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-30 18:30:13 UTC (rev 4370) +++ main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-30 18:43:28 UTC (rev 4371) @@ -157,10 +157,27 @@ // (Yeah, that's complicated, but screenshots are saved compressed horizontally so it's hard to be clean) IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_STRETCH, false, false); core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y2-10); - screenshotWidget->x = area_right.UpperLeftCorner.X; - screenshotWidget->y = area_right.UpperLeftCorner.Y; - screenshotWidget->w = area_right.getWidth(); - screenshotWidget->h = area_right.getHeight(); + + const int x_from = area_right.UpperLeftCorner.X; + const int y_from = area_right.UpperLeftCorner.Y; + const int available_w = area_right.getWidth(); + const int available_h = area_right.getHeight(); + + // TODO: move that "custom aspect ratio" code into the Image widget + // find a size that has the right aspect ratio (4:3) and fits within available space + int suggested_h = available_h; + int suggested_w = (4.0f / 3.0f) * suggested_h; + if (suggested_w > available_w) + { + const float needed_scale_factor = (float)available_w / (float)suggested_w; + suggested_w *= needed_scale_factor; + suggested_h *= needed_scale_factor; + } + + screenshotWidget->x = x_from + (available_w - suggested_w)/2; // center horizontally + screenshotWidget->y = y_from + (available_h - suggested_h)/2; // center vertically + screenshotWidget->w = suggested_w; + screenshotWidget->h = suggested_h; screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png"; // temporary icon, will replace it just after screenshotWidget->setParent(m_irrlicht_window); screenshotWidget->add(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-30 19:09:17
|
Revision: 4372 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4372&view=rev Author: auria Date: 2009-12-30 19:09:10 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Improved capabilities of icon widget, and use that for track screenshot instead of locally duplicated code Modified Paths: -------------- main/trunk/src/guiengine/engine.hpp main/trunk/src/guiengine/widgets/icon_button_widget.cpp main/trunk/src/guiengine/widgets/icon_button_widget.hpp main/trunk/src/states_screens/dialogs/track_info_dialog.cpp Modified: main/trunk/src/guiengine/engine.hpp =================================================================== --- main/trunk/src/guiengine/engine.hpp 2009-12-30 18:43:28 UTC (rev 4371) +++ main/trunk/src/guiengine/engine.hpp 2009-12-30 19:09:10 UTC (rev 4372) @@ -55,6 +55,11 @@ WTYPE_ICON_BUTTON "icon-button", "icon" A component with an image, and optional text to go under it. The "icon" variant will have no border and will not be clickable. PROP_ICON is mandatory for this component. +There are three ways to place the texture within the allocated space; the default (and only way currently accessible +through xml files) is to scale the texture to fit, while preserving its aspect ratio; other methods, currently only +accessible through C++ code, are to stretch the texture to fill the area without caring for aspect ratio, and another +to respect an aspect ratio other than the texture's (useful for track screenshots, which are 4:3 compressed to fit +in a power-of-two 256x256 texture) WTYPE_CHECKBOX "checkbox" A checkbox. Not used at the moment. Modified: main/trunk/src/guiengine/widgets/icon_button_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2009-12-30 18:43:28 UTC (rev 4371) +++ main/trunk/src/guiengine/widgets/icon_button_widget.cpp 2009-12-30 19:09:10 UTC (rev 4372) @@ -26,10 +26,12 @@ // ----------------------------------------------------------------------------- IconButtonWidget::IconButtonWidget(ScaleMode scale_mode, const bool tab_stop, const bool focusable) { - m_tab_stop = tab_stop; m_label = NULL; + m_texture = NULL; m_type = WTYPE_ICON_BUTTON; - m_texture = NULL; + m_custom_aspect_ratio = 1.0f; + + m_tab_stop = tab_stop; m_focusable = focusable; m_scale_mode = scale_mode; } @@ -44,14 +46,34 @@ // irrlicht widgets don't support scaling while keeping aspect ratio // so, happily, let's implement it ourselves - int x_gap = 0; + float useAspectRatio = -1.0f; if (m_scale_mode == SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO) { - x_gap = (int)((float)w - (float)m_texture_w * (float)h / m_texture_h); + useAspectRatio = (float)m_texture_w / (float)m_texture_h; + //std::cout << "m_texture_h=" << m_texture_h << "; m_texture_w="<< m_texture_w << "; useAspectRatio=" << useAspectRatio << std::endl; } + else if (m_scale_mode == SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO) + { + useAspectRatio = m_custom_aspect_ratio; + } - rect<s32> widget_size = rect<s32>(x + x_gap/2, y, x + w - x_gap/2, y + h); + int suggested_h = h; + int suggested_w = (useAspectRatio < 0 ? w : useAspectRatio*suggested_h); + + if (suggested_w > w) + { + const float needed_scale_factor = (float)w / (float)suggested_w; + suggested_w *= needed_scale_factor; + suggested_h *= needed_scale_factor; + } + const int x_from = x + (w - suggested_w)/2; // center horizontally + const int y_from = y + (h - suggested_h)/2; // center vertically + + rect<s32> widget_size = rect<s32>(x_from, + y_from, + x_from + suggested_w, + y_from + suggested_h); //std::cout << "Creating a IGUIButton " << widget_size.UpperLeftCorner.X << ", " << widget_size.UpperLeftCorner.Y << //" : " << widget_size.getWidth() << "x" << widget_size.getHeight() << std::endl; Modified: main/trunk/src/guiengine/widgets/icon_button_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/icon_button_widget.hpp 2009-12-30 18:43:28 UTC (rev 4371) +++ main/trunk/src/guiengine/widgets/icon_button_widget.hpp 2009-12-30 19:09:10 UTC (rev 4372) @@ -35,7 +35,8 @@ enum ScaleMode { SCALE_MODE_STRETCH, - SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO + SCALE_MODE_KEEP_TEXTURE_ASPECT_RATIO, + SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO }; protected: @@ -46,10 +47,10 @@ int m_texture_w, m_texture_h; ScaleMode m_scale_mode; + float m_custom_aspect_ratio; + public: - - /** Whether to make the widget included in keyboard navigation order when adding */ bool m_tab_stop; @@ -59,6 +60,10 @@ /** Callback called when this widget needs to be added (see base class Widget) */ virtual void add(); + /** Call this if scale mode is SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO. + * \param custom_aspect_ratio The width/height aspect ratio */ + void setCustomAspectRatio(float custom_aspect_ratio) { m_custom_aspect_ratio = custom_aspect_ratio; } + /** Change the text label if there is a label (label won't be added if there initially wasn't one) */ void setLabel(irr::core::stringw new_label); Modified: main/trunk/src/states_screens/dialogs/track_info_dialog.cpp =================================================================== --- main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-30 18:43:28 UTC (rev 4371) +++ main/trunk/src/states_screens/dialogs/track_info_dialog.cpp 2009-12-30 19:09:10 UTC (rev 4372) @@ -153,31 +153,16 @@ // ---- Track screenshot - // stretch the *texture* within the widget (and the widget has the right aspect ratio) - // (Yeah, that's complicated, but screenshots are saved compressed horizontally so it's hard to be clean) - IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_STRETCH, false, false); + IconButtonWidget* screenshotWidget = new IconButtonWidget(IconButtonWidget::SCALE_MODE_KEEP_CUSTOM_ASPECT_RATIO, + false, false); + screenshotWidget->setCustomAspectRatio(4.0f / 3.0f); // images are saved squared, but must be stretched to 4:3 core::rect< s32 > area_right(m_area.getWidth()/2, y1, m_area.getWidth(), y2-10); - const int x_from = area_right.UpperLeftCorner.X; - const int y_from = area_right.UpperLeftCorner.Y; - const int available_w = area_right.getWidth(); - const int available_h = area_right.getHeight(); + screenshotWidget->x = area_right.UpperLeftCorner.X; + screenshotWidget->y = area_right.UpperLeftCorner.Y; + screenshotWidget->w = area_right.getWidth(); + screenshotWidget->h = area_right.getHeight(); - // TODO: move that "custom aspect ratio" code into the Image widget - // find a size that has the right aspect ratio (4:3) and fits within available space - int suggested_h = available_h; - int suggested_w = (4.0f / 3.0f) * suggested_h; - if (suggested_w > available_w) - { - const float needed_scale_factor = (float)available_w / (float)suggested_w; - suggested_w *= needed_scale_factor; - suggested_h *= needed_scale_factor; - } - - screenshotWidget->x = x_from + (available_w - suggested_w)/2; // center horizontally - screenshotWidget->y = y_from + (available_h - suggested_h)/2; // center vertically - screenshotWidget->w = suggested_w; - screenshotWidget->h = suggested_h; screenshotWidget->m_properties[PROP_ICON] = "gui/main_help.png"; // temporary icon, will replace it just after screenshotWidget->setParent(m_irrlicht_window); screenshotWidget->add(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-30 19:42:13
|
Revision: 4375 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4375&view=rev Author: auria Date: 2009-12-30 19:41:59 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Karts in kkart selection screens are now animation aware and will display the center frame (though elephant still seems slightly off-center, not sure why) Modified Paths: -------------- main/trunk/src/graphics/irr_driver.cpp main/trunk/src/graphics/irr_driver.hpp main/trunk/src/guiengine/widgets/model_view_widget.cpp main/trunk/src/guiengine/widgets/model_view_widget.hpp main/trunk/src/karts/kart_model.hpp main/trunk/src/states_screens/kart_selection.cpp Modified: main/trunk/src/graphics/irr_driver.cpp =================================================================== --- main/trunk/src/graphics/irr_driver.cpp 2009-12-30 19:40:59 UTC (rev 4374) +++ main/trunk/src/graphics/irr_driver.cpp 2009-12-30 19:41:59 UTC (rev 4375) @@ -820,24 +820,50 @@ * object inside the GUI. If there are multiple meshes, the first mesh is considered * to be the root, and all following meshes will have their locations relative to * the location of the first mesh. - * - * Parameters: - * \param mesh Vector of meshes to render. - * \param mesh_location For each mesh the location where it should be - * positioned. */ void IrrDriver::RTTProvider::setupRTTScene(ptr_vector<scene::IMesh, REF>& mesh, - std::vector<Vec3>& mesh_location) -{ - m_rtt_main_node = irr_driver->getSceneManager()->addMeshSceneNode(mesh.get(0)); + std::vector<Vec3>& mesh_location, + const std::vector<int>& model_frames) +{ + if (model_frames[0] == -1) + { + scene::ISceneNode* node = irr_driver->getSceneManager()->addMeshSceneNode(mesh.get(0), NULL); + node->setPosition( mesh_location[0].toIrrVector() ); + m_rtt_main_node = node; + } + else + { + scene::IAnimatedMeshSceneNode* node = irr_driver->getSceneManager()->addAnimatedMeshSceneNode((IAnimatedMesh*)mesh.get(0), NULL); + node->setPosition( mesh_location[0].toIrrVector() ); + node->setFrameLoop(model_frames[0], model_frames[0]); + node->setAnimationSpeed(0); + + m_rtt_main_node = node; + //std::cout << "(((( set frame " << model_frames[0] << " ))))\n"; + } + assert(m_rtt_main_node != NULL); - + assert(mesh.size() == (int)mesh_location.size()); + assert(mesh.size() == (int)model_frames.size()); + const int mesh_amount = mesh.size(); for (int n=1; n<mesh_amount; n++) { - scene::ISceneNode* node = irr_driver->getSceneManager()->addMeshSceneNode(mesh.get(n), m_rtt_main_node); - node->setPosition( mesh_location[n].toIrrVector() ); - node->updateAbsolutePosition(); + if (model_frames[n] == -1) + { + scene::ISceneNode* node = irr_driver->getSceneManager()->addMeshSceneNode(mesh.get(n), m_rtt_main_node); + node->setPosition( mesh_location[n].toIrrVector() ); + node->updateAbsolutePosition(); + } + else + { + scene::IAnimatedMeshSceneNode* node = irr_driver->getSceneManager()->addAnimatedMeshSceneNode((IAnimatedMesh*)mesh.get(n), m_rtt_main_node); + node->setPosition( mesh_location[n].toIrrVector() ); + node->setFrameLoop(model_frames[n], model_frames[n]); + node->setAnimationSpeed(0); + node->updateAbsolutePosition(); + //std::cout << "(((( set frame " << model_frames[n] << " ))))\n"; + } } m_rtt_main_node->setScale( core::vector3df(35.0f, 35.0f, 35.0f) ); Modified: main/trunk/src/graphics/irr_driver.hpp =================================================================== --- main/trunk/src/graphics/irr_driver.hpp 2009-12-30 19:40:59 UTC (rev 4374) +++ main/trunk/src/graphics/irr_driver.hpp 2009-12-30 19:41:59 UTC (rev 4375) @@ -154,8 +154,23 @@ ~RTTProvider(); + /** + * \brief Quick utility method to setup a scene from a plain list of models + * + * Sets up a given vector of meshes for render-to-texture. Ideal to embed a 3D + * object inside the GUI. If there are multiple meshes, the first mesh is considered + * to be the root, and all following meshes will have their locations relative to + * the location of the first mesh. + * + * \param mesh The list of meshes to add to the scene + * \param mesh_location Location of each fo these meshes + * \param model_frames For animated meshes, which frame to use (value can be -1 to set none) + * When frame is not -1, the corresponding IMesh must be an IAnimatedMesh. + * \precondition The 3 vectors have the same size. + */ void setupRTTScene(ptr_vector<scene::IMesh, REF>& mesh, - std::vector<Vec3>& mesh_location); + std::vector<Vec3>& mesh_location, + const std::vector<int>& model_frames); /** Optional 'angle' parameter will rotate the object added *through setupRTTScene* */ video::ITexture* renderToTexture(float angle=-1, Modified: main/trunk/src/guiengine/widgets/model_view_widget.cpp =================================================================== --- main/trunk/src/guiengine/widgets/model_view_widget.cpp 2009-12-30 19:40:59 UTC (rev 4374) +++ main/trunk/src/guiengine/widgets/model_view_widget.cpp 2009-12-30 19:41:59 UTC (rev 4375) @@ -63,15 +63,17 @@ { m_models.clearWithoutDeleting(); m_model_location.clear(); + m_model_frames.clear(); delete m_rtt_provider; m_rtt_provider = NULL; } // ----------------------------------------------------------------------------- -void ModelViewWidget::addModel(irr::scene::IMesh* mesh, const Vec3& location) +void ModelViewWidget::addModel(irr::scene::IMesh* mesh, const Vec3& location, const int frame) { m_models.push_back(mesh); m_model_location.push_back(location); + m_model_frames.push_back(frame); /* ((IGUIMeshViewer*)m_element)->setMesh( mesh ); @@ -138,7 +140,7 @@ std::string name = "model view "; name += m_properties[PROP_ID].c_str(); m_rtt_provider = new IrrDriver::RTTProvider(core::dimension2d< u32 >(512, 512), name ); - m_rtt_provider->setupRTTScene(m_models, m_model_location); + m_rtt_provider->setupRTTScene(m_models, m_model_location, m_model_frames); } m_texture = m_rtt_provider->renderToTexture(angle); Modified: main/trunk/src/guiengine/widgets/model_view_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/model_view_widget.hpp 2009-12-30 19:40:59 UTC (rev 4374) +++ main/trunk/src/guiengine/widgets/model_view_widget.hpp 2009-12-30 19:41:59 UTC (rev 4375) @@ -43,6 +43,7 @@ ptr_vector<scene::IMesh, REF> m_models; std::vector<Vec3> m_model_location; + std::vector<int> m_model_frames; video::ITexture* m_texture; @@ -55,7 +56,7 @@ void add(); void clearModels(); - void addModel(irr::scene::IMesh* mesh, const Vec3& location = Vec3(0,0,0)); + void addModel(irr::scene::IMesh* mesh, const Vec3& location = Vec3(0,0,0), const int frame=-1); void update(float delta); /** Disables any model rotation */ Modified: main/trunk/src/karts/kart_model.hpp =================================================================== --- main/trunk/src/karts/kart_model.hpp 2009-12-30 19:40:59 UTC (rev 4374) +++ main/trunk/src/karts/kart_model.hpp 2009-12-30 19:41:59 UTC (rev 4375) @@ -109,6 +109,9 @@ scene::IMesh* getWheelModel(const int wheelID) const { return m_wheel_model[wheelID]; } + /** Since karts might be animated, we might need to know which base frame to use */ + int getBaseFrame() const { return m_af_straight; } + /** Returns the position of a wheel relative to the kart. * \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear * right, 3 = rear left. */ Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2009-12-30 19:40:59 UTC (rev 4374) +++ main/trunk/src/states_screens/kart_selection.cpp 2009-12-30 19:41:59 UTC (rev 4375) @@ -281,7 +281,7 @@ const KartProperties* props = kart_properties_manager->getKart(default_kart); KartModel* kartModel = props->getKartModel(); - this->modelView->addModel( kartModel->getModel() ); + this->modelView->addModel( kartModel->getModel(), Vec3(0,0,0), kartModel->getBaseFrame() ); this->modelView->addModel( kartModel->getWheelModel(0), kartModel->getWheelGraphicsPosition(0) ); this->modelView->addModel( kartModel->getWheelModel(1), kartModel->getWheelGraphicsPosition(1) ); this->modelView->addModel( kartModel->getWheelModel(2), kartModel->getWheelGraphicsPosition(2) ); @@ -659,7 +659,7 @@ KartModel* kartModel = kart->getKartModel(); w3->clearModels(); - w3->addModel( kartModel->getModel() ); + w3->addModel( kartModel->getModel(), Vec3(0,0,0), kartModel->getBaseFrame() ); w3->addModel( kartModel->getWheelModel(0), kartModel->getWheelGraphicsPosition(0) ); w3->addModel( kartModel->getWheelModel(1), kartModel->getWheelGraphicsPosition(1) ); w3->addModel( kartModel->getWheelModel(2), kartModel->getWheelGraphicsPosition(2) ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-30 21:00:03
|
Revision: 4376 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4376&view=rev Author: auria Date: 2009-12-30 20:59:56 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Fixed crash on reschange caused by very subtle pointer management issue; added various debug checks to make sure this doesn't happen again -.- those debug checks should have unnoticeable performance effect on a release build Modified Paths: -------------- main/trunk/src/guiengine/screen.cpp main/trunk/src/guiengine/screen.hpp main/trunk/src/guiengine/widget.cpp main/trunk/src/guiengine/widget.hpp main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/kart_selection.hpp main/trunk/src/utils/ptr_vector.hpp Modified: main/trunk/src/guiengine/screen.cpp =================================================================== --- main/trunk/src/guiengine/screen.cpp 2009-12-30 19:41:59 UTC (rev 4375) +++ main/trunk/src/guiengine/screen.cpp 2009-12-30 20:59:56 UTC (rev 4376) @@ -42,6 +42,8 @@ Screen::Screen(const char* file) { + m_magic_number = 0xCAFEC001; + throttleFPS = true; m_mouse_x = 0; @@ -55,6 +57,8 @@ Screen::Screen() { + m_magic_number = 0xCAFEC001; + m_mouse_x = 0; m_mouse_y = 0; m_loaded = false; @@ -62,8 +66,20 @@ m_render_3d = false; } +Screen::~Screen() +{ + assert(m_magic_number == 0xCAFEC001); + m_magic_number = 0xDEADBEEF; +} + void Screen::forgetWhatWasLoaded() { + assert(m_magic_number == 0xCAFEC001); + for (int n=0; n<m_widgets.size(); n++) + { + assert(m_widgets[n].m_magic_number == 0xCAFEC001); + } + m_loaded = false; m_inited = false; m_widgets.clearAndDeleteAll(); @@ -77,6 +93,7 @@ // ----------------------------------------------------------------------------- void Screen::loadFromFile() { + assert(m_magic_number == 0xCAFEC001); IrrXMLReader* xml = irr::io::createIrrXMLReader( (file_manager->getGUIDir() + "/" + m_filename).c_str() ); parseScreenFileDiv(xml, m_widgets); m_loaded = true; @@ -86,6 +103,7 @@ /* small shortcut so this method can be called without arguments */ void Screen::calculateLayout() { + assert(m_magic_number == 0xCAFEC001); // build layout calculateLayout( m_widgets ); } @@ -97,6 +115,7 @@ */ void Screen::calculateLayout(ptr_vector<Widget>& widgets, Widget* parent) { + assert(m_magic_number == 0xCAFEC001); const unsigned short widgets_amount = widgets.size(); // ----- read x/y/size parameters @@ -264,6 +283,7 @@ void Screen::addWidgets() { + assert(m_magic_number == 0xCAFEC001); if (!m_loaded) loadFromFile(); addWidgetsRecursively( m_widgets ); @@ -312,6 +332,7 @@ */ void Screen::elementsWereDeleted(ptr_vector<Widget>* within_vector) { + assert(m_magic_number == 0xCAFEC001); if (within_vector == NULL) within_vector = &m_widgets; const unsigned short widgets_amount = within_vector->size(); @@ -330,11 +351,13 @@ // ----------------------------------------------------------------------------- void Screen::manualAddWidget(Widget* w) { + assert(m_magic_number == 0xCAFEC001); m_widgets.push_back(w); } // ----------------------------------------------------------------------------- void Screen::manualRemoveWidget(Widget* w) { + assert(m_magic_number == 0xCAFEC001); m_widgets.remove(w); } Modified: main/trunk/src/guiengine/screen.hpp =================================================================== --- main/trunk/src/guiengine/screen.hpp 2009-12-30 19:41:59 UTC (rev 4375) +++ main/trunk/src/guiengine/screen.hpp 2009-12-30 20:59:56 UTC (rev 4376) @@ -92,6 +92,8 @@ /** Will be called to determine if the 3D scene must be rendered when at this screen. */ bool m_render_3d; + + int m_magic_number; public: bool throttleFPS; @@ -107,11 +109,12 @@ /** Next time this menu needs to be shown, don't use cached values, re-calculate everything. (useful e.g. on reschange, when sizes have changed and must be re-calculated) */ - void forgetWhatWasLoaded(); + virtual void forgetWhatWasLoaded(); Screen(); /**< creates a dummy incomplete object; only use to override behaviour in sub-class */ Screen(const char* filename); - virtual ~Screen(){} + virtual ~Screen(); + bool operator ==(const char* filename) const { return m_filename == filename; } /** returns an object by name, or NULL if not found */ Modified: main/trunk/src/guiengine/widget.cpp =================================================================== --- main/trunk/src/guiengine/widget.cpp 2009-12-30 19:41:59 UTC (rev 4375) +++ main/trunk/src/guiengine/widget.cpp 2009-12-30 20:59:56 UTC (rev 4376) @@ -56,6 +56,8 @@ // ----------------------------------------------------------------------------- Widget::Widget(bool reserve_id) { + m_magic_number = 0xCAFEC001; + x = -1; y = -1; w = -1; @@ -88,6 +90,8 @@ Widget::~Widget() { + assert(m_magic_number == 0xCAFEC001); + // If any player focused this widget, unset that focus for (int n=0; n<MAX_PLAYER_COUNT; n++) { @@ -97,10 +101,13 @@ } } + m_magic_number = 0xDEADBEEF; } void Widget::elementRemoved() { + assert(m_magic_number == 0xCAFEC001); + m_element = NULL; // If any player focused this widget, unset that focus @@ -137,6 +144,7 @@ // ----------------------------------------------------------------------------- void Widget::add() { + assert(m_magic_number == 0xCAFEC001); if (m_reserve_id) { m_reserved_id = getNewID(); @@ -151,6 +159,8 @@ */ void Widget::setFocusForPlayer(const int playerID) { + assert(m_magic_number == 0xCAFEC001); + // Unset focus flag on previous widget that had focus if (GUIEngine::getFocusForPlayer(playerID) != NULL) { @@ -167,6 +177,8 @@ void Widget::unsetFocusForPlayer(const int playerID) { + assert(m_magic_number == 0xCAFEC001); + if (m_player_focus[playerID]) this->unfocused(playerID); m_player_focus[playerID] = false; } @@ -176,6 +188,8 @@ */ bool Widget::isFocusedForPlayer(const int playerID) { + assert(m_magic_number == 0xCAFEC001); + return m_player_focus[playerID]; } @@ -189,7 +203,7 @@ * Returns false if couldn't convert to either */ bool Widget::convertToCoord(std::string& x, int* absolute /* out */, int* percentage /* out */) -{ +{ bool is_number; int i; std::istringstream myStream(x); @@ -211,6 +225,8 @@ void Widget::move(const int x, const int y, const int w, const int h) { + assert(m_magic_number == 0xCAFEC001); + this->x = x; this->y = y; this->w = w; @@ -226,6 +242,8 @@ */ void Widget::readCoords(Widget* parent) { + assert(m_magic_number == 0xCAFEC001); + /* determine widget position and size if not already done by sizers */ std::string x = m_properties[PROP_X]; std::string y = m_properties[PROP_Y]; @@ -360,6 +378,7 @@ void Widget::setParent(IGUIElement* parent) { + assert(m_magic_number == 0xCAFEC001); m_parent = parent; } Modified: main/trunk/src/guiengine/widget.hpp =================================================================== --- main/trunk/src/guiengine/widget.hpp 2009-12-30 19:41:59 UTC (rev 4375) +++ main/trunk/src/guiengine/widget.hpp 2009-12-30 20:59:56 UTC (rev 4376) @@ -93,6 +93,7 @@ class Widget : public SkinWidgetContainer { protected: + int m_magic_number; friend class EventHandler; friend class RibbonWidget; Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2009-12-30 19:41:59 UTC (rev 4375) +++ main/trunk/src/states_screens/kart_selection.cpp 2009-12-30 20:59:56 UTC (rev 4376) @@ -684,13 +684,25 @@ { g_dispatcher = new FocusDispatcher(this); } - // ----------------------------------------------------------------------------- +void KartSelectionScreen::forgetWhatWasLoaded() +{ + Screen::forgetWhatWasLoaded(); + + // this pointer is no more valid + g_dispatcher = NULL; +} +// ----------------------------------------------------------------------------- // Return true if event was handled successfully bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer) { std::cout << "playerJoin() ==========\n"; + if (g_dispatcher == NULL) + { + g_dispatcher = new FocusDispatcher(this); + } + DynamicRibbonWidget* w = this->getWidget<DynamicRibbonWidget>("karts"); if (w == NULL) { @@ -717,7 +729,7 @@ { g_dispatcher->setRootID(kartsArea.m_reserved_id); g_dispatcher->add(); - m_widgets.push_back(g_dispatcher); + if (!m_widgets.contains(g_dispatcher)) m_widgets.push_back(g_dispatcher); // We keep the ID of the "root" widget, see comment at top g_root_id = kartsArea.m_reserved_id; Modified: main/trunk/src/states_screens/kart_selection.hpp =================================================================== --- main/trunk/src/states_screens/kart_selection.hpp 2009-12-30 19:41:59 UTC (rev 4375) +++ main/trunk/src/states_screens/kart_selection.hpp 2009-12-30 20:59:56 UTC (rev 4376) @@ -70,4 +70,7 @@ /** Standard 'Screen' callback every frame */ void onUpdate(float dt, irr::video::IVideoDriver*); + + /** overload */ + virtual void forgetWhatWasLoaded(); }; Modified: main/trunk/src/utils/ptr_vector.hpp =================================================================== --- main/trunk/src/utils/ptr_vector.hpp 2009-12-30 19:41:59 UTC (rev 4375) +++ main/trunk/src/utils/ptr_vector.hpp 2009-12-30 20:59:56 UTC (rev 4376) @@ -129,10 +129,15 @@ void clearAndDeleteAll() { - for(unsigned int n=0; n<contentsVector.size(); n++) + for (unsigned int n=0; n<contentsVector.size(); n++) { TYPE * pointer = contentsVector[n]; delete pointer; + contentsVector[n] = (TYPE*)0xDEADBEEF; + + // When deleting, it's important that the same pointer cannot be + // twice in the vector, resulting in a double delete + assert( !contains(pointer) ); } contentsVector.clear(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2009-12-30 21:29:06
|
Revision: 4378 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4378&view=rev Author: auria Date: 2009-12-30 21:28:59 +0000 (Wed, 30 Dec 2009) Log Message: ----------- Fixed resolution change messing up kart selection screen Modified Paths: -------------- main/trunk/src/graphics/irr_driver.cpp main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp main/trunk/src/karts/kart_properties_manager.cpp main/trunk/src/karts/kart_properties_manager.hpp main/trunk/src/states_screens/kart_selection.cpp Modified: main/trunk/src/graphics/irr_driver.cpp =================================================================== --- main/trunk/src/graphics/irr_driver.cpp 2009-12-30 21:07:38 UTC (rev 4377) +++ main/trunk/src/graphics/irr_driver.cpp 2009-12-30 21:28:59 UTC (rev 4378) @@ -250,7 +250,7 @@ attachment_manager -> removeTextures(); projectile_manager -> removeTextures(); item_manager -> removeTextures(); - kart_properties_manager -> removeTextures(); + kart_properties_manager -> unloadAllKarts(); powerup_manager -> removeTextures(); GUIEngine::clear(); GUIEngine::cleanUp(); Modified: main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp =================================================================== --- main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2009-12-30 21:07:38 UTC (rev 4377) +++ main/trunk/src/guiengine/widgets/dynamic_ribbon_widget.hpp 2009-12-30 21:28:59 UTC (rev 4378) @@ -161,7 +161,8 @@ 'updateItemDisplay' to update the display. */ void clearItems(); - /** Register a listener to be notified of selection changes within the ribbon */ + /** Register a listener to be notified of selection changes within the ribbon. + * The ribbon takes ownership of this listener and will delete it. */ void registerHoverListener(DynamicRibbonHoverListener* listener); /** Called when right key is pressed */ Modified: main/trunk/src/karts/kart_properties_manager.cpp =================================================================== --- main/trunk/src/karts/kart_properties_manager.cpp 2009-12-30 21:07:38 UTC (rev 4377) +++ main/trunk/src/karts/kart_properties_manager.cpp 2009-12-30 21:28:59 UTC (rev 4378) @@ -68,7 +68,7 @@ } // addKartSearchDir //----------------------------------------------------------------------------- -void KartPropertiesManager::removeTextures() +void KartPropertiesManager::unloadAllKarts() { for(KartPropertiesVector::iterator i = m_karts_properties.begin(); i != m_karts_properties.end(); ++i) @@ -76,6 +76,11 @@ delete *i; } m_karts_properties.clear(); + m_selected_karts.clear(); + m_kart_available.clear(); + m_groups.clear(); + m_all_groups.clear(); + m_kart_search_path.clear(); } // removeTextures //----------------------------------------------------------------------------- @@ -145,8 +150,8 @@ //----------------------------------------------------------------------------- const int KartPropertiesManager::getKartId(const std::string &ident) const { - std::cout << "======\n"; - std::cout << "Searching for kart " << ident.c_str() << std::endl; + //std::cout << "======\n"; + //std::cout << "Searching for kart " << ident.c_str() << std::endl; for(KartPropertiesVector::const_iterator i = m_karts_properties.begin(); i != m_karts_properties.end(); ++i) Modified: main/trunk/src/karts/kart_properties_manager.hpp =================================================================== --- main/trunk/src/karts/kart_properties_manager.hpp 2009-12-30 21:07:38 UTC (rev 4377) +++ main/trunk/src/karts/kart_properties_manager.hpp 2009-12-30 21:28:59 UTC (rev 4378) @@ -60,7 +60,10 @@ const KartProperties* getKart (const std::string &ident) const; const int getKartId (const std::string &ident) const; int getKartByGroup (const std::string& group, int i) const; + void loadAllKarts (); + void unloadAllKarts (); + const unsigned int getNumberOfKarts () const {return (unsigned int)m_karts_properties.size();} const std::vector<std::string>& getAllGroups () const {return m_all_groups; } @@ -77,7 +80,6 @@ void selectKartName(const std::string &kart_name); bool testAndSetKart(int kartid); std::vector<std::string> getRandomKartList(int count, RemoteKartInfoList& existing_karts); - void removeTextures (); /** Returns all directories from which karts were loaded. */ const std::vector<std::string>* getAllKartDirs() const { return &m_all_kart_dirs; } Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2009-12-30 21:07:38 UTC (rev 4377) +++ main/trunk/src/states_screens/kart_selection.cpp 2009-12-30 21:28:59 UTC (rev 4378) @@ -617,14 +617,25 @@ { KartSelectionScreen* m_parent; public: + int m_magic_number; + KartHoverListener(KartSelectionScreen* parent) { + m_magic_number = 0xCAFEC001; m_parent = parent; } + virtual ~KartHoverListener() + { + assert(m_magic_number == 0xCAFEC001); + m_magic_number = 0xDEADBEEF; + } + void onSelectionChanged(DynamicRibbonWidget* theWidget, const std::string& selectionID, const irr::core::stringw& selectionText, const int playerID) { + assert(m_magic_number == 0xCAFEC001); + // Don't allow changing the selection after confirming it if (m_parent->m_kart_widgets[playerID].isReady()) { @@ -689,8 +700,9 @@ { Screen::forgetWhatWasLoaded(); - // this pointer is no more valid + // these pointers is no more valid (have been deleted along other widgets) g_dispatcher = NULL; + karthoverListener = NULL; } // ----------------------------------------------------------------------------- // Return true if event was handled successfully This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-01-02 01:46:40
|
Revision: 4380 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4380&view=rev Author: auria Date: 2010-01-02 01:46:29 +0000 (Sat, 02 Jan 2010) Log Message: ----------- Fixed compilation warnings, + warn if many keys are assigned to the same action in input settings Modified Paths: -------------- main/trunk/src/guiengine/screen.hpp main/trunk/src/guiengine/skin.cpp main/trunk/src/guiengine/widget.cpp main/trunk/src/guiengine/widget.hpp main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/options_screen_input.cpp Modified: main/trunk/src/guiengine/screen.hpp =================================================================== --- main/trunk/src/guiengine/screen.hpp 2010-01-01 17:01:32 UTC (rev 4379) +++ main/trunk/src/guiengine/screen.hpp 2010-01-02 01:46:29 UTC (rev 4380) @@ -93,7 +93,7 @@ bool m_render_3d; - int m_magic_number; + unsigned int m_magic_number; public: bool throttleFPS; Modified: main/trunk/src/guiengine/skin.cpp =================================================================== --- main/trunk/src/guiengine/skin.cpp 2010-01-01 17:01:32 UTC (rev 4379) +++ main/trunk/src/guiengine/skin.cpp 2010-01-02 01:46:29 UTC (rev 4380) @@ -1152,8 +1152,8 @@ SColor color(255, 255, 0, 0); GUIEngine::getFont()->draw(idstring.c_str(), rect, color, true, true); } - - if (widget->m_lock_badge || widget->m_okay_badge) + + if (widget->m_lock_badge || widget->m_okay_badge || widget->m_bad_badge) { drawBadgeOn(widget, rect); } @@ -1163,6 +1163,7 @@ { video::ITexture* texture = NULL; float max_icon_size = 0.35f; + bool badge_at_left = true; if (widget->m_lock_badge) { @@ -1173,6 +1174,11 @@ { texture = irr_driver->getTexture(file_manager->getTextureFile("green_check.png")); } + else if (widget->m_bad_badge) + { + texture = irr_driver->getTexture(file_manager->getTextureFile("red_mark.png")); + badge_at_left = false; + } else { assert(false); @@ -1180,14 +1186,20 @@ } const core::dimension2d<u32>& texture_size = texture->getSize(); const float aspectRatio = (float)texture_size.Width / (float)texture_size.Height; - const int h = std::min( (int)(rect.getHeight()*max_icon_size), (int)(texture_size.Height) ); + const int h = rect.getHeight() <= 50 ? + rect.getHeight() : + std::min( (int)(rect.getHeight()*max_icon_size), (int)(texture_size.Height) ); int w = (int)(aspectRatio*h); const core::rect<s32> source_area = core::rect<s32>(0, 0, texture_size.Width, texture_size.Height); - const core::rect< s32 > rect2 = core::rect< s32 >(rect.UpperLeftCorner.X, + const core::rect< s32 > rect2 = core::rect< s32 >(badge_at_left ? + rect.UpperLeftCorner.X : + rect.LowerRightCorner.X - w, rect.LowerRightCorner.Y - h, - rect.UpperLeftCorner.X + w, + badge_at_left ? + rect.UpperLeftCorner.X + w : + rect.LowerRightCorner.X, rect.LowerRightCorner.Y); GUIEngine::getDriver()->draw2DImage(texture, rect2, source_area, Modified: main/trunk/src/guiengine/widget.cpp =================================================================== --- main/trunk/src/guiengine/widget.cpp 2010-01-01 17:01:32 UTC (rev 4379) +++ main/trunk/src/guiengine/widget.cpp 2010-01-02 01:46:29 UTC (rev 4380) @@ -86,6 +86,7 @@ m_lock_badge = false; m_okay_badge = false; + m_bad_badge = false; } Widget::~Widget() Modified: main/trunk/src/guiengine/widget.hpp =================================================================== --- main/trunk/src/guiengine/widget.hpp 2010-01-01 17:01:32 UTC (rev 4379) +++ main/trunk/src/guiengine/widget.hpp 2010-01-02 01:46:29 UTC (rev 4380) @@ -93,7 +93,7 @@ class Widget : public SkinWidgetContainer { protected: - int m_magic_number; + unsigned int m_magic_number; friend class EventHandler; friend class RibbonWidget; @@ -204,6 +204,9 @@ /** Show a 'good' badge on this widget */ bool m_okay_badge; + /** Show a 'good' badge on this widget */ + bool m_bad_badge; + /** Set to false if widget is something that should not receieve focus */ bool m_focusable; Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2010-01-01 17:01:32 UTC (rev 4379) +++ main/trunk/src/states_screens/kart_selection.cpp 2010-01-02 01:46:29 UTC (rev 4380) @@ -617,7 +617,7 @@ { KartSelectionScreen* m_parent; public: - int m_magic_number; + unsigned int m_magic_number; KartHoverListener(KartSelectionScreen* parent) { Modified: main/trunk/src/states_screens/options_screen_input.cpp =================================================================== --- main/trunk/src/states_screens/options_screen_input.cpp 2010-01-01 17:01:32 UTC (rev 4379) +++ main/trunk/src/states_screens/options_screen_input.cpp 2010-01-02 01:46:29 UTC (rev 4380) @@ -32,6 +32,7 @@ #include <iostream> #include <sstream> +#include <set> using namespace GUIEngine; @@ -49,41 +50,165 @@ abort(); } + // to detect duplicate entries + std::set<core::stringw> existing_bindings; + { ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_up"); - btn->setLabel( config->getBindingAsString(PA_ACCEL) ); + core::stringw binding_name = config->getBindingAsString(PA_ACCEL); + btn->setLabel( binding_name ); + + // check if another binding already uses this key + if (existing_bindings.find(binding_name) != existing_bindings.end()) + { + btn->m_bad_badge = true; + } + else + { + existing_bindings.insert(binding_name); + btn->m_bad_badge = false; + } } { ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_down"); - btn->setLabel( config->getBindingAsString(PA_BRAKE) ); + core::stringw binding_name = config->getBindingAsString(PA_BRAKE); + btn->setLabel( binding_name ); + + // check if another binding already uses this key + if (existing_bindings.find(binding_name) != existing_bindings.end()) + { + btn->m_bad_badge = true; + } + else + { + existing_bindings.insert(binding_name); + btn->m_bad_badge = false; + } } { ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_left"); - btn->setLabel( config->getBindingAsString(PA_LEFT) ); + core::stringw binding_name = config->getBindingAsString(PA_LEFT); + btn->setLabel( binding_name ); + + // check if another binding already uses this key + if (existing_bindings.find(binding_name) != existing_bindings.end()) + { + btn->m_bad_badge = true; + } + else + { + existing_bindings.insert(binding_name); + btn->m_bad_badge = false; + } } { ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_right"); - btn->setLabel( config->getBindingAsString(PA_RIGHT) ); + core::stringw binding_name = config->getBindingAsString(PA_RIGHT); + btn->setLabel( binding_name ); + + // check if another binding already uses this key + if (existing_bindings.find(binding_name) != existing_bindings.end()) + { + btn->m_bad_badge = true; + } + else + { + existing_bindings.insert(binding_name); + btn->m_bad_badge = false; + } } + + std::set<core::stringw>::iterator it; + + /* + std::cout << "existing_bindings contains:"; + for ( it=existing_bindings.begin() ; it != existing_bindings.end(); it++ ) { + std::wcout << (*it).c_str() << ", "; + } + std::cout << "\n"; + */ + + { ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_fire"); - btn->setLabel( config->getBindingAsString(PA_FIRE) ); + core::stringw binding_name = config->getBindingAsString(PA_FIRE); + btn->setLabel( binding_name ); + + // check if another binding already uses this key + if (existing_bindings.find(binding_name) != existing_bindings.end()) + { + btn->m_bad_badge = true; + //std::cout << "Setting bad badge!!!!\n"; + } + else + { + existing_bindings.insert(binding_name); + btn->m_bad_badge = false; + } } { ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_nitro"); - btn->setLabel( config->getBindingAsString(PA_NITRO) ); + core::stringw binding_name = config->getBindingAsString(PA_NITRO); + btn->setLabel( binding_name ); + + // check if another binding already uses this key + if (existing_bindings.find(binding_name) != existing_bindings.end()) + { + btn->m_bad_badge = true; + } + else + { + existing_bindings.insert(binding_name); + btn->m_bad_badge = false; + } } { ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_drift"); - btn->setLabel( config->getBindingAsString(PA_DRIFT) ); + core::stringw binding_name = config->getBindingAsString(PA_DRIFT); + btn->setLabel( binding_name ); + + // check if another binding already uses this key + if (existing_bindings.find(binding_name) != existing_bindings.end()) + { + btn->m_bad_badge = true; + } + else + { + existing_bindings.insert(binding_name); + btn->m_bad_badge = false; + } } { ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_rescue"); - btn->setLabel( config->getBindingAsString(PA_RESCUE) ); + core::stringw binding_name = config->getBindingAsString(PA_RESCUE); + btn->setLabel( binding_name ); + + // check if another binding already uses this key + if (existing_bindings.find(binding_name) != existing_bindings.end()) + { + btn->m_bad_badge = true; + } + else + { + existing_bindings.insert(binding_name); + btn->m_bad_badge = false; + } } { ButtonWidget* btn = this->getWidget<ButtonWidget>("binding_look_back"); - btn->setLabel( config->getBindingAsString(PA_LOOK_BACK) ); + core::stringw binding_name = config->getBindingAsString(PA_LOOK_BACK); + btn->setLabel( binding_name ); + + // check if another binding already uses this key + if (existing_bindings.find(binding_name) != existing_bindings.end()) + { + btn->m_bad_badge = true; + } + else + { + existing_bindings.insert(binding_name); + btn->m_bad_badge = false; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-01-05 01:14:01
|
Revision: 4399 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4399&view=rev Author: hikerstk Date: 2010-01-05 01:13:53 +0000 (Tue, 05 Jan 2010) Log Message: ----------- Applied Graham's 'reverse camera' patch, which changes to reverse camera when driving backwards faster than a certain speed (defined in user config). Modified Paths: -------------- main/trunk/src/config/user_config.hpp main/trunk/src/karts/player_kart.cpp Modified: main/trunk/src/config/user_config.hpp =================================================================== --- main/trunk/src/config/user_config.hpp 2010-01-04 19:33:51 UTC (rev 4398) +++ main/trunk/src/config/user_config.hpp 2010-01-05 01:13:53 UTC (rev 4399) @@ -250,6 +250,9 @@ PARAM_PREFIX BoolUserConfigParam m_log_errors PARAM_DEFAULT( BoolUserConfigParam(false, "log_errors", "Enable logging of stdout and stderr to logfile") ); + PARAM_PREFIX IntUserConfigParam m_reverse_look_threshold + PARAM_DEFAULT( IntUserConfigParam(9, "reverse_look_threshold") ); + PARAM_PREFIX StringUserConfigParam m_item_style PARAM_DEFAULT( StringUserConfigParam("items", "item_style", "Name of the .items file to use.") ); Modified: main/trunk/src/karts/player_kart.cpp =================================================================== --- main/trunk/src/karts/player_kart.cpp 2010-01-04 19:33:51 UTC (rev 4398) +++ main/trunk/src/karts/player_kart.cpp 2010-01-05 01:13:53 UTC (rev 4399) @@ -278,9 +278,17 @@ if (m_powerup.getType()==POWERUP_NOTHING) Kart::beep(); } + + // Camera looks back when reversing if(m_camera->getMode()!=Camera::CM_FINAL) - m_camera->setMode(m_controls.m_look_back ? Camera::CM_REVERSE - : Camera::CM_NORMAL); + { + // look backward when the player requests or + // if automatic reverse camera is active + if (m_controls.m_look_back || (UserConfigParams::m_reverse_look_threshold>0 && Kart::getSpeed()<-UserConfigParams::m_reverse_look_threshold)) + m_camera->setMode(Camera::CM_REVERSE); + else + m_camera->setMode(Camera::CM_NORMAL); + } // We can't restrict rescue to fulfil isOnGround() (which would be more like // MK), since e.g. in the City track it is possible for the kart to end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-01-05 03:38:42
|
Revision: 4400 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4400&view=rev Author: hikerstk Date: 2010-01-05 03:38:35 +0000 (Tue, 05 Jan 2010) Log Message: ----------- Added support for irrlicht 1.7. Modified Paths: -------------- main/trunk/src/graphics/irr_driver.cpp main/trunk/src/graphics/material_manager.cpp main/trunk/src/guiengine/skin.cpp main/trunk/src/guiengine/skin.hpp main/trunk/src/ide/vc9/bullet_lib.vcproj main/trunk/src/ide/vc9/enet.vcproj main/trunk/src/ide/vc9/supertuxkart.sln main/trunk/src/ide/vc9/supertuxkart.vcproj main/trunk/src/tracks/track.cpp Modified: main/trunk/src/graphics/irr_driver.cpp =================================================================== --- main/trunk/src/graphics/irr_driver.cpp 2010-01-05 01:13:53 UTC (rev 4399) +++ main/trunk/src/graphics/irr_driver.cpp 2010-01-05 03:38:35 UTC (rev 4400) @@ -344,7 +344,11 @@ */ scene::ISceneNode *IrrDriver::addOctTree(scene::IMesh *mesh) { +#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR == 7) + return m_scene_manager->addOctreeSceneNode(mesh); +#else return m_scene_manager->addOctTreeSceneNode(mesh); +#endif } // addOctTree // ---------------------------------------------------------------------------- Modified: main/trunk/src/graphics/material_manager.cpp =================================================================== --- main/trunk/src/graphics/material_manager.cpp 2010-01-05 01:13:53 UTC (rev 4399) +++ main/trunk/src/graphics/material_manager.cpp 2010-01-05 03:38:35 UTC (rev 4400) @@ -50,7 +50,11 @@ void MaterialManager::setAllMaterialFlags(video::ITexture* t, scene::IMeshBuffer *mb) const { +#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR == 7) + const std::string image = StringUtils::getBasename(core::stringc(t->getName()).c_str()); +#else const std::string image = StringUtils::getBasename(t->getName().c_str()); +#endif // Search backward so that temporary (track) textures are found first for(int i = (int)m_materials.size()-1; i>=0; i-- ) { Modified: main/trunk/src/guiengine/skin.cpp =================================================================== --- main/trunk/src/guiengine/skin.cpp 2010-01-05 01:13:53 UTC (rev 4399) +++ main/trunk/src/guiengine/skin.cpp 2010-01-05 03:38:35 UTC (rev 4400) @@ -1326,7 +1326,18 @@ GUIEngine::getDriver()->getCurrentRenderTargetSize()) ); } -core::rect< s32 > Skin::draw3DWindowBackground (IGUIElement *element, bool drawTitleBar, video::SColor titleBarColor, const core::rect< s32 > &rect, const core::rect< s32 > *clip) +#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR==7) +core::rect< s32 > Skin::draw3DWindowBackground(IGUIElement *element, bool drawTitleBar, + video::SColor titleBarColor, + const core::rect< s32 > &rect, + const core::rect< s32 > *clip, + core::rect<s32>* checkClientArea) +#else +core::rect< s32 > Skin::draw3DWindowBackground(IGUIElement *element, bool drawTitleBar, + video::SColor titleBarColor, + const core::rect< s32 > &rect, + const core::rect< s32 > *clip) +#endif { drawBGFadeColor(); Modified: main/trunk/src/guiengine/skin.hpp =================================================================== --- main/trunk/src/guiengine/skin.hpp 2010-01-05 01:13:53 UTC (rev 4399) +++ main/trunk/src/guiengine/skin.hpp 2010-01-05 03:38:35 UTC (rev 4400) @@ -254,7 +254,12 @@ virtual void draw3DTabBody (irr::gui::IGUIElement *element, bool border, bool background, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip, irr::s32 tabHeight=-1, irr::gui::EGUI_ALIGNMENT alignment=irr::gui::EGUIA_UPPERLEFT); virtual void draw3DTabButton (irr::gui::IGUIElement *element, bool active, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip, irr::gui::EGUI_ALIGNMENT alignment=irr::gui::EGUIA_UPPERLEFT); virtual void draw3DToolBar (irr::gui::IGUIElement *element, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); +#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR==7) + virtual irr::core::rect< irr::s32 > draw3DWindowBackground (irr::gui::IGUIElement *element, bool drawTitleBar, irr::video::SColor titleBarColor, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip, + irr::core::rect<irr::s32>* checkClientArea=0); +#else virtual irr::core::rect< irr::s32 > draw3DWindowBackground (irr::gui::IGUIElement *element, bool drawTitleBar, irr::video::SColor titleBarColor, const irr::core::rect< irr::s32 > &rect, const irr::core::rect< irr::s32 > *clip); +#endif virtual void drawIcon (irr::gui::IGUIElement *element, irr::gui::EGUI_DEFAULT_ICON icon, const irr::core::position2di position, irr::u32 starttime, irr::u32 currenttime, bool loop=false, const irr::core::rect< irr::s32 > *clip=NULL); virtual irr::video::SColor getColor (irr::gui::EGUI_DEFAULT_COLOR color) const; virtual const wchar_t* getDefaultText (irr::gui::EGUI_DEFAULT_TEXT text) const; Modified: main/trunk/src/ide/vc9/bullet_lib.vcproj =================================================================== --- main/trunk/src/ide/vc9/bullet_lib.vcproj 2010-01-05 01:13:53 UTC (rev 4399) +++ main/trunk/src/ide/vc9/bullet_lib.vcproj 2010-01-05 03:38:35 UTC (rev 4400) @@ -209,6 +209,70 @@ Name="VCPostBuildEventTool" /> </Configuration> + <Configuration + Name="irr1.7|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="2" + ManagedExtensions="0" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + WholeProgramOptimization="false" + AdditionalIncludeDirectories="..\..\bullet\src;"$(STK_INCLUDE)"" + PreprocessorDefinitions="WIN32;NDEBUG;BT_NO_PROFILE;HAVE_GLUT" + MinimalRebuild="true" + RuntimeLibrary="0" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> </Configurations> <References> <AssemblyReference Modified: main/trunk/src/ide/vc9/enet.vcproj =================================================================== --- main/trunk/src/ide/vc9/enet.vcproj 2010-01-05 01:13:53 UTC (rev 4399) +++ main/trunk/src/ide/vc9/enet.vcproj 2010-01-05 03:38:35 UTC (rev 4400) @@ -206,6 +206,70 @@ Name="VCPostBuildEventTool" /> </Configuration> + <Configuration + Name="irr1.7|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="4" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + WholeProgramOptimization="false" + AdditionalIncludeDirectories="../../enet/include" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLibrarianTool" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> </Configurations> <References> </References> Modified: main/trunk/src/ide/vc9/supertuxkart.sln =================================================================== --- main/trunk/src/ide/vc9/supertuxkart.sln 2010-01-05 01:13:53 UTC (rev 4399) +++ main/trunk/src/ide/vc9/supertuxkart.sln 2010-01-05 03:38:35 UTC (rev 4400) @@ -15,6 +15,7 @@ GlobalSection(SolutionConfigurationPlatforms) = preSolution debug|Win32 = debug|Win32 irr1.6|Win32 = irr1.6|Win32 + irr1.7|Win32 = irr1.7|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution @@ -22,18 +23,24 @@ {B1BC2764-1A43-4800-A654-788B0D05EDA2}.debug|Win32.Build.0 = Debug|Win32 {B1BC2764-1A43-4800-A654-788B0D05EDA2}.irr1.6|Win32.ActiveCfg = irr1.6|Win32 {B1BC2764-1A43-4800-A654-788B0D05EDA2}.irr1.6|Win32.Build.0 = irr1.6|Win32 + {B1BC2764-1A43-4800-A654-788B0D05EDA2}.irr1.7|Win32.ActiveCfg = irr1.7|Win32 + {B1BC2764-1A43-4800-A654-788B0D05EDA2}.irr1.7|Win32.Build.0 = irr1.7|Win32 {B1BC2764-1A43-4800-A654-788B0D05EDA2}.Release|Win32.ActiveCfg = Release|Win32 {B1BC2764-1A43-4800-A654-788B0D05EDA2}.Release|Win32.Build.0 = Release|Win32 {54AA44B9-B07B-49DA-8B1A-05BBFE8AD5D4}.debug|Win32.ActiveCfg = Release|Win32 {54AA44B9-B07B-49DA-8B1A-05BBFE8AD5D4}.debug|Win32.Build.0 = Release|Win32 {54AA44B9-B07B-49DA-8B1A-05BBFE8AD5D4}.irr1.6|Win32.ActiveCfg = irr1.6|Win32 {54AA44B9-B07B-49DA-8B1A-05BBFE8AD5D4}.irr1.6|Win32.Build.0 = irr1.6|Win32 + {54AA44B9-B07B-49DA-8B1A-05BBFE8AD5D4}.irr1.7|Win32.ActiveCfg = irr1.7|Win32 + {54AA44B9-B07B-49DA-8B1A-05BBFE8AD5D4}.irr1.7|Win32.Build.0 = irr1.7|Win32 {54AA44B9-B07B-49DA-8B1A-05BBFE8AD5D4}.Release|Win32.ActiveCfg = Release|Win32 {54AA44B9-B07B-49DA-8B1A-05BBFE8AD5D4}.Release|Win32.Build.0 = Release|Win32 {B0E92B97-089A-4D5B-BF17-77F1BC5DAEEF}.debug|Win32.ActiveCfg = Release|Win32 {B0E92B97-089A-4D5B-BF17-77F1BC5DAEEF}.debug|Win32.Build.0 = Release|Win32 {B0E92B97-089A-4D5B-BF17-77F1BC5DAEEF}.irr1.6|Win32.ActiveCfg = irr1.6|Win32 {B0E92B97-089A-4D5B-BF17-77F1BC5DAEEF}.irr1.6|Win32.Build.0 = irr1.6|Win32 + {B0E92B97-089A-4D5B-BF17-77F1BC5DAEEF}.irr1.7|Win32.ActiveCfg = irr1.7|Win32 + {B0E92B97-089A-4D5B-BF17-77F1BC5DAEEF}.irr1.7|Win32.Build.0 = irr1.7|Win32 {B0E92B97-089A-4D5B-BF17-77F1BC5DAEEF}.Release|Win32.ActiveCfg = Release|Win32 {B0E92B97-089A-4D5B-BF17-77F1BC5DAEEF}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection Modified: main/trunk/src/ide/vc9/supertuxkart.vcproj =================================================================== --- main/trunk/src/ide/vc9/supertuxkart.vcproj 2010-01-05 01:13:53 UTC (rev 4399) +++ main/trunk/src/ide/vc9/supertuxkart.vcproj 2010-01-05 03:38:35 UTC (rev 4400) @@ -272,6 +272,94 @@ Name="VCPostBuildEventTool" /> </Configuration> + <Configuration + Name="irr1.7|Win32" + OutputDirectory="$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + WholeProgramOptimization="false" + AdditionalIncludeDirectories="../../../src;../../../src/bullet/src;"$(STK_INCLUDE)";../../../src/enet/include;"C:\cygwin\home\jh235117\local\irrlicht-1.7\include"" + PreprocessorDefinitions="BT_NO_PROFILE;HAVE_OPENAL;HAVE_OGGVORBIS;_DEBUG;_CONSOLE;WIN32;NOMINMAX;VERSION=\"SVN\";_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;DEBUG;PACKAGE=\"supertuxkart\";HAVE_GETTEXT;ENABLE_NLS;HAVE_GLUT;HAVE_IRRLICHT;_CRTDBG_MAP_ALLOC;IRR_SVN" + GeneratePreprocessedFile="0" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + FloatingPointExceptions="false" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="opengl32.lib user32.lib gdi32.lib winmm.lib advapi32.lib OpenAL32.lib libogg.lib libvorbis.lib libvorbisfile.lib intl.lib Irrlicht.lib ws2_32.lib" + OutputFile="./../../../$(ProjectName)_d16.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(STK_LIB)";"C:\cygwin\home\jh235117\local\irrlicht-1.7\lib\Win32-visualstudio"" + IgnoreAllDefaultLibraries="false" + IgnoreDefaultLibraryNames="libcmt.lib" + GenerateDebugInformation="true" + GenerateMapFile="false" + MapFileName="" + MapExports="false" + SubSystem="1" + LinkTimeCodeGeneration="0" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" + TargetMachine="1" + Profile="false" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> </Configurations> <References> </References> Modified: main/trunk/src/tracks/track.cpp =================================================================== --- main/trunk/src/tracks/track.cpp 2010-01-05 01:13:53 UTC (rev 4399) +++ main/trunk/src/tracks/track.cpp 2010-01-05 03:38:35 UTC (rev 4400) @@ -371,7 +371,11 @@ const Material* material=0; TriangleMesh *tmesh = m_track_mesh; if(t) { +#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR == 7) + std::string image = std::string(core::stringc(t->getName()).c_str()); +#else std::string image = std::string(t->getName().c_str()); +#endif material=material_manager->getMaterial(StringUtils::getBasename(image)); // Zipper are converted to non-collision mesh, since otherwise // the road becomes 'bumpy' if the meshes are not 100% correctly @@ -515,7 +519,11 @@ video::ITexture* t=irrMaterial.getTexture(j); if(!t) continue; const std::string texture_name = +#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR == 7) + StringUtils::getBasename(core::stringc(t->getName()).c_str()); +#else StringUtils::getBasename(t->getName().c_str()); +#endif if(texture_name!=name) continue; core::matrix4 *m = &irrMaterial.getTextureMatrix(j); m_animated_textures.push_back(new MovingTexture(m, *texture_node)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-01-07 22:55:50
|
Revision: 4406 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4406&view=rev Author: auria Date: 2010-01-07 22:55:38 +0000 (Thu, 07 Jan 2010) Log Message: ----------- Use the irrlicht 1.7 feature that enables smooth scaling in the GUI (ahhhh, my eyes =). A few known issues have been introduced, they will hopefully be fixed soonish. Modified Paths: -------------- main/trunk/src/graphics/irr_driver.cpp main/trunk/src/guiengine/engine.cpp Modified: main/trunk/src/graphics/irr_driver.cpp =================================================================== --- main/trunk/src/graphics/irr_driver.cpp 2010-01-07 01:14:46 UTC (rev 4405) +++ main/trunk/src/graphics/irr_driver.cpp 2010-01-07 22:55:38 UTC (rev 4406) @@ -174,6 +174,13 @@ m_video_driver = m_device->getVideoDriver(); const std::string &font = file_manager->getFontFile("DomesticManners.xml"); m_race_font = m_gui_env->getFont(font.c_str()); + +#if (IRRLICHT_VERSION_MAJOR == 1) && (IRRLICHT_VERSION_MINOR >= 7) + video::SMaterial& material2D = m_video_driver->getMaterial2D(); + material2D.TextureLayer[0].BilinearFilter=true; + material2D.AntiAliasing=video::EAAM_FULL_BASIC; + //m_video_driver->enableMaterial2D(); +#endif } Modified: main/trunk/src/guiengine/engine.cpp =================================================================== --- main/trunk/src/guiengine/engine.cpp 2010-01-07 01:14:46 UTC (rev 4405) +++ main/trunk/src/guiengine/engine.cpp 2010-01-07 22:55:38 UTC (rev 4406) @@ -250,6 +250,8 @@ g_skin->drawBGFadeColor(); } + g_driver->enableMaterial2D(); + if (gamestate == MENU || gamestate == INGAME_MENU) { g_skin->renderSections(); @@ -267,6 +269,8 @@ { RaceManager::getWorld()->getRaceGUI()->renderGlobal(elapsed_time); } + + g_driver->enableMaterial2D(false); } // render // ----------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-01-10 23:12:36
|
Revision: 4424 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4424&view=rev Author: hikerstk Date: 2010-01-10 23:12:29 +0000 (Sun, 10 Jan 2010) Log Message: ----------- Removed #include of kart and player_kart from world. Modified Paths: -------------- main/trunk/src/challenges/challenge_data.cpp main/trunk/src/config/player.cpp main/trunk/src/graphics/irr_driver.cpp main/trunk/src/input/input_device.cpp main/trunk/src/input/input_manager.cpp main/trunk/src/modes/profile_world.cpp main/trunk/src/modes/world.hpp main/trunk/src/network/kart_control_message.cpp main/trunk/src/robots/default_robot.cpp main/trunk/src/robots/new_ai.cpp main/trunk/src/states_screens/race_gui.cpp main/trunk/src/tracks/ambient_light_sphere.cpp main/trunk/src/utils/translation.cpp Modified: main/trunk/src/challenges/challenge_data.cpp =================================================================== --- main/trunk/src/challenges/challenge_data.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/challenges/challenge_data.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -23,6 +23,7 @@ #include "karts/kart.hpp" #include "karts/kart_properties_manager.hpp" +#include "karts/player_kart.hpp" #include "lisp/lisp.hpp" #include "lisp/parser.hpp" #include "modes/linear_world.hpp" Modified: main/trunk/src/config/player.cpp =================================================================== --- main/trunk/src/config/player.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/config/player.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -1,5 +1,6 @@ #include "config/player.hpp" +#include "karts/player_kart.hpp" #include "race/race_manager.hpp" #include "modes/world.hpp" Modified: main/trunk/src/graphics/irr_driver.cpp =================================================================== --- main/trunk/src/graphics/irr_driver.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/graphics/irr_driver.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -39,6 +39,7 @@ #include "items/attachment_manager.hpp" #include "items/projectile_manager.hpp" #include "karts/kart_properties_manager.hpp" +#include "karts/player_kart.hpp" #include "main_loop.hpp" #include "modes/world.hpp" #include "states_screens/state_manager.hpp" Modified: main/trunk/src/input/input_device.cpp =================================================================== --- main/trunk/src/input/input_device.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/input/input_device.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -3,6 +3,7 @@ #include "guiengine/abstract_state_manager.hpp" #include "input/input.hpp" #include "input/input_device.hpp" +#include "karts/player_kart.hpp" #include "modes/world.hpp" #include "race/race_manager.hpp" #include "states_screens/state_manager.hpp" Modified: main/trunk/src/input/input_manager.cpp =================================================================== --- main/trunk/src/input/input_manager.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/input/input_manager.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -37,6 +37,7 @@ #include "input/input.hpp" #include "items/projectile_manager.hpp" #include "karts/kart.hpp" +#include "karts/player_kart.hpp" #include "modes/world.hpp" #include "race/history.hpp" #include "race/race_manager.hpp" Modified: main/trunk/src/modes/profile_world.cpp =================================================================== --- main/trunk/src/modes/profile_world.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/modes/profile_world.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -17,8 +17,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#include "modes/profile_world.hpp" + +#include "graphics/camera.hpp" #include "graphics/irr_driver.hpp" -#include "modes/profile_world.hpp" #include "robots/default_robot.hpp" Modified: main/trunk/src/modes/world.hpp =================================================================== --- main/trunk/src/modes/world.hpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/modes/world.hpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -22,8 +22,6 @@ #include <vector> -#include "karts/kart.hpp" -#include "karts/player_kart.hpp" #include "modes/clock.hpp" #include "network/network_kart.hpp" #include "physics/physics.hpp" @@ -31,10 +29,12 @@ #include "states_screens/race_gui.hpp" #include "utils/random_generator.hpp" +class btRigidBody; +class Kart; +class PlayerKart; +class RaceGUI; class SFXBase; -class btRigidBody; class Track; -class RaceGUI; /** This class is responsible for running the actual race. A world is created * by the race manager on the start of each race (so a new world is created Modified: main/trunk/src/network/kart_control_message.cpp =================================================================== --- main/trunk/src/network/kart_control_message.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/network/kart_control_message.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -19,6 +19,7 @@ #include "network/kart_control_message.hpp" +#include "karts/player_kart.hpp" #include "modes/world.hpp" #include "network/network_kart.hpp" Modified: main/trunk/src/robots/default_robot.cpp =================================================================== --- main/trunk/src/robots/default_robot.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/robots/default_robot.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -37,6 +37,7 @@ #ifdef AI_DEBUG #include "graphics/irr_driver.hpp" #endif +#include "karts/player_kart.hpp" #include "modes/linear_world.hpp" #include "network/network_manager.hpp" #include "race/race_manager.hpp" Modified: main/trunk/src/robots/new_ai.cpp =================================================================== --- main/trunk/src/robots/new_ai.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/robots/new_ai.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -37,6 +37,7 @@ #ifdef AI_DEBUG #include "graphics/irr_driver.hpp" #endif +#include "karts/player_kart.hpp" #include "modes/linear_world.hpp" #include "network/network_manager.hpp" #include "race/race_manager.hpp" Modified: main/trunk/src/states_screens/race_gui.cpp =================================================================== --- main/trunk/src/states_screens/race_gui.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/states_screens/race_gui.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -33,6 +33,7 @@ #include "input/input.hpp" #include "input/input_manager.hpp" #include "karts/kart_properties_manager.hpp" +#include "karts/player_kart.hpp" #include "modes/world.hpp" #include "race/race_manager.hpp" #include "tracks/track.hpp" @@ -227,10 +228,7 @@ if(player_kart->hasViewBlockedByPlunger()) { - int offset_x = viewport.UpperLeftCorner.X; int offset_y = viewport.UpperLeftCorner.Y; - float split_screen_ratio_x = scaling.X; - float split_screen_ratio_y = scaling.Y; const int screen_width = viewport.LowerRightCorner.X-viewport.UpperLeftCorner.X; const int plunger_size = viewport.UpperLeftCorner.Y-viewport.LowerRightCorner.Y; @@ -577,7 +575,7 @@ const int lap = info[kart->getWorldKartId()].lap; if(lap<0) return; // don't display 'lap 0/...' - float minRatio = std::min(scaling.X, scaling.Y); + core::recti pos; pos.UpperLeftCorner.X = viewport.UpperLeftCorner.X + (int)(0.15f*UserConfigParams::m_width*scaling.X); Modified: main/trunk/src/tracks/ambient_light_sphere.cpp =================================================================== --- main/trunk/src/tracks/ambient_light_sphere.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/tracks/ambient_light_sphere.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -24,6 +24,7 @@ #include "graphics/camera.hpp" #include "io/xml_node.hpp" +#include "karts/player_kart.hpp" #include "modes/world.hpp" #include "race/race_manager.hpp" #include "tracks/track.hpp" Modified: main/trunk/src/utils/translation.cpp =================================================================== --- main/trunk/src/utils/translation.cpp 2010-01-10 22:50:13 UTC (rev 4423) +++ main/trunk/src/utils/translation.cpp 2010-01-10 23:12:29 UTC (rev 4424) @@ -335,7 +335,7 @@ #else const char* original_t = original; #endif - + wchar_t* out_ptr = utf8_to_wchar_t(original_t); if (out_ptr == NULL) @@ -343,7 +343,8 @@ std::cerr << " ERROR in w_gettext! could not be converted to wchar_t.\n"; } - std::wcout << L" translation : " << out_ptr << std::endl; + std::wcout << L" translation : " << irr::core::stringc(out_ptr).c_str() << std::endl; + fprintf(stdout, "translation is '%s'.\n", irr::core::stringc(out_ptr).c_str()); return out_ptr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-01-11 23:22:50
|
Revision: 4433 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4433&view=rev Author: auria Date: 2010-01-11 23:22:44 +0000 (Mon, 11 Jan 2010) Log Message: ----------- Fixed i18n on OS X too (may not work on PPC macs) Modified Paths: -------------- main/trunk/src/ide/Xcode/Config.xcconfig main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj main/trunk/src/utils/translation.cpp Modified: main/trunk/src/ide/Xcode/Config.xcconfig =================================================================== --- main/trunk/src/ide/Xcode/Config.xcconfig 2010-01-11 22:08:33 UTC (rev 4432) +++ main/trunk/src/ide/Xcode/Config.xcconfig 2010-01-11 23:22:44 UTC (rev 4433) @@ -4,5 +4,5 @@ OTHER_CFLAGS = -Wall -DHAVE_OGGVORBIS=1 -DHAS_SOCKLEN_T -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAS_POLL=1 -DHAS_FCNTL=1 -DHAS_INET_PTON=1 -DHAS_INET_NTOP=1 -DHAS_MSGHDR_FLAGS=1 -DENABLE_NLS=1 -DHAVE_GETTEXT=1 -DHAVE_GLUT=1 -DHAVE_IRRLICHT=1 -DPACKAGE="\"supertuxkart\"" -D__MACOSX__=1 -DHAVE_RTT=1 -OTHER_LDFLAGS = -lirrlicht -liconv +OTHER_LDFLAGS = -lirrlicht -lintl LIBRARY_SEARCH_PATHS = /usr/local/lib /usr/lib Modified: main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj =================================================================== --- main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj 2010-01-11 22:08:33 UTC (rev 4432) +++ main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj 2010-01-11 23:22:44 UTC (rev 4433) @@ -17,7 +17,6 @@ 9507E96A0FC1C8C200BD2B92 /* GlutStuff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9507E9490FC1C8C100BD2B92 /* GlutStuff.cpp */; }; 9507E9700FC1C8C200BD2B92 /* RenderTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9507E9500FC1C8C200BD2B92 /* RenderTexture.cpp */; }; 9507E9B70FC1CCE900BD2B92 /* stk.icns in Resources */ = {isa = PBXBuildFile; fileRef = 9507E9B60FC1CCE900BD2B92 /* stk.icns */; }; - 9507E9D00FC1CDCE00BD2B92 /* libintl.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7F80FC1B63C00DB481B /* libintl.framework */; }; 9507E9D10FC1CDCE00BD2B92 /* Ogg.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7F90FC1B63C00DB481B /* Ogg.framework */; }; 9507E9D20FC1CDCE00BD2B92 /* OpenAL.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FA0FC1B63C00DB481B /* OpenAL.framework */; }; 9507E9DB0FC1CDD500BD2B92 /* Vorbis.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FB0FC1B63C00DB481B /* Vorbis.framework */; }; @@ -230,7 +229,6 @@ 9551C8F90FC1B72500DB481B /* physical_object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95CA59F70F82FCB7003323DB /* physical_object.cpp */; }; 9551C8FA0FC1B72500DB481B /* quad_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951C357E0FC05BF400A48379 /* quad_set.cpp */; }; 9551C8FB0FC1B72500DB481B /* quad_graph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951C35800FC05BF400A48379 /* quad_graph.cpp */; }; - 9551C9F00FC1B7EE00DB481B /* libintl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7F80FC1B63C00DB481B /* libintl.framework */; }; 9551C9F10FC1B7EE00DB481B /* Ogg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7F90FC1B63C00DB481B /* Ogg.framework */; }; 9551C9F20FC1B7EE00DB481B /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FA0FC1B63C00DB481B /* OpenAL.framework */; }; 9551C9F30FC1B7EE00DB481B /* Vorbis.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FB0FC1B63C00DB481B /* Vorbis.framework */; }; @@ -297,7 +295,6 @@ dstSubfolderSpec = 10; files = ( 9507E9DB0FC1CDD500BD2B92 /* Vorbis.framework in Copy frameworks */, - 9507E9D00FC1CDCE00BD2B92 /* libintl.framework in Copy frameworks */, 9507E9D10FC1CDCE00BD2B92 /* Ogg.framework in Copy frameworks */, 9507E9D20FC1CDCE00BD2B92 /* OpenAL.framework in Copy frameworks */, ); @@ -423,7 +420,6 @@ 954E4C2A0FF98B6E0047FE3E /* billboard_animation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = billboard_animation.hpp; path = ../../animations/billboard_animation.hpp; sourceTree = SOURCE_ROOT; }; 954E4C2B0FF98B6E0047FE3E /* three_d_animation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = three_d_animation.cpp; path = ../../animations/three_d_animation.cpp; sourceTree = SOURCE_ROOT; }; 954E4C2C0FF98B6E0047FE3E /* three_d_animation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = three_d_animation.hpp; path = ../../animations/three_d_animation.hpp; sourceTree = SOURCE_ROOT; }; - 9551C7F80FC1B63C00DB481B /* libintl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libintl.framework; path = /Library/Frameworks/libintl.framework; sourceTree = "<absolute>"; }; 9551C7F90FC1B63C00DB481B /* Ogg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Ogg.framework; path = /Library/Frameworks/Ogg.framework; sourceTree = "<absolute>"; }; 9551C7FA0FC1B63C00DB481B /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = /Library/Frameworks/OpenAL.framework; sourceTree = "<absolute>"; }; 9551C7FB0FC1B63C00DB481B /* Vorbis.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Vorbis.framework; path = /Library/Frameworks/Vorbis.framework; sourceTree = "<absolute>"; }; @@ -1094,7 +1090,6 @@ 9551CBD50FC1BB7600DB481B /* GLUT.framework in Frameworks */, 9551CBD60FC1BB7600DB481B /* Cocoa.framework in Frameworks */, 9551CBD70FC1BB7600DB481B /* OpenGL.framework in Frameworks */, - 9551C9F00FC1B7EE00DB481B /* libintl.framework in Frameworks */, 9551C9F10FC1B7EE00DB481B /* Ogg.framework in Frameworks */, 9551C9F20FC1B7EE00DB481B /* OpenAL.framework in Frameworks */, 9551C9F30FC1B7EE00DB481B /* Vorbis.framework in Frameworks */, @@ -1160,7 +1155,6 @@ isa = PBXGroup; children = ( 9551CBD90FC1BB9200DB481B /* AGL.framework */, - 9551C7F80FC1B63C00DB481B /* libintl.framework */, 9551C7F90FC1B63C00DB481B /* Ogg.framework */, 9551C7FA0FC1B63C00DB481B /* OpenAL.framework */, 9551C7FB0FC1B63C00DB481B /* Vorbis.framework */, Modified: main/trunk/src/utils/translation.cpp =================================================================== --- main/trunk/src/utils/translation.cpp 2010-01-11 22:08:33 UTC (rev 4432) +++ main/trunk/src/utils/translation.cpp 2010-01-11 23:22:44 UTC (rev 4433) @@ -38,8 +38,12 @@ #include "io/file_manager.hpp" +// set to 1 to debug i18n +#define TRANSLATE_VERBOSE 0 + Translations* translations=NULL; +bool remove_bom = false; // ---------------------------------------------------------------------------- Translations::Translations() @@ -55,9 +59,20 @@ setlocale(LC_MESSAGES, ""); #endif bindtextdomain (PACKAGE, file_manager->getTranslationDir().c_str()); - if (sizeof(wchar_t) == 4) bind_textdomain_codeset(PACKAGE, "UTF-32"); - else if (sizeof(wchar_t) == 2) bind_textdomain_codeset(PACKAGE, "UTF-16LE"); - else assert(false); + if (sizeof(wchar_t) == 4) + { + // FIXME: will probably not work on PPC maccs + bind_textdomain_codeset(PACKAGE, "UTF-32LE"); + } + else if (sizeof(wchar_t) == 2) + { + bind_textdomain_codeset(PACKAGE, "UTF-16LE"); + } + else + { + fprintf(stderr, "Your wchar_t is neither 2 byte-long nor 4. What now??\n"); + exit(1); + } textdomain (PACKAGE); #endif @@ -68,7 +83,9 @@ { if (original[0] == '\0') return L""; +#if TRANSLATE_VERBOSE std::cout << "Translating " << original << "\n"; +#endif #if ENABLE_NLS const char* original_t = gettext(original); @@ -76,13 +93,42 @@ m_converted_string = core::stringw(original); return m_converted_string.c_str(); #endif + + /* + std::cout << "--> original_t==original ? " << (original_t==original) << std::endl; + int zeros = 0; + for (int n=0;; n+=1) + { + std::cout << original_t[n] << " (" << (unsigned)(original_t[n]) << ")\n"; + if (original_t[n] == 0) + { + zeros++; + if (zeros >= 4) break; + } + else + { + zeros = 0; + } + }*/ + if(original_t==original) { m_converted_string = core::stringw(original); + +#if TRANSLATE_VERBOSE + std::wcout << L" translation : " << m_converted_string.c_str() << std::endl; +#endif return m_converted_string.c_str(); } + + // print + //for (int n=0;; n+=4) + wchar_t* out_ptr = (wchar_t*)original_t; - //std::wcout << L" translation : " << out_ptr << std::endl; + if (remove_bom) out_ptr++; +#if TRANSLATE_VERBOSE + std::wcout << L" translation : " << out_ptr << std::endl; +#endif return out_ptr; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-01-12 02:02:20
|
Revision: 4439 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4439&view=rev Author: hikerstk Date: 2010-01-12 02:02:13 +0000 (Tue, 12 Jan 2010) Log Message: ----------- Applied Stephen Just's patch 2926028: search for data directory relative to the executable, which allows STK to be started/debugged in VS without having to set a working directory. Modified Paths: -------------- main/trunk/src/io/file_manager.cpp main/trunk/src/io/file_manager.hpp main/trunk/src/main.cpp Modified: main/trunk/src/io/file_manager.cpp =================================================================== --- main/trunk/src/io/file_manager.cpp 2010-01-11 23:56:16 UTC (rev 4438) +++ main/trunk/src/io/file_manager.cpp 2010-01-12 02:02:13 UTC (rev 4439) @@ -90,7 +90,7 @@ * exists) changed in reInit(). * */ -FileManager::FileManager() +FileManager::FileManager(char *argv[]) { #ifdef __APPLE__ // irrLicht's createDevice method has a nasty habit of messing the CWD. @@ -108,18 +108,30 @@ m_file_system = m_device->getFileSystem(); m_is_full_path = false; + irr::io::path exe_path; + + // Also check for data dirs relative to the path of the executable. + // This is esp. useful for Visual Studio, since it's not necessary + // to define the working directory when debugging, it works automatically. + if(m_file_system->existFile(argv[0])) + exe_path = m_file_system->getFileDir(argv[0]); + if ( getenv ( "SUPERTUXKART_DATADIR" ) != NULL ) m_root_dir= getenv ( "SUPERTUXKART_DATADIR" ) ; #ifdef __APPLE__ else if( macSetBundlePathIfRelevant( m_root_dir ) ) { /* nothing to do */ } #endif - // else if(m_file_system->existFile("/Developer/games/supertuxkart/data/stk_config.xml")) - // m_root_dir = "/Developer/games/supertuxkart" ; - // FIXME - existFile() fails to detect the file, even though it exists, on my computer else if(m_file_system->existFile("data/stk_config.xml")) m_root_dir = "." ; else if(m_file_system->existFile("../data/stk_config.xml")) m_root_dir = ".." ; + else if(m_file_system->existFile(exe_path+"/data/stk_config.xml")) + m_root_dir = exe_path.c_str(); + else if(m_file_system->existFile(exe_path+"/../data/stk_config.xml")) + { + m_root_dir = exe_path.c_str(); + m_root_dir += "/.."; + } else #ifdef SUPERTUXKART_DATADIR m_root_dir = SUPERTUXKART_DATADIR ; Modified: main/trunk/src/io/file_manager.hpp =================================================================== --- main/trunk/src/io/file_manager.hpp 2010-01-11 23:56:16 UTC (rev 4438) +++ main/trunk/src/io/file_manager.hpp 2010-01-12 02:02:13 UTC (rev 4439) @@ -53,7 +53,7 @@ io::path createAbsoluteFilename(const std::string &f); public: - FileManager(); + FileManager(char *argv[]); ~FileManager(); void setDevice(IrrlichtDevice *device); void dropFileSystem(); Modified: main/trunk/src/main.cpp =================================================================== --- main/trunk/src/main.cpp 2010-01-11 23:56:16 UTC (rev 4438) +++ main/trunk/src/main.cpp 2010-01-12 02:02:13 UTC (rev 4439) @@ -492,9 +492,9 @@ //============================================================================= /** Initialises the minimum number of managers to get access to user_config. */ -void initUserConfig() +void initUserConfig(char *argv[]) { - file_manager = new FileManager(); + file_manager = new FileManager(argv); translations = new Translations(); // needs file_manager user_config = new UserConfig(); // needs file_manager } // initUserConfig @@ -579,7 +579,8 @@ // Init the minimum managers so that user config exists, then // handle all command line options that do not need (or must // not have) other managers initialised: - initUserConfig(); + initUserConfig(argv); // argv passed so config file can be + // found more reliably handleCmdLinePreliminary(argc, argv); initRest(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hik...@us...> - 2010-01-12 23:00:16
|
Revision: 4443 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4443&view=rev Author: hikerstk Date: 2010-01-12 23:00:10 +0000 (Tue, 12 Jan 2010) Log Message: ----------- Bugfix: the rotating stars were being shown when restarting a race. Modified Paths: -------------- main/trunk/src/graphics/stars.cpp main/trunk/src/graphics/stars.hpp main/trunk/src/karts/kart.cpp Modified: main/trunk/src/graphics/stars.cpp =================================================================== --- main/trunk/src/graphics/stars.cpp 2010-01-12 22:55:03 UTC (rev 4442) +++ main/trunk/src/graphics/stars.cpp 2010-01-12 23:00:10 UTC (rev 4443) @@ -90,6 +90,13 @@ } // ---------------------------------------------------------------------------- +/** Resets the stars, esp. disabling them at a restart. + */ +void Stars::reset() +{ + m_enabled = false; +} // unShow +// ---------------------------------------------------------------------------- void Stars::update(float delta_t) { Modified: main/trunk/src/graphics/stars.hpp =================================================================== --- main/trunk/src/graphics/stars.hpp 2010-01-12 22:55:03 UTC (rev 4442) +++ main/trunk/src/graphics/stars.hpp 2010-01-12 23:00:10 UTC (rev 4443) @@ -45,12 +45,11 @@ float m_remaining_time; public: - Stars (scene::IAnimatedMeshSceneNode* parentKart); - ~Stars (); - //void show (); - void showFor (float time); - //void hide (); - void update (float delta_t); + Stars (scene::IAnimatedMeshSceneNode* parentKart); + ~Stars (); + void showFor(float time); + void reset(); + void update (float delta_t); }; #endif Modified: main/trunk/src/karts/kart.cpp =================================================================== --- main/trunk/src/karts/kart.cpp 2010-01-12 22:55:03 UTC (rev 4442) +++ main/trunk/src/karts/kart.cpp 2010-01-12 23:00:10 UTC (rev 4443) @@ -380,7 +380,8 @@ m_controls.m_drift = false; m_controls.m_fire = false; m_controls.m_look_back = false; - + // Reset star effect in case that it is currently being shown. + m_stars_effect->reset(); m_vehicle->deactivateZipper(); // Set the brakes so that karts don't slide downhill This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <au...@us...> - 2010-01-13 00:57:23
|
Revision: 4446 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=4446&view=rev Author: auria Date: 2010-01-13 00:57:17 +0000 (Wed, 13 Jan 2010) Log Message: ----------- Endianness detection cleanup Modified Paths: -------------- main/trunk/src/Makefile.am main/trunk/src/audio/music_ogg.cpp main/trunk/src/audio/sfx_manager.cpp main/trunk/src/audio/sound_manager.cpp main/trunk/src/audio/sound_manager.hpp main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj main/trunk/src/utils/constants.hpp main/trunk/src/utils/translation.cpp Added Paths: ----------- main/trunk/src/utils/constants.cpp Modified: main/trunk/src/Makefile.am =================================================================== --- main/trunk/src/Makefile.am 2010-01-13 00:56:31 UTC (rev 4445) +++ main/trunk/src/Makefile.am 2010-01-13 00:57:17 UTC (rev 4446) @@ -329,6 +329,7 @@ tracks/track_object_manager.cpp \ tracks/track_object_manager.hpp \ utils/constants.hpp \ + utils/constants.cpp \ utils/coord.hpp \ utils/no_copy.hpp \ utils/ptr_vector.hpp \ Modified: main/trunk/src/audio/music_ogg.cpp =================================================================== --- main/trunk/src/audio/music_ogg.cpp 2010-01-13 00:56:31 UTC (rev 4445) +++ main/trunk/src/audio/music_ogg.cpp 2010-01-13 00:57:17 UTC (rev 4446) @@ -30,6 +30,7 @@ #include "audio/sound_manager.hpp" #include "config/user_config.hpp" +#include "utils/constants.hpp" MusicOggStream::MusicOggStream() { Modified: main/trunk/src/audio/sfx_manager.cpp =================================================================== --- main/trunk/src/audio/sfx_manager.cpp 2010-01-13 00:56:31 UTC (rev 4445) +++ main/trunk/src/audio/sfx_manager.cpp 2010-01-13 00:57:17 UTC (rev 4446) @@ -42,6 +42,7 @@ #include "config/user_config.hpp" #include "io/file_manager.hpp" #include "race/race_manager.hpp" +#include "utils/constants.hpp" SFXManager* sfx_manager= NULL; Modified: main/trunk/src/audio/sound_manager.cpp =================================================================== --- main/trunk/src/audio/sound_manager.cpp 2010-01-13 00:56:31 UTC (rev 4445) +++ main/trunk/src/audio/sound_manager.cpp 2010-01-13 00:57:17 UTC (rev 4446) @@ -39,18 +39,6 @@ SoundManager* sound_manager= NULL; -// the ogg loader needs to know about endianness so do a simple test. -// 0 : little endian -// 1 : big endian -// I'm doing it at runtime rather than at compile-time to be friendly with -// cross-compilation (universal binaries on mac, namely) -static const int endianness_test = 0x01000000; -static const char* endianness_test_ptr = (const char*)&endianness_test; - -// in little-endian, byte 0 will be 0. in big endian, byte 0 will be 1 -bool IS_LITTLE_ENDIAN = (endianness_test_ptr[0] == 0); - - SoundManager::SoundManager() { m_current_music= NULL; Modified: main/trunk/src/audio/sound_manager.hpp =================================================================== --- main/trunk/src/audio/sound_manager.hpp 2010-01-13 00:56:31 UTC (rev 4445) +++ main/trunk/src/audio/sound_manager.hpp 2010-01-13 00:57:17 UTC (rev 4446) @@ -31,8 +31,6 @@ class Vec3; -extern bool IS_LITTLE_ENDIAN; - class SoundManager { private: Modified: main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj =================================================================== --- main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj 2010-01-13 00:56:31 UTC (rev 4445) +++ main/trunk/src/ide/Xcode/STK_XCode.xcodeproj/project.pbxproj 2010-01-13 00:57:17 UTC (rev 4446) @@ -241,6 +241,7 @@ 9551CBD70FC1BB7600DB481B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 95F423120E26E3DC00692113 /* OpenGL.framework */; }; 9551CBDA0FC1BB9200DB481B /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551CBD90FC1BB9200DB481B /* AGL.framework */; }; 9551DB34104CABFC001C53E5 /* race_over_dialog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9551DB33104CABFC001C53E5 /* race_over_dialog.cpp */; }; + 9553823A10FD4FEC00737979 /* constants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9553823910FD4FEC00737979 /* constants.cpp */; }; 955DE88310042701006A4F3C /* check_manager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE88110042701006A4F3C /* check_manager.cpp */; }; 955DE88C1004273B006A4F3C /* check_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 955DE8871004273B006A4F3C /* check_structure.cpp */; }; 956541BB10DD5F0A00C83E99 /* arenas_screen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 956541B910DD5F0A00C83E99 /* arenas_screen.cpp */; }; @@ -429,6 +430,7 @@ 9551CBD90FC1BB9200DB481B /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = /System/Library/Frameworks/AGL.framework; sourceTree = "<absolute>"; }; 9551DB32104CABFC001C53E5 /* race_over_dialog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = race_over_dialog.hpp; path = ../../states_screens/dialogs/race_over_dialog.hpp; sourceTree = SOURCE_ROOT; }; 9551DB33104CABFC001C53E5 /* race_over_dialog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = race_over_dialog.cpp; path = ../../states_screens/dialogs/race_over_dialog.cpp; sourceTree = SOURCE_ROOT; }; + 9553823910FD4FEC00737979 /* constants.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = constants.cpp; path = ../../utils/constants.cpp; sourceTree = SOURCE_ROOT; }; 955DE88110042701006A4F3C /* check_manager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = check_manager.cpp; path = ../../tracks/check_manager.cpp; sourceTree = SOURCE_ROOT; }; 955DE88210042701006A4F3C /* check_manager.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = check_manager.hpp; path = ../../tracks/check_manager.hpp; sourceTree = SOURCE_ROOT; }; 955DE8871004273B006A4F3C /* check_structure.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = check_structure.cpp; path = ../../tracks/check_structure.cpp; sourceTree = SOURCE_ROOT; }; @@ -2007,16 +2009,17 @@ 95C2B1DF0F296546000D3E5D /* utils */ = { isa = PBXGroup; children = ( - 953EAAB50F30A4650000D57D /* translation.cpp */, - 953EAAB40F30A4650000D57D /* translation.hpp */, + 9553823910FD4FEC00737979 /* constants.cpp */, 95C2B1E00F296546000D3E5D /* constants.hpp */, 95C2B1E10F296546000D3E5D /* coord.hpp */, + 9540E2570FD5F8FD002985B8 /* no_copy.hpp */, + 9540E2560FD5F8FD002985B8 /* ptr_vector.hpp */, 95C2B1E20F296546000D3E5D /* random_generator.cpp */, 95C2B1E30F296546000D3E5D /* random_generator.hpp */, 95C2B1E60F296546000D3E5D /* string_utils.cpp */, 95C2B1E70F296546000D3E5D /* string_utils.hpp */, - 9540E2560FD5F8FD002985B8 /* ptr_vector.hpp */, - 9540E2570FD5F8FD002985B8 /* no_copy.hpp */, + 953EAAB50F30A4650000D57D /* translation.cpp */, + 953EAAB40F30A4650000D57D /* translation.hpp */, 95C2B1E80F296546000D3E5D /* vec3.cpp */, 95C2B1E90F296546000D3E5D /* vec3.hpp */, ); @@ -2588,6 +2591,7 @@ 95C9C97210E93456005A418D /* stars.cpp in Sources */, 959482D310EBC0790031BADF /* track_object_manager.cpp in Sources */, 959482D410EBC0790031BADF /* track_object.cpp in Sources */, + 9553823A10FD4FEC00737979 /* constants.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Added: main/trunk/src/utils/constants.cpp =================================================================== --- main/trunk/src/utils/constants.cpp (rev 0) +++ main/trunk/src/utils/constants.cpp 2010-01-13 00:57:17 UTC (rev 4446) @@ -0,0 +1,27 @@ +// +// SuperTuxKart - a fun racing game with go-kart +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// for code that needs to know about endianness so do a simple test. +// 0 : little endian +// 1 : big endian +// I'm doing it at runtime rather than at compile-time to be friendly with +// cross-compilation (universal binaries on mac, namely) +static const int endianness_test = 0x01000000; +static const char* endianness_test_ptr = (const char*)&endianness_test; + +// in little-endian, byte 0 will be 0. in big endian, byte 0 will be 1 +bool IS_LITTLE_ENDIAN = (endianness_test_ptr[0] == 0); Property changes on: main/trunk/src/utils/constants.cpp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: main/trunk/src/utils/constants.hpp =================================================================== --- main/trunk/src/utils/constants.hpp 2010-01-13 00:56:31 UTC (rev 4445) +++ main/trunk/src/utils/constants.hpp 2010-01-13 00:57:17 UTC (rev 4446) @@ -49,5 +49,7 @@ const int MAX_PLAYER_COUNT = 4; +extern int IS_LITTLE_ENDIAN; + #endif Modified: main/trunk/src/utils/translation.cpp =================================================================== --- main/trunk/src/utils/translation.cpp 2010-01-13 00:56:31 UTC (rev 4445) +++ main/trunk/src/utils/translation.cpp 2010-01-13 00:57:17 UTC (rev 4446) @@ -37,11 +37,11 @@ #include "irrlicht.h" #include "io/file_manager.hpp" +#include "utils/constants.hpp" // set to 1 to debug i18n #define TRANSLATE_VERBOSE 0 - Translations* translations=NULL; bool remove_bom = false; @@ -62,7 +62,8 @@ if (sizeof(wchar_t) == 4) { // FIXME: will probably not work on PPC maccs - bind_textdomain_codeset(PACKAGE, "UTF-32LE"); + if (IS_LITTLE_ENDIAN) bind_textdomain_codeset(PACKAGE, "UTF-32LE"); + else bind_textdomain_codeset(PACKAGE, "UTF-32BE"); } else if (sizeof(wchar_t) == 2) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |