gcompris r3615 - in branches/gcomprixogoo/src: boards gcompris goocanvas/src watercycle-activity watercycle-activity/resources/watercycle



Author: bcoudoin
Date: Sun Nov 16 19:57:51 2008
New Revision: 3615
URL: http://svn.gnome.org/viewvc/gcompris?rev=3615&view=rev

Log:
In progress watercycle.


Removed:
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/background.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/badwater.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/badwater_off.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/cleanwater.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/cleanwater_off.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/cloud.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/fishingboat.gif
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/fishingboat.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/fishingboat_tux.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/minitux.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/pumpwater.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/pumpwater_off.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/rain.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/riverempty.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/riverfull.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/shower.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/shower_off.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/shower_on.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/showerwater.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/snow.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/sun.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/tuxboat.txt
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/vapor.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/watercleaning.png
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/waterpump.png
Modified:
   branches/gcomprixogoo/src/boards/goocanvas.defs
   branches/gcomprixogoo/src/gcompris/about.c
   branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.c
   branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.h
   branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/watercycle.svgz
   branches/gcomprixogoo/src/watercycle-activity/watercycle.py

Modified: branches/gcomprixogoo/src/boards/goocanvas.defs
==============================================================================
--- branches/gcomprixogoo/src/boards/goocanvas.defs	(original)
+++ branches/gcomprixogoo/src/boards/goocanvas.defs	Sun Nov 16 19:57:51 2008
@@ -733,6 +733,8 @@
   (parameters
     '("GooCanvasItem*" "parent")
     '("RsvgHandle*" "svg_handle")
+    '("const-gchar*" "svg_id")
+    '("gboolean" "hit_detection")
   )
   (varargs #t)
 )

Modified: branches/gcomprixogoo/src/gcompris/about.c
==============================================================================
--- branches/gcomprixogoo/src/gcompris/about.c	(original)
+++ branches/gcomprixogoo/src/gcompris/about.c	Sun Nov 16 19:57:51 2008
@@ -241,8 +241,6 @@
 		   (GtkSignalFunc) item_event_ok,
 		   "ok");
   gc_item_focus_init(item, NULL);
-  gdk_pixbuf_unref(pixmap);
-
 
   goo_canvas_text_new (rootitem,
 		       _("OK"),
@@ -266,6 +264,8 @@
 		     (GtkSignalFunc) item_event_ok,
 		     "ok");
   gc_item_focus_init(item2, item);
+  gdk_pixbuf_unref(pixmap);
+
 
   pixmap = gc_skin_pixmap_load("gcompris-about.png");
 

Modified: branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.c
==============================================================================
--- branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.c	(original)
+++ branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.c	Sun Nov 16 19:57:51 2008
@@ -12,7 +12,8 @@
 
   /* Convenience properties. */
   PROP_SVGHANDLE,
-  PROP_SVG_ID
+  PROP_SVG_ID,
+  PROP_HIT_DETECTION
 };
 
 static void goo_canvas_svg_finalize     (GObject            *object);
@@ -44,6 +45,13 @@
 							NULL,
 							G_PARAM_WRITABLE));
 
+  g_object_class_install_property (gobject_class, PROP_HIT_DETECTION,
+				   g_param_spec_boolean ("hit-detection",
+                                                         "Hit detection",
+                                                         "Set to false to disable hit detection",
+                                                         TRUE,
+                                                         G_PARAM_WRITABLE));
+
 }
 
 static void _init_surface(GooCanvasSvg *canvas_svg,
@@ -110,7 +118,7 @@
   canvas_svg->id = NULL;
   canvas_svg->cr = NULL;
   canvas_svg->pattern = NULL;
-
+  canvas_svg->hit_detection = TRUE;
 }
 
 
@@ -119,8 +127,8 @@
    in with the standard canvas items. */
 GooCanvasItem*
 goo_canvas_svg_new (GooCanvasItem      *parent,
-		  RsvgHandle         *svg_handle,
-		  ...)
+                    RsvgHandle         *svg_handle,
+                    ...)
 {
   GooCanvasItem *item;
   GooCanvasSvg *canvas_svg;
@@ -227,6 +235,9 @@
       else
         canvas_svg->id = g_value_dup_string(value);
       break;
+    case PROP_HIT_DETECTION:
+      canvas_svg->hit_detection = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -236,9 +247,9 @@
 
 static void
 goo_canvas_svg_set_property (GObject              *object,
-			   guint                 prop_id,
-			   const GValue         *value,
-			   GParamSpec           *pspec)
+                             guint                 prop_id,
+                             const GValue         *value,
+                             GParamSpec           *pspec)
 {
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) object;
   GooCanvasSvg *image = (GooCanvasSvg*) object;
@@ -250,7 +261,7 @@
     }
 
   goo_canvas_svg_set_common_property (object, image, prop_id,
-				    value, pspec);
+                                      value, pspec);
   goo_canvas_item_simple_changed (simple, TRUE);
 }
 
@@ -261,18 +272,18 @@
    otherwise it should return FALSE. */
 static gboolean
 goo_canvas_svg_is_item_at (GooCanvasItemSimple *simple,
-			  gdouble              x,
-			  gdouble              y,
-			  cairo_t             *cr,
-			  gboolean             is_pointer_event)
+                           gdouble              x,
+                           gdouble              y,
+                           cairo_t             *cr,
+                           gboolean             is_pointer_event)
 {
   GooCanvasSvg *canvas_svg = (GooCanvasSvg*) simple;
 
-  /* FIXME BAD HACK: Disable detection of huge objects to allow
-     having an SVG FOREGROUND scene while having hits on items bellow */
-  if ( canvas_svg->x2 - canvas_svg->x1 > 400
-       || x < canvas_svg->x1 || x > canvas_svg->x2
-       || y < canvas_svg->y1 || y > canvas_svg->y2)
+  if (!canvas_svg->hit_detection)
+    return FALSE;
+
+  if ( x < canvas_svg->x1 || x > canvas_svg->x2
+       || y < canvas_svg->y1 || y > canvas_svg->y2 )
     return FALSE;
 
   return TRUE;

Modified: branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.h
==============================================================================
--- branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.h	(original)
+++ branches/gcomprixogoo/src/goocanvas/src/goocanvassvg.h	Sun Nov 16 19:57:51 2008
@@ -38,6 +38,7 @@
   double y1;
   double x2;
   double y2;
+  gboolean hit_detection;
 };
 
 struct _GooCanvasSvgClass

Modified: branches/gcomprixogoo/src/watercycle-activity/resources/watercycle/watercycle.svgz
==============================================================================
Binary files. No diff available.

Modified: branches/gcomprixogoo/src/watercycle-activity/watercycle.py
==============================================================================
--- branches/gcomprixogoo/src/watercycle-activity/watercycle.py	(original)
+++ branches/gcomprixogoo/src/watercycle-activity/watercycle.py	Sun Nov 16 19:57:51 2008
@@ -42,9 +42,6 @@
     # The basic tick for object moves
     self.timerinc = 50
 
-    # The tick for the boat is variable
-    self.boat_timerinc = self.timerinc
-
     # Need to manage the timers to quit properly
     self.boat_timer = 0
     self.sun_timer = 0
@@ -66,7 +63,8 @@
     goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
-      svg_id = "#BACKGROUND"
+      svg_id = "#BACKGROUND",
+      hit_detection = False
       )
 
     # Take care, the items are stacked on each other in the order you add them.
@@ -102,7 +100,7 @@
     self.sunitem = goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
-      svg_id = "#SUN"
+      svg_id = "#SUN",
       )
     self.sunitem.connect("button_press_event", self.sun_item_event)
     # This item is clickeable and it must be seen
@@ -175,6 +173,7 @@
       svg_handle = svghandle,
       svg_id = "#BOAT"
       )
+    self.boatitem.translate(-100, 0);
     self.boatitem_parked = goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
@@ -195,7 +194,6 @@
       svg_id = "#SHOWER_TUX"
       )
     self.shower_tux.props.visibility = goocanvas.ITEM_INVISIBLE
-    self.tuxisinshower = 0
 
     # Tux in the shower with the water
     self.tuxshowerwateritem = goocanvas.Svg(
@@ -245,7 +243,8 @@
     goocanvas.Svg(
       parent = self.rootitem,
       svg_handle = svghandle,
-      svg_id = "#FOREGROUND"
+      svg_id = "#FOREGROUND",
+      hit_detection = False
       )
 
     # Some item ordering
@@ -253,7 +252,19 @@
     self.clouditem.raise_(None)
 
     # Ready GO
-    self.move_boat()
+    target_x = 700
+    trip_x = int(target_x - self.boatitem.get_bounds().x1)
+    print self.boatitem.get_bounds().x1
+    print trip_x
+    self.boatitem.animate(target_x,
+                          0,
+                          1,
+                          1,
+                          True,
+                          40*trip_x,
+                          40,
+                          goocanvas.ANIMATE_FREEZE)
+    self.boat_timer = gobject.timeout_add(40 * trip_x + 4000, self.boat_arrived)
 
 
   def end(self):
@@ -295,7 +306,7 @@
       self.waterlevel -= 1
 
     # It tux is in the shower and it works, then remove some water
-    if (self.tuxisinshower and self.cleanwaterstatus and self.showerbutton
+    if (self.cleanwaterstatus and self.showerbutton
         and self.waterlevel < self.waterlevel_min) :
       self.waterlevel += 2
 
@@ -328,31 +339,15 @@
     self.cleanwaterstatus = status
 
 
-  def move_boat(self):
-    if( self.boatitem.get_bounds().x2 < 760 ) :
-
-      # Make the boat slow down when arriving
-      if(self.boatitem.get_bounds().x2 == 700
-         or self.boatitem.get_bounds().x2 == 701):
-        self.boat_timerinc+=50
-
-      self.boatitem.translate(2, 0)
-      self.boat_timer = gobject.timeout_add(self.boat_timerinc, self.move_boat)
-    else:
-      if self.boatitem.get_bounds().x2 < 770 :
-        # Park the boat
-        self.boatitem.translate(0.7, -0.7)
-        self.boat_timer = gobject.timeout_add(self.timerinc, self.move_boat)
-      else :
-        # We are parked, change the boat to remove tux
-        self.boatitem_parked.props.visibility = goocanvas.ITEM_VISIBLE
-        self.boatitem.props.visibility = goocanvas.ITEM_INVISIBLE
-        gcompris.sound.play_ogg("sounds/Harbor3.wav")
-
-        # Now display tux in the shower
-        self.tuxshoweritem.props.visibility = goocanvas.ITEM_VISIBLE
-        self.shower_tux.props.visibility = goocanvas.ITEM_VISIBLE
-        self.tuxisinshower = 1
+  def boat_arrived(self):
+    # We are parked, change the boat to remove tux
+    self.boatitem_parked.props.visibility = goocanvas.ITEM_VISIBLE
+#    self.boatitem.props.visibility = goocanvas.ITEM_INVISIBLE
+    gcompris.sound.play_ogg("sounds/Harbor3.wav")
+
+    # Now display tux in the shower
+    self.tuxshoweritem.props.visibility = goocanvas.ITEM_VISIBLE
+    self.shower_tux.props.visibility = goocanvas.ITEM_VISIBLE
 
 
   def move_cloud(self):
@@ -477,9 +472,6 @@
   # If Tux is in the shower, we must display the water if needed
   def shower_water_update(self):
 
-    if not self.tuxisinshower:
-      return
-
     if self.cleanwaterstatus and self.showerbutton:
       self.tuxshoweritem.props.visibility = goocanvas.ITEM_INVISIBLE
       self.tuxshowerwateritem.props.visibility = goocanvas.ITEM_VISIBLE
@@ -490,10 +482,6 @@
 
   def showerbutton_item_event(self, widget, target, event=None):
 
-    # Not active until tux is in the shower and the watercleaning station is running
-    if not self.tuxisinshower:
-      return
-
     if not self.watercleaning_on:
       return
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]