Card Flippen auch per gobject signal
authorJoachim Breitner <mail@joachim-breitner.de>
Wed, 23 May 2007 10:13:30 +0000 (10:13 +0000)
committerJoachim Breitner <mail@joachim-breitner.de>
Wed, 23 May 2007 10:13:30 +0000 (10:13 +0000)
cairoboard.py
ozeanien.py

index 652a868..a89c71f 100644 (file)
@@ -76,12 +76,19 @@ class CairoBoard(gtk.DrawingArea):
         if self.event2reset(event):
             self.emit("reset-clicked")
 
+        if self.pileclick(event):
+            self.emit("card-flipped")
+
         rot = self.pilerotclick(event)
         if rot == 1:
             self.board.pile.rotate_right()
         elif rot == -1:
             self.board.pile.rotate_left()
 
+        # Schaded nicht...
+        self.queue_draw()
+
+
     def do_expose_event(self,widget,event):
         gc = self.window.new_gc()
         gc.set_clip_rectangle(event.area)
@@ -160,7 +167,6 @@ class CairoBoard(gtk.DrawingArea):
         self.board.bh.guiinfo.draw(window)
         self.board.pile.guiinfo.draw(window)
         self.board.hand.guiinfo.draw(window)
-
     
     def draw_points(self, points, window):
         cr = window.cairo_create()
@@ -210,6 +216,7 @@ class CairoBoard(gtk.DrawingArea):
 # GObject signals
 gobject.signal_new("quit-clicked", CairoBoard, gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
 gobject.signal_new("reset-clicked", CairoBoard, gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
+gobject.signal_new("card-flipped", CairoBoard, gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())
 
 
 class CairoSlot:
index 364020a..ccc36d9 100644 (file)
@@ -53,11 +53,17 @@ class Game:
         self.boarddraw.connect("button-release-event", self.release)
         self.boarddraw.connect("quit-clicked", lambda w: self.window.destroy())
         self.boarddraw.connect("reset-clicked", lambda w: self.reset())
+        self.boarddraw.connect("card-flipped", lambda w: self.card_flip())
 
         self.boarddraw.show()
 
         self.window.add(self.boarddraw)
 
+    def card_flip(self):
+        if self.board.get_state() == SHIPPING and self.board.pile.can_flip_card():
+                self.board.pile.flip_card()
+
+
     def press(self, widget, event):
         assert not self.drag_from
 
@@ -72,9 +78,6 @@ class Game:
                 if slot.ship:
                     self.drag_from = slot
                     self.board.hand.move_ship_from(slot)
-            elif self.boarddraw.pileclick(event):
-                if self.board.pile.can_flip_card():
-                    self.board.pile.flip_card()
 
         elif self.board.get_state() == PLACING:
             if slot:
@@ -85,7 +88,6 @@ class Game:
 
         self.boarddraw.queue_draw()
 
-
     def release(self, widget, event):
         slot = self.boarddraw.event2slot(event)
         if self.board.hand.ship: