Back to index

extremetuxracer  0.5beta
credits.cpp
Go to the documentation of this file.
00001 /* 
00002  * Extreme Tux Racer (Not Copyrighted)
00003  * 
00004  * based on Planet Penguin Racer, Open Racer, and Tux Racer: 
00005  * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de>
00006  *
00007  * Copyright (C) 1999-2001 Jasmin F. Patry
00008  * 
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License
00011  * as published by the Free Software Foundation; either version 2
00012  * of the License, or (at your option) any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022  */
00023 
00024 
00025 #include "credits.h"
00026 
00027 #include "ppgltk/audio/audio.h"
00028 #include "ppgltk/font.h"
00029 
00030 
00031 #define CREDITS_MAX_Y -140
00032 #define CREDITS_MIN_Y 64
00033 
00034 typedef struct {
00035     pp::Font *font;
00036        char *binding;
00037     char *text;
00038 } credit_line_t;
00039 
00040 static credit_line_t credit_lines[] = 
00041 {
00042        { NULL, "credits_text_big", "Extreme Tux Racer" },
00043     { NULL, "credits_text", N_("Version 0.5") },
00044     { NULL, "credits_text", "www.extremetuxracer.com" },
00045     { NULL, "credits_text", "" },  
00046        { NULL, "credits_text", N_("Extreme Tux Racer is in the process of being") },       
00047        { NULL, "credits_text", N_("completely rewritten. All versions after 0.35,") },     
00048        { NULL, "credits_text", N_("including this one, won't have major code changes") },  
00049        { NULL, "credits_text", N_("because the programmers are busy making a new,") },
00050     { NULL, "credits_text", N_("improved game.") },
00051        { NULL, "credits_text", "" },             
00052        { NULL, "credits_text", N_("Extreme Tux Racer is based on") },
00053        { NULL, "credits_text", N_("PlanetPenguin Racer, Open Racer and Tux Racer.") },
00054            { NULL, "credits_text", "" },
00055               { NULL, "credits_text", N_("Some courses may have been modified from their") },
00056               { NULL, "credits_text", N_("original versions to fit the requirements of the game.") },           
00057     { NULL, "credits_text", "" },
00058     { NULL, "credits_h2", N_("Development") },
00059     { NULL, "credits_text", "Jean-Vivien Maurice" },
00060     { NULL, "credits_text", "Paweł Drewniak" },
00061     { NULL, "credits_text", "Steven Bell" },
00062     { NULL, "credits_text", "Hamish Morrison" },
00063     { NULL, "credits_text", "Andreas Tarandi" },
00064     { NULL, "credits_text", "Volker Ströbel (PlanetPenguin Racer)" },
00065        { NULL, "credits_text_small", N_("from Sunspire Studios:") },
00066     { NULL, "credits_text", "Patrick \"Pog\" Gilhuly" },
00067     { NULL, "credits_text", "Eric \"Monster\" Hall" },
00068     { NULL, "credits_text", "Rick Knowles" },
00069     { NULL, "credits_text", "Vincent Ma" },
00070     { NULL, "credits_text", "Jasmin Patry" },
00071     { NULL, "credits_text", "Mark Riddell" },
00072               { NULL, "credits_text", "" },
00073               { NULL, "credits_h2", N_("Release Organization") },
00074               { NULL, "credits_text", "Christian Picon" },     
00075               { NULL, "credits_text", "" },
00076     { NULL, "credits_h2", N_("Graphics") },
00077     { NULL, "credits_text", N_("Nicosmos (Logo, HUD and Interface)") },
00078     { NULL, "credits_text", N_("Christian Picon (Objects, Skyboxes, Characters)") },
00079     { NULL, "credits_text", N_("Reinhard Niehoff (Trees)") },  
00080     { NULL, "credits_text", N_("Daniel Poeira and Christian Picon (Papercuts Font)") },
00081     { NULL, "credits_text", "" },
00082     { NULL, "credits_h2", N_("Music") },
00083     { NULL, "credits_text", "Joseph Toscano" },
00084            { NULL, "credits_text_small", N_("'Race 1'") },
00085               { NULL, "credits_text_small", N_("'Menu'") },
00086            { NULL, "credits_text_small", N_("'Options'") },    
00087            { NULL, "credits_text_small", N_("'Won Race'") },
00088            { NULL, "credits_text_small", "" },          
00089     { NULL, "credits_text", "Christian Picon" },
00090            { NULL, "credits_text_small", N_("'Credits Ballad'") },
00091            { NULL, "credits_text_small", "" },          
00092     { NULL, "credits_text", "Grady O'Connell" },
00093            { NULL, "credits_text_small", N_("'Freezing Point'") },
00094        { NULL, "credits_text_small", "" },
00095     { NULL, "credits_text", "Karl Schroeder" },
00096             { NULL, "credits_text_small", N_("'Calm Race'") }, 
00097             { NULL, "credits_text_small", N_("'Lost Race'") }, 
00098             { NULL, "credits_text_small", N_("'Race Intro'") },       
00099             { NULL, "credits_text_small", N_("'Spunky Race'") },      
00100             { NULL, "credits_text_small", N_("'Won Race: kschroeder Remix'") },     
00101                   { NULL, "credits_text", "" },
00102        { NULL, "credits_h2", N_("Misc. PPRacer Contributors") },
00103        { NULL, "credits_text", "Peter Reichel" },
00104        { NULL, "credits_text", "Teemu Vesala" },
00105        { NULL, "credits_text", "Theo Snelleman" },
00106     { NULL, "credits_text", "" },
00107     { NULL, "credits_text", "blaukreuz" },
00108     { NULL, "credits_text_small", N_("52143__blaukreuz__imp_01.wav - Original sound of ice cracking...") },
00109     { NULL, "credits_text_small", N_("http://www.freesound.org/samplesViewSingle.php?id=52143") },
00110     { NULL, "credits_text", "" },
00111     { NULL, "credits_h2", N_("Thanks To") },
00112     { NULL, "credits_text_small", N_("(for Extreme Tux Racer)") },
00113     { NULL, "credits_text", N_("Ranger (for hosting the website)") },
00114     { NULL, "credits_text", N_("Slythfox (for making the website)") },
00115     { NULL, "credits_text", N_("The Course Creators") },       
00116     { NULL, "credits_text", N_("The OpenRacer project") },
00117     { NULL, "credits_text", N_("Reinhard Niehoff (tons of advice)") },
00118     { NULL, "credits_text", N_("All the people of the forum") },
00119     { NULL, "credits_text", N_("Larry Ewing (creator of Tux)") },
00120     { NULL, "credits_text_small", N_("(for Tux Racer)") },
00121     { NULL, "credits_text", "Thatcher Ulrich" },
00122     { NULL, "credits_text", "Steve Baker" },
00123     { NULL, "credits_text", "Ingo Ruhnke" },
00124     { NULL, "credits_text", "James Barnard" },
00125     { NULL, "credits_text", "Alan Levy" },
00126     { NULL, "credits_text", "" },
00127   { NULL, "credits_text_small", N_("Tux Racer is a trademark of Jasmin F. Patry.") },
00128        { NULL, "credits_text_small", N_("Extreme Tux Racer is licenced under the GPL.") },
00129        { NULL, "credits_text_small", N_("We grant use of the name 'Extreme Tux Racer'") },
00130     { NULL, "credits_text_small", N_("to any forks or continuations.") },
00131        { NULL, "credits_text_small", "" },
00132        { NULL, "credits_text_small", N_("PlanetPenguin Racer is Copyright © 2005 Volker Stroebel.") },
00133   { NULL, "credits_text_small", N_("Tux Racer and the Tux Racer Name are Copyright © 2001 Jasmin F. Patry.") },
00134 };
00135 
00136 Credits::Credits()
00137  : m_yOffset(0.0)
00138 {
00139        for (unsigned int i=0; i<sizeof( credit_lines ) / sizeof( credit_lines[0] ); i++) {
00140               credit_lines[i].font = pp::Font::get(credit_lines[i].binding);        
00141        }
00142        
00143   play_music( "credits_screen" );
00144 
00145 
00146        pp::Vec2d pos(0,0);
00147        mp_backBtn = new pp::Button(pos,
00148                               pp::Vec2d(50, 40),
00149                               "button_label",
00150                               _("Back") );
00151        mp_backBtn->setHilitFontBinding( "button_label_hilit" );
00152        mp_backBtn->signalClicked.Connect(pp::CreateSlot(this,&Credits::CredBack)); 
00153        mp_backBtn->setPosition( pp::Vec2d(100,0) );
00154 
00155 
00156 mp_creditstransBtn = new pp::Button(pos,
00157                               pp::Vec2d(120, 40),
00158                               "button_label",
00159                               _("Translators") );
00160        mp_creditstransBtn->setHilitFontBinding( "button_label_hilit" );
00161        mp_creditstransBtn->signalClicked.Connect(pp::CreateSlot(this,&Credits::Trans)); 
00162        mp_creditstransBtn->setPosition( pp::Vec2d(700,0) );
00163 
00164 }
00165 
00166 
00167 Credits::~Credits()
00168 {      
00169 delete mp_creditstransBtn;
00170 delete mp_backBtn;
00171 }
00172 
00173 void
00174 Credits::loop(float timeStep)
00175 {
00176        int width, height;
00177 
00178   width = getparam_x_resolution();
00179   height = getparam_y_resolution();
00180 
00181   update_audio();
00182 
00183   clear_rendering_context();
00184 
00185   set_gl_options( GUI );
00186 
00187   UIMgr.setupDisplay();
00188 
00189   drawText( timeStep );
00190 
00191        drawSnow(timeStep);
00192 
00193        theme.drawMenuDecorations();
00194 
00195   UIMgr.draw();
00196 
00197   reshape( width, height );
00198 
00199   winsys_swap_buffers();
00200 }
00201 
00202 
00203 void
00204 Credits::drawText( float timeStep )
00205 {
00206     int w = getparam_x_resolution();
00207     int h = getparam_y_resolution();
00208     float y;
00209 
00210     m_yOffset += timeStep * 30;
00211     y = CREDITS_MIN_Y + m_yOffset;
00212 
00213        //loop through all credit lines
00214        for (unsigned int i=0; i<sizeof( credit_lines ) / sizeof( credit_lines[0] ); i++) {
00215            credit_line_t line = credit_lines[i];
00216 
00217               //get the font and sizes for the binding
00218               //pp::Font *font = pp::Font::get(line.binding);
00219         
00220               float width = line.font->advance(_(line.text));
00221               float desc = line.font->descender();
00222               float asc = line.font->ascender();
00223               
00224               //draw the line on the screen
00225               line.font->draw(_(line.text), w/2 - width/2, y);
00226 
00227               //calculate the y value for the next line
00228               y-=asc-desc;
00229        }
00230 
00231        //if the last string reaches the top, reset the y offset
00232     if ( y > h+CREDITS_MAX_Y ) {
00233               m_yOffset = 0;
00234     }
00235 
00236     // Draw strips at the top and bottom to clip out text 
00237     glDisable( GL_TEXTURE_2D );
00238 
00239     glColor4dv( (double*)&theme.background );
00240 
00241     glRectf( 0, 0, w, CREDITS_MIN_Y );
00242 
00243     glBegin( GL_QUADS );
00244     {
00245        glVertex2f( 0, CREDITS_MIN_Y );
00246        glVertex2f( w, CREDITS_MIN_Y );
00247        glColor4f( theme.background.r, 
00248                  theme.background.g,
00249                  theme.background.b,
00250                  0 );
00251        glVertex2f( w, CREDITS_MIN_Y + 30 );
00252        glVertex2f( 0, CREDITS_MIN_Y + 30 );
00253     }
00254     glEnd();
00255 
00256     glColor4dv( (double*)&theme.background );
00257 
00258     glRectf( 0, h+CREDITS_MAX_Y, w, h );
00259 
00260     glBegin( GL_QUADS );
00261     {
00262        glVertex2f( w, h+CREDITS_MAX_Y );
00263        glVertex2f( 0, h+CREDITS_MAX_Y );
00264        glColor4f( theme.background.r, 
00265                  theme.background.g,
00266                  theme.background.b,
00267                  0 );
00268        glVertex2f( 0, h+CREDITS_MAX_Y - 30 );
00269        glVertex2f( w, h+CREDITS_MAX_Y - 30 );
00270     }
00271     glEnd();
00272 
00273     glColor4f( 1, 1, 1, 1 );
00274 
00275     glEnable( GL_TEXTURE_2D );
00276 }
00277 
00278 
00279 
00280 bool
00281 Credits::keyPressEvent(SDLKey key)
00282 {
00283        if (key == SDLK_t) { set_game_mode( CREDITS_TRANS ); return true; }
00284        set_game_mode( GAME_TYPE_SELECT );
00285     winsys_post_redisplay();
00286        return true;
00287 }
00288 
00289 void
00290 Credits::Trans()
00291 {
00292 set_game_mode( CREDITS_TRANS );
00293 UIMgr.setDirty();
00294 }
00295 
00296 void
00297 Credits::CredBack()
00298 {
00299 set_game_mode( GAME_TYPE_SELECT );
00300 UIMgr.setDirty();
00301     winsys_post_redisplay();
00302 }
00303