1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
/*
*
* gPlanarity:
* The geeky little puzzle game with a big noodly crunch!
*
* gPlanarity copyright (C) 2005 Monty <monty@xiph.org>
* Original Flash game by John Tantalo <john.tantalo@case.edu>
* Original game concept by Mary Radcliffe
*
* gPlanarity is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* gPlanarity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Postfish; see the file COPYING. If not, write to the
* Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*/
#include <math.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include "graph.h"
#include "timer.h"
#include "gameboard.h"
#include "gameboard_draw_button.h"
#include "dialog_level.h"
#include "levelstate.h"
#include "main.h"
static void unlevel_post (Gameboard *g){
g->level_dialog_active=0;
pop_curtain(g);
levelstate_go();
prepare_reenter_game(g);
reenter_game(g);
}
static void unlevel_quit (Gameboard *g){
gtk_main_quit();
}
static void local_go (Gameboard *g){
undeploy_buttons(g,unlevel_post);
}
static void local_quit (Gameboard *g){
undeploy_buttons(g,unlevel_quit);
}
/* initialize the rather weird little animation engine */
static void setup_level_buttons(Gameboard *g,int bw, int bh){
int i;
int w=g->g.width;
int h=g->g.height;
buttonstate *states=g->b.states;
states[0].rollovertext=_("exit gPlanarity");
states[2].rollovertext=_("reset level");
states[10].rollovertext=_("play level!");
states[0].callback = local_quit;
states[2].callback = local_reset;
states[10].callback = local_go;
for(i=0;i<NUMBUTTONS;i++)
states[i].position=0;
states[0].position = 2; //center
states[2].position = -2; //undeployed by default (redundant)
states[10].position = 2; //center
{
buttonstate *b=states;
b->x = b->x_target = w/2 - bw/2 + LEVEL_BUTTON_BORDER;
b->y_active = h/2 + bh/2 - LEVEL_BUTTON_Y;
b->y = b->y_target = b->y_inactive = b->y_active + BUTTON_EXPOSE;
b->sweepdeploy = 0;
}
{
buttonstate *b=states+2;
b->x = b->x_target = w/2;
b->y_active = h/2 + bh/2 - LEVEL_BUTTON_Y;
b->y = b->y_target = b->y_inactive = b->y_active + BUTTON_EXPOSE;
b->sweepdeploy = SWEEP_DELTA;
}
{
buttonstate *b=states+10;
b->x = b->x_target = w/2 + bw/2 - LEVEL_BUTTON_BORDER;
b->y_active = h/2 + bh/2 - LEVEL_BUTTON_Y;
b->y = b->y_target = b->y_inactive = b->y_active + BUTTON_EXPOSE;
b->sweepdeploy = SWEEP_DELTA;
}
rollover_extents(g,states);
rollover_extents(g,states+2);
rollover_extents(g,states+10);
}
static void draw_levelbox(Gameboard *g){
int w= g->g.width;
int h= g->g.height;
cairo_t *c = cairo_create(g->background);
borderbox_path(c,
w/2 - LEVELBOX_WIDTH/2,
h/2 - LEVELBOX_HEIGHT/2,
LEVELBOX_WIDTH,
LEVELBOX_HEIGHT);
cairo_set_source_rgb(c,1,1,1);
cairo_fill(c);
centerbox(c,
w/2 - LEVELBOX_WIDTH/2,
h/2 - LEVELBOX_HEIGHT/2,
LEVELBOX_WIDTH,
SCOREHEIGHT);
centerbox(c,
w/2 - LEVELBOX_WIDTH/2,
h/2 + LEVELBOX_HEIGHT/2 - SCOREHEIGHT,
LEVELBOX_WIDTH,
SCOREHEIGHT);
set_font(c,18,18,0,1);
cairo_set_source_rgba (c, TEXT_COLOR);
render_text_centered(c,_("Available Levels"), w/2,h/2-LEVELBOX_HEIGHT/2+SCOREHEIGHT/2);
cairo_destroy(c);
}
void level_dialog(Gameboard *g, int advance){
g->level_dialog_active=1;
levelstate_write();
if(advance)
levelstate_next();
// set up new buttons
setup_level_buttons(g,LEVELBOX_WIDTH, LEVELBOX_HEIGHT);
level_icons_init(g);
// draw pausebox
push_curtain(g,draw_levelbox);
// deploy new buttons
deploy_buttons(g,0);
}
|