Changeset 26 for trunk/Classes/intro.cpp


Ignore:
Timestamp:
2010-05-28 07:39:52 (2 years ago)
Author:
kpoole
Message:

Episode 5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Classes/intro.cpp

    r15 r26  
    3434#define LOG_NG LOG_STREAM(info, engine) 
    3535 
     36extern bool gRedraw; 
     37 
    3638namespace { 
    3739    void scan_deprecation_messages(const config& cfg) 
     
    5153 
    5254static bool show_intro_part(display &disp, const vconfig& part, 
    53         const std::string& scenario); 
     55        const std::string& scenario, bool redrawOnly=false); 
    5456 
    5557void show_intro(display &disp, const vconfig& data, const config& level) 
     
    101103 
    102104bool show_intro_part(display &disp, const vconfig& part, 
    103         const std::string& scenario) 
     105        const std::string& scenario, bool redrawOnly) 
    104106{ 
    105107    LOG_NG << "showing intro part\n"; 
     
    110112 
    111113    // Play music if available 
    112     if(music_file != "") { 
     114    if(!redrawOnly && music_file != "") { 
    113115        sound::play_music_repeatedly(music_file); 
    114116    } 
    115117 
    116118    CKey key; 
    117  
    118     gui::button next_button(video,_("Next") + std::string(">>>")); 
     119#ifdef __IPAD__ 
     120    gui::button next_button(video,_("Next") + std::string(" >>>")); 
    119121    gui::button skip_button(video,_("Skip")); 
     122#else 
     123    gui::button next_button(video,_("Next") + std::string(">>>"), gui::button::TYPE_PRESS, "button"); 
     124    gui::button skip_button(video,_("Skip"), gui::button::TYPE_PRESS, "button"); 
     125#endif 
    120126 
    121127//  draw_solid_tinted_rectangle(0,0,video.getx(),video.gety(), 
     
    162168    if(images.empty()) 
    163169        dstrect.y -= 75/2; 
     170#endif 
     171     
     172#ifdef __IPAD__ 
     173    if(images.empty()) 
     174        dstrect.y -= 75; 
    164175#endif 
    165176     
     
    188199    ybuttons = video.gety() - 40; 
    189200 
    190     next_button.set_location(xbuttons,ybuttons-30); 
     201    next_button.set_location(xbuttons,ybuttons-50); 
    191202    skip_button.set_location(xbuttons,ybuttons); 
    192203#endif 
     
    223234 
    224235            const int delay = lexical_cast_default<int>((*i)["delay"], 0); 
    225             const int x = static_cast<int>(atoi((*i)["x"].c_str())*scale); 
    226             const int y = static_cast<int>(atoi((*i)["y"].c_str())*scale); 
     236            int x = static_cast<int>(atoi((*i)["x"].c_str())*scale); 
     237            int y = static_cast<int>(atoi((*i)["y"].c_str())*scale); 
     238             
     239#ifndef __IPAD__ 
     240            // KP: fix progress images 
     241            double xs = 427.0f/1024.0f; //480.0f/1024.0f; 
     242            double ys = 320.0f/768.0f; 
     243            x = x * xs; 
     244            y = y * ys; 
     245#endif 
    227246 
    228247            if (utils::string_bool((*i)["scaled"])){ 
     
    280299        } 
    281300    } 
     301     
     302    if (redrawOnly) 
     303        return true; 
     304     
    282305    try { 
    283306        return show_intro_part_helper( 
     
    452475        if(!skip || itor == utils::utf8_iterator::end(story)) 
    453476            disp.delay(20); 
     477         
     478        if (gRedraw == true) 
     479        { 
     480            gRedraw = false; 
     481             
     482            itor = utils::utf8_iterator::begin(story); 
     483#ifdef USE_TINY_GUI 
     484            xpos = textx; 
     485            ypos = texty + 10; 
     486#else 
     487            xpos = textx; 
     488            ypos = texty + 20; 
     489#endif 
     490             
     491            // mid-story flip support 
     492            show_intro_part(disp, part, "", true); 
     493 
     494            if(story.empty() != true) 
     495            { 
     496                // this should kill the tiniest flickering caused 
     497                // by the buttons being hidden and unhidden in this scope. 
     498                update_locker locker(disp.video()); 
     499                 
     500                const SDL_Rect total_size = font::draw_text(NULL, screen_area(), font::SIZE_PLUS, 
     501                                                            font::NORMAL_COLOUR, story, 0, 0); 
     502                 
     503                next_button.hide(); 
     504                skip_button.hide(); 
     505                 
     506                if (texty + 20 + total_size.h > screen_area().h) { 
     507                    texty = screen_area().h > total_size.h + 1 ? screen_area().h - total_size.h - 21 : 0; 
     508                } 
     509                 
     510                update_y = texty; 
     511                update_h = screen_area().h-texty; 
     512                blur_helper(disp.video(), update_y, update_h); 
     513                 
     514                //draw_solid_tinted_rectangle( 
     515                //  0, texty, screen_area().w, screen_area().h - texty, 
     516                //  0, 0, 0, 1.0, video.getSurface() 
     517                //); 
     518                SDL_Rect tintRect = {0, texty, screen_area().w, screen_area().h - texty}; 
     519                SDL_SetRenderDrawColor(0, 0, 0, 0xff); 
     520                SDL_RenderFill(&tintRect); 
     521                 
     522                // Draw a nice border 
     523                if(has_background) { 
     524                    // FIXME: perhaps hard-coding the image path isn't a really 
     525                    // good idea - it must not be forgotten if someone decides to switch 
     526                    // the image directories around. 
     527                    surface top_border = image::get_image("dialogs/translucent54-border-top.png"); 
     528                    top_border = scale_surface_blended(top_border, screen_area().w, top_border->h); 
     529                    update_y = texty - top_border->h; 
     530                    update_h += top_border->h; 
     531                    blur_helper(disp.video(), update_y, top_border->h); 
     532                    blit_surface(0, texty - top_border->h, top_border); 
     533                } 
     534                 
     535                // Make buttons aware of the changes in the background 
     536                next_button.set_location(next_button.location()); 
     537                next_button.hide(false); 
     538                skip_button.set_location(skip_button.location()); 
     539                skip_button.hide(false); 
     540            } 
     541             
     542             
     543        } 
    454544    } 
    455545 
Note: See TracChangeset for help on using the changeset viewer.