Recognizes if input is ogg or not.
[xiph/unicode.git] / planarity / gameboard_draw_score.c
blobd6e3be8ee716a939832e197e8c2955e7ade77d11
1 /*
3 * gPlanarity:
4 * The geeky little puzzle game with a big noodly crunch!
5 *
6 * gPlanarity copyright (C) 2005 Monty <monty@xiph.org>
7 * Original Flash game by John Tantalo <john.tantalo@case.edu>
8 * Original game concept by Mary Radcliffe
10 * gPlanarity is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
15 * gPlanarity is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Postfish; see the file COPYING. If not, write to the
22 * Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 #define _GNU_SOURCE
28 #include <gtk/gtk.h>
29 #include <gtk/gtkmain.h>
30 #include <gdk/gdk.h>
31 #include <gdk/gdkx.h>
32 #include <stdlib.h>
33 #include <math.h>
34 #include <string.h>
36 #include "graph.h"
37 #include "gameboard.h"
38 #include "levelstate.h"
39 #include "main.h"
41 void draw_score(Gameboard *g){
42 char level_string[160];
43 char score_string[160];
44 char mult_string[160];
45 char int_string[160];
46 char obj_string[160];
47 cairo_text_extents_t extentsL;
48 cairo_text_extents_t extentsS;
49 cairo_text_extents_t extentsM;
50 cairo_text_extents_t extentsO;
51 cairo_text_extents_t extentsI;
53 cairo_t *c = cairo_create(g->forescore);
54 int xpx = 12;
55 int ty1 = 23;
56 int ty2 = 38;
58 // clear the pane
59 cairo_save(c);
60 cairo_set_operator(c,CAIRO_OPERATOR_CLEAR);
61 cairo_set_source_rgba (c, 1,1,1,1);
62 cairo_paint(c);
63 cairo_restore(c);
65 topbox(g,c,g->g.width,SCOREHEIGHT);
67 snprintf(level_string,160,_("Level %d: %s"),get_level_num()+1,get_level_desc());
68 snprintf(score_string,160,_("Score: %d"),graphscore_get_raw_score(&g->g));
69 snprintf(mult_string,160,_("%d%%"),graphscore_get_multiplier_percent(&g->g));
70 snprintf(int_string,160,_("Intersections: %ld"),g->g.active_intersections);
71 snprintf(obj_string,160,_("Objective: %s"),graphscore_objective_string(&g->g));
73 set_font(c,xpx,15,0,1);
74 cairo_set_source_rgba (c, TEXT_COLOR);
76 cairo_text_extents (c, obj_string, &extentsO);
77 cairo_text_extents (c, int_string, &extentsI);
78 cairo_text_extents (c, score_string, &extentsS);
79 cairo_text_extents (c, mult_string, &extentsM);
82 cairo_move_to (c, 15, ty1);
83 cairo_show_text (c, int_string);
84 cairo_move_to (c, 15, ty2);
85 cairo_show_text (c, score_string);
86 if(graphscore_get_multiplier_percent(&g->g)>100){
87 cairo_save(c);
88 cairo_set_source_rgba (c, HIGH_COLOR);
89 cairo_move_to (c, 15 + extentsS.width+10, ty2);
90 cairo_show_text (c, mult_string);
91 cairo_restore(c);
94 cairo_move_to (c, g->g.width-extentsO.width-15, ty2);
95 cairo_show_text (c, obj_string);
98 while(xpx){
99 cairo_text_extents (c, level_string, &extentsL);
101 if(extentsL.width > 300){
102 xpx--;
103 set_font(c,xpx,15,0,1);
104 }else
105 break;
108 cairo_move_to (c, g->g.width-extentsL.width-15, ty1);
109 cairo_show_text (c, level_string);
111 cairo_destroy(c);
114 void update_score(Gameboard *g){
115 GdkRectangle r;
116 draw_score(g);
118 r.x=0;
119 r.y=0;
120 r.width=g->g.width;
121 r.height = SCOREHEIGHT;
122 gdk_window_invalidate_rect (g->w.window, &r, FALSE);