static gboolean configure_event_cb (GtkWidget *widget, GdkEventConfigure *event, gpointer data) { int tilesize, ts_x, ts_y; int i; /* Compute the new tile size based on the size of the * drawing area, rounded down. */ ts_x = event->width / BOARDWIDTH; ts_y = event->height / BOARDHEIGHT; if (ts_x * BOARDWIDTH > event->width) ts_x--; if (ts_y * BOARDHEIGHT > event->height) ts_y--; tilesize = MIN (ts_x, ts_y); gnibbles_load_pixmap (tilesize); gnibbles_load_logo (tilesize); clutter_actor_set_size (CLUTTER_ACTOR (stage), BOARDWIDTH * tilesize, BOARDWIDTH * tilesize); if (game_running ()) { if (board) { gnibbles_board_rescale (board, tilesize); gnibbles_boni_rescale (boni, tilesize); for (i=0; i<properties->numworms; i++) gnibbles_worm_rescale (worms[i], tilesize); if (warpmanager) gnibbles_warpmanager_rescale (warpmanager, tilesize); } } else { if (logo) hide_logo (); if (board) gnibbles_board_rescale (board, tilesize); render_logo (); } /* But, has the tile size changed? */ if (properties->tilesize == tilesize) { /* We must always re-load the logo. */ gnibbles_load_logo (tilesize); return FALSE; } properties->tilesize = tilesize; gnibbles_properties_set_tile_size (tilesize); return FALSE; }
static gboolean new_game_2_cb (GtkWidget * widget, gpointer data) { if (!paused) { if (!keyboard_id) keyboard_id = g_signal_connect (G_OBJECT (stage), "key-press-event", G_CALLBACK (key_press_cb), NULL); #ifdef GGZ_CLIENT if (!main_id && ggz_network_mode && network_is_host ()) { main_id = g_timeout_add (GAMEDELAY * (properties->gamespeed + NETDELAY), (GSourceFunc) network_loop, NULL); } else #endif if (!main_id && !ggz_network_mode) { main_id = g_timeout_add (GAMEDELAY * properties->gamespeed, (GSourceFunc) main_loop, NULL); } #ifdef GGZ_CLIENT if (!add_bonus_id && network_is_host ()) { #else if (!add_bonus_id) { #endif add_bonus_id = g_timeout_add (BONUSDELAY * properties->gamespeed, (GSourceFunc) add_bonus_cb, NULL); } } dummy_id = 0; return FALSE; } gboolean new_game (void) { int i; gtk_action_set_sensitive (new_network_action, FALSE); if (ggz_network_mode) { gtk_action_set_sensitive (pause_action, FALSE); } else { gtk_action_set_sensitive (pause_action, TRUE); } gtk_action_set_sensitive (end_game_action, TRUE); gtk_action_set_sensitive (preferences_action, !ggz_network_mode); if (game_running ()) { end_game (FALSE); main_id = 0; } if (ggz_network_mode || !properties->random) { current_level = properties->startlevel; } else { current_level = rand () % MAXLEVEL + 1; } hide_logo (); gnibbles_init (); gnibbles_board_level_new (board, current_level); gnibbles_board_level_add_bonus (board, 1); for (i = 0; i < properties->numworms; i++) { if (!clutter_actor_get_stage (worms[i]->actors)) clutter_container_add_actor (CLUTTER_CONTAINER (stage), worms[i]->actors); gnibbles_worm_show (worms[i]); } paused = 0; gtk_action_set_visible (pause_action, !paused); gtk_action_set_visible (resume_action, paused); gtk_action_set_visible (player_list_action, ggz_network_mode); if (restart_id) { g_source_remove (restart_id); restart_id = 0; } if (add_bonus_id) { g_source_remove (add_bonus_id); add_bonus_id = 0; } if (dummy_id) g_source_remove (dummy_id); dummy_id = g_timeout_add_seconds (1, (GSourceFunc) new_game_2_cb, NULL); network_gui_update (); return TRUE; }
static bool LogoCallBack(t_x11 *x11, XEvent *event, Window /*w*/, void *data) { /* Assume window is 100x110 */ static bool bFirst = true; #define CSIZE 9 #define NSIZE 8 #define OSIZE 9 #define HSIZE 7 #define YOFFS 30 static t_circle c[] = { { 10, YOFFS+12, CSIZE, &LIGHTGREEN }, { 20, YOFFS+22, CSIZE, &LIGHTGREEN }, { 20, YOFFS+34, OSIZE, &LIGHTRED }, { 30, YOFFS+12, NSIZE, &LIGHTCYAN }, { 30, YOFFS+ 2, HSIZE, &WHITE }, { 40, YOFFS+22, CSIZE, &LIGHTGREEN }, { 40, YOFFS+34, CSIZE, &LIGHTGREEN }, { 50, YOFFS+12, CSIZE, &LIGHTGREEN }, { 50, YOFFS, OSIZE, &LIGHTRED }, { 60, YOFFS+22, NSIZE, &LIGHTCYAN }, { 60, YOFFS+32, HSIZE, &WHITE }, { 70, YOFFS+12, CSIZE, &LIGHTGREEN }, { 80, YOFFS+22, CSIZE, &LIGHTGREEN }, { 80, YOFFS+34, OSIZE, &LIGHTRED }, { 90, YOFFS+12, NSIZE, &LIGHTCYAN }, { 90, YOFFS+ 2, HSIZE, &WHITE }, {100, YOFFS+22, CSIZE, &LIGHTGREEN } }; static int lines[] = { 0, 1, 1, 2, 1, 3, 3, 4, 3, 5, 5, 6, 5, 7, 7, 8, 7, 9, 9, 10, 9, 11, 11, 12, 12, 13, 12, 14, 14, 15, 14, 16 }; #define COFFS 70 static t_mess Mess[] = { { "GROMACS", 0, 20, NULL }, { NULL, 16, 9, NULL }, { "Copyright (c) 1991-2013", COFFS+ 2, 9, NULL }, { "D.v.d.Spoel, E.Lindahl, B.Hess", COFFS+11, 9, NULL }, { "& Groningen University ", COFFS+20, 9, NULL }, { "click to dismiss", COFFS+31, 8, NULL } }; #define NMESS asize(Mess) int i; real wfac, hfac; t_logo *logo; t_windata *wd; logo = (t_logo *)data; wd = &(logo->wd); if (bFirst) { wfac = wd->width/110.0; hfac = wd->height/110.0; for (i = 0; (i < asize(c)); i++) { c[i].x *= wfac; c[i].y *= hfac; } Mess[1].text = GromacsVersion(); for (i = 0; (i < NMESS); i++) { Mess[i].y *= hfac; Mess[i].h *= hfac; Mess[i].fnt = (i == 0) ? logo->bigfont : (i == NMESS-1) ? x11->font : logo->smallfont; } bFirst = false; } switch (event->type) { case Expose: XSetForeground(x11->disp, x11->gc, WHITE); XSetLineAttributes(x11->disp, x11->gc, 3, LineSolid, CapNotLast, JoinRound); for (i = 0; (i < asize(lines)); i += 2) { XDrawLine(x11->disp, wd->self, x11->gc, c[lines[i]].x, c[lines[i]].y, c[lines[i+1]].x, c[lines[i+1]].y); } XSetLineAttributes(x11->disp, x11->gc, 1, LineSolid, CapNotLast, JoinRound); for (i = 0; (i < asize(c)); i++) { XSetForeground(x11->disp, x11->gc, *(c[i].col)); XFillCircle(x11->disp, wd->self, x11->gc, c[i].x, c[i].y, c[i].rad); } XSetForeground(x11->disp, x11->gc, BLACK); XDrawRectangle(x11->disp, wd->self, x11->gc, 2, 2, wd->width-5, wd->height-5); for (i = 0; (i < NMESS); i++) { SpecialTextInRect(x11, Mess[i].fnt, wd->self, Mess[i].text, 0, Mess[i].y, wd->width, Mess[i].h, eXCenter, eYCenter); } XSetForeground(x11->disp, x11->gc, x11->fg); break; case ButtonPress: hide_logo(x11, logo); return logo->bQuitOnClick; break; default: break; } return false; }