Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activity/activity.info4
-rw-r--r--data.py24
-rw-r--r--hoparound.py66
-rw-r--r--view.py17
4 files changed, 68 insertions, 43 deletions
diff --git a/activity/activity.info b/activity/activity.info
index 3f2c651..e284afb 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -1,8 +1,8 @@
[Activity]
name = Hop-A-Round
bundle_id = org.laptop.HopaRound
-class = hoparound.HopaRoundActivity
+class = hoparound.HopARoundActivity
icon = hoparound-icon
-activity_version = 2
+activity_version = 3
host_version = 1
show_launcher = yes
diff --git a/data.py b/data.py
index 2bd91e9..f799fd4 100644
--- a/data.py
+++ b/data.py
@@ -1,7 +1,7 @@
"""
Copyright (C) 2009 Mike Major <ossfm@yahoo.com>
- This file is part of HopAround.
+ This file is part of Hop-A-Round.
Hop-A-Round is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Hop-A-Round. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import random
@@ -24,18 +24,22 @@ class LevelData():
def __init__(self):
self.question_max = 3 # number of questions in each section (slider, multiple choice & entry)
self.thresh_slider = 0 # if question count matches this number, change to this section
- self.thresh_mult = self.question_max # if question count matches this number, change to this section
- self.thresh_entry = 2 * self.question_max # if question count matches this number, change to this section
self.min_level = 1 # minimum levels in the activity; also the exponent of the current level
self.max_level = 5 # maximum levels in the activity; also the exponent of the current level
self.current_level = 1 # starting and current level indicator
- self.question_count = 0 # number of questions asked on current level
- self.level_score = 0 # number of questions correct on current level
- self.thresh_up = 6 # level score at/above which the level will be increased
self.thresh_down = 0 # level score at/below which the level will be reduced
self.level_change = 0 # flag indicating a level change
self.digits = [] # collection of digits to create the question from
+ self.set_question_count(self.question_max)
random.seed()
+
+ def set_question_count(self, max):
+ self.question_max = max
+ self.thresh_mult = self.question_max # if question count matches this number, change to this section
+ self.thresh_entry = self.question_max * 2 # if question count matches this number, change to this section
+ self.thresh_up = self.question_max * 3 # level score at/above which the level will be increased
+ self.question_count = 0 # number of questions asked on current level
+ self.level_score = 0 # number of questions correct on current level
def check_answer(self, response):
if response == self.correct_answer:
@@ -91,14 +95,14 @@ class LevelData():
else:
factor = random.choice([0.1,10.0])
self.mult.append(int(math.floor(self.random_number/(self.answer_decade*factor)) * self.answer_decade * factor))
- self.mult.append(int(math.ceil(self.random_number/(self.answer_decade*factor)) * self.answer_decade * factor))
+ self.mult.append(int(math.ceil(self.random_number/(self.answer_decade*factor)) * self.answer_decade * factor))
def get_game_data(self):
- temp = "\n\nLevel: " + str(self.current_level)
+ temp = "Level: " + str(self.current_level)
#temp += "\nRandom Number: " + str(self.random_number)
#temp += "\nDecade: " + str(self.answer_decade)
#temp += "\nCorrect Answer: " + str(self.correct_answer)
- #temp += "\nMult Choices: " + str(self.mult)
+ temp += "\nQuestion max: " + str(self.question_max)
temp += "\nScore: " + str(self.level_score)
temp += "\nCount: " + str(self.question_count)
return temp
diff --git a/hoparound.py b/hoparound.py
index 56d87a3..3e3d656 100644
--- a/hoparound.py
+++ b/hoparound.py
@@ -1,7 +1,7 @@
"""
Copyright (C) 2009 Mike Major <ossfm@yahoo.com>
- This file is part of HopAround.
+ This file is part of Hop-A-Round.
Hop-A-Round is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -14,52 +14,57 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Hop-A-Round. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from sugar.activity import activity
-from view import Views
-from data import LevelData
+import view
+import data
import gtk
import locale
import gobject
-class HopaRoundActivity(activity.Activity):
+class HopARoundActivity(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
+ self.data = data.LevelData()
+ self.ui = view.Views()
# make the toolbox
toolbox = activity.ActivityToolbox(self)
self.set_toolbox(toolbox)
toolbox.show()
- self.data = LevelData()
- self.ui = Views()
+ # make the settings toolbar
+ self.settings_toolbar = view.SettingsToolbar(self.data)
+ self.settings_toolbar.question_count_spin.connect("value-changed", self.tool_item_question_count_cb)
+ toolbox.add_toolbar("Settings", self.settings_toolbar)
+ self.settings_toolbar.show()
self.ui.clear(self.data)
- self.ui.slider_click.connect("clicked", self.submit_answer, self.ui.slider_tool)
- self.ui.mult_1.connect("clicked", self.submit_answer, self.ui.mult_1)
- self.ui.mult_2.connect("clicked", self.submit_answer, self.ui.mult_2)
- self.ui.mult_3.connect("clicked", self.submit_answer, self.ui.mult_3)
- self.ui.mult_4.connect("clicked", self.submit_answer, self.ui.mult_4)
- self.ui.entry_click.connect("clicked", self.submit_answer, self.ui.entry_tool)
- self.ui.entry_tool.connect("activate", self.submit_answer, self.ui.entry_tool)
- self.setup(self.data, self.ui)
+ self.ui.slider_click.connect_object("clicked", self.submit_answer, self.ui.slider_tool)
+ self.ui.mult_1.connect("clicked", self.submit_answer)
+ self.ui.mult_2.connect("clicked", self.submit_answer)
+ self.ui.mult_3.connect("clicked", self.submit_answer)
+ self.ui.mult_4.connect("clicked", self.submit_answer)
+ self.ui.entry_click.connect_object("clicked", self.submit_answer, self.ui.entry_tool)
+ self.ui.entry_tool.connect("activate", self.submit_answer)
+ self.setup()
self.set_canvas(self.ui.get_user_interaction())
self.show_all()
self.ui.help.hide()
- def setup(self, data, ui):
- data.gen_random()
- ui.set_rounding_phrase(data)
- ui.set_choices(data.random_number, data.mult)
- ui.set_tab(data)
+ def setup(self):
+ self.data.gen_random()
+ self.ui.set_rounding_phrase(self.data)
+ self.ui.set_choices(self.data.random_number, self.data.mult)
+ self.ui.set_tab(self.data)
- def submit_answer(self, widget, answer):
+ def submit_answer(self, widget):
try: # for int answer because of entry field
- if answer.get_name() == "GtkHScale":
- num = int(answer.get_value())
- elif answer.get_name() == "GtkButton":
- num = locale.atoi(answer.get_label())
- elif answer.get_name() == "GtkEntry":
- num = locale.atoi(answer.get_text())
+ if widget.get_name() == "GtkHScale":
+ num = int(widget.get_value())
+ elif widget.get_name() == "GtkButton":
+ num = locale.atoi(widget.get_label())
+ elif widget.get_name() == "GtkEntry":
+ num = locale.atoi(widget.get_text())
except:
self.ui.answer_nan()
else:
@@ -68,5 +73,10 @@ class HopaRoundActivity(activity.Activity):
else:
self.ui.answer_incorrect(self.data)
gobject.timeout_add(2500, self.ui.clear, self.data)
- self.setup(self.data, self.ui)
+ self.setup()
+
+ def tool_item_question_count_cb(self, widget):
+ self.data.set_question_count(widget.get_value_as_int())
+ self.ui.clear(self.data)
+ self.setup()
diff --git a/view.py b/view.py
index 0b9d62f..f9c0634 100644
--- a/view.py
+++ b/view.py
@@ -1,7 +1,7 @@
"""
Copyright (C) 2009 Mike Major <ossfm@yahoo.com>
- This file is part of HopAround.
+ This file is part of Hop-A-Round.
Hop-A-Round is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with Hop-A-Round. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import gtk
@@ -29,7 +29,7 @@ class Views():
self.user_interaction = gtk.VBox()
self.activity = gtk.Notebook()
self.activity.set_show_tabs(False)
- self.activity.set_size_request(800, 600)
+ self.activity.set_size_request(800, 560)
self.user_interaction.pack_start(self.activity, False, False, 10)
# navigation
self.navigation = gtk.HButtonBox()
@@ -227,3 +227,14 @@ class Views():
def locl(self, characters):
return str(locale.format("%d", characters, True))
+
+class SettingsToolbar(gtk.Toolbar):
+ def __init__(self, data):
+ gtk.Toolbar.__init__(self)
+ self.question_count_spin_adj = gtk.Adjustment(data.question_max, 1, 100, 1, 1, 0)
+ self.question_count_spin = gtk.SpinButton(self.question_count_spin_adj, 0, 0)
+ self.question_count_spin.set_numeric(True)
+ self.question_count_spin.show()
+ tool_item_question_count = gtk.ToolItem()
+ tool_item_question_count.add(self.question_count_spin)
+ self.insert(tool_item_question_count, -1)