/* ==================================== */ static void highlight_selected(GooCanvasItem * button) { GdkPixbuf *button_pixmap_selected = NULL, *button_pixmap = NULL; if (selected_button != NULL && selected_button != button) { button_pixmap = gc_pixmap_load("missing_letter/button.png"); g_object_set(selected_button, "pixbuf", button_pixmap, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(button_pixmap); #else g_object_unref(button_pixmap); #endif } if (selected_button != button) { button_pixmap_selected = gc_pixmap_load("missing_letter/button_selected.png"); g_object_set(button, "pixbuf", button_pixmap_selected, NULL); selected_button = button; #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(button_pixmap_selected); #else g_object_unref(button_pixmap_selected); #endif } }
/* ===================================================================== * Submarine explosion * =====================================================================*/ static void submarine_explosion() { GdkPixbuf *pixmap = NULL; if (submarine_destroyed) return; submarine_destroyed = TRUE; gamewon = FALSE; gc_sound_play_ogg("sounds/crash.wav", NULL); /* make the submarine die */ setSpeed(speed_ordered = submarine_horizontal_speed = 0.0); setBattery(battery = 0.0); setAir(air = 0.0); regleur = MAX_REGLEUR; weight = 2000.0; /* Stop the frigate */ goo_canvas_item_stop_animation (frigate_item); /* display the boken submarine */ pixmap = gc_pixmap_load("submarine/submarine-broken.png"); g_object_set(submarine_item, "pixbuf", pixmap, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif ok(); }
static void display_sponsor(GooCanvasItem *rootitem) { GooCanvasItem *item; GdkPixbuf *pixmap = NULL; /* Location for a potential sponsor */ gchar *sponsor_image = gc_file_find_absolute("sponsor.png"); if(sponsor_image) { pixmap = gc_pixmap_load("sponsor.png"); item = goo_canvas_image_new (rootitem, pixmap, 0.0, 0.0, NULL); SET_ITEM_LOCATION_CENTER(item, display_x + display_w/2.0, display_y + display_h/3.0 + 150); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif g_free(sponsor_image); } }
static void start_frigate_anim() { GdkPixbuf *pixmap; int w; if (frigate_item) stop_frigate_anim(); // the antisubmarine warfare frigate pixmap = gc_pixmap_load("submarine/asw_frigate.png"); w = gdk_pixbuf_get_width(pixmap); frigate_item = goo_canvas_image_new (goo_canvas_get_root_item(gcomprisBoard->canvas), pixmap, 0, 0, NULL); goo_canvas_item_translate(frigate_item, BOARDWIDTH, 6); goo_canvas_item_animate(frigate_item, -w, 2.0, 1, 0, TRUE, 100*1000, 100, GOO_CANVAS_ANIMATE_RESTART); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif }
static void scale_prepare_level() { GdkPixbuf *pixmap; int show_weight = 0; const int default_list_weight[10] = { 1, 2, 2, 5, 5, 10, 10}; int list_weight[10]= {0}; int i, tmp[5]; group_m = goo_canvas_group_new(boardRootItem, NULL); switch(gcomprisBoard->level) { case 1: case 2: objet_weight = g_random_int_range(5,20); for(i=0; i<10; i++) list_weight[i] = default_list_weight[i]; show_weight = gcomprisBoard->level == 1; break; case 3: case 4: while(1) { for(i=0; i< 5; i++) do tmp[i] = default_list_weight[g_random_int_range(0,10)]; while(tmp[i]==0); objet_weight=0; for(i=0; i<5; i++) objet_weight += g_random_int_range(-1,2) * tmp[i]; objet_weight = abs(objet_weight); if(!test_addition(objet_weight, tmp, 5)) break; } for(i=0; i<5; i++) list_weight[i] = tmp[i]; show_weight = gcomprisBoard->level == 3; break; } ask_for_answer = !show_weight; for(i=0; list_weight[i] ; i++) scale_list_add_weight(group_m, list_weight[i], 0); pixmap = gc_pixmap_load(imageList[g_random_int_range(0,imageListCount)]); scale_list_add_object(group_d, pixmap, objet_weight, -1, show_weight); gdk_pixbuf_unref(pixmap); }
static void display_paying_tux(guint note) { GdkPixbuf *pixmap = NULL; g_assert(boardRootItem); pixmap = gc_pixmap_load("money/tux_graduate.png"); goo_canvas_image_new (boardRootItem, pixmap, 20, 130, NULL); gdk_pixbuf_unref(pixmap); if (note == 30) { display_paying_note(20, 20, 200); display_paying_note(10, 30, 250); } else if (note == 40) { display_paying_note(20, 20, 200); display_paying_note(20, 30, 250); } else if (note == 100) { display_paying_note(50, 20, 200); display_paying_note(50, 30, 250); } else display_paying_note(note, 20, 200); /* Set here the way to display money. Change only the money sign, and it's place, always keep %d */ gchar *text = g_strdup_printf(_("Tux just bought some items in your shop.\n" "He gives you $ %d, please give back his change."), note); goo_canvas_text_new(boardRootItem, text, BOARDWIDTH / 2, 320, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_medium, "fill-color", "white", "alignment", PANGO_ALIGN_CENTER, NULL); g_free(text); }
/* ===================================================================== * * =====================================================================*/ static GooCanvasItem *colors_create_item(GooCanvasItem *parent) { GdkPixbuf *pixmap; char *str = NULL; boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir, "highlight.png"); pixmap = gc_pixmap_load(str); highlight_image_item = goo_canvas_image_new (boardRootItem, pixmap, 0, 0, NULL); highlight_width = gdk_pixbuf_get_width(pixmap); highlight_height = gdk_pixbuf_get_height(pixmap); g_free(str); g_object_set (highlight_image_item, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); gdk_pixbuf_unref(pixmap); /* setup the clock */ str = g_strdup_printf("%s%d.png", "timers/clock",errors); pixmap = gc_skin_pixmap_load(str); clock_image_item = goo_canvas_image_new (boardRootItem, pixmap, CLOCK_X, CLOCK_Y, NULL); gdk_pixbuf_unref(pixmap); g_free(str); return NULL; }
/* * Do all the bar display and register the events */ void gc_about_start () { GdkPixbuf *pixmap = NULL; gdouble y_start = 0; gint y = 0; GooCanvasItem *item; static gchar *content = N_("Author: Bruno Coudoin\n" "Contribution: Pascal Georges, Jose Jorge, Yves Combe\n" "Graphics: Renaud Blanchard, Franck Doucet\n" "Intro Music: Djilali Sebihi\n" "Background Music: Rico Da Halvarez\n" ); /* TRANSLATORS: Replace this string with your names, one name per line. */ gchar *translators = _("translator_credits"); /* Pause the board */ gc_board_pause(TRUE); if(rootitem) { gc_about_stop(); return; } gc_bar_hide (TRUE); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gc_get_canvas()), NULL); item = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#DIALOG", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); GooCanvasBounds bounds; goo_canvas_item_get_bounds(item, &bounds); y_start = bounds.y1; y = bounds.y2 - 26; goo_canvas_text_new (rootitem, _("About GCompris"), (gdouble) BOARDWIDTH/2, (gdouble) y_start + 35, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_title, NULL); goo_canvas_text_new (rootitem, _("GCompris Home Page: http://gcompris.net"), (gdouble) BOARDWIDTH/2, (gdouble) y_start + 58, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_subtitle, NULL); gchar *text = g_strdup_printf("%s\n%s\n%s", _(content), _("Translators:"), translators); y_start += 100; goo_canvas_text_new (rootitem, text, (gdouble) BOARDWIDTH/2-320, (gdouble) y_start, -1, GTK_ANCHOR_NORTH_WEST, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); g_free(text); // Version item = \ goo_canvas_text_new (rootitem, "GCompris V" VERSION, (gdouble) 0, (gdouble) y_start, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_title, "fill-color-rgba", gc_skin_color_subtitle, NULL); goo_canvas_item_get_bounds(item, &bounds); gdouble x = BOARDWIDTH - (bounds.x2 - bounds.x1) - 20; g_object_set( (GooCanvasItem*)item, "x", x, NULL); y_start += 180; /* Location for a potential sponsor */ gchar *sponsor_image = gc_file_find_absolute("sponsor_about.png"); if(sponsor_image) { pixmap = gc_pixmap_load("sponsor_about.png"); goo_canvas_text_new (rootitem, "Version parrainée par", (gdouble) BOARDWIDTH*0.75, (gdouble) y_start - gdk_pixbuf_get_height(pixmap), -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); item = goo_canvas_image_new (rootitem, pixmap, (gdouble) (BOARDWIDTH*0.75) - gdk_pixbuf_get_width(pixmap)/2, (gdouble) y_start - gdk_pixbuf_get_height(pixmap) + 15, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif g_free(sponsor_image); } else { // Default sponsor is the FSF RsvgHandle *svg_handle; svg_handle = gc_skin_rsvg_get(); item = goo_canvas_svg_new (rootitem, svg_handle, "svg-id", "#FSF_LOGO", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); goo_canvas_item_get_bounds(item, &bounds); SET_ITEM_LOCATION_CENTER(item, (BOARDWIDTH*0.75), y_start + 50 - (bounds.y2 - bounds.y1) / 2); item = goo_canvas_text_new (rootitem, "Free Software Foundation\nhttp://www.fsf.org", (gdouble) (BOARDWIDTH*0.75), (gdouble) y_start + 80, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_subtitle, NULL); } // Copyright item = goo_canvas_text_new (rootitem, "Copyright 2000-2013 Bruno Coudoin and Others", (gdouble) BOARDWIDTH/2, (gdouble) y - 55, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_content, "fill-color-rgba", gc_skin_color_content, NULL); // License item = goo_canvas_text_new (rootitem, _("This software is a GNU Package and is released under the GNU General Public License"), (gdouble) BOARDWIDTH/2, (gdouble) y - 40, -1, GTK_ANCHOR_CENTER, "font", "sans 8", "fill-color-rgba", gc_skin_color_content, NULL); // OK gc_util_button_text_svg(rootitem, BOARDWIDTH * 0.5, y, "#BUTTON_TEXT", _("OK"), (GCallback) item_event_ok, "ok"); is_displayed = TRUE; }
// show_weight: // 0 -> no unit, // 1 -> display g, 1000 -> display kg, // 10000 -> random (weighted 1:2) static ScaleItem * scale_list_add_weight(GooCanvasItem *group, gint weight, int show_weight) { ScaleItem *new_item; GdkPixbuf *pixmap; gchar *weight_text; double x, y; GList *last; last = g_list_last(item_list); if(last) { new_item = last->data; x = new_item->x + ITEM_W; y = new_item->y; if(x > ITEM_X_MAX) { x = ITEM_X_MIN; y += ITEM_H; if(y > ITEM_Y_MAX) g_warning("No more place for new item"); } } else { x = ITEM_X_MIN; y = ITEM_Y_MIN; } new_item = g_new0(ScaleItem, 1); new_item->x = x; new_item->y = y; new_item->weight = weight; /* If selected, display multiples of 500g as 'g' or 'kg' randomly */ if (show_weight > 9999) { if ((weight % 500) == 0) show_weight = g_random_int_range(1,3000); else show_weight = 1; } if (show_weight < 1000) { weight_text = g_strdup_printf("%d%s", weight, show_weight ? "\n g" : ""); } else { int thousand = weight / 1000; int hundred = (weight % 1000) / 100; weight_text = g_strdup_printf("%c %c\n kg", '0' + thousand, '0' + hundred); } pixmap = gc_pixmap_load("scale/masse.png"); new_item->item = goo_canvas_group_new(group, NULL); goo_canvas_image_new(new_item->item, pixmap, 0, 0, NULL); goo_canvas_text_new(new_item->item, weight_text, 18, 35, -1, GTK_ANCHOR_CENTER, "font", "sans 10", "fill_color_rgba", 0x000000FFL, NULL); goo_canvas_item_translate(new_item->item, new_item->x, new_item->y); gdk_pixbuf_unref(pixmap); g_free(weight_text); gc_item_focus_init(new_item->item, NULL); g_signal_connect(new_item->item, "button_press_event", (GtkSignalFunc)gc_drag_event, new_item); g_signal_connect(new_item->item, "button_release_event", (GtkSignalFunc)gc_drag_event, new_item); g_signal_connect(new_item->item, "button_press_event", (GtkSignalFunc) scale_item_event, new_item); item_list = g_list_append(item_list, new_item); return new_item; }
static void create_item(GooCanvasItem *parent) { MemoryItem *memoryItem; gint x, y; double height, width; double height2, width2; GdkPixbuf *pixmap = NULL; // Calc width and height of one card width = (base_x2-(currentMode == MODE_TUX ? base_x1_tux : base_x1))/numberOfColumn; height = (base_y2-base_y1)/numberOfLine; // Respect the card ratio if( width * 1.418 > height) width = height * 0.704; else height = width * 1.418; /* Remove a little bit of space for the card shadow */ height2 = height * 0.95; width2 = width * 0.95; if (currentUiMode == UIMODE_SOUND) { goo_canvas_rect_new (parent, (currentMode == MODE_TUX ? base_x1_tux : base_x1) - 20, base_y1 - 15, width * numberOfColumn + 20*2, height * numberOfLine + 15*2, "stroke_color_rgba", 0xFFFFFFFFL, "fill_color_rgba", 0x66666690L, "line-width", (double) 2, "radius-x", (double) 10, "radius-y", (double) 10, NULL); } if (currentMode == MODE_TUX){ GdkPixbuf *pixmap_tux = gc_pixmap_load("memory/tux-teacher.png"); tux = goo_canvas_image_new (parent, pixmap_tux, 50, 140, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap_tux); #else g_object_unref(pixmap_tux); #endif tux_score = goo_canvas_text_new (parent, "", (double) 115, (double) 235, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_huge_bold, "fill_color_rgba", 0xFF0F0FFF, NULL); player_score = goo_canvas_text_new (parent, "", (double) 100, (double) BASE_CARD_Y2 - 20, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_huge_bold, "fill_color_rgba", 0xFF0F0FFF, NULL); } for(x=0; x<numberOfColumn; x++) { for(y=0; y<numberOfLine; y++) { memoryItem = g_malloc0(sizeof(MemoryItem)); memoryItem->rootItem = \ goo_canvas_group_new (parent, NULL); goo_canvas_item_translate(memoryItem->rootItem, (currentMode == MODE_TUX ? base_x1_tux : base_x1) + x*width, base_y1 + y*height); if (currentUiMode == UIMODE_SOUND) pixmap = gc_pixmap_load("memory/Tux_mute.png"); else pixmap = gc_pixmap_load("memory/backcard.png"); memoryItem->backcardItem = \ goo_canvas_image_new (memoryItem->rootItem, pixmap, 0, 0, NULL); goo_canvas_item_scale(memoryItem->backcardItem, width2 / gdk_pixbuf_get_width(pixmap), height2 / gdk_pixbuf_get_height(pixmap)); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif if (currentUiMode != UIMODE_SOUND){ pixmap = gc_pixmap_load("memory/emptycard.png"); memoryItem->framecardItem = \ goo_canvas_image_new (memoryItem->rootItem, pixmap, 0, 0, NULL); goo_canvas_item_scale(memoryItem->framecardItem, (width2 / gdk_pixbuf_get_width(pixmap)), (height2 / gdk_pixbuf_get_height(pixmap))); g_object_set (memoryItem->framecardItem, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif } // Display the image itself while taking care of its size and maximize the ratio get_image(memoryItem, x, y); if (currentUiMode == UIMODE_SOUND){ pixmap = gc_pixmap_load("memory/Tux_play.png"); memoryItem->frontcardItem = \ goo_canvas_image_new (memoryItem->rootItem, pixmap, 0, 0, NULL); goo_canvas_item_scale(memoryItem->frontcardItem, (width2 / gdk_pixbuf_get_width(pixmap)), (height2 / gdk_pixbuf_get_height(pixmap))); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif } else { if(memoryItem->type & (TYPE_IMAGE|TYPE_ENUMERATE_IMAGE)) { pixmap = gc_pixmap_load(memoryItem->data); memoryItem->frontcardItem = \ goo_canvas_image_new (memoryItem->rootItem, pixmap, 0.0, 0.0, NULL); /* scale only in ENUMERATE (image size too big) */ if(memoryItem->type == TYPE_ENUMERATE_IMAGE) { goo_canvas_item_scale(memoryItem->frontcardItem, (0.9*width2 / gdk_pixbuf_get_width(pixmap)), (0.9*height2 / gdk_pixbuf_get_height(pixmap))); goo_canvas_item_translate(memoryItem->frontcardItem, 0.1 * width2, 0.1 * height2); } else { goo_canvas_item_translate(memoryItem->frontcardItem, (width2 - gdk_pixbuf_get_width(pixmap))/2, (height2 - gdk_pixbuf_get_height(pixmap))/2); } #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif } else { gchar *font; if (memoryItem->type & (TYPE_ADD|TYPE_MINUS|TYPE_MULT|TYPE_DIV)) font = op_fonts[gcomprisBoard->level]; else font = TEXT_FONT; /* It's a letter */ memoryItem->frontcardItem = \ goo_canvas_text_new (memoryItem->rootItem, memoryItem->data, (double) (width2)/2, (double) (height2)/2, -1, GTK_ANCHOR_CENTER, "font", font, "fill_color_rgba", 0x000000FF, NULL); if(memoryItem->type == TYPE_WORDNUMBER){ gcompris_adapt_font_size(GOO_CANVAS_TEXT(memoryItem->frontcardItem), width2, height2); } } } g_object_set (memoryItem->frontcardItem, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); g_signal_connect(memoryItem->rootItem, "button_press_event", (GCallback) item_event, memoryItem); } } //return (NULL); }
/* ==================================== */ static GooCanvasItem *wordprocessor_create() { GooCanvasItem *item = NULL; GdkPixbuf *pixmap; double y; boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); selected_tag = NULL; view = gtk_text_view_new (); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD); /* Change left margin throughout the widget */ gtk_text_view_set_left_margin (GTK_TEXT_VIEW (view), 1); g_signal_connect (view, "key-release-event", G_CALLBACK (key_release_event), NULL); g_signal_connect (view, "event-after", G_CALLBACK (event_after), NULL); g_signal_connect (view, "motion-notify-event", G_CALLBACK (motion_notify_event), NULL); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); gtk_container_add (GTK_CONTAINER (sw), view); item = goo_canvas_widget_new (boardRootItem, GTK_WIDGET(sw), word_area_x1, word_area_y1, word_area_width, word_area_height, "anchor", GTK_ANCHOR_NW, NULL); gtk_widget_show(GTK_WIDGET(view)); gtk_widget_show(GTK_WIDGET(sw)); /* * Create the default style tags */ doctype_list[0] = &type_text; doctype_list[1] = &type_normal; doctype_list[2] = &type_letter; doctype_list[3] = &type_small; doctype_list[4] = &type_big; // doctype_list[5] = &type_link; y = 20.0; /* * The save button */ pixmap = gc_pixmap_load("wordprocessor/tool-save.png"); item = \ goo_canvas_image_new (boardRootItem, pixmap, 17.0, y, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif g_signal_connect(item, "button_press_event", (GCallback) save_event, buffer); gc_item_focus_init(item, NULL); /* * The load button */ pixmap = gc_pixmap_load("wordprocessor/tool-load.png"); item = \ goo_canvas_image_new (boardRootItem, pixmap, 60.0, y, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif g_signal_connect(item, "button_press_event", (GCallback) load_event, buffer); gc_item_focus_init(item, NULL); y += 45; /* * Display the style buttons */ y = display_style_buttons(boardRootItem, 20.0, y); y += 20; display_style_selector(boardRootItem, y); y += 40; display_color_style_selector(boardRootItem, y); /* Now we can create the tags */ create_tags(buffer, doctype_list[0]); gtk_widget_grab_focus(view); return NULL; }
static void create_panel(GooCanvasItem *parent) { int n_sections; GList *list = NULL; GcomprisBoard *board; GdkPixbuf *pixmap = NULL; GooCanvasItem *item; gdouble x, y; gint int_y; GcomprisProperties *properties = gc_prop_get(); g_assert(properties); /* In normal mode, we show all the sections in panel */ /* in direct submenu access, we show the icon of the submenu */ if (strcmp(properties->root_menu,"/")==0) panelBoards = gc_menu_getlist(properties->root_menu); else panelBoards = g_list_append(list, gcomprisBoard); n_sections = g_list_length(panelBoards); if (n_sections == 0) return; if ( (panel_h/n_sections) <= icon_size_panel) { icon_size_panel = panel_h / n_sections; int_y = 0; } else { int_y = (panel_h - n_sections*icon_size_panel)/n_sections; } x = panel_x + panel_w * 0.25; y = panel_y + int_y / 2.0 - 20; for (list = panelBoards; list != NULL; list = list->next) { board = (GcomprisBoard *) list->data; pixmap = gc_pixmap_load(board->icon_name); item = goo_canvas_image_new (parent, pixmap, x, y, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif y += int_y + icon_size_panel; g_object_set_data (G_OBJECT (item), "board", board); g_signal_connect(item, "button_press_event", (GCallback) item_event, menuitems); g_signal_connect (item, "enter_notify_event", (GCallback) on_enter_notify, menuitems); g_signal_connect (item, "leave_notify_event", (GCallback) on_leave_notify, menuitems); if ( ! gc_board_is_demo_only(board) ) gc_item_focus_init(item, NULL); } }
/* ==================================== */ static void missing_letter_create_item(GooCanvasItem *parent) { int xOffset, yOffset; GdkPixbuf *button_pixmap = NULL; GdkPixbuf *pixmap = NULL; Board *board; /* This are the values of the area in which we must display the image */ gint img_area_x = 290; gint img_area_y = 80; gint img_area_w = 440; gint img_area_h = 310; /* this is the coordinate of the text to find */ gint txt_area_x = 515; gint txt_area_y = 435; guint vertical_separation; gint i; board_number = gcomprisBoard_missing->sublevel-1; g_assert(board_number >= 0 && board_number < g_list_length(board_list)); boardRootItem = \ goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard_missing->canvas), NULL); button_pixmap = gc_pixmap_load("missing_letter/button.png"); /* display the image */ board = g_list_nth_data(board_list, board_number); g_assert(board != NULL); pixmap = gc_pixmap_load(board->pixmapfile); text = goo_canvas_text_new (boardRootItem, _(board->question), (double) txt_area_x, (double) txt_area_y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_huge_bold, "fill_color_rgba", 0xFFFFFFFFL, NULL); goo_canvas_image_new (boardRootItem, pixmap, img_area_x+(img_area_w - gdk_pixbuf_get_width(pixmap))/2, img_area_y+(img_area_h - gdk_pixbuf_get_height(pixmap))/2, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif /* Calc the number of proposals */ i = 0; while(board->text[i++]); vertical_separation = 10 + 20 / i; yOffset = ( BOARDHEIGHT - i * gdk_pixbuf_get_height(button_pixmap) - 2 * vertical_separation) / 2 - 20; xOffset = (img_area_x - gdk_pixbuf_get_width(button_pixmap))/2; i = 0; while(board->text[i]) { GooCanvasItem *button; GooCanvasItem *item; GooCanvasItem *group = goo_canvas_group_new (boardRootItem, NULL); button = goo_canvas_image_new (group, button_pixmap, xOffset, yOffset, NULL); g_object_set_data(G_OBJECT(group), "answer", board->answer); g_object_set_data(G_OBJECT(group), "button", button); g_object_set_data(G_OBJECT(group), "solution", GINT_TO_POINTER(board->solution)); g_signal_connect(button, "button_press_event", (GCallback) item_event, GINT_TO_POINTER(i)); item = goo_canvas_text_new (group, board->text[i], xOffset + gdk_pixbuf_get_width(button_pixmap)/2 + 1.0, yOffset + gdk_pixbuf_get_height(button_pixmap)/2 + 1.0, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_huge_bold, "fill_color_rgba", gc_skin_color_shadow, NULL); g_signal_connect(item, "button_press_event", (GCallback) item_event, GINT_TO_POINTER(i)); item = goo_canvas_text_new (group, board->text[i], xOffset + gdk_pixbuf_get_width(button_pixmap)/2, yOffset + gdk_pixbuf_get_height(button_pixmap)/2, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_huge_bold, "fill_color_rgba", gc_skin_color_text_button, NULL); g_signal_connect(item, "button_press_event", (GCallback) item_event, GINT_TO_POINTER(i)); yOffset += gdk_pixbuf_get_height(button_pixmap) + vertical_separation; i++; } #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(button_pixmap); #else g_object_unref(button_pixmap); #endif }
/* ==================================== */ static GooCanvasItem *fifteen_create_item(GooCanvasItem *parent) { int i; int x, y; GooCanvasItem **board; GooCanvasItem *text; char buf[20]; GdkPixbuf *pixmap = NULL; boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); goo_canvas_item_translate(boardRootItem, (BOARDWIDTH-(4*PIECE_SIZE))/2, (BOARDHEIGHT-(4*PIECE_SIZE))/2); /* Load the cute frame */ pixmap = gc_pixmap_load("fifteen/fifteen_frame.png"); goo_canvas_image_new (boardRootItem, pixmap, -1*((gdk_pixbuf_get_width(pixmap)-(4*PIECE_SIZE))/2), -1*((gdk_pixbuf_get_height(pixmap)-(4*PIECE_SIZE))/2)-2, NULL); gdk_pixbuf_unref(pixmap); board = g_new (GooCanvasItem *, 16); g_object_set_data (G_OBJECT (boardRootItem), "board", board); for (i = 0; i < 15; i++) { y = i / 4; x = i % 4; board[i] = goo_canvas_group_new (boardRootItem, NULL); goo_canvas_item_translate(board[i], (x * PIECE_SIZE), (y * PIECE_SIZE)); goo_canvas_rect_new (board[i], 0.0, 0.0, PIECE_SIZE, PIECE_SIZE, "fill-color", get_piece_color (i), "stroke-color", "black", NULL); sprintf (buf, "%d", i + 1); text = goo_canvas_text_new (board[i], buf, (double) PIECE_SIZE / 2.0, (double) PIECE_SIZE / 2.0, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_medium, "fill-color", "black", NULL); g_object_set_data (G_OBJECT (board[i]), "piece_num", GINT_TO_POINTER (i)); g_object_set_data (G_OBJECT (board[i]), "piece_pos", GINT_TO_POINTER (i)); g_object_set_data (G_OBJECT (board[i]), "text", text); g_signal_connect (board[i], "button-press-event", G_CALLBACK (piece_event), NULL); } board[15] = NULL; /* Select level difficulty */ switch(gcomprisBoard->level) { case 1: scramble(board, 10); break; case 2: scramble(board, 50); break; case 3: case 4: scramble(board, 100); break; case 5: scramble(board, 150); break; default: scramble(board, 256); } return NULL; }
/* ===================================================================== * set initial values for the next level * =====================================================================*/ static void maze_next_level() { GdkPixbuf *pixmap = NULL; maze_destroy_all_items(); gc_bar_set_level(gcomprisBoard); setlevelproperties(); mapActive = FALSE; ind = 0; gamewon = FALSE; initMaze(); generateMaze((g_random_int()%breedte),(g_random_int()%hoogte)); removeSet(); /* Try the next level */ maze_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas)); draw_background(wallgroup); if(modeIsInvisible) { g_object_set (wallgroup, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); } /* make a new group for the items */ begin=g_random_int()%hoogte; end=g_random_int()%hoogte; /* Draw the tux */ RsvgHandle *svg_handle = gc_rsvg_load("maze/tux_top_south.svg"); tuxitem = goo_canvas_svg_new (tuxgroup, svg_handle, NULL); g_object_unref (svg_handle); goo_canvas_item_translate(tuxgroup, cellsize*(0)-breedte + board_border_x, cellsize*(begin)-hoogte + board_border_y); g_signal_connect(tuxitem, "button_press_event", (GCallback) tux_event, NULL); if(run_fast_possible) { /* Load the tux shoes */ svg_handle = gc_rsvg_load("maze/tux_shoes_top_south.svgz"); tuxshoes = goo_canvas_svg_new (tuxgroup, svg_handle, "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); g_object_unref (svg_handle); /* Load fast-mode switch button */ svg_handle = gc_rsvg_load("maze/fast-mode-button.svgz"); fast_mode_button = goo_canvas_svg_new (boardRootItem, svg_handle, NULL); g_object_unref (svg_handle); goo_canvas_item_translate(fast_mode_button, 10, 10); g_signal_connect(fast_mode_button, "button_press_event", (GCallback) on_fast_mode_button_press, NULL); gc_item_focus_init(fast_mode_button, NULL); } /* Draw the target */ pixmap = gc_pixmap_load("maze/door.png"); if(pixmap) { draw_image(mazegroup,breedte-1,end,pixmap); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif } position[ind][0]=0; position[ind][1]=begin; Maze[0][begin]=Maze[0][begin]+SET; viewing_direction=EAST; threeDactive=FALSE; if(run_fast_possible) { // run_fast-mode should be initialized at every level, whether TRUE or FALSE if (gcomprisBoard->level < 14) set_run_fast(FALSE); if (gcomprisBoard->level >= 14) set_run_fast(TRUE); } update_tux(viewing_direction); if(!modeIs2D) threeDdisplay(); }
/* ===================================================================== * * =====================================================================*/ static GooCanvasItem *submarine_create_item(GooCanvasItem *parent) { GdkPixbuf *pixmap = NULL; GooCanvasItem *item = NULL; char s12[12]; int i; GooCanvasItem *rootItem = goo_canvas_group_new (parent, NULL); pixmap = gc_pixmap_load("submarine/submarine.png"); submarine_width = gdk_pixbuf_get_width(pixmap); submarine_height = gdk_pixbuf_get_height(pixmap); submarine_item = goo_canvas_image_new (rootItem, pixmap, 0, 0, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif pixmap = gc_pixmap_load("submarine/vanne.svg"); ballast_ar_purge_item = goo_canvas_image_new (rootItem, pixmap, PURGE_AR + schema_x, schema_y -1.0, NULL); g_signal_connect(ballast_ar_purge_item, "button-press-event", (GCallback) ballast_ar_purge_event, NULL); ballast_av_purge_item = goo_canvas_image_new (rootItem, pixmap, PURGE_AV + schema_x, schema_y -1.0, NULL); g_signal_connect(ballast_av_purge_item, "button-press-event", (GCallback) ballast_av_purge_event, NULL); regleur_purge_item = goo_canvas_image_new (rootItem, pixmap, REGLEUR + schema_x, schema_y -2.0, NULL); g_signal_connect(regleur_purge_item, "button-press-event", (GCallback) regleur_purge_event, NULL); item = goo_canvas_image_new (rootItem, pixmap, schema_x + CHASSE_BALLAST_AV_X, schema_y + CHASSE_BALLAST_AV_Y, NULL); g_signal_connect(item, "button-press-event", (GCallback) ballast_av_chasse_event, NULL); item = goo_canvas_image_new (rootItem, pixmap, schema_x + CHASSE_BALLAST_AR_X, schema_y + CHASSE_BALLAST_AR_Y, NULL); g_signal_connect(item, "button-press-event", (GCallback) ballast_ar_chasse_event, NULL); regleur_chasse_item = goo_canvas_image_new (rootItem, pixmap, schema_x + CHASSE_REGLEUR_X, schema_y + CHASSE_REGLEUR_Y, NULL); g_signal_connect(regleur_chasse_item, "button-press-event", (GCallback) regleur_chasse_event, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif // DEPTH RUDDERS pixmap = gc_pixmap_load("submarine/rudder.png"); barre_av_item = goo_canvas_image_new (rootItem, pixmap, schema_x + BARRE_AV_X, schema_y + BARRE_AV_Y, NULL); barre_ar_item = goo_canvas_image_new (rootItem, pixmap, schema_x + BARRE_AR_X, schema_y + BARRE_AR_Y, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif // displays the speed on the engine sprintf(s12,"%d",(int)submarine_horizontal_speed); speed_item_back = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X +1, (gdouble) schema_y + ENGINE_UP_Y + 10 + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "alignment", PANGO_ALIGN_CENTER, "fill-color", TEXT_COLOR_BACK, NULL); speed_item_front = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X, (gdouble) schema_y + ENGINE_UP_Y + 10, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "alignment", PANGO_ALIGN_CENTER, "fill-color", TEXT_COLOR_FRONT, NULL); // displays the ballast_av_air value ballast_av_air_item_rect = goo_canvas_rect_new (rootItem, schema_x + BALLAST_AV_AIR_X1, schema_y + BALLAST_AV_AIR_Y1 + BALLAST_AV_AIR_H, BALLAST_AV_AIR_W, BALLAST_AV_AIR_H, "fill-color", "blue", "line-width", 0.0, NULL); sprintf(s12,"%d",(int)ballast_av_air); ballast_av_air_item_back = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X + 1, (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_BACK, NULL); ballast_av_air_item_front = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X, (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_FRONT, NULL); setBallastAV(ballast_av_air); // displays the ballast_ar_air value ballast_ar_air_item_rect = goo_canvas_rect_new (rootItem, schema_x + BALLAST_AR_AIR_X1, schema_y + BALLAST_AR_AIR_Y1 + BALLAST_AR_AIR_H, BALLAST_AR_AIR_W, BALLAST_AR_AIR_H, "fill-color", "blue", "line-width", 0.0, NULL); sprintf(s12,"%d",(int)ballast_ar_air); ballast_ar_air_item_back = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X + 1, (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_BACK, NULL); ballast_ar_air_item_front = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X, (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_FRONT, NULL); setBallastAR(ballast_ar_air); // displays the remaining air value sprintf(s12,"%d", (int)air); air_item_back = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + AIR_X +1, (gdouble) schema_y + AIR_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_BACK, NULL); air_item_front = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + AIR_X, (gdouble) schema_y + AIR_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_FRONT, NULL); // displays the remaining battery value sprintf(s12,"%d", (int)battery); battery_item_back = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + BATTERY_X +1, (gdouble) schema_y + BATTERY_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "alignment", PANGO_ALIGN_CENTER, "fill-color", TEXT_COLOR_BACK, NULL); battery_item_front = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + BATTERY_X, (gdouble) schema_y + BATTERY_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "alignment", PANGO_ALIGN_CENTER, "fill-color", TEXT_COLOR_FRONT, NULL); // displays the remaining regleur value regleur_item_rect = goo_canvas_rect_new (rootItem, schema_x + REGLEUR_X1, schema_y + REGLEUR_Y1 + REGLEUR_H, REGLEUR_W, REGLEUR_H, "fill-color", "blue", "line-width", 0.0, NULL); sprintf(s12,"%d", (int)regleur); regleur_item_back = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + REGLEUR_TEXT_X +1, (gdouble) schema_y + REGLEUR_TEXT_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_BACK, NULL); regleur_item_front = goo_canvas_text_new (rootItem, s12, (gdouble) schema_x + REGLEUR_TEXT_X, (gdouble) schema_y + REGLEUR_TEXT_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_FRONT, NULL); setRegleur(regleur); // displays an alert when some parameters are bad pixmap = gc_pixmap_load("submarine/alert_submarine.png"); alert_submarine = goo_canvas_image_new (rootItem, pixmap, ALERT_SUBMARINE_X, ALERT_SUBMARINE_Y, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif g_object_set (alert_submarine, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); // when the submarine makes some bubbles ... pixmap = gc_pixmap_load("submarine/bubbling.png"); for (i=0; i<3; i++) { bubbling[i] = goo_canvas_image_new (rootItem, pixmap, 0, 0, NULL); g_object_set (bubbling[i], "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); } #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif // whale item switch(gcomprisBoard->level) { case 1: whale_x = 50; whale_y = MAX_DEPTH - 100; break; case 2: whale_x = 150; whale_y = MAX_DEPTH - 100; break; case 3: whale_x = 250; whale_y = MAX_DEPTH - 100; break; default: whale_x = 380; whale_y = MAX_DEPTH - 100; break; } pixmap = gc_pixmap_load("submarine/whale.png"); whale = goo_canvas_image_new (rootItem, pixmap, whale_x, whale_y, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif // whale being hit pixmap = gc_pixmap_load("submarine/whale_hit.png"); big_explosion = goo_canvas_image_new (rootItem, pixmap, whale_x, whale_y, NULL); g_object_set (big_explosion, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif // treasure item pixmap = gc_pixmap_load("submarine/crown.png"); treasure_x = (BOARDWIDTH*3)/4; treasure_y = MAX_DEPTH; treasure = goo_canvas_image_new (rootItem, pixmap, 0, 0, NULL); goo_canvas_item_translate(treasure, treasure_x, 0); goo_canvas_item_animate(treasure, treasure_x, treasure_y, 0.6, 0, TRUE, 6*1000, 40, GOO_CANVAS_ANIMATE_FREEZE); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif // the triggers for air compressor and battery charger pixmap = gc_pixmap_load("submarine/manette.png"); air_compressor_item = goo_canvas_image_new (rootItem, pixmap, schema_x + AIR_TRIGGER_X, schema_y + AIR_TRIGGER_Y, NULL); battery_charger_item = goo_canvas_image_new (rootItem, pixmap, schema_x + BATTERY_TRIGGER_X, schema_y + BATTERY_TRIGGER_Y, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif g_signal_connect(air_compressor_item, "button-press-event", (GCallback) air_compressor_event, NULL); g_signal_connect(battery_charger_item, "button-press-event", (GCallback) battery_charger_event, NULL); /* * Set the right wall * ------------------ */ switch(gcomprisBoard->level) { case 1: gate_top_y = 80; gate_bottom_y = schema_y - 100; break; case 2: gate_top_y = 100; gate_bottom_y = schema_y - 120; break; default: gate_top_y = 120; gate_bottom_y = schema_y - 120; break; } /* At startup, the gate is closed */ gate_top_current_y = gate_bottom_y; top_gate_item = goo_canvas_rect_new (rootItem, BOARDWIDTH - 25, 40, 27, gate_top_current_y - 40, "fill_color_rgba", 0x989677FF, "stroke-color", "black", "line-width", 2.0, NULL); goo_canvas_rect_new (rootItem, BOARDWIDTH - 25, gate_bottom_y, 27, schema_y - gate_bottom_y, "fill_color_rgba", 0x989677FF, "stroke-color", "black", "line-width", 2.0, NULL); timer_id = g_timeout_add(UPDATE_DELAY, update_timeout, NULL); timer_slow_id = g_timeout_add(UPDATE_DELAY_SLOW, update_timeout_slow, NULL); timer_very_slow_id = g_timeout_add(UPDATE_DELAY_VERY_SLOW, update_timeout_very_slow, NULL); return rootItem; }
static GooCanvasItem *submarine_drawbackground(GooCanvasItem *parent) { GooCanvasItem *backgroundRootItem = goo_canvas_group_new (parent, NULL); GooCanvasItem *item; GdkPixbuf *pixmap = NULL; int w, h; pixmap = gc_pixmap_load("submarine/sub_schema.svg"); w = gdk_pixbuf_get_width(pixmap); h = gdk_pixbuf_get_height(pixmap); schema_x = (BOARDWIDTH - w)/2 ; schema_y = BOARDHEIGHT - h; goo_canvas_image_new (backgroundRootItem, pixmap, schema_x, schema_y, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif #define COMMAND_OFFSET 20.0 pixmap = gc_pixmap_load("submarine/up.png"); int w2 = gdk_pixbuf_get_width(pixmap); w = 80; // The rudder width item = goo_canvas_image_new (backgroundRootItem, pixmap, schema_x + BARRE_AV_X + w - w2, schema_y + BARRE_AV_Y - COMMAND_OFFSET, NULL); g_signal_connect(item, "button-press-event", (GCallback) barre_av_event, GINT_TO_POINTER(UP)); item = goo_canvas_image_new (backgroundRootItem, pixmap, schema_x + BARRE_AR_X + w - w2, schema_y + BARRE_AR_Y - COMMAND_OFFSET, NULL); g_signal_connect(item, "button-press-event", (GCallback) barre_ar_event, GINT_TO_POINTER(UP)); item = goo_canvas_image_new (backgroundRootItem, pixmap, schema_x + ENGINE_UP_X, schema_y + ENGINE_UP_Y, NULL); g_signal_connect(item, "button-press-event", (GCallback) engine_event, GINT_TO_POINTER(UP)); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif pixmap = gc_pixmap_load("submarine/down.png"); item = goo_canvas_image_new (backgroundRootItem, pixmap, schema_x + BARRE_AV_X + w - w2, schema_y + BARRE_AV_Y + COMMAND_OFFSET, NULL); g_signal_connect(item, "button-press-event", (GCallback) barre_av_event, GINT_TO_POINTER(DOWN)); item = goo_canvas_image_new (backgroundRootItem, pixmap, schema_x + BARRE_AR_X + w - w2, schema_y + BARRE_AR_Y + COMMAND_OFFSET, NULL); g_signal_connect(item, "button-press-event", (GCallback) barre_ar_event, GINT_TO_POINTER(DOWN)); item = goo_canvas_image_new (backgroundRootItem, pixmap, schema_x + ENGINE_DOWN_X, schema_y + ENGINE_DOWN_Y, NULL); g_signal_connect(item, "button-press-event", (GCallback) engine_event, GINT_TO_POINTER(DOWN)); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif return backgroundRootItem; }
static void menu_create_item(GooCanvasItem *parent, MenuItems *menuitems, GcomprisBoard *board) { GdkPixbuf *menu_pixmap = NULL; GooCanvasItem *menu_button; int difficulty; gdouble ratio, pixmap_w, pixmap_h; menu_pixmap = gc_pixmap_load(board->icon_name); ratio = get_ratio (menu_pixmap, icon_size); pixmap_w = gdk_pixbuf_get_width(menu_pixmap) * ratio; pixmap_h = gdk_pixbuf_get_height(menu_pixmap) * ratio; next_spot(); menu_button = goo_canvas_image_new (parent, menu_pixmap, current_x - pixmap_w/2, current_y - pixmap_h/2, NULL); goo_canvas_item_scale(menu_button, ratio, ratio); // display board availability due to sound voice not present if(board->mandatory_sound_file) { gchar *soundfile = NULL; /* We search a fixed path sound file */ soundfile = gc_file_find_absolute(board->mandatory_sound_file); if (!soundfile || !gc_prop_get()->fx) { GooCanvasItem *item = \ goo_canvas_svg_new (parent, gc_skin_rsvg_get(), "svg-id", "#SOUND_UNCHECKED", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); GooCanvasBounds bounds; goo_canvas_item_get_bounds(item, &bounds); SET_ITEM_LOCATION(item, current_x - pixmap_w/2 - 25 - (bounds.x2 - bounds.x1)/2, current_y - pixmap_h/2 + 28- (bounds.y2 - bounds.y1)/2); } g_free(soundfile); } // display menu icon ========================== BEGIN if(g_ascii_strcasecmp(board->type, "menu") == 0) { GooCanvasItem *item = goo_canvas_svg_new (parent, gc_skin_rsvg_get(), "svg-id", "#MENUICON", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); SET_ITEM_LOCATION(item, current_x - pixmap_w/2 - 25, current_y - pixmap_h/2); } else { // display difficulty stars if (board->difficulty != NULL) { difficulty = atoi(board->difficulty); menu_difficulty_display(parent, (double)current_x - pixmap_w/2 - 25, (double)current_y - pixmap_h/2, (double) 0.6, difficulty); } if ( gc_board_is_demo_only(board) ) menu_demo_display(parent, (gdouble)(current_x - pixmap_w/2 - 20), (gdouble)(current_y - pixmap_h/2 + 60) ); } #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(menu_pixmap); #else g_object_unref(menu_pixmap); #endif // display menu icon ========================== END /* * Now everything ready, map the events * ------------------------------------- */ g_object_set_data (G_OBJECT (menu_button), "board", board); g_signal_connect(menu_button, "button_press_event", (GCallback) item_event, menuitems); g_signal_connect (menu_button, "enter_notify_event", (GCallback) on_enter_notify, menuitems); g_signal_connect (menu_button, "leave_notify_event", (GCallback) on_leave_notify, menuitems); gc_item_focus_init(menu_button, NULL); }
/* ==================================== */ static void imageid_create_item(GooCanvasItem *parent) { GooCanvasItem *item; GooCanvasItem *group; GooCanvasItem *button; int x, y, xp, yp; guint vertical_separation; GdkPixbuf *pixmap = NULL; Board *board; guint i; board_number = gcomprisBoard->sublevel-1; g_assert(board_number >= 0 && board_number < g_list_length(board_list)); boardRootItem = \ goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); /* display the image */ board = g_list_nth_data(board_list, board_number); g_assert(board != NULL); right_word = board->solution; pixmap = gc_pixmap_load(board->pixmapfile); x = IMAGE_AREA_X1 + ( IMAGE_AREA_X2 - IMAGE_AREA_X1 - gdk_pixbuf_get_width(pixmap))/2; y = IMAGE_AREA_Y1 + ( IMAGE_AREA_Y2 - IMAGE_AREA_Y1 - gdk_pixbuf_get_height(pixmap))/2; item = goo_canvas_image_new (boardRootItem, pixmap, x, y, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif xp = HORIZONTAL_SEPARATION; /* Calc the number of proposals */ i = 0; while(board->text[i++]); vertical_separation = 10 + 60 / i; guint button_pixmap_height = 48; guint button_pixmap_width = 191; yp = (BOARDHEIGHT - i * button_pixmap_height - 2 * vertical_separation)/2 - 20; i = 0; while(board->text[i]) { group = goo_canvas_group_new (boardRootItem, NULL); button = goo_canvas_svg_new (group, gc_skin_rsvg_get(), "svg-id", "#BUTTON_TEXT", NULL); SET_ITEM_LOCATION(button, xp, yp); g_object_set_data(G_OBJECT(group), "button", button); g_signal_connect(button, "button_press_event", (GCallback) item_event, GINT_TO_POINTER(i)); item = goo_canvas_text_new (group, board->text[i], xp + button_pixmap_width/2 + 1.0, yp + button_pixmap_height/2 + 1.0, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_big, "fill_color_rgba", gc_skin_color_shadow, NULL); g_signal_connect(item, "button_press_event", (GCallback) item_event, GINT_TO_POINTER(i)); item = goo_canvas_text_new (group, board->text[i], xp + button_pixmap_width/2, yp + button_pixmap_height/2, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_big, "fill_color_rgba", gc_skin_color_text_button, NULL); g_signal_connect(item, "button_press_event", (GCallback) item_event, GINT_TO_POINTER(i)); yp += button_pixmap_height + vertical_separation; i++; } }
static void create_top(GooCanvasItem *parent, gchar *path) { gchar **splitted_section; gint i = 1; GdkPixbuf *pixmap = NULL; gdouble ratio; GcomprisBoard *board; gchar *path1, *path2; GooCanvasItem *item; GcomprisProperties *properties = gc_prop_get(); if (!path) return; splitted_section = g_strsplit (path, "/", 0); path1 = g_strdup(""); /* splitted_section[0] is always "" */ i = 1; while (splitted_section[i] != NULL) { path2 = g_strdup_printf("%s/%s", path1, splitted_section[i]); g_free(path1); path1 = path2; if (strcmp(path1, properties->root_menu)<0) { i++; continue; } if (current_top_x == 0.0) { current_top_x = top_x; current_top_y = top_y; } else { item = \ goo_canvas_svg_new (parent, gc_skin_rsvg_get(), "svg-id", "#MENUICON", "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); SET_ITEM_LOCATION(item, current_top_x, current_top_y + top_arrow_size); // goo_canvas_item_scale(item, ratio, ratio); current_top_x += top_arrow_size + top_int_x; } board = gc_menu_section_get(path1); pixmap = gc_pixmap_load(board->icon_name); ratio = get_ratio( pixmap, icon_size_top); item = goo_canvas_image_new (parent, pixmap, 0, 0, NULL); goo_canvas_item_translate(item, current_top_x, current_top_y); goo_canvas_item_scale(item, ratio, ratio); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif current_top_x += top_int_x + icon_size_top; g_object_set_data (G_OBJECT (item), "board", board); g_signal_connect(item, "button_press_event", (GCallback) item_event, menuitems); gc_item_focus_init(item, NULL); i++; } g_strfreev(splitted_section); g_free(path1); }
void create_mainwindow (GooCanvasItem *rootitem) { GtkWidget *wdrawareagrande; GtkWidget *wdrawareapetite; /* GCompris : suppression of all menus */ g_assert(rootitem != NULL); wdrawareagrande = gtk_drawing_area_new (); gtk_widget_set_name (wdrawareagrande, "wdrawareagrande"); //gtk_widget_set_size_request (wdrawareagrande, // WIDTH_BIGAREA, // WIDTH_BIGAREA // ); //gtk_container_add (GTK_CONTAINER (aspectframe1), wdrawareagrande); gtk_widget_set_events (wdrawareagrande, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK); /* Gcompris */ goo_canvas_widget_new ( rootitem, wdrawareagrande, X_BASE_BIGAREA, Y_BASE_BIGAREA, WIDTH_BIGAREA, WIDTH_BIGAREA, NULL ); gtk_widget_show (wdrawareagrande); wdrawareapetite = gtk_drawing_area_new (); gtk_widget_set_name (wdrawareapetite, "wdrawareapetite"); gtk_widget_set_events (wdrawareapetite, GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK); /* Gcompris */ goo_canvas_widget_new ( rootitem, wdrawareapetite, X_BASE_SMALLAREA, Y_BASE_SMALLAREA, WIDTH_SMALLAREA, WIDTH_SMALLAREA, NULL ); gtk_widget_show (wdrawareapetite); g_signal_connect (GTK_OBJECT (wdrawareagrande), "expose_event", GTK_SIGNAL_FUNC (on_wdrawareagrande_expose_event), NULL); g_signal_connect (GTK_OBJECT (wdrawareagrande), "configure_event", GTK_SIGNAL_FUNC (on_wdrawareagrande_configure_event), NULL); g_signal_connect (GTK_OBJECT (wdrawareagrande), "button_press_event", GTK_SIGNAL_FUNC (on_wdrawareagrande_button_press_event), NULL); g_signal_connect (GTK_OBJECT (wdrawareagrande), "button_release_event", GTK_SIGNAL_FUNC (on_wdrawareagrande_button_release_event), NULL); g_signal_connect (GTK_OBJECT (wdrawareagrande), "motion_notify_event", GTK_SIGNAL_FUNC (on_wdrawareagrande_motion_notify_event), NULL); g_signal_connect (GTK_OBJECT (wdrawareapetite), "configure_event", GTK_SIGNAL_FUNC (on_wdrawareapetite_configure_event), NULL); g_signal_connect (GTK_OBJECT (wdrawareapetite), "expose_event", GTK_SIGNAL_FUNC (on_wdrawareapetite_expose_event), NULL); /* Gcompris */ /* add here buttons */ GdkPixbuf *pixmap_show = NULL; GdkPixbuf *pixmap_outline = NULL; GdkPixbuf *pixmap_symetry = NULL; GooCanvasItem *previous_figure, *next_figure; GooCanvasItem *show_figure, *outline_figure, *symetry; previous_figure = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#PREVIOUS", NULL); SET_ITEM_LOCATION_CENTER(previous_figure, X_BASE_SMALLAREA, Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 30); next_figure = goo_canvas_svg_new (rootitem, gc_skin_rsvg_get(), "svg-id", "#NEXT", NULL); SET_ITEM_LOCATION_CENTER(next_figure, X_BASE_SMALLAREA + WIDTH_SMALLAREA, Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 30); g_signal_connect(previous_figure, "button_press_event", (GtkSignalFunc) on_arrow_clicked, (gpointer) FALSE); gc_item_focus_init(previous_figure, NULL); g_signal_connect(next_figure, "button_press_event", (GtkSignalFunc) on_arrow_clicked, (gpointer) TRUE); gc_item_focus_init(next_figure, NULL); pixmap_show = gc_pixmap_load("tangram/gtans_show.png"); pixmap_outline = gc_pixmap_load("tangram/gtans_outline.png"); show_figure = goo_canvas_image_new (rootitem, pixmap_show, X_BASE_SMALLAREA, Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 80, NULL); outline_figure = goo_canvas_image_new (rootitem, pixmap_outline, X_BASE_SMALLAREA, Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 130, NULL); g_signal_connect(outline_figure, "button_press_event", (GtkSignalFunc) on_outline_clicked, NULL); g_signal_connect(show_figure, "button_press_event", (GtkSignalFunc) on_show_clicked, NULL); gc_item_focus_init(outline_figure, NULL); gc_item_focus_init(show_figure, NULL); pixmap_symetry = gc_pixmap_load("tangram/tool-flip.png"); symetry = goo_canvas_image_new (rootitem, pixmap_symetry, X_BASE_SMALLAREA + WIDTH_SMALLAREA - 50, Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 180, NULL); g_signal_connect(symetry, "button_press_event", (GtkSignalFunc) on_symetry_clicked, NULL); gc_item_focus_init(symetry, NULL); /* rotation buttons */ GdkPixbuf *right_rot = NULL; GdkPixbuf *left_rot = NULL; GdkPixbuf *right_rot_big = NULL; GdkPixbuf *left_rot_big = NULL; GooCanvasItem *l_rot_s, *r_rot_s, *l_rot_b, *r_rot_b; right_rot = gc_pixmap_load("tangram/gtans_rotate.png"); left_rot = gc_pixmap_load("tangram/gtans_rotate-left.png"); r_rot_s = goo_canvas_image_new (rootitem, right_rot, X_BASE_SMALLAREA + WIDTH_SMALLAREA, Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 60, NULL); l_rot_s = goo_canvas_image_new (rootitem, left_rot, X_BASE_SMALLAREA + WIDTH_SMALLAREA - 100, Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 60, NULL); gdk_pixbuf_unref(right_rot); gdk_pixbuf_unref(left_rot); right_rot_big = gc_pixmap_load("tangram/gtans_2x-rotate.png"); left_rot_big = gc_pixmap_load("tangram/gtans_2x-rotate-left.png"); r_rot_b = goo_canvas_image_new (rootitem, right_rot_big, X_BASE_SMALLAREA + WIDTH_SMALLAREA, Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 120, NULL); l_rot_b = goo_canvas_image_new (rootitem, left_rot_big, X_BASE_SMALLAREA + WIDTH_SMALLAREA - 100, Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 120, NULL); gdk_pixbuf_unref(right_rot_big); gdk_pixbuf_unref(left_rot_big); g_signal_connect(r_rot_s, "button_press_event", (GtkSignalFunc) on_rotation_clicked, (gpointer) 0); gc_item_focus_init(r_rot_s, NULL); g_signal_connect(l_rot_s, "button_press_event", (GtkSignalFunc) on_rotation_clicked, (gpointer) 1); gc_item_focus_init(l_rot_s, NULL); g_signal_connect(r_rot_b, "button_press_event", (GtkSignalFunc) on_rotation_clicked, (gpointer) 2); gc_item_focus_init(r_rot_b, NULL); g_signal_connect(l_rot_b, "button_press_event", (GtkSignalFunc) on_rotation_clicked, (gpointer) 3); gc_item_focus_init(l_rot_b, NULL); }
/* ===================================================================== * * =====================================================================*/ static GooCanvasItem *submarine_create_item(GooCanvasItem *parent) { GdkPixbuf *pixmap = NULL; char s12[12]; int i, w, h; boardRootItem = \ goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); pixmap = gc_pixmap_load("submarine/submarine.png"); submarine_width = gdk_pixbuf_get_width(pixmap); submarine_height = gdk_pixbuf_get_height(pixmap); submarine_item = goo_canvas_image_new (boardRootItem, pixmap, 0,//SUBMARINE_INITIAL_X, 0,//SUBMARINE_INITIAL_DEPTH + SURFACE_IN_BACKGROUND - submarine_height, NULL); gdk_pixbuf_unref(pixmap); pixmap = gc_pixmap_load("submarine/sub_schema.png"); w = gdk_pixbuf_get_width(pixmap); h = gdk_pixbuf_get_height(pixmap); schema_x = (BOARDWIDTH - w)/2 ; schema_y = BOARDHEIGHT - h; goo_canvas_image_new (boardRootItem, pixmap, schema_x, schema_y, NULL); gdk_pixbuf_unref(pixmap); pixmap = gc_pixmap_load("submarine/vanne.png"); ballast_ar_purge_item = goo_canvas_image_new (boardRootItem, pixmap, PURGE_AR + schema_x, schema_y -1.0, NULL); g_signal_connect(ballast_ar_purge_item, "button-press-event", (GtkSignalFunc) ballast_ar_purge_event, NULL); ballast_av_purge_item = goo_canvas_image_new (boardRootItem, pixmap, PURGE_AV + schema_x, schema_y -1.0, NULL); g_signal_connect(ballast_av_purge_item, "button-press-event", (GtkSignalFunc) ballast_av_purge_event, NULL); regleur_purge_item = goo_canvas_image_new (boardRootItem, pixmap, REGLEUR + schema_x, schema_y -2.0, NULL); g_signal_connect(regleur_purge_item, "button-press-event", (GtkSignalFunc) regleur_purge_event, NULL); ballast_av_chasse_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + CHASSE_BALLAST_AV_X, schema_y + CHASSE_BALLAST_AV_Y, NULL); g_signal_connect(ballast_av_chasse_item, "button-press-event", (GtkSignalFunc) ballast_av_chasse_event, NULL); ballast_ar_chasse_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + CHASSE_BALLAST_AR_X, schema_y + CHASSE_BALLAST_AR_Y, NULL); g_signal_connect(ballast_ar_chasse_item, "button-press-event", (GtkSignalFunc) ballast_ar_chasse_event, NULL); regleur_chasse_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + CHASSE_REGLEUR_X, schema_y + CHASSE_REGLEUR_Y, NULL); g_signal_connect(regleur_chasse_item, "button-press-event", (GtkSignalFunc) regleur_chasse_event, NULL); gdk_pixbuf_unref(pixmap); // DEPTH RUDDERS pixmap = gc_pixmap_load("submarine/rudder.png"); w = gdk_pixbuf_get_width(pixmap); h = gdk_pixbuf_get_height(pixmap); barre_av_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + BARRE_AV_X, schema_y + BARRE_AV_Y, NULL); barre_ar_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + BARRE_AR_X, schema_y + BARRE_AR_Y, NULL); gdk_pixbuf_unref(pixmap); #define COMMAND_OFFSET 20.0 pixmap = gc_pixmap_load("submarine/up.png"); int w2 = gdk_pixbuf_get_width(pixmap); barre_av_up_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + BARRE_AV_X + w - w2, schema_y + BARRE_AV_Y - COMMAND_OFFSET, NULL); barre_ar_up_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + BARRE_AR_X + w - w2, schema_y + BARRE_AR_Y - COMMAND_OFFSET, NULL); engine_up_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + ENGINE_UP_X, schema_y + ENGINE_UP_Y, NULL); gdk_pixbuf_unref(pixmap); pixmap = gc_pixmap_load("submarine/down.png"); barre_av_down_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + BARRE_AV_X + w - w2, schema_y + BARRE_AV_Y + COMMAND_OFFSET, NULL); barre_ar_down_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + BARRE_AR_X + w - w2, schema_y + BARRE_AR_Y + COMMAND_OFFSET, NULL); engine_down_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + ENGINE_DOWN_X, schema_y + ENGINE_DOWN_Y, NULL); gdk_pixbuf_unref(pixmap); g_signal_connect(barre_av_up_item, "button-press-event", (GtkSignalFunc) barre_av_event, GINT_TO_POINTER(UP)); g_signal_connect(barre_ar_up_item, "button-press-event", (GtkSignalFunc) barre_ar_event, GINT_TO_POINTER(UP)); g_signal_connect(barre_av_down_item, "button-press-event", (GtkSignalFunc) barre_av_event, GINT_TO_POINTER(DOWN)); g_signal_connect(barre_ar_down_item, "button-press-event", (GtkSignalFunc) barre_ar_event, GINT_TO_POINTER(DOWN)); g_signal_connect(engine_up_item, "button-press-event", (GtkSignalFunc) engine_event, GINT_TO_POINTER(UP)); g_signal_connect(engine_down_item, "button-press-event", (GtkSignalFunc) engine_event, GINT_TO_POINTER(DOWN)); // displays the speed on the engine sprintf(s12,"%d",(int)submarine_horizontal_speed); speed_item_back = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X +1, (gdouble) schema_y + ENGINE_UP_Y + 10 + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "alignment", PANGO_ALIGN_CENTER, "fill-color", TEXT_COLOR_BACK, NULL); speed_item_front = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X, (gdouble) schema_y + ENGINE_UP_Y + 10, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "alignment", PANGO_ALIGN_CENTER, "fill-color", TEXT_COLOR_FRONT, NULL); // displays the ballast_av_air value ballast_av_air_item_rect = goo_canvas_rect_new (boardRootItem, schema_x + BALLAST_AV_AIR_X1, schema_y + BALLAST_AV_AIR_Y1 + BALLAST_AV_AIR_H, BALLAST_AV_AIR_W, BALLAST_AV_AIR_H, "fill-color", "blue", "line-width", 0.0, NULL); sprintf(s12,"%d",(int)ballast_av_air); ballast_av_air_item_back = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X + 1, (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_BACK, NULL); ballast_av_air_item_front = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X, (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_FRONT, NULL); setBallastAV(ballast_av_air); // displays the ballast_ar_air value ballast_ar_air_item_rect = goo_canvas_rect_new (boardRootItem, schema_x + BALLAST_AR_AIR_X1, schema_y + BALLAST_AR_AIR_Y1 + BALLAST_AR_AIR_H, BALLAST_AR_AIR_W, BALLAST_AR_AIR_H, "fill-color", "blue", "line-width", 0.0, NULL); sprintf(s12,"%d",(int)ballast_ar_air); ballast_ar_air_item_back = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X + 1, (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_BACK, NULL); ballast_ar_air_item_front = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X, (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_FRONT, NULL); setBallastAR(ballast_ar_air); // displays the remaining air value sprintf(s12,"%d", (int)air); air_item_back = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + AIR_X +1, (gdouble) schema_y + AIR_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_BACK, NULL); air_item_front = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + AIR_X, (gdouble) schema_y + AIR_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_FRONT, NULL); // displays the remaining battery value sprintf(s12,"%d", (int)battery); battery_item_back = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + BATTERY_X +1, (gdouble) schema_y + BATTERY_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "alignment", PANGO_ALIGN_CENTER, "fill-color", TEXT_COLOR_BACK, NULL); battery_item_front = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + BATTERY_X, (gdouble) schema_y + BATTERY_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "alignment", PANGO_ALIGN_CENTER, "fill-color", TEXT_COLOR_FRONT, NULL); // displays the remaining regleur value regleur_item_rect = goo_canvas_rect_new (boardRootItem, schema_x + REGLEUR_X1, schema_y + REGLEUR_Y1 + REGLEUR_H, REGLEUR_W, REGLEUR_H, "fill-color", "blue", "line-width", 0.0, NULL); sprintf(s12,"%d", (int)regleur); regleur_item_back = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + REGLEUR_TEXT_X +1, (gdouble) schema_y + REGLEUR_TEXT_Y + 1, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_BACK, NULL); regleur_item_front = goo_canvas_text_new (boardRootItem, s12, (gdouble) schema_x + REGLEUR_TEXT_X, (gdouble) schema_y + REGLEUR_TEXT_Y, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", TEXT_COLOR_FRONT, NULL); setRegleur(regleur); // displays an alert when some parameters are bad pixmap = gc_pixmap_load("submarine/alert_submarine.png"); w = gdk_pixbuf_get_width(pixmap); h = gdk_pixbuf_get_height(pixmap); alert_submarine = goo_canvas_image_new (boardRootItem, pixmap, ALERT_SUBMARINE_X, ALERT_SUBMARINE_Y, NULL); gdk_pixbuf_unref(pixmap); g_object_set (alert_submarine, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); // when the submarine makes some bubbles ... pixmap = gc_pixmap_load("submarine/bubbling.png"); for (i=0; i<3; i++) { bubbling[i] = goo_canvas_image_new (boardRootItem, pixmap, 0, 0, NULL); g_object_set (bubbling[i], "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); } gdk_pixbuf_unref(pixmap); // whale item pixmap = gc_pixmap_load("submarine/whale.png"); whale_x = g_random_int_range((int)(BOARDWIDTH/4), (int)(BOARDWIDTH/2)); whale_y = g_random_int_range((int)(SURFACE_IN_BACKGROUND + gdk_pixbuf_get_height(pixmap)*2), (int)MAX_DEPTH); whale = goo_canvas_image_new (boardRootItem, pixmap, whale_x, whale_y, NULL); gdk_pixbuf_unref(pixmap); // whale being hit pixmap = gc_pixmap_load("submarine/whale_hit.png"); big_explosion = goo_canvas_image_new (boardRootItem, pixmap, whale_x, whale_y, NULL); g_object_set (big_explosion, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); gdk_pixbuf_unref(pixmap); // treasure item pixmap = gc_pixmap_load("submarine/crown.png"); treasure_x = (BOARDWIDTH*3)/4; treasure_y = MAX_DEPTH; treasure = goo_canvas_image_new (boardRootItem, pixmap, 0, 0, NULL); goo_canvas_item_translate(treasure, treasure_x, 0); goo_canvas_item_animate(treasure, treasure_x, treasure_y, 0.6, 0, TRUE, 6*1000, 40, GOO_CANVAS_ANIMATE_FREEZE); gdk_pixbuf_unref(pixmap); // the triggers for air compressor and battery charger pixmap = gc_pixmap_load("submarine/manette.png"); air_compressor_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + AIR_TRIGGER_X, schema_y + AIR_TRIGGER_Y, NULL); battery_charger_item = goo_canvas_image_new (boardRootItem, pixmap, schema_x + BATTERY_TRIGGER_X, schema_y + BATTERY_TRIGGER_Y, NULL); gdk_pixbuf_unref(pixmap); g_signal_connect(air_compressor_item, "button-press-event", (GtkSignalFunc) air_compressor_event, NULL); g_signal_connect(battery_charger_item, "button-press-event", (GtkSignalFunc) battery_charger_event, NULL); // the antisubmarine warfare frigate pixmap = gc_pixmap_load("submarine/asw_frigate.png"); w = gdk_pixbuf_get_width(pixmap); frigate_item = goo_canvas_image_new (boardRootItem, pixmap, 0, 0, NULL); goo_canvas_item_translate(frigate_item, BOARDWIDTH, 2); goo_canvas_item_animate(frigate_item, -w, 2.0, 1, 0, TRUE, 30*1000, 40, GOO_CANVAS_ANIMATE_RESTART); gdk_pixbuf_unref(pixmap); /* * Set the right wall * ------------------ */ switch(gcomprisBoard->level) { case 1: gate_top_y = 80; gate_bottom_y = schema_y - 100; break; case 2: gate_top_y = 100; gate_bottom_y = schema_y - 120; break; default: gate_top_y = 120; gate_bottom_y = schema_y - 120; break; } /* At startup, the gate is closed */ gate_top_current_y = gate_bottom_y; top_gate_item = goo_canvas_rect_new (boardRootItem, BOARDWIDTH - 25, 40, 27, gate_top_current_y - 40, "fill_color_rgba", 0x989677FF, "stroke-color", "black", "line-width", 2.0, NULL); goo_canvas_rect_new (boardRootItem, BOARDWIDTH - 25, gate_bottom_y, 27, schema_y - gate_bottom_y, "fill_color_rgba", 0x989677FF, "stroke-color", "black", "line-width", 2.0, NULL); timer_id = g_timeout_add(UPDATE_DELAY, update_timeout, NULL); timer_slow_id = g_timeout_add(UPDATE_DELAY_SLOW, update_timeout_slow, NULL); timer_very_slow_id = g_timeout_add(UPDATE_DELAY_VERY_SLOW, update_timeout_very_slow, NULL); return NULL; }