Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2009-12-01 22:48:32 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2009-12-01 22:48:32 (GMT)
commit8e50513de9ee55f653ddff7b1b49d3c20216a654 (patch)
tree8df1397eb3063fd175b355eedbbad7076613087d
parent7e5d0b2a016243aaadd16f33c68099c3768ea4f5 (diff)
added clock to counter seconds between matches
-rw-r--r--VisualMatchActivity.py40
-rw-r--r--window.py32
2 files changed, 58 insertions, 14 deletions
diff --git a/VisualMatchActivity.py b/VisualMatchActivity.py
index 6b41463..a199607 100644
--- a/VisualMatchActivity.py
+++ b/VisualMatchActivity.py
@@ -96,7 +96,7 @@ class VisualMatchActivity(activity.Activity):
toolbar_box.toolbar.insert(separator, -1)
# Label for showing deck status
- self.deck_label = gtk.Label(_("%d cards remain in the deck") % (96))
+ self.deck_label = gtk.Label(_("%d cards remaining") % (96))
self.deck_label.show()
deck_toolitem = gtk.ToolItem()
deck_toolitem.add(self.deck_label)
@@ -107,7 +107,7 @@ class VisualMatchActivity(activity.Activity):
toolbar_box.toolbar.insert(separator, -1)
# Label for showing match status
- self.match_label = gtk.Label(_("%d matches found.") % (0))
+ self.match_label = gtk.Label(_("%d matches") % (0))
self.match_label.show()
match_toolitem = gtk.ToolItem()
match_toolitem.add(self.match_label)
@@ -117,8 +117,19 @@ class VisualMatchActivity(activity.Activity):
separator.show()
toolbar_box.toolbar.insert(separator, -1)
+ # Label for showing counter
+ self.clock_label = gtk.Label(_("-"))
+ self.clock_label.show()
+ clock_toolitem = gtk.ToolItem()
+ clock_toolitem.add(self.clock_label)
+ toolbar_box.toolbar.insert(clock_toolitem,-1)
+
+ separator = gtk.SeparatorToolItem()
+ separator.show()
+ toolbar_box.toolbar.insert(separator, -1)
+
# Label for showing play status
- self.status_label = gtk.Label(_("Try to find a match."))
+ self.status_label = gtk.Label(_("Find a match."))
self.status_label.show()
status_toolitem = gtk.ToolItem()
status_toolitem.add(self.status_label)
@@ -192,7 +203,7 @@ class VisualMatchActivity(activity.Activity):
def show_button2(self, tw):
self.button2.set_icon("plus-3on")
tw.deck.deal_3_extra_cards(tw)
- tw.activity.deck_label.set_text(_("%d cards remain in the deck") % \
+ tw.activity.deck_label.set_text(_("%d cards remaining") % \
(tw.deck.count-tw.deck.index))
self.button2.set_icon("plus-3")
@@ -205,7 +216,7 @@ class VisualMatchActivity(activity.Activity):
tw.activity.status_label.set_text(_("Keep looking."))
print tw.msg
else:
- tw.activity.status_label.set_text(_("No matches found."))
+ tw.activity.status_label.set_text(_("No matches."))
def _journal_cb(self, button, path):
title_alert = NamingAlert(self, path)
@@ -270,7 +281,7 @@ class ProjectToolbar(gtk.Toolbar):
separator.show()
# Label for showing match status
- self.activity.match_label = gtk.Label(_("%d matches found.") % (0))
+ self.activity.match_label = gtk.Label(_("%d matches") % (0))
self.activity.match_label.show()
self.activity.match_toolitem = gtk.ToolItem()
self.activity.match_toolitem.add(self.activity.match_label)
@@ -282,8 +293,21 @@ class ProjectToolbar(gtk.Toolbar):
self.insert(separator, -1)
separator.show()
- # Label for showing play status
- self.activity.status_label = gtk.Label(_("Try to find a match."))
+ # Label for showing counter
+ self.activity.clock_label = gtk.Label(_("-"))
+ self.activity.clock_label.show()
+ self.activity.clock_toolitem = gtk.ToolItem()
+ self.activity.clock_toolitem.add(self.activity.clock_label)
+ self.insert(self.activity.clock_toolitem, -1)
+ self.activity.clock_toolitem.show()
+
+ separator = gtk.SeparatorToolItem()
+ separator.set_draw(True)
+ self.insert(separator, -1)
+ separator.show()
+
+ # Label for showing play status
+ self.activity.status_label = gtk.Label(_("Find a match."))
self.activity.status_label.show()
self.activity.status_toolitem = gtk.ToolItem()
self.activity.status_toolitem.add(self.activity.status_label)
diff --git a/window.py b/window.py
index 032cb52..dc68538 100644
--- a/window.py
+++ b/window.py
@@ -23,6 +23,7 @@
import pygtk
pygtk.require('2.0')
import gtk
+import gobject
from gettext import gettext as _
try:
@@ -100,8 +101,12 @@ def new_window(canvas, path, parent=None):
tw.release = -1
tw.start_drag = [0,0]
+ tw.start_time = gobject.get_current_time()
+ tw.timeout_id = None
+ _counter(tw)
return tw
+
#
# Button press
#
@@ -161,22 +166,29 @@ def _button_release_cb(win, event, tw):
tw.deck.spr_to_card(tw.clicked[1]),
tw.deck.spr_to_card(tw.clicked[2])]):
if tw.deck.remove_and_replace(tw.clicked, tw) is None:
- tw.activity.deck_label.set_text(_("The deck is empty."))
+ tw.activity.deck_label.set_text(_("No more cards"))
else:
tw.activity.deck_label.set_text(
- _("%d cards remain in the deck") % \
+ _("%d cards remaining") % \
(tw.deck.count-tw.deck.index))
tw.matches += 1
- tw.activity.status_label.set_text(_("Found a match."))
+ tw.activity.status_label.set_text(_("Match"))
if tw.matches == 1:
tw.activity.match_label.set_text(
- _("%d match found.") % (tw.matches))
+ _("%d match") % (tw.matches))
else:
tw.activity.match_label.set_text(
- _("%d matches found.") % (tw.matches))
+ _("%d matches") % (tw.matches))
+
+ # reset the game clock
+ if tw.timeout_id is not None:
+ gobject.source_remove(tw.timeout_id)
+ tw.start_time = gobject.get_current_time()
+ tw.timeout_id = None
+ _counter(tw)
else:
- tw.activity.status_label.set_text(_("Not a match."))
+ tw.activity.status_label.set_text(_("No match"))
tw.clicked = [None, None, None]
for a in tw.selected:
a.hide_card()
@@ -204,6 +216,14 @@ def _destroy_cb(win, event, tw):
#
+# Display # of seconds since start_time
+#
+def _counter(tw):
+ tw.activity.clock_label.set_text(str(int(gobject.get_current_time()-\
+ tw.start_time)))
+ tw.timeout_id = gobject.timeout_add(1000,_counter,tw)
+
+#
# Check to see whether there are any matches on the board
#
def find_a_match(tw):