Ejemplo n.º 1
0
/*! 
 Draws the text for the loading screen
 \author  jfpatry
 */
void draw_loading_text( void )
{
    int w = getparam_x_resolution();
    int h = getparam_y_resolution();
    int x_org, y_org;
    const char *string;
    int string_w, asc, desc;
    font_t *font;
    
    x_org = w/2.0;
    y_org = h/2.0;
    
    if ( !get_font_binding( "loading", &font ) ) {
        print_warning( IMPORTANT_WARNING,
                      "Couldn't get font for binding loading" );
    } else {
        string = Localize("Loading, Please Wait...","");
        get_font_metrics( font, string, &string_w, &asc, &desc );
        
        glPushMatrix();
        {
            glTranslatef( w/2.0 - string_w/2.0,
                         h/2.0 - desc-30, 
                         0 );
            bind_font_texture( font );
            draw_string( font, string );
        }
        glPopMatrix();
    }
}
Ejemplo n.º 2
0
/*! 
  Draws the listbox
  \return  None
  \author  jfpatry
  \date    Created:  2000-09-18
  \date    Modified: 2000-09-18
*/
void listbox_draw( listbox_t *listbox )
{
    font_t *font;

    check_assertion( listbox != NULL, "listbox is NULL" );

    glDisable( GL_TEXTURE_2D );
    
    if(listbox->background_colour.a != 0.0) {
        glColor4dv( (scalar_t*)&listbox->border_colour );
        
        glRectf( listbox->pos.x, 
             listbox->pos.y,
             listbox->pos.x + listbox->w - listbox->arrow_width,
             listbox->pos.y + listbox->h );

        glColor4dv( (scalar_t*)&listbox->background_colour );

        glRectf( listbox->pos.x + listbox->border_width, 
             listbox->pos.y + listbox->border_width,
             listbox->pos.x + listbox->w - listbox->border_width -
             listbox->arrow_width,
             listbox->pos.y + listbox->h - listbox->border_width );
    }
    
    glEnable( GL_TEXTURE_2D );

    if ( !get_font_binding( listbox->font_binding, &font ) ) {
	print_warning( IMPORTANT_WARNING,
		       "Couldn't get font object for binding %s",
		       listbox->font_binding );
    } else {
	int w, asc, desc;
	char *string;

	string = listbox->label_gen_func( 
	    get_list_elem_data( listbox->cur_item ) );

	get_font_metrics( font, string, &w, &asc, &desc );

	bind_font_texture( font );

	glColor4f( 1.0, 1.0, 1.0, 1.0 );

	glPushMatrix();
	{
	    glTranslatef( 
		listbox->pos.x + listbox->border_width + listbox->text_pad,
		listbox->pos.y + listbox->h/2.0 - asc/2.0 + desc/2.0,
		0 );

	    draw_string( font, string );
	}
	glPopMatrix();
    }

    button_draw( listbox->up_button );
    button_draw( listbox->down_button );
}
Ejemplo n.º 3
0
void draw_bonus(player_data_t *plyr) {
    bonus_data_t* bonus = bonus_list;

    int i=0;
    while (bonus!=NULL)
    {
        i++;
        bonus_data_t* next_bonus = bonus->next;
        scalar_t anim_time = g_game.time-bonus->start_time;
        if (anim_time < BONUS_TIME_ANIMATION) {
            char *binding;
            font_t *font;

            //Use the same font as for FPS
            binding = "bonus";

            if ( !get_font_binding( binding, &font ) ) {
                print_warning( IMPORTANT_WARNING,
                               "Couldn't get font for binding %s", binding );
                return;
            }

            char* string = bonus->bonus_string;

            set_font_color(font, color_from_time_delta(anim_time));
            set_font_size(font, scale_from_time_delta(anim_time) * 12);
            scalar_t width, a, d;
            get_font_metrics_scalar( font, string, &width, &a, &d);

            bind_font_texture( font );
            set_gl_options( TEXFONT );

            glPushMatrix();
            {
                glTranslatef( 800 * (1 - position_from_time_delta(anim_time)) - width/2 - 140, 200.0 + i*18.0, 0 );

                draw_string( font, string );
            }
            glPopMatrix();
        } else {
            remove_bonus(bonus);
        }

        bonus = next_bonus;

    }
}
Ejemplo n.º 4
0
static void draw_preference()
{
    int h = getparam_y_resolution();
    int box_width, box_height, box_max_y;
    int x_org, y_org;
    char *string;
    font_t *font;
    int text_width, asc, desc;
    list_t cup_list;
    GLuint texobj;
    
    box_width = getparam_x_resolution();
    box_height = 310 * mHeight / 320;
    box_max_y = h - 128 * mHeight / 320;
    x_org = 0;
    y_org = h/2 - box_height/2 + 30 * mHeight / 320;
    
    if ( y_org + box_height > box_max_y ) {
        y_org = box_max_y - box_height;
    }
    
    button_set_position( 
                        chancel_btn,
                        make_point2d( 0,
                                     0 ) );
    
    button_set_position(
                        save_btn,
                        make_point2d( box_width - button_get_width( save_btn ),
                                     0 ) );
    listbox_set_position( 
                         sound_listbox,
                         make_point2d( box_width - 140 * mHeight / 320,
                                      y_org + 290 * mHeight / 320 ) );

    listbox_set_position( 
                         video_listbox,
                         make_point2d( box_width - 140 * mHeight / 320,
                                      y_org + 190 * mHeight / 320 ) );
    
    if ( !get_font_binding( "menu_label", &font ) ) {
        print_warning( IMPORTANT_WARNING,
                      "Couldn't get font for binding menu_label" );
    } else {
        bind_font_texture( font );
        
        string = "Audio enabled";
        
        glPushMatrix();
        {
            glTranslatef( x_org + 70 * mHeight / 320,
                         y_org + 300 * mHeight / 320, 
                         0 );
            
            draw_string( font, string );
        }
        glPopMatrix();

        string = "Video quality";
        
        glPushMatrix();
        {
            glTranslatef( x_org + 70 * mHeight / 320,
                         y_org + 200 * mHeight / 320, 
                         0 );
            
            draw_string( font, string );
        }
        glPopMatrix();
    }
    
}
Ejemplo n.º 5
0
static void set_widget_positions_and_draw_decorations()
{
    int h = getparam_y_resolution();
    int box_width, box_height, box_max_y;
    int x_org, y_org;
    char *string;
    font_t *font;
    int text_width, asc, desc;
    list_t cup_list;
    GLuint texobj;
    
#ifdef __APPLE__
    /* set the dimensions of the box in which all widgets should fit */
    box_width = 300;
    box_height = 310;
    box_max_y = h - 128;
    x_org = 10;
    y_org = h/2 - box_height/2;
    
    if ( y_org + box_height > box_max_y ) {
        y_org = box_max_y - box_height;
    }
    
    button_set_position( 
                        back_btn,
                        make_point2d( x_org + 40 - button_get_width( back_btn )/2.0,
                                     12 ) );
    
    button_set_position(
                        continue_btn,
                        make_point2d( x_org + 232 - button_get_width( continue_btn )/2.0,
                                     12 ) );
                                     
    button_set_position(
                        howToPlay_btn,
                        make_point2d( x_org + 160 - button_get_width( continue_btn )/2.0,
                                     100 ) );
    //Out of the field of view
    //in Tux Rider World Challenge, there is no more events and cup, just training
    //I'm adapting from The Tux Racer system by selecting the first and only event
    //I hide its list box out of the field of view
    //and each cup for this event is a training
    
    listbox_set_position( 
                         event_listbox,
                         make_point2d( x_org+500,
                                      y_org + 500 ) );
    
    listbox_set_position( 
                         cup_listbox,
                         make_point2d( x_org+50,
                                      y_org + 193 ) );
    
#else
    int w = getparam_x_resolution();

    /* set the dimensions of the box in which all widgets should fit */
    box_width = 460;
    box_height = 310;
    box_max_y = h - 128;
    
    x_org = w/2 - box_width/2;
    y_org = h/2 - box_height/2;
    if ( y_org + box_height > box_max_y ) {
        y_org = box_max_y - box_height;
    }
    
    button_set_position( 
                        back_btn,
                        make_point2d( x_org + 131 - button_get_width( back_btn )/2.0,
                                     42 ) );
    
    button_set_position(
                        continue_btn,
                        make_point2d( x_org + 329 - button_get_width( continue_btn )/2.0,
                                     42 ) );
    
    listbox_set_position( 
                         cup_listbox,
                         make_point2d( x_org + 52,
                                      y_org + 103 ) );
    
    listbox_set_position( 
                         event_listbox,
                         make_point2d( x_org + 52,
                                      y_org + 193 ) );
    
#endif
    
    /* 
     * Draw other stuff 
     */
    
    /* Event & cup icons */
    if ( !get_texture_binding( get_event_icon_texture_binding( event_data ),
                              &texobj ) ) {
        texobj = 0;
    }
    
    glBindTexture( GL_TEXTURE_2D, texobj );
    
    glBegin( GL_QUADS );
    {
        point2d_t tll, tur;
        point2d_t ll, ur;
        
#ifdef __APPLE__
        //out of the field of view
        ll = make_point2d( x_org, y_org + 500 );
        ur = make_point2d( x_org + 44, y_org + 500 + 44 );
        tll = make_point2d( 0, 0 );
        tur = make_point2d( 44.0/64.0, 44.0/64.0 );
#else
        ll = make_point2d( x_org, y_org + 193 );
        ur = make_point2d( x_org + 44, y_org + 193 + 44 );
        tll = make_point2d( 0, 0 );
        tur = make_point2d( 44.0/64.0, 44.0/64.0 );
#endif
        
        glTexCoord2f( tll.x, tll.y );
        glVertex2f( ll.x, ll.y );
        
        glTexCoord2f( tur.x, tll.y );
        glVertex2f( ur.x, ll.y );
        
        glTexCoord2f( tur.x, tur.y );
        glVertex2f( ur.x, ur.y );
        
        glTexCoord2f( tll.x, tur.y );
        glVertex2f( ll.x, ur.y );
    }
    glEnd();
    
    
    if ( !get_texture_binding( 
                              get_cup_icon_texture_binding( 
                                                           (cup_data_t*) get_list_elem_data( cur_cup ) ), &texobj ) ) 
    {
        texobj = 0;
    }
    
    glBindTexture( GL_TEXTURE_2D, texobj );
    
#ifdef __APPLE__DISABLED__
    {
        point2d_t tll, tur;
        point2d_t ll, ur;
        
        ll = make_point2d( x_org, y_org + 103 );
        ur = make_point2d( x_org + 44, y_org + 103 + 44 );
        tll = make_point2d( 0, 0 );
        tur = make_point2d( 44.0/64.0, 44.0/64.0 );
        
        const GLfloat vertices []=
        {
            ll.x, ll.y,
            ur.x, ll.y,
            ur.x, ur.y,
            ll.x, ur.y
        };
        
        const GLfloat texCoords []=
        {
            tll.x, tll.y,
            tur.x, tll.y,
            tur.x, tur.y,
            tll.x, tur.y,
        };
        
        glEnableClientState (GL_VERTEX_ARRAY);
        glVertexPointer (2, GL_FLOAT , 0, vertices);	
        glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    }
#else
    glBegin( GL_QUADS );
    {
        point2d_t tll, tur;
        point2d_t ll, ur;
        
#ifdef __APPLE__
        ll = make_point2d( x_org, y_org + 193 );
        ur = make_point2d( x_org + 44, y_org + 193 + 44 );
        tll = make_point2d( 0, 0 );
        tur = make_point2d( 44.0/64.0, 44.0/64.0 );
#else
        ll = make_point2d( x_org, y_org + 103 );
        ur = make_point2d( x_org + 44, y_org + 103 + 44 );
        tll = make_point2d( 0, 0 );
        tur = make_point2d( 44.0/64.0, 44.0/64.0 );
#endif
        
        glTexCoord2f( tll.x, tll.y );
        glVertex2f( ll.x, ll.y );
        
        glTexCoord2f( tur.x, tll.y );
        glVertex2f( ur.x, ll.y );
        
        glTexCoord2f( tur.x, tur.y );
        glVertex2f( ur.x, ur.y );
        
        glTexCoord2f( tll.x, tur.y );
        glVertex2f( ll.x, ur.y );
    }
    glEnd();
#endif
    
    if ( !get_font_binding( "menu_label", &font ) ) {
        print_warning( IMPORTANT_WARNING,
                      "Couldn't get font for binding menu_label" );
    } else {
        bind_font_texture( font );
#ifdef __APPLE__
        string = "Select a training";
#else
        string = "Select event and cup";
#endif
        get_font_metrics( font, string, &text_width,  &asc, &desc );
        
        glPushMatrix();
        {
            glTranslatef( x_org + box_width/2.0 - text_width/2.0,
                         y_org + 310 - asc, 
                         0 );
            
            draw_string( font, string );
        }
        glPopMatrix();
    }
    
    if ( !get_font_binding( "event_and_cup_label", &font ) ) {
        print_warning( IMPORTANT_WARNING,
                      "Couldn't get font for binding menu_label" );
    } 
#ifdef __APPLE__
    
    cur_event = listbox_get_current_item( event_listbox );
    event_data = (event_data_t*) get_list_elem_data( cur_event );
    cup_list = get_event_cup_list( event_data );
    cur_cup = listbox_get_current_item( cup_listbox );
    
    if ( is_cup_complete( event_data, cur_cup ) ) {
        string = "You've won this Training !";
    } else if ( is_cup_first_incomplete_cup( event_data, cur_cup ) ) {
        string = "You must complete this training first";
    } else {
        string = "You cannot enter this training yet"; 
    }
    
    if ( !get_font_binding( "cup_status", &font ) ) {
        print_warning( IMPORTANT_WARNING,
                      "Couldn't get font for binding cup_status" );
    } else {
        bind_font_texture( font );
        
        get_font_metrics( font, string, &text_width, &asc, &desc );
        
        glPushMatrix();
        {
            glTranslatef( x_org + box_width/2.0 - text_width/2.0,
                         y_org+140, 
                         0 );
            
            draw_string( font, string );
        }
        glPopMatrix();
    }
    
#else
    else {
Ejemplo n.º 6
0
/*! 
  Draws a button widget
  \return  None
  \author  jfpatry
  \date    Created:  2000-09-18
  \date    Modified: 2000-09-18
*/
void button_draw( button_t *button )
{
    GLuint texobj;
    texture_region_t *tex;
    point2d_t pos;
    scalar_t w, h;
    char *font_binding;

    check_assertion( button != NULL, "button is NULL" );

    pos = button->pos;
    w = button->w;
    h = button->h;

    glEnable( GL_TEXTURE_2D );

    tex = NULL;
    font_binding = NULL;

    if ( !button->enabled ) {
	if ( button->disabled_tex.binding ) {
	    tex = &button->disabled_tex;
	} else if ( button->tex.binding ) {
	    tex = &button->tex;
	}

	if ( button->disabled_font_binding ) {
	    font_binding = button->disabled_font_binding;
	} else if ( button->font_binding ) {
	    font_binding = button->font_binding;
	}
    } else if ( button->clicked ) {
	if ( button->clicked_tex.binding ) {
	    tex = &button->clicked_tex;
	} else if ( button->hilit_tex.binding ) {
	    tex = &button->hilit_tex;
	} else if ( button->tex.binding ) {
	    tex = &button->tex;
	} 

	if ( button->hilit_font_binding ) {
	    font_binding = button->hilit_font_binding;
	} else if ( button->font_binding ) {
	    font_binding = button->font_binding;
	}
    } else if ( button->focused ) {
	if ( button->hilit_tex.binding ) {
	    tex = &button->hilit_tex;
	} else if ( button->tex.binding ) {
	    tex = &button->tex;
	} 

	if ( button->hilit_font_binding ) {
	    font_binding = button->hilit_font_binding;
	} else if ( button->font_binding ) {
	    font_binding = button->font_binding;
	}
    } else {
	if ( button->tex.binding ) {
	    tex = &button->tex;
	} 

	if ( button->font_binding ) {
	    font_binding = button->font_binding;
	}
    }

    if ( tex != NULL ) {
	if ( !get_texture_binding( tex->binding, &texobj ) ) {
	    print_warning( IMPORTANT_WARNING,
			   "Couldnt get texture object for binding %s",
			   tex->binding );
	    texobj = 0;
	} 

	glBindTexture( GL_TEXTURE_2D, texobj );

	glColor4dv( (scalar_t*) &tex->colour );

	glBegin( GL_QUADS );
	{
	    glTexCoord2f( tex->ll.x, tex->ll.y );
	    glVertex3f( pos.x, pos.y, 0 );

	    glTexCoord2f( tex->ur.x, tex->ll.y );
	    glVertex3f( pos.x + w, pos.y, 0 );

	    glTexCoord2f( tex->ur.x, tex->ur.y );
	    glVertex3f( pos.x + w, pos.y + h, 0 );

	    glTexCoord2f( tex->ll.x, tex->ur.y );
	    glVertex3f( pos.x, pos.y + h, 0 );
	}
	glEnd();
    }

    if ( font_binding && button->label != NULL ) {
	font_t *font;
	int w, asc, desc;

	if (!get_font_binding( font_binding, &font )) {
	    print_warning( IMPORTANT_WARNING, 
			   "Couldn't get font object for binding %s",
			   font_binding );
	    font = NULL;
	} else {
	    bind_font_texture( font );

	    get_font_metrics( font, button->label, &w, &asc, &desc );

	    glPushMatrix();
	    {
		glTranslatef( button->pos.x + button->w/2.0 - w/2.0,
			      button->pos.y + button->h/2.0 - asc/2.0 + desc/2.0,
			      0.0 );

		draw_string( font, button->label );
	    
	    }
	    glPopMatrix();
	}
    }
    
}
Ejemplo n.º 7
0
/*! 
 Sets the widget positions and draws other on-screen goo 
 \author  jfpatry
 \date    Created:  2000-09-24
 \date    Modified: 2000-09-24
 */
static void set_widget_positions_and_draw_decorations()
{
    int w = getparam_x_resolution();
    int h = getparam_y_resolution();
    int box_width, box_height, box_max_y;
    int x_org, y_org;
    char *string;
    font_t *font;
    char *current_course;
    int text_width, asc, desc;
    GLuint texobj;
    
    /* set the dimensions of the box in which all widgets should fit */
#ifdef __APPLE__
    box_width = w;
    box_height = 200 * mHeight / 320;
    box_max_y = h - 128 * mHeight / 320;
    x_org = 10 * mHeight / 320;
    y_org = box_height/2 * mHeight / 320;
    
    if ( y_org + box_height > box_max_y ) {
        y_org = box_max_y - box_height + 50 * mHeight / 320;
    }
    
    button_set_position( 
                        back_btn,
                        make_point2d( 0,
                                     0 ) );
    
    button_set_position(
                        start_btn,
                        make_point2d( box_width - button_get_width( start_btn ),
                                     0 ) );
    
    listbox_set_position(
                         race_listbox,
                         make_point2d( 160 * mHeight / 320,
                                       box_height/2.0+40 * mHeight / 320 ) );
#ifdef __APPLE__    
    textarea_set_position( 
                          desc_ta,
                          make_point2d( 1000,
                                        1000 ) );
#else
    textarea_set_position( 
                          desc_ta,
                          make_point2d( x_org,
                                       y_org + 66 * mHeight / 320 ) );
#endif
    
    if ( g_game.practicing || 
        ( cup_complete &&
         conditions_ssbtn &&
         wind_ssbtn &&
         snow_ssbtn &&
         mirror_ssbtn ) ) 
    {
        ssbutton_set_position(
                              conditions_ssbtn,
                              make_point2d( x_org + box_width - 4*36 + 4,
                                           y_org + 151 ) );
        
        ssbutton_set_position(
                              wind_ssbtn,
                              make_point2d( x_org + box_width - 3*36 + 4 ,
                                           y_org + 151 ) );
        
        ssbutton_set_position(
                              snow_ssbtn,
                              make_point2d( x_org + box_width - 2*36 + 4,
                                           y_org + 151 ) );
        
        ssbutton_set_position(
                              mirror_ssbtn,
                              make_point2d( x_org + box_width - 1*36 + 4,
                                           y_org + 151 ) );
        
#else
        box_width = 460;
        box_height = 310;
        box_max_y = h - 128;
        x_org = w/2 - box_width/2;
        y_org = h/2 - box_height/2;
        
        if ( y_org + box_height > box_max_y ) {
            y_org = box_max_y - box_height;
        }
        
        button_set_position( 
                            back_btn,
                            make_point2d( x_org + 131 - button_get_width( back_btn )/2.0,
                                         42 ) );
        
        button_set_position(
                            start_btn,
                            make_point2d( x_org + 343 - button_get_width( start_btn )/2.0,
                                         42 ) );
        
        listbox_set_position(
                             race_listbox,
                             make_point2d( x_org,
                                          y_org + 221 ) );
        
        textarea_set_position( 
                              desc_ta,
                              make_point2d( x_org,
                                           y_org + 66 ) );
        
        if ( g_game.practicing || 
            ( cup_complete &&
             conditions_ssbtn &&
             wind_ssbtn &&
             snow_ssbtn &&
             mirror_ssbtn ) ) 
        {
            ssbutton_set_position(
                                  conditions_ssbtn,
                                  make_point2d( x_org + box_width - 4*36 + 4,
                                               y_org + 181 ) );
            
            ssbutton_set_position(
                                  wind_ssbtn,
                                  make_point2d( x_org + box_width - 3*36 + 4 ,
                                               y_org + 181 ) );
            
            ssbutton_set_position(
                                  snow_ssbtn,
                                  make_point2d( x_org + box_width - 2*36 + 4,
                                               y_org + 181 ) );
            
            ssbutton_set_position(
                                  mirror_ssbtn,
                                  make_point2d( x_org + box_width - 1*36 + 4,
                                               y_org + 181 ) );
#endif
        } else {
            /* Draw tux life icons */
            GLuint texobj;
            int i;
            
            glPushMatrix();
            {
#ifdef __APPLE__
                glTranslatef( 10 * mHeight / 320,
                             60 * mHeight / 320,
                             0 );
#else
                glTranslatef( x_org + box_width - 4*36 + 4,
                             y_org + 181,
                             0 );
#endif
                
                
                check_assertion( INIT_NUM_LIVES == 4, 
                                "Assumption about number of lives invalid -- "
                                "need to recode this part" );
                
                if ( !get_texture_binding( "tux_life", &texobj ) ) {
                    texobj = 0;
                }
                
                glBindTexture( GL_TEXTURE_2D, texobj );
                
                for ( i=0; i<4; i++ ) {
                    point2d_t ll, ur;
                    if ( plyr->lives > i ) {
                        ll = make_point2d( 0, 0.5 );
                        ur = make_point2d( 1, 1 );
                    } else {
                        ll = make_point2d( 0, 0 );
                        ur = make_point2d( 1, 0.5 );
                    }
                    
                    glBegin( GL_QUADS );
                    {
                        glTexCoord2f( ll.x, ll.y );
                        glVertex2f( 0, 0 );
                        
                        glTexCoord2f( ur.x, ll.y );
                        glVertex2f( 32 * mHeight / 320, 0 );
                        
                        glTexCoord2f( ur.x, ur.y );
                        glVertex2f( 32 * mHeight / 320, 32 * mHeight / 320 );
                        
                        glTexCoord2f( ll.x, ur.y );
                        glVertex2f( 0, 32 * mHeight / 320 );
                    }
                    glEnd();
                    glTranslatef( 36 * mHeight / 320, 0, 0 );
                }
            }
            glPopMatrix();
        }

#ifndef __APPLE__ // We don't care about that stuff

        /* Draw other stuff */
        if ( !get_font_binding( "menu_label", &font ) ) {
            print_warning( IMPORTANT_WARNING,
                          "Couldn't get font for binding menu_label" );
        } else {
            bind_font_texture( font );
            string = "Select a race";
            get_font_metrics( font, string, &text_width,  &asc, &desc );
            
            glPushMatrix();
            {
                glTranslatef( x_org + box_width/2.0 - text_width/2.0,
                             y_org + 310 - asc, 
                             0 );
                
                draw_string( font, string );
            }
            glPopMatrix();
        }
        /* Draw text indicating race requirements (if race not completed), 
         or results in race if race completed. */
        draw_status_msg( x_org, y_org, box_width, box_height );

#else

        /* Draw text indicating race requirements (if race not completed), 
         or results in race if race completed. */
        draw_status_msg( x_org, y_org, box_width, box_height );

#endif


        /* Draw preview */
        if ( g_game.practicing ) {
            list_elem_t elem;
            open_course_data_t *data;
            
            elem = listbox_get_current_item( race_listbox );
            data = (open_course_data_t*) get_list_elem_data( elem );
            current_course = data->course;
        } else {
            list_elem_t elem;
            race_data_t *data;
            
            elem = listbox_get_current_item( race_listbox );
            data = (race_data_t*) get_list_elem_data( elem );
            current_course = data->course;
        }
        
        glDisable( GL_TEXTURE_2D );
        
        glColor4f( 0.0, 0.0, 0.0, 0.3 );
        
#ifdef __APPLE__
        float margin = 4.f * mHeight / 320;
        float yoffset = 26 * mHeight / 320 + 30 * mHeight / 320;
        glBegin( GL_QUADS );
        {
            glVertex2f( x_org, y_org + yoffset );
            glVertex2f( x_org + 140 * mHeight / 320, y_org + yoffset );
            glVertex2f( x_org + 140 * mHeight / 320, y_org + yoffset+107 * mHeight / 320 );
            glVertex2f( x_org, y_org + yoffset+107 * mHeight / 320 );
        }
        glEnd();
#else
        glBegin( GL_QUADS );
        {
            glVertex2f( x_org+box_width-140, y_org+66 );
            glVertex2f( x_org+box_width, y_org+66 );
            glVertex2f( x_org+box_width, y_org+66+107 );
            glVertex2f( x_org+box_width-140, y_org+66+107 );
        }
        glEnd();
#endif

        glColor4f( 1.0, 1.0, 1.0, 1.0 );
        glEnable( GL_TEXTURE_2D );
        
        if ( !get_texture_binding( current_course, &texobj ) ) {
            if ( !get_texture_binding( "no_preview", &texobj ) ) {
                texobj = 0;
            }
        }
        
        glBindTexture( GL_TEXTURE_2D, texobj );
        
#ifdef __APPLE__
        glBegin( GL_QUADS );
        {
            glTexCoord2d( 0, 0);
            glVertex2f( x_org + margin, y_org + yoffset+margin );
            
            glTexCoord2d( 1, 0);
            glVertex2f( x_org + 140 * mHeight / 320 - margin, y_org + yoffset+margin );
            
            glTexCoord2d( 1, 1);
            glVertex2f( x_org + 140 * mHeight / 320 - margin, y_org + yoffset+margin+99 * mHeight / 320 );
            
            glTexCoord2d( 0, 1);
            glVertex2f( x_org + margin, y_org + yoffset+margin+99 * mHeight / 320 );
        }
        glEnd();
        
#else
        glBegin( GL_QUADS );
        {
            glTexCoord2d( 0, 0);
            glVertex2f( x_org+box_width-136, y_org+70 );
            
            glTexCoord2d( 1, 0);
            glVertex2f( x_org+box_width-4, y_org+70 );
            
            glTexCoord2d( 1, 1);
            glVertex2f( x_org+box_width-4, y_org+70+99 );
            
            glTexCoord2d( 0, 1);
            glVertex2f( x_org+box_width-136, y_org+70+99 );
        }
        glEnd();
#endif
    }
    
    
    /*---------------------------------------------------------------------------*/
    /*! 
     Mode initialization function
     \author  jfpatry
     \date    Created:  2000-09-24
     \date    Modified: 2000-09-24
     */
    static void race_select_init(void)
    {
        listbox_list_elem_to_string_fptr_t conv_func = NULL;
        point2d_t dummy_pos = {0, 0};
        int i;
        
        winsys_set_display_func( main_loop );
        winsys_set_idle_func( main_loop );
        winsys_set_reshape_func( reshape );
        winsys_set_mouse_func( ui_event_mouse_func );
        winsys_set_motion_func( ui_event_motion_func );
        winsys_set_passive_motion_func( ui_event_motion_func );
        
        plyr = get_player_data( local_player() );
        
        /* Setup the race list */
        if ( g_game.practicing ) {
            g_game.current_event = "__Practice_Event__";
            g_game.current_cup = "__Practice_Cup__";
            race_list = get_open_courses_list();
            conv_func = get_name_from_open_course_data;
            cup_data = NULL;
            last_completed_race = NULL;
            event_data = NULL;
        } else {
            event_data = (event_data_t*) get_list_elem_data( 
                                                            get_event_by_name( g_game.current_event ) );
            check_assertion( event_data != NULL,
                            "Couldn't find current event." );
            cup_data = (cup_data_t*) get_list_elem_data(
                                                        get_event_cup_by_name( event_data, g_game.current_cup ) );
            check_assertion( cup_data != NULL,
                            "Couldn't find current cup." );
            race_list = get_cup_race_list( cup_data );
            conv_func = get_name_from_race_data;
        }
        
        /* Unless we're coming back from a race, initialize the race data to 
         defaults.
         */
        if ( g_game.prev_mode != GAME_OVER ) {
            /* Make sure we don't play previously loaded course */
            cup_complete = False;
            
            /* Initialize the race data */
            cur_elem = get_list_head( race_list );
            
            if ( g_game.practicing ) {
                g_game.race.course = NULL;
                g_game.race.name = NULL;
                g_game.race.description = NULL;
                
                for (i=0; i<DIFFICULTY_NUM_LEVELS; i++) {
                    g_game.race.herring_req[i] = 0;
                    g_game.race.time_req[i] = 0;
                    g_game.race.score_req[i] = 0;
                }
                
                g_game.race.mirrored = False;
                g_game.race.conditions = RACE_CONDITIONS_SUNNY;
                g_game.race.windy = False;
                g_game.race.snowing = False;
            } else {
                /* Not practicing */
                
                race_data_t *data;
                data = (race_data_t*) get_list_elem_data( cur_elem );
                g_game.race = *data;
                
                if ( is_cup_complete( event_data, 
                                     get_event_cup_by_name( 
                                                           event_data, 
                                                           g_game.current_cup ) ) )
                {
                    cup_complete = True;
                    last_completed_race = get_list_tail( race_list );
                } else {
                    cup_complete = False;
                    last_completed_race = NULL;
                }
            }
        } else {
            /* Back from a race */
            if ( !g_game.race_aborted ) {
                update_race_results();
            }
            
            if (!g_game.practicing && !cup_complete) {
                if ( was_current_race_won() ) {
                    update_for_won_race();
                    
                    /* Advance to next race */
                    if ( cur_elem != get_list_tail( race_list ) ) {
                        cur_elem = get_next_list_elem( race_list, cur_elem );
                    }
                } else {
                    /* lost race */
                    plyr->lives -= 1;
                }
                print_debug( DEBUG_GAME_LOGIC, "Current lives: %d", plyr->lives );
            }
        }
        
        back_btn = button_create( dummy_pos,
                                 80 * mWidth / 480, 48 * mHeight / 320, 
                                 "button_label", 
                                 (mWidth>320)?"Back":"<< " );
        button_set_hilit_font_binding( back_btn, "button_label_hilit" );
        button_set_visible( back_btn, True );
        button_set_click_event_cb( back_btn, back_click_cb, NULL );
        
        start_btn = button_create( dummy_pos,
                                  80 * mWidth / 480, 48 * mHeight / 320,
                                  "button_label",
                                  (mWidth>320)?"Race":" >>" );
        button_set_hilit_font_binding( start_btn, "button_label_hilit" );
        button_set_disabled_font_binding( start_btn, "button_label_disabled" );
        button_set_visible( start_btn, True );
        button_set_click_event_cb( start_btn, start_click_cb, NULL );
        
#ifdef __APPLE__
        race_listbox = listbox_create( dummy_pos,
                                      mWidth - 170 * mHeight / 320, 44 * mHeight / 320,
                                      "course_name_label",
                                      race_list,
                                      conv_func );
        
#else
        race_listbox = listbox_create( dummy_pos,
                                      460 * mHeight / 320, 44 * mHeight / 320,
                                      "listbox_item",
                                      race_list,
                                      conv_func );
        
#endif
        
        
        listbox_set_current_item( race_listbox, cur_elem );
        
        listbox_set_item_change_event_cb( race_listbox, 
                                         race_listbox_item_change_cb, 
                                         NULL );
        
        listbox_set_visible( race_listbox, True );
        
        /* 
         * Create text area 
         */
#ifdef __APPLE__
        desc_ta = textarea_create( dummy_pos,
                                  150, 147,
                                  "race_description",
                                  "" );
        
#else
        desc_ta = textarea_create( dummy_pos,
                                  312, 107,
                                  "race_description",
                                  "" );
        
#endif
        
        if ( g_game.practicing ) {
            open_course_data_t *data;
            data = (open_course_data_t*) get_list_elem_data( cur_elem );
            textarea_set_text( desc_ta, data->description );
        } else {
            race_data_t *data;
            data = (race_data_t*) get_list_elem_data( cur_elem );
            textarea_set_text( desc_ta, data->description );
        }
        
        textarea_set_visible( desc_ta, True );
        
        
        /* 
         * Create state buttons - only if practicing or if cup_complete
         */
        
        if ( g_game.practicing || cup_complete ) {
            /* mirror */
            mirror_ssbtn = ssbutton_create( dummy_pos,
                                           32, 32,
                                           2 );
            ssbutton_set_state_image( mirror_ssbtn, 
                                     0, 
                                     "mirror_button",
                                     make_point2d( 0.0/64.0, 32.0/64.0 ),
                                     make_point2d( 32.0/64.0, 64.0/64.0 ),
                                     white );
            
            ssbutton_set_state_image( mirror_ssbtn, 
                                     1, 
                                     "mirror_button",
                                     make_point2d( 32.0/64.0, 32.0/64.0 ),
                                     make_point2d( 64.0/64.0, 64.0/64.0 ),
                                     white );
            
            ssbutton_set_state( mirror_ssbtn, (int)g_game.race.mirrored );
#ifdef __APPLE__
            ssbutton_set_visible( mirror_ssbtn, False );
#else
            ssbutton_set_visible( mirror_ssbtn, True );
#endif
            
            /* conditions */
            conditions_ssbtn = ssbutton_create( dummy_pos,
                                               32, 32,
                                               4 );

            float border = 2.0;
            ssbutton_set_state_image( conditions_ssbtn, 
                                     0, 
                                     "conditions_button",
                                     make_point2d( (0.0 + border)/64.0, (32.0 + border)/64.0 ),
                                     make_point2d( (32.0 - border)/64.0, (64.0 - border)/64.0 ),
                                     white );
            
            ssbutton_set_state_image( conditions_ssbtn, 
                                     1, 
                                     "conditions_button",
                                     make_point2d( (32.0 + border)/64.0, (0.0 + border)/64.0 ),
                                     make_point2d( (64.0 - border)/64.0, (32.0 - border)/64.0 ),
                                     white );
            
            ssbutton_set_state_image( conditions_ssbtn, 
                                     2, 
                                     "conditions_button",
                                     make_point2d( (32.0 + border)/64.0, (32.0 + border)/64.0 ),
                                     make_point2d( (64.0 - border)/64.0, (64.0 - border)/64.0 ),
                                     white );

            ssbutton_set_state_image( conditions_ssbtn, 
                                     3, 
                                     "conditions_button",
                                     make_point2d( (0.0 + border)/64.0, (0.0 + border)/64.0 ),
                                     make_point2d( (32.0 - border)/64.0, (32.0 - border)/64.0 ),
                                     white );
            
            ssbutton_set_state( conditions_ssbtn, (int)g_game.race.conditions );
            ssbutton_set_visible( conditions_ssbtn, True );

#ifdef __APPLE__
            ssbutton_set_visible( conditions_ssbtn, False );
#else
            ssbutton_set_visible( conditions_ssbtn, True );
#endif
            
            /* wind */
            wind_ssbtn = ssbutton_create( dummy_pos,
                                         32, 32,
                                         2 );
            ssbutton_set_state_image( wind_ssbtn, 
                                     0, 
                                     "wind_button",
                                     make_point2d( 0.0/64.0, 32.0/64.0 ),
                                     make_point2d( 32.0/64.0, 64.0/64.0 ),
                                     white );
            
            ssbutton_set_state_image( wind_ssbtn, 
                                     1, 
                                     "wind_button",
                                     make_point2d( 32.0/64.0, 32.0/64.0 ),
                                     make_point2d( 64.0/64.0, 64.0/64.0 ),
                                     white );
            
            ssbutton_set_state( wind_ssbtn, (int)g_game.race.windy );
#ifdef __APPLE__
            ssbutton_set_visible( wind_ssbtn, False );
#else
            ssbutton_set_visible( wind_ssbtn, True );
#endif
            
            /* snow */
            snow_ssbtn = ssbutton_create( dummy_pos,
                                         32, 32,
                                         2 );
            ssbutton_set_state_image( snow_ssbtn, 
                                     0, 
                                     "snow_button",
                                     make_point2d( 0.0/64.0, 32.0/64.0 ),
                                     make_point2d( 32.0/64.0, 64.0/64.0 ),
                                     white );
            
            ssbutton_set_state_image( snow_ssbtn, 
                                     1, 
                                     "snow_button",
                                     make_point2d( 32.0/64.0, 32.0/64.0 ),
                                     make_point2d( 64.0/64.0, 64.0/64.0 ),
                                     white );
            
            ssbutton_set_state( snow_ssbtn, (int)g_game.race.snowing );
#ifdef __APPLE__
            ssbutton_set_visible( snow_ssbtn, False );
#else
            ssbutton_set_visible( snow_ssbtn, True );
#endif
            /* XXX snow button doesn't do anything, so disable for now */
            ssbutton_set_enabled( snow_ssbtn, False );
            
            /* Can't change conditions if in cup mode */
            if ( !g_game.practicing ) {
                ssbutton_set_enabled( conditions_ssbtn, False );
                ssbutton_set_enabled( wind_ssbtn, False );
                ssbutton_set_enabled( snow_ssbtn, False );
                ssbutton_set_enabled( mirror_ssbtn, False );
            }
            
        } else {
            conditions_ssbtn = NULL;
            wind_ssbtn = NULL;
            snow_ssbtn = NULL;
            mirror_ssbtn = NULL;
        }
        
        update_race_data();
        update_button_enabled_states();
        
        play_music( "start_screen" );
    }
Ejemplo n.º 8
0
/*! 
 Draws a status message on the screen
 \author  jfpatry
 \date    Created:  2000-09-24
 \date    Modified: 2000-09-24
 */
void draw_status_msg( int x_org, int y_org, int box_width, int box_height )
{
    char *msg;
    scalar_t time;
    int herring;
    int score;
    font_t *label_font;
    font_t *font;
    char buff[BUFF_LEN];
    bool_t draw_stats = True;
    
    if ( !g_game.practicing ) {
        if ( is_current_race_completed() ) {
            race_data_t *race_data;
            
            if ( cup_complete ) {
                msg = "Best result:";
            } else {
                msg = "Race won! Your result:";
            }
            
            race_data = (race_data_t*)get_list_elem_data( cur_elem );
            
            if ( !get_saved_race_results( plyr->name,
                                         g_game.current_event,
                                         g_game.current_cup,
                                         race_data->name,
                                         g_game.difficulty,
                                         &time,
                                         &herring,
                                         &score ) )
            {
                difficulty_level_t d = g_game.difficulty;
                
                print_warning( IMPORTANT_WARNING,
                              "No saved results for race `%s'.  Using "
                              "race minimum requirements.",
                              race_data->name );
                
                time = g_game.race.time_req[d];
                herring = g_game.race.herring_req[d];
                score = g_game.race.score_req[d];
            }
        } else if ( plyr->lives <= 0 ) {
            msg = "You don't have any lives left.";
            draw_stats = False;
        } else {
            difficulty_level_t d = g_game.difficulty;
            
            time = g_game.race.time_req[d];
            herring = g_game.race.herring_req[d];
            score = g_game.race.score_req[d];
            
            if ( is_current_race_first_incomplete() ) {
                msg = "Needed to advance:";
            } else {
                msg = "You can't enter this race yet.";
                draw_stats = False;
            }
        }
    } else {
        open_course_data_t *data;
        
        data = (open_course_data_t*)get_list_elem_data( cur_elem );
        
        msg = "Best result:";
        
        if ( !get_saved_race_results( plyr->name,
                                     g_game.current_event,
                                     g_game.current_cup,
                                     data->name,
                                     g_game.difficulty,
                                     &time,
                                     &herring,
                                     &score ) )
        {
            /* Don't display anything if no score saved */
            return;
        }
    }
    
#ifdef __APPLE__
#define yTranslation -10
#else
#define yTranslation 0
#endif
    
    if ( !get_font_binding( "race_requirements", &font ) ||
        !get_font_binding( "race_requirements_label", &label_font ) ) 
    {
        print_warning( IMPORTANT_WARNING,
                      "Couldn't get fonts for race requirements" );
    } else {
        glPushMatrix();
        {
            glTranslatef( x_org + 160 * mHeight / 320,
                         y_org + 60 * mHeight / 320+yTranslation * mHeight / 320,
                         0 );
            
            bind_font_texture( label_font );
            draw_string( label_font, msg );
        }
        glPopMatrix();
        
        if ( draw_stats ) {
            glPushMatrix();
            {
                int minutes;
                int seconds;
                int hundredths;
                
                get_time_components( time, &minutes, &seconds, &hundredths );
                
                glTranslatef( x_org + 160 * mHeight / 320,
                             y_org + 44 * mHeight / 320+yTranslation * mHeight / 320,
                             0 );
                
                
                bind_font_texture( label_font );
                draw_string( label_font, "Time: " );
                
                sprintf( buff, "%02d:%02d.%02d",
                        minutes, seconds, hundredths );
                bind_font_texture( font );
                draw_string( font, buff );
                
                bind_font_texture( label_font );
                draw_string( label_font, "    Fish: " );
                
                sprintf( buff, "%03d", herring ); 
                bind_font_texture( font );
                draw_string( font, buff );
            }
            glPopMatrix();
            glPushMatrix();
            {                
                glTranslatef( x_org + 160 * mHeight / 320,
                             y_org + 28 * mHeight / 320+yTranslation * mHeight / 320,
                             0 );
                
                bind_font_texture( label_font );
                draw_string( label_font, "Score: " );
                
                sprintf( buff, "%06d", score );
                bind_font_texture( font );
                draw_string( font, buff );
            }
            glPopMatrix();
        }
    }
}
Ejemplo n.º 9
0
/*! 
 Draws a status message on the screen
 \author  jfpatry
 \date    Created:  2000-09-24
 \date    Modified: 2000-09-24
 */
void draw_status_msg( int x_org, int y_org, int box_width, int box_height )
{
    const char *msg;
    scalar_t time;
    int herring;
    int score;
    font_t *label_font;
    font_t *font;
    char buff[BUFF_LEN];
    bool_t draw_stats = True;
    
    if ( g_game.practicing ) {
        open_course_data_t *data;
        
        data = (open_course_data_t*)get_list_elem_data( cur_elem );
        
        msg = Localize("Best result:","");
        
        if ( !get_saved_race_results( plyr->name,
                                     g_game.current_event,
                                     g_game.current_cup,
                                     data->name,
                                     g_game.difficulty,
                                     &time,
                                     &herring,
                                     &score ) )
        {
            /* Don't display anything if no score saved */
            return;
        }
        
        
#ifdef __APPLE__
#define yTranslation -10
#else
#define yTranslation 0
#endif
        
        if ( !get_font_binding( "race_requirements", &font ) ||
            !get_font_binding( "race_requirements_label", &label_font ) ) 
        {
            print_warning( IMPORTANT_WARNING,
                          "Couldn't get fonts for race requirements" );
        } else {
            glPushMatrix();
            {
                glTranslatef( x_org + 0,
                             y_org + 200+yTranslation,
                             0 );
                
                bind_font_texture( label_font );
                draw_string( label_font, msg );
            }
            glPopMatrix();
            
            if ( draw_stats ) {
                glPushMatrix();
                {
                    int minutes;
                    int seconds;
                    int hundredths;
                    
                    get_time_components( time, &minutes, &seconds, &hundredths );
                    
                    glTranslatef( x_org + 0,
                                 y_org + 184+yTranslation,
                                 0 );
                    
                    
                    bind_font_texture( label_font );
                    draw_string( label_font, Localize("Time: ","") );
                    
                    sprintf( buff, "%02d:%02d.%02d",
                            minutes, seconds, hundredths );
                    bind_font_texture( font );
                    draw_string( font, buff );
#ifdef __APPLE__
                    if (!g_game.is_speed_only_mode || !g_game.practicing) {
#endif
                        bind_font_texture( label_font );
                        draw_string( label_font, Localize("    Fish: ","") );
                        
                        sprintf( buff, "%03d", herring ); 
                        bind_font_texture( font );
                        draw_string( font, buff );
                        
                        bind_font_texture( label_font );
                        draw_string( label_font, Localize("     Score: ","") );
                        
                        sprintf( buff, "%06d", score );
                        bind_font_texture( font );
                        draw_string( font, buff );
#ifdef __APPLE__
                    }
#endif
                }
                glPopMatrix();
            }
        }
    }
}
Ejemplo n.º 10
0
/*! 
 Scrolls the credits text up the screen.
 \author  jfpatry
 \date    Created:  2000-09-27
 \date    Modified: 2000-09-27
 */
static void draw_credits_text( scalar_t time_step )
{
    int w = getparam_x_resolution();
    int h = getparam_y_resolution();
    font_t *font;
    int i;
    scalar_t y;
    int string_w, asc, desc;
    
    y_offset += time_step * 30;
    y = CREDITS_MIN_Y+y_offset;
    
    glPushMatrix();
    {
        glTranslatef( w/2, y, 0 );
        
        for (i=0; i<sizeof( credit_lines ) / sizeof( credit_lines[0] ); i++) {
            credit_line_t line = credit_lines[i];
            
            if ( !get_font_binding( line.binding, &font ) ) {
                print_warning( IMPORTANT_WARNING,
                              "Couldn't get font for binding %s", 
                              line.binding );
            } else {
                get_font_metrics( font, line.text, &string_w, &asc, &desc );
                
                glTranslatef( 0, -asc, 0 );
                y += -asc;
                
                glPushMatrix();
                {
                    bind_font_texture( font );
                    glTranslatef( -string_w/2, 0, 0 );
                    draw_string( font, line.text );
                }
                glPopMatrix();
                
                glTranslatef( 0, -desc, 0 );
                y += -desc;
            }
        }
        
    }
    glPopMatrix();
    
    if ( y > h+CREDITS_MAX_Y ) {
        y_offset = 0;
    }
    
    /* Draw strips at the top and bottom to clip out text */
    //glDisable( GL_TEXTURE_2D );
    
    
#ifdef __APPLE__DISABLED__
	glColor4f( ui_background_colour.r, ui_background_colour.g, ui_background_colour.b, ui_background_colour.a );
    
    //draws rect a la place de glRectf
    const GLfloat vertices []=
    {
        0, 0,
        w, 0 ,
        w , CREDITS_MIN_Y,
        0, CREDITS_MIN_Y
    };
    
    glEnableClientState (GL_VERTEX_ARRAY);
    glVertexPointer (2, GL_FLOAT , 0, vertices);	
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
	
    const GLfloat vertices1 []=
    {
        0, CREDITS_MIN_Y,
        w, CREDITS_MIN_Y,
        w, CREDITS_MIN_Y + 30,
        0, CREDITS_MIN_Y + 30
    };
    
    const GLfloat colors1 []=
    {
        ui_background_colour.r, ui_background_colour.g, ui_background_colour.b, ui_background_colour.a,
        ui_background_colour.r, ui_background_colour.g, ui_background_colour.b, ui_background_colour.a,
        ui_background_colour.r, ui_background_colour.g, ui_background_colour.b, 0.0,
        ui_background_colour.r, ui_background_colour.g, ui_background_colour.b, 0.0,
    };
    
    glEnableClientState (GL_VERTEX_ARRAY);
    glVertexPointer (2, GL_FLOAT , 0, vertices);	
    glColorPointer(4, GL_FLOAT, 0, colors1);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    
    glColor4f( ui_background_colour.r,  ui_background_colour.g, ui_background_colour.b, ui_background_colour.a );
    
    //draws rect a la place de glRectf( 0, h+CREDITS_MAX_Y, w, h );
    const GLfloat vertices2 []=
    {
        0, h+CREDITS_MAX_Y,
        w, h+CREDITS_MAX_Y ,
        w , h,
        0, h
    };
    
    glEnableClientState (GL_VERTEX_ARRAY);
    glVertexPointer (2, GL_FLOAT , 0, vertices2);	
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    
    
    const GLfloat vertices3 []=
    {
        w, h+CREDITS_MAX_Y,
        0, h+CREDITS_MAX_Y,
        0, h+CREDITS_MAX_Y - 30,
        w, h+CREDITS_MAX_Y - 30
    };
    
    const GLfloat colors3 []=
    {
        ui_background_colour.r, ui_background_colour.g, ui_background_colour.b, ui_background_colour.a,
        ui_background_colour.r, ui_background_colour.g, ui_background_colour.b, ui_background_colour.a,
        ui_background_colour.r, ui_background_colour.g, ui_background_colour.b, 0.0,
        ui_background_colour.r, ui_background_colour.g, ui_background_colour.b, 0.0,
    };
    
    glEnableClientState (GL_VERTEX_ARRAY);
    glVertexPointer (2, GL_FLOAT , 0, vertices3);	
    glColorPointer(4, GL_FLOAT, 0, colors3);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    
    
    
#else
    
    glColor4dv( (scalar_t*)&ui_background_colour );
    
    glRectf( 0, 0, w, CREDITS_MIN_Y );
    
    glBegin( GL_QUADS );
    {
        glVertex2f( 0, CREDITS_MIN_Y );
        glVertex2f( w, CREDITS_MIN_Y );
        glColor4f( ui_background_colour.r, 
                  ui_background_colour.g,
                  ui_background_colour.b,
                  0 );
        glVertex2f( w, CREDITS_MIN_Y + 30 );
        glVertex2f( 0, CREDITS_MIN_Y + 30 );
    }
    glEnd();
    
    glColor4dv( (scalar_t*)&ui_background_colour );
    
    glRectf( 0, h+CREDITS_MAX_Y, w, h );
    
    glBegin( GL_QUADS );
    {
        glVertex2f( w, h+CREDITS_MAX_Y );
        glVertex2f( 0, h+CREDITS_MAX_Y );
        glColor4f( ui_background_colour.r, 
                  ui_background_colour.g,
                  ui_background_colour.b,
                  0 );
        glVertex2f( 0, h+CREDITS_MAX_Y - 30 );
        glVertex2f( w, h+CREDITS_MAX_Y - 30 );
    }
    glEnd();
    
#endif
    
    glColor4f( 1, 1, 1, 1 );
    
    glEnable( GL_TEXTURE_2D );
}
Ejemplo n.º 11
0
/*!
 Draws the text for the game over screen
 \author  jfpatry
 \date    Created:  2000-09-24
 \date    Modified: 2000-09-24
 */
void draw_game_over_text( void )
{
    int w = getparam_x_resolution();
    int h = getparam_y_resolution();
    int x_org, y_org;
    int box_width, box_height;
    const char *string;
    int string_w, asc, desc;
    char buff[BUFF_LEN];
    font_t *font;
    font_t *stat_label_font;
    player_data_t *plyr = get_player_data( local_player() );

    box_width = 200;
    box_height = 250;

    x_org = w/2.0 - box_width/2.0;
    y_org = h/2.0 - box_height/2.0;

    if ( !get_font_binding( "race_over", &font ) ) {
        print_warning( IMPORTANT_WARNING,
                       "Couldn't get font for binding race_over" );
    } else {

        if ( !g_game.race_aborted && g_game.practicing && g_game.needs_save_or_display_rankings) {
            string = Localize("World rankings", "");
        } else string = Localize("Race Over", "");

        get_font_metrics( font, string, &string_w, &asc, &desc );

        glPushMatrix();
        {
            glTranslatef( x_org + box_width/2.0 - string_w/2.0,
                          y_org + box_height - asc,
                          0 );
            bind_font_texture( font );
            draw_string( font, string );
        }
        glPopMatrix();
    }

    /* If race was aborted, don't print stats, and if doesnt need to print rankings, dont print them */

    if ( !g_game.race_aborted && !g_game.needs_save_or_display_rankings && g_game.practicing)

    {
        if ( !get_font_binding( "race_stats_label", &stat_label_font ) ||
                !get_font_binding( "race_stats", &font ) )
        {
            print_warning( IMPORTANT_WARNING,
                           "Couldn't get fonts for race stats" );
        } else {
            int asc2;
            int desc2;
            get_font_metrics( font, "", &string_w, &asc, &desc );
            get_font_metrics( stat_label_font, "", &string_w, &asc2, &desc2 );

            if ( asc < asc2 ) {
                asc = asc2;
            }
            if ( desc < desc2 ) {
                desc = desc2;
            }

            glPushMatrix();
            {
                int minutes;
                int seconds;
                int hundredths;

                glTranslatef( x_org,
                              y_org + 150,
                              0 );

                bind_font_texture( stat_label_font );

                if (!strcmp(get_calculation_mode(),"jump") )
                {

                    draw_string( stat_label_font, Localize("Flying time: ","src/game_over.c"));
                    g_game.time = plyr->control.fly_total_time;
                }
                //default mode
                else {
                    draw_string( stat_label_font, Localize("Time: ","src/game_over.c"));
                }
                get_time_components( g_game.time, &minutes, &seconds, &hundredths );
                sprintf( buff, "%02d:%02d:%02d", minutes, seconds, hundredths );

                bind_font_texture( font );
                draw_string( font, buff );
            }
            glPopMatrix();

            glPushMatrix();
            {
                glTranslatef( x_org,
                              y_org + 150 - (asc + desc),
                              0 );

                bind_font_texture( stat_label_font );
#ifdef __APPLE__
                if (!g_game.is_speed_only_mode)
#endif
                    draw_string( stat_label_font, Localize("Fish: ","") );

                sprintf( buff, "%3d", plyr->herring );

                bind_font_texture( font );
#ifdef __APPLE__
                if (!g_game.is_speed_only_mode)
#endif
                    draw_string( font, buff );
            }
            glPopMatrix();

            glPushMatrix();
            {
                glTranslatef( x_org,
                              y_org + 150 - 2*(asc + desc),
                              0 );

                bind_font_texture( stat_label_font );
#ifdef __APPLE__
                if (!g_game.is_speed_only_mode)
#endif
                    draw_string( stat_label_font, "Score: " );

                sprintf( buff, "%6d", plyr->score );

                bind_font_texture( font );

#ifdef __APPLE__
                if (!g_game.is_speed_only_mode)
#endif
                    draw_string( font, buff );
            }
            glPopMatrix();
        }
    }
#ifdef __APPLE__
    //display rankings if needed
    else if ( !g_game.race_aborted && g_game.practicing && g_game.needs_save_or_display_rankings)
    {
        if ( !get_font_binding( "race_stats_label", &stat_label_font ) ||
                !get_font_binding( "race_stats", &font ) )
        {
            print_warning( IMPORTANT_WARNING,
                           "Couldn't get fonts for race stats" );
        } else {
            int asc2;
            int desc2;
            get_font_metrics( font, "", &string_w, &asc, &desc );
            get_font_metrics( stat_label_font, "", &string_w, &asc2, &desc2 );

            if ( asc < asc2 ) {
                asc = asc2;
            }
            if ( desc < desc2 ) {
                desc = desc2;
            }

            glPushMatrix();
            {
                glTranslatef( x_org - 50,
                              y_org + 150,
                              0 );

                bind_font_texture( stat_label_font );
                draw_string( stat_label_font, Localize("Friends: ","") );
                if (strcmp(friendsRanking, "Empty friends list.")==0) {
                    free(friendsRanking);
                    friendsRanking = strdup(Localize("No friends",""));
                }

                if (friendsPercent>=0)
                    sprintf( buff, "%s (%.1f%%)", friendsRanking , friendsPercent);
                else
                    sprintf( buff, "%s", friendsRanking);

                bind_font_texture( font );
                draw_string( font, buff );
            }
            glPopMatrix();

            glPushMatrix();
            {
                glTranslatef( x_org -50 ,
                              y_org + 150 - (asc + desc),
                              0 );

                bind_font_texture( stat_label_font );
                draw_string( stat_label_font, Localize("Country: ","") );

                sprintf( buff, "%s (%.1f%%)", countryRanking , countryPercent );

                bind_font_texture( font );
                draw_string( font, buff );
            }
            glPopMatrix();

            glPushMatrix();
            {
                glTranslatef( x_org - 50,
                              y_org + 150 - 2*(asc + desc),
                              0 );

                bind_font_texture( stat_label_font );
                draw_string( stat_label_font, Localize("World: ","") );

                sprintf( buff, "%s (%.1f%%)", worldRanking , worldPercent);

                bind_font_texture( font );
                draw_string( font, buff );
            }
            glPopMatrix();
        }
    }
#endif

    if ( g_game.race_aborted && !g_game.race_time_over) {
        string = Localize("Race aborted.","");
    } else if ( g_game.race_aborted && g_game.race_time_over) {
        string = Localize("Time is up.","");
    } else if ( ( g_game.practicing || is_current_cup_complete() ) &&
                did_player_beat_best_results() )
    {

        if ( !g_game.race_aborted && g_game.practicing && g_game.needs_save_or_display_rankings) {
            string = "";
        } else string = Localize("You beat your best score!","");

    } else {
        string = "";
    }

    if ( !get_font_binding( "race_result_msg", &font ) ) {
        print_warning( IMPORTANT_WARNING,
                       "Couldn't get font for binding race_result_msg" );
    } else {
        get_font_metrics( font, string, &string_w, &asc, &desc );
        glPushMatrix();
        {
            glTranslatef( x_org + box_width/2. - string_w/2.,
                          y_org + desc +20.,
                          0 );
            bind_font_texture( font );
            draw_string( font, string );
        }
        glPopMatrix();
    }
#ifdef __APPLE__
    //Draws "touch screen to contin"ue
    string = Localize("Touch screen to continue","");

    if ( !get_font_binding( "fps", &font ) ) {
        print_warning( IMPORTANT_WARNING,
                       "Couldn't get font for binding race_result_msg" );
    } else {
        get_font_metrics( font, string, &string_w, &asc, &desc );
        glPushMatrix();
        {
            glTranslatef( x_org + box_width/2. - string_w/2.,
                          y_org + desc-20.,
                          0 );
            bind_font_texture( font );
            draw_string( font, string );
        }
        glPopMatrix();
    }
#endif

}