Add Russian translation provided by Валерий Крувялис <valkru@mail.ru>
[xiph-mirror.git] / planarity / dialog_level.c
blob65ec1e9e372d522fd3ff00c40036270e8994b50c
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 #include <math.h>
28 #include <string.h>
29 #include <gtk/gtk.h>
30 #include <gdk/gdk.h>
32 #include "graph.h"
33 #include "timer.h"
34 #include "gameboard.h"
35 #include "gameboard_draw_button.h"
36 #include "dialog_level.h"
37 #include "levelstate.h"
38 #include "main.h"
40 static void unlevel_post (Gameboard *g){
41 g->level_dialog_active=0;
42 pop_curtain(g);
43 levelstate_go();
44 prepare_reenter_game(g);
45 reenter_game(g);
48 static void unlevel_quit (Gameboard *g){
49 gtk_main_quit();
52 static void local_go (Gameboard *g){
53 undeploy_buttons(g,unlevel_post);
56 static void local_quit (Gameboard *g){
57 undeploy_buttons(g,unlevel_quit);
60 /* initialize the rather weird little animation engine */
61 static void setup_level_buttons(Gameboard *g,int bw, int bh){
62 int i;
63 int w=g->g.width;
64 int h=g->g.height;
65 buttonstate *states=g->b.states;
67 states[0].rollovertext=_("exit gPlanarity");
68 states[2].rollovertext=_("reset level");
69 states[10].rollovertext=_("play level!");
71 states[0].callback = local_quit;
72 states[2].callback = local_reset;
73 states[10].callback = local_go;
75 for(i=0;i<NUMBUTTONS;i++)
76 states[i].position=0;
78 states[0].position = 2; //center
79 states[2].position = -2; //undeployed by default (redundant)
80 states[10].position = 2; //center
83 buttonstate *b=states;
84 b->x = b->x_target = w/2 - bw/2 + LEVEL_BUTTON_BORDER;
85 b->y_active = h/2 + bh/2 - LEVEL_BUTTON_Y;
86 b->y = b->y_target = b->y_inactive = b->y_active + BUTTON_EXPOSE;
87 b->sweepdeploy = 0;
91 buttonstate *b=states+2;
92 b->x = b->x_target = w/2;
93 b->y_active = h/2 + bh/2 - LEVEL_BUTTON_Y;
94 b->y = b->y_target = b->y_inactive = b->y_active + BUTTON_EXPOSE;
95 b->sweepdeploy = SWEEP_DELTA;
99 buttonstate *b=states+10;
100 b->x = b->x_target = w/2 + bw/2 - LEVEL_BUTTON_BORDER;
101 b->y_active = h/2 + bh/2 - LEVEL_BUTTON_Y;
102 b->y = b->y_target = b->y_inactive = b->y_active + BUTTON_EXPOSE;
103 b->sweepdeploy = SWEEP_DELTA;
106 rollover_extents(g,states);
107 rollover_extents(g,states+2);
108 rollover_extents(g,states+10);
111 static void draw_levelbox(Gameboard *g){
112 int w= g->g.width;
113 int h= g->g.height;
115 cairo_t *c = cairo_create(g->background);
116 borderbox_path(c,
117 w/2 - LEVELBOX_WIDTH/2,
118 h/2 - LEVELBOX_HEIGHT/2,
119 LEVELBOX_WIDTH,
120 LEVELBOX_HEIGHT);
121 cairo_set_source_rgb(c,1,1,1);
122 cairo_fill(c);
124 centerbox(c,
125 w/2 - LEVELBOX_WIDTH/2,
126 h/2 - LEVELBOX_HEIGHT/2,
127 LEVELBOX_WIDTH,
128 SCOREHEIGHT);
130 centerbox(c,
131 w/2 - LEVELBOX_WIDTH/2,
132 h/2 + LEVELBOX_HEIGHT/2 - SCOREHEIGHT,
133 LEVELBOX_WIDTH,
134 SCOREHEIGHT);
136 set_font(c,18,18,0,1);
137 cairo_set_source_rgba (c, TEXT_COLOR);
139 render_text_centered(c,_("Available Levels"), w/2,h/2-LEVELBOX_HEIGHT/2+SCOREHEIGHT/2);
141 cairo_destroy(c);
144 void level_dialog(Gameboard *g, int advance){
146 g->level_dialog_active=1;
147 levelstate_write();
149 if(advance)
150 levelstate_next();
152 // set up new buttons
153 setup_level_buttons(g,LEVELBOX_WIDTH, LEVELBOX_HEIGHT);
154 level_icons_init(g);
156 // draw pausebox
157 push_curtain(g,draw_levelbox);
159 // deploy new buttons
160 deploy_buttons(g,0);