4 * The geeky little puzzle game with a big noodly crunch!
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)
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.
34 #include "gameboard.h"
35 #include "gameboard_draw_button.h"
36 #include "dialog_level.h"
37 #include "levelstate.h"
40 static void unlevel_post (Gameboard
*g
){
41 g
->level_dialog_active
=0;
44 prepare_reenter_game(g
);
48 static void unlevel_quit (Gameboard
*g
){
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
){
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
++)
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
;
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
){
115 cairo_t
*c
= cairo_create(g
->background
);
117 w
/2 - LEVELBOX_WIDTH
/2,
118 h
/2 - LEVELBOX_HEIGHT
/2,
121 cairo_set_source_rgb(c
,1,1,1);
125 w
/2 - LEVELBOX_WIDTH
/2,
126 h
/2 - LEVELBOX_HEIGHT
/2,
131 w
/2 - LEVELBOX_WIDTH
/2,
132 h
/2 + LEVELBOX_HEIGHT
/2 - 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);
144 void level_dialog(Gameboard
*g
, int advance
){
146 g
->level_dialog_active
=1;
152 // set up new buttons
153 setup_level_buttons(g
,LEVELBOX_WIDTH
, LEVELBOX_HEIGHT
);
157 push_curtain(g
,draw_levelbox
);
159 // deploy new buttons