Changeset 724 – HoverRace

Changeset 724

Show
Ignore:
Timestamp:
07/12/09 03:20:07 (13 months ago)
Author:
zoogie
Message:

#116: Display a bit more info about the fullscreen test:

  • What resolution is being tested.
  • How many seconds remain until the test ends.
Location:
trunk/client/Game2
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/client/Game2/FullscreenTest.cpp

    r722 r724  
    3434#include "FullscreenTest.h" 
    3535 
     36using boost::format; 
     37using boost::str; 
     38 
    3639using namespace HoverRace::Client; 
    3740using namespace HoverRace::Util; 
     
    4750    oldX(oldX), oldY(oldY), oldMonitor(oldMonitor), 
    4851    viewport(new MR_2DViewPort()), widgetsInitialized(false), 
    49     heading(NULL), 
     52    heading(NULL), subheading(NULL), 
    5053    timeRemaining(5) 
    5154{ 
     
    5457FullscreenTest::~FullscreenTest() 
    5558{ 
     59    delete subheading; 
    5660    delete heading; 
    5761    delete viewport; 
     
    9296} 
    9397 
    94 void FullscreenTest::InitWidgets(int resY) 
     98int FullscreenTest::ScaleFont(int i, int resY) 
    9599{ 
    96     Font headingFont("Arial", 20 * resY / 480, true); 
     100    // Assume that font sizes given are relative to a 640x480 screen. 
     101    return i * resY / 480; 
     102} 
     103 
     104void FullscreenTest::UpdateSubheading(int resY) 
     105{ 
     106    // Keep these translations short -- the user doesn't have much time to read them! 
     107    const char *text = ngettext( 
     108        "Returning in %d second.", 
     109        "Returning in %d seconds.", 
     110        timeRemaining); 
     111    std::string subheadingStr = str(format(text) % timeRemaining); 
     112    if (subheading == NULL) { 
     113        Font subheadingFont("Arial", ScaleFont(16, resY), true); 
     114        subheading = new StaticText(subheadingStr, subheadingFont, 0x10); 
     115    } 
     116    else { 
     117        subheading->SetText(subheadingStr); 
     118    } 
     119} 
     120 
     121void FullscreenTest::InitWidgets(int resX, int resY) 
     122{ 
     123    Font headingFont("Arial", ScaleFont(20, resY), true); 
    97124     
    98     heading = new StaticText(_("HoverRace fullscreen settings test"), headingFont, 0x08); 
     125    // Keep these translations short -- the user doesn't have much time to read them! 
     126    std::string headingStr = _("HoverRace fullscreen test"); 
     127    headingStr += ": "; 
     128    headingStr += str(format("%dx%d", OS::stdLocale) % resX % resY); 
     129    heading = new StaticText(headingStr, headingFont, 0x0c); 
    99130} 
    100131 
     
    110141    int resY = dest->GetYRes(); 
    111142    if (!widgetsInitialized) { 
    112         InitWidgets(resY); 
     143        InitWidgets(resX, resY); 
    113144        widgetsInitialized = true; 
    114145    } 
     146    UpdateSubheading(resY); 
    115147 
    116148    dest->Lock(); 
     
    121153    int curY = resY / 2 - heading->GetHeight(); 
    122154    heading->Blt(leftMargin, curY, viewport); 
    123     //curY += heading->GetHeight(); 
     155    curY += heading->GetHeight(); 
     156 
     157    subheading->Blt(leftMargin, curY, viewport); 
    124158 
    125159    dest->Unlock(); 
    126160} 
    127  
  • trunk/client/Game2/FullscreenTest.h

    r722 r724  
    4949 
    5050    private: 
    51         void InitWidgets(int resY); 
     51        static int ScaleFont(int i, int resY); 
     52        void UpdateSubheading(int resY); 
     53        void InitWidgets(int resX, int resY); 
    5254    public: 
    5355        void Render(MR_VideoBuffer *dest); 
     
    6062        bool widgetsInitialized; 
    6163        VideoServices::StaticText *heading; 
     64        VideoServices::StaticText *subheading; 
    6265 
    6366        int timeRemaining;