1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Changeset 10664

Show
Ignore:
Timestamp:
01/14/12 19:16:25 (16 months ago)
Author:
auria
Message:

Show summary of challenge when approaching orb

Location:
main/trunk/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/src/challenges/challenge_data.cpp

    r10363 r10664  
    4242    m_num_laps    = -1; 
    4343    m_num_karts   = -1; 
    44  
     44    m_position    = -1; 
    4545    m_time        = -1.0f; 
    46     m_track_name  = ""; 
     46    m_track_id  = ""; 
    4747    m_gp_id       = ""; 
    4848    m_energy      = -1; 
     
    9595    setName( s.c_str() ); 
    9696 
    97     if(!root->get("description", &s) ) error("description"); 
    98     setChallengeDescription( s.c_str() ); 
     97    //if(!root->get("description", &s) ) error("description"); 
     98    //setChallengeDescription( s.c_str() ); 
    9999    //std::cout << "    // Challenge description = <" << s.c_str() << ">\n"; 
    100100 
     101     
     102     
    101103    if(!root->get("karts", &m_num_karts)  ) error("karts"); 
    102104 
     
    125127    if(m_major==RaceManager::MAJOR_MODE_SINGLE) 
    126128    { 
    127         if (!root->get("track",  &m_track_name )) 
     129        if (!root->get("track",  &m_track_id )) 
    128130        { 
    129131            error("track"); 
    130132        } 
    131         if (track_manager->getTrack(m_track_name) == NULL) 
     133        if (track_manager->getTrack(m_track_id) == NULL) 
    132134        { 
    133135            error("track"); 
     
    164166    delete root; 
    165167 
     168     
     169     
     170    core::stringw description; 
     171    //I18N: number of laps to race in a challenge 
     172    description += _("Laps : %i", m_num_laps); 
     173    description += core::stringw(L"\n"); 
     174    //I18N: number of AI karts in a challenge 
     175    description += _("AI Karts : %i", m_num_karts - 1); 
     176    if (m_position > 0) 
     177    { 
     178        description += core::stringw(L"\n"); 
     179        //I18N: position required to win in a challenge 
     180        description += _("Required rank : %i", m_position); 
     181    } 
     182    if (m_time > 0) 
     183    { 
     184        description += core::stringw(L"\n"); 
     185        //I18N: time required to win a challenge 
     186        description += _("Time to achieve : %s", StringUtils::timeToString(m_time).c_str()); 
     187    } 
     188    if (m_energy > 0) 
     189    { 
     190        description += core::stringw(L"\n"); 
     191        //I18N: nitro points needed to win a challenge 
     192        description += _("Collect %i points of nitr", m_energy); 
     193    } 
     194     
     195    m_challenge_description = description; 
    166196}   // ChallengeData 
    167197 
     
    189219        try 
    190220        { 
    191             track_manager->getTrack(m_track_name); 
     221            track_manager->getTrack(m_track_id); 
    192222        } 
    193223        catch(std::exception&) 
     
    271301    { 
    272302        race_manager->setMinorMode(m_minor); 
    273         race_manager->setTrack(m_track_name); 
     303        race_manager->setTrack(m_track_id); 
    274304        race_manager->setDifficulty(m_difficulty); 
    275305        race_manager->setNumLaps(m_num_laps); 
     
    299329    World *world = World::getWorld(); 
    300330    std::string track_name = world->getTrack()->getIdent(); 
    301     if(track_name!=m_track_name                         ) return false; 
     331    if(track_name!=m_track_id                         ) return false; 
    302332    if((int)world->getNumKarts()<m_num_karts            ) return false; 
    303333    Kart* kart = world->getPlayerKart(0); 
  • main/trunk/src/challenges/challenge_data.hpp

    r10502 r10664  
    6262    float                          m_time; 
    6363    std::string                    m_gp_id; 
    64     std::string                    m_track_name; 
     64    std::string                    m_track_id; 
    6565    int                            m_energy; 
    6666    std::string                    m_filename; 
     
    106106        getFeatures() const                    { return m_feature;          } 
    107107 
    108     void  setChallengeDescription(const irr::core::stringw& d)  
    109         {m_challenge_description=d;  } 
    110  
    111108    const irr::core::stringw getChallengeDescription() const  
    112109        {return _(m_challenge_description.c_str()); } 
     
    130127    void  setId(const std::string& s)             { m_id = s;                 } 
    131128     
    132     const std::string& getTrackName() const        { return m_track_name;     } 
     129    const std::string& getTrackId() const        { return m_track_id;     } 
    133130 
    134131     
     
    142139                              const irr::core::stringw &user_name); 
    143140     
     141     
     142    RaceManager::MajorRaceModeType getMajorMode()  const { return m_major;      } 
     143    RaceManager::MinorRaceModeType getMinorMode()  const { return m_minor;      } 
     144    RaceManager::Difficulty        getDifficulty() const { return m_difficulty; } 
     145    int                            getNumLaps()    const { return m_num_laps;   } 
     146    int                            getPosition()   const { return m_position;   } 
     147    int                            getNumKarts()   const { return m_num_karts;  } 
     148    float                          getTime()       const { return m_time;       } 
     149    int                            getEnergy()     const { return m_energy;     } 
     150     
    144151};   // ChallengeData 
    145152 
  • main/trunk/src/states_screens/race_gui_overworld.cpp

    r10660 r10664  
    4242#include "race/race_manager.hpp" 
    4343#include "tracks/track.hpp" 
     44#include "tracks/track_manager.hpp" 
    4445#include "utils/constants.hpp" 
    4546#include "utils/string_utils.hpp" 
     
    244245     
    245246    Track* t = world->getTrack(); 
     247     
     248    Vec3 kart_xyz; 
    246249     
    247250    // In the first iteration, only draw AI karts, then only draw 
     
    259262            if(kart->getController()->isPlayerController()  
    260263               !=(only_draw_player_kart==1)) continue; 
    261             const Vec3& xyz = kart->getXYZ(); 
     264            kart_xyz= kart->getXYZ(); 
    262265            Vec3 draw_at; 
    263             t->mapPoint2MiniMap(xyz, &draw_at); 
     266            t->mapPoint2MiniMap(kart_xyz, &draw_at); 
    264267             
    265268            core::rect<s32> source(i    *m_marker_rendered_size, 
     
    297300     
    298301    //const std::vector<OverworldChallenge>& challenges = t->getChallengeList(); 
    299     const std::vector<OverworldForceField>& challenges = t->getForceFieldList(); 
    300      
    301     for (unsigned int n=0; n<challenges.size(); n++) 
     302    const std::vector<OverworldForceField>& forcefields = t->getForceFieldList(); 
     303     
     304    for (unsigned int n=0; n<forcefields.size(); n++) 
    302305    { 
    303306        Vec3 draw_at; 
    304         t->mapPoint2MiniMap(challenges[n].m_position, &draw_at); 
     307        t->mapPoint2MiniMap(forcefields[n].m_position, &draw_at); 
    305308         
    306309        //const ChallengeData* c = unlock_manager->getChallenge(challenges[n].m_challenge_id); 
    307310       // bool locked = (m_locked_challenges.find(c) != m_locked_challenges.end()); 
    308         bool locked = challenges[n].m_is_locked; 
     311        bool locked = forcefields[n].m_is_locked; 
    309312         
    310313        const core::rect<s32> source(core::position2d<s32>(0,0), 
     
    318321                                                  dest, source, NULL, NULL, true); 
    319322    } 
     323     
     324     
     325    // ---- Draw nearby challenge if any 
     326    const std::vector<OverworldChallenge>& challenges = t->getChallengeList(); 
     327    for (unsigned int n=0; n<challenges.size(); n++) 
     328    { 
     329        if ((kart_xyz - Vec3(challenges[n].m_position)).length2_2d() < 20) 
     330        { 
     331            core::rect<s32> pos(15, 
     332                                10,  
     333                                15 + UserConfigParams::m_width/2, 
     334                                10 + GUIEngine::getTitleFontHeight()); 
     335             
     336            const ChallengeData* challenge = unlock_manager->getChallenge(challenges[n].m_challenge_id); 
     337             
     338            if (challenge == NULL) 
     339            { 
     340                fprintf(stderr, "[RaceGUIOverworld] ERROR: Cannot find challenge <%s>\n", 
     341                        challenges[n].m_challenge_id.c_str()); 
     342                break; 
     343            } 
     344             
     345            Track* track = track_manager->getTrack(challenge->getTrackId()); 
     346            if (track == NULL) 
     347            { 
     348                fprintf(stderr, "[RaceGUIOverworld] ERROR: Cannot find track <%s>, " 
     349                        "referenced from challenge <%s>\n", 
     350                        challenge->getTrackId().c_str(), 
     351                        challenges[n].m_challenge_id.c_str()); 
     352                break; 
     353            } 
     354             
     355            gui::ScalableFont* font = GUIEngine::getTitleFont(); 
     356            font->draw(track->getName(), pos, video::SColor(255,255,255,255), 
     357                       false, true /* vcenter */, NULL); 
     358             
     359             
     360            pos.UpperLeftCorner.Y += GUIEngine::getTitleFontHeight(); 
     361            pos.LowerRightCorner.Y = UserConfigParams::m_height; 
     362            GUIEngine::getFont()->draw(challenge->getChallengeDescription().c_str(), 
     363                                       pos, video::SColor(255,255,255,255), 
     364                                       false, false /* vcenter */, NULL); 
     365            break; 
     366        } 
     367    } 
     368     
    320369}   // drawGlobalMiniMap 
    321370 
  • main/trunk/src/tracks/track.cpp

    r10660 r10664  
    858858                m_challenges.push_back( OverworldChallenge(xyz, challenge) ); 
    859859                 
    860                 Track* t = track_manager->getTrack(c->getTrackName()); 
     860                Track* t = track_manager->getTrack(c->getTrackId()); 
    861861                if (t == NULL) 
    862862                { 
    863                     fprintf(stderr, "[WARNING] Cannot find track named <%s>\n", c->getTrackName().c_str()); 
     863                    fprintf(stderr, "[WARNING] Cannot find track named <%s>\n", c->getTrackId().c_str()); 
    864864                    continue; 
    865865                }