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.
35 #include "gameboard.h"
36 #include "gameboard_draw_button.h"
37 #include "gameboard_logic_buttonbar.h"
38 #include "dialog_finish.h"
39 #include "dialog_pause.h"
40 #include "dialog_level.h"
42 /************************ the lower button bar *********************/
44 /* initialize the rather weird little animation engine */
45 void setup_buttonbar(Gameboard
*g
){
47 buttonstate
*states
=g
->b
.states
;
48 int xcount
=BUTTONBAR_BORDER
;
54 states
[0].rollovertext
=_("exit gPlanarity");
55 states
[1].rollovertext
=_("level selection menu");
56 states
[2].rollovertext
=_("reset board");
57 states
[3].rollovertext
=_("pause");
58 states
[4].rollovertext
=_("help / about");
59 states
[5].rollovertext
=_("expand");
60 states
[6].rollovertext
=_("shrink");
61 states
[7].rollovertext
=_("hide/show lines");
62 states
[8].rollovertext
=_("mark intersections");
63 states
[9].rollovertext
=_("click when finished!");
65 states
[0].callback
= quit_action
;
66 states
[1].callback
= level_action
;
67 states
[2].callback
= reset_action
;
68 states
[3].callback
= pause_action
;
69 states
[4].callback
= about_action
;
70 states
[5].callback
= expand_action
;
71 states
[6].callback
= shrink_action
;
72 states
[7].callback
= toggle_hide_lines
;
73 states
[8].callback
= toggle_show_intersections
;
74 states
[9].callback
= finish_action
;
76 for(i
=0;i
<NUMBUTTONS
;i
++)
79 states
[0].position
= 1; //left;
80 states
[1].position
= 1; //left;
81 states
[2].position
= 1; //left;
82 states
[3].position
= 1; //left;
83 states
[4].position
= 1; //left;
84 states
[5].position
= 3; //right
85 states
[6].position
= 3; //right
86 states
[7].position
= 3; //right
87 states
[8].position
= 3; //right
88 states
[9].position
= 3; //right
90 for(i
=0;i
<NUMBUTTONS
;i
++){
91 buttonstate
*b
=states
+i
;
94 b
->x
= b
->x_target
= xcount
;
95 b
->y_active
= h
- BUTTONBAR_Y_FROM_BOTTOM
;
96 b
->y
= b
->y_target
= b
->y_inactive
= h
- BUTTONBAR_Y_FROM_BOTTOM
+ BUTTON_EXPOSE
;
97 b
->sweepdeploy
= dcount
;
98 xcount
+= BUTTONBAR_SPACING
;
99 dcount
+= SWEEP_DELTA
;
100 rollover_extents(g
,states
+i
);
104 xcount
= w
-BUTTONBAR_BORDER
;
106 for(i
=NUMBUTTONS
-1;i
>=0;i
--){
107 buttonstate
*b
=states
+i
;
108 if(b
->position
== 3){
110 b
->x
= b
->x_target
= xcount
;
111 b
->y_active
= h
- BUTTONBAR_Y_FROM_BOTTOM
;
112 b
->y
= b
->y_target
= b
->y_inactive
= h
- BUTTONBAR_Y_FROM_BOTTOM
+ BUTTON_EXPOSE
;
113 b
->sweepdeploy
= dcount
;
115 if(i
!=9 || g
->checkbutton_deployed
){ // special-case the checkbutton
116 xcount
-= BUTTONBAR_SPACING
;
117 dcount
+= SWEEP_DELTA
;
119 states
[9].position
= -3; //deactivate it for the deploy
121 rollover_extents(g
,states
+i
);
126 /* effects animated 'rollout' of buttons when level begins */
127 void deploy_buttonbar(Gameboard
*g
){
128 if(!g
->b
.buttons_ready
){
129 if(g
->g
.active_intersections
<= g
->g
.objective
)
130 g
->checkbutton_deployed
=1;
132 g
->checkbutton_deployed
=0;
139 /* effects animated rollout of 'check' button */
140 void deploy_check(Gameboard
*g
){
141 buttonstate
*states
=g
->b
.states
;
142 if(g
->b
.buttons_ready
&& !g
->checkbutton_deployed
){
145 states
[i
].x_target
-=BUTTONBAR_SPACING
;
146 states
[i
].sweepdeploy
+= SWEEP_DELTA
;
149 states
[9].position
= 3; //activate it
150 states
[9].y_target
= states
[9].y_active
;
151 states
[i
].sweepdeploy
= 0;
153 if(g
->button_timer
!=0)
154 g_source_remove(g
->button_timer
);
155 g
->button_callback
=0;
156 g
->button_timer
= g_timeout_add(BUTTON_ANIM_INTERVAL
, animate_button_frame
, (gpointer
)g
);
157 g
->checkbutton_deployed
=1;
161 /* effects animated rollback of 'check' button */
162 void undeploy_check(Gameboard
*g
){
163 buttonstate
*states
=g
->b
.states
;
164 if(g
->checkbutton_deployed
){
167 states
[i
].x_target
+=BUTTONBAR_SPACING
;
168 states
[i
].sweepdeploy
-= SWEEP_DELTA
;
170 states
[9].y_target
=states
[9].y_inactive
;
172 if(g
->button_timer
!=0)
173 g_source_remove(g
->button_timer
);
174 g
->button_callback
=0;
175 g
->button_timer
= g_timeout_add(BUTTON_ANIM_INTERVAL
, animate_button_frame
, (gpointer
)g
);
176 g
->checkbutton_deployed
=0;