Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLionel LASKE <llaske@c2s.fr>2013-04-18 20:02:42 (GMT)
committer Lionel LASKE <llaske@c2s.fr>2013-04-18 20:02:42 (GMT)
commite62984c24b0c7c6ab3714a7fb8650b92c2d89c9c (patch)
treee66ec9d18f4fab8259b56236d56babcd118b9af6
parentf5330eb90da1d56efd0c08bfccbb4a3fd3d493fa (diff)
Credit screen. Context saving on the XO.
-rw-r--r--activity.py4
-rw-r--r--html/app.js36
-rw-r--r--html/buttons.js4
-rw-r--r--html/credits.js43
-rw-r--r--html/depends.js1
-rw-r--r--html/filter.js2
-rw-r--r--html/images/class.pngbin0 -> 74853 bytes
-rw-r--r--html/images/credit.pngbin1023 -> 1245 bytes
-rw-r--r--html/l10n.js3
-rw-r--r--html/learn.js68
-rw-r--r--html/letter.js2
-rw-r--r--html/play.js56
-rw-r--r--html/styles.css27
-rw-r--r--html/util.js37
14 files changed, 237 insertions, 46 deletions
diff --git a/activity.py b/activity.py
index 8ac0309..c0ca284 100644
--- a/activity.py
+++ b/activity.py
@@ -162,7 +162,7 @@ class AbecedariumActivity(activity.Activity):
"Called by Enyo to save the current context"
file = open(self.file_path, 'w')
try:
- nop
+ file.write(context['context']+'\n')
finally:
file.close()
@@ -172,7 +172,7 @@ class AbecedariumActivity(activity.Activity):
file = open(file_path, 'r')
self.context = {}
try:
- nop
+ self.context['context'] = file.readline().strip('\n')
finally:
file.close()
diff --git a/html/app.js b/html/app.js
index beee00a..3579d8a 100644
--- a/html/app.js
+++ b/html/app.js
@@ -1,4 +1,4 @@
-
+
// Sounds theme
var soundThemes = [ "audio/theme_piano", "audio/theme_guitar", "audio/theme_violon", "audio/theme_oboe", "audio/theme_trompet", "audio/theme_mallets", "audio/theme_soprano"];
var soundNotesPos = [ 24, 536, 1024, 1536, 2057, 2569, 3048, 4040, 4552, 5032, 5560, 6064, 6349, 6570, 6836, 7072, 8056, 8560, 9072, 10071, 10575, 11071, 12063, 13061, 14063, 15062 ];
@@ -21,14 +21,28 @@ enyo.kind({
{name: "play", kind: "Image", src: "images/play.png", classes: "playButton", ontap: "playGame"},
{name: "build", kind: "Image", src: "images/build.png", classes: "buildButton", ontap: "buildGame"}
]},
- {kind: "Signals", onEndOfSound: "endOfSound", onSoundTimeupdate: "soundTimeupdate"}
+ {name: "creditsPopup", kind: "Abcd.CreditsPopup"},
+ {kind: "Signals", onEndOfSound: "endOfSound", onSoundTimeupdate: "soundTimeupdate"}
],
// Constructor, save home
create: function() {
this.inherited(arguments);
Abcd.context.home = this;
- this.playTheme();
+ },
+
+ // Start the last closed activity if context not null
+ rendered: function() {
+ if (Abcd.context.screen != "") {
+ Abcd.context.object = enyo.create({
+ kind: Abcd.context.screen,
+ context: Abcd.context.screenContext
+ }).renderInto(document.getElementById("body"));
+ Abcd.context.screen = "";
+ return true;
+ }
+ this.playTheme();
+ Abcd.context.object = null;
},
// Play theme
@@ -38,17 +52,23 @@ enyo.kind({
Abcd.sound.play(soundThemes[this.soundindex]);
},
- // Play games
+ // Launch activities
learnGame: function(e, s) {
- Abcd.sound.pause();
- Abcd.context.screen = new Abcd.Learn().renderInto(document.getElementById("body"));
+ Abcd.sound.pause();
+
+ Abcd.context.object = new Abcd.Learn().renderInto(document.getElementById("body"));
},
playGame: function(e, s) {
Abcd.sound.pause();
- Abcd.context.screen = new Abcd.Play().renderInto(document.getElementById("body"));
+ Abcd.context.object = new Abcd.Play().renderInto(document.getElementById("body"));
},
-
+
+ // Display credits page
+ displayCredits: function(e, s) {
+ this.$.creditsPopup.show();
+ },
+
// Sound ended, play next instrument
endOfSound: function(e, s) {
if (s == soundThemes[this.soundindex])
diff --git a/html/buttons.js b/html/buttons.js
index 049641f..e53af37 100644
--- a/html/buttons.js
+++ b/html/buttons.js
@@ -84,12 +84,12 @@ enyo.kind({
// Change current language
localEnglish: function() {
Abcd.changeVisibility(this, {switchToEnglish: false, switchToFrench: true});
- Abcd.setLocale(Abcd.enTexts);
+ Abcd.setLocale("en");
},
localFrench: function() {
Abcd.changeVisibility(this, {switchToEnglish: true, switchToFrench: false});
- Abcd.setLocale(Abcd.frTexts);
+ Abcd.setLocale("fr");
}
});
diff --git a/html/credits.js b/html/credits.js
new file mode 100644
index 0000000..bc0761d
--- /dev/null
+++ b/html/credits.js
@@ -0,0 +1,43 @@
+
+// Credits popup
+enyo.kind({
+ name: "Abcd.CreditsPopup",
+ kind: "onyx.Popup",
+ classes: "credits-popup",
+ centered: true,
+ modal: true,
+ floating: true,
+ components: [
+ { kind: "Image", src: "images/class.png", classes: "credit-image" },
+ { content: "concept & code:", classes: "credit-title" },
+ { content: "Lionel Laské", classes: "credit-name" },
+ { content: "arts:", classes: "credit-title" },
+ { content: "Art4Apps (images)", classes: "credit-name" },
+ { content: "Vicki Wenderlich (letters)", classes: "credit-name" },
+ { content: "TamTam Mini (music instruments)", classes: "credit-name" },
+ { content: "Rochester Font by Squid (script font)", classes: "credit-name" },
+ { content: "Nordic factory (flags)", classes: "credit-name" },
+ { content: "Giorgia Guarino from The Noun Project (listen icon)", classes: "credit-name" },
+ { content: "Drew Ellis from The Noun Project (dice icon)", classes: "credit-name" },
+ { content: "jon trillana from The Noun Project (Lego icon)", classes: "credit-name" },
+ { content: "Patrick N. from The Noun Project (funnel icon)", classes: "credit-name" },
+ { content: "John Caserta from The Noun Project (trash can icon)", classes: "credit-name" },
+ { content: "The Noun Project (picture icon)", classes: "credit-name" },
+ { content: "music:", classes: "credit-title" },
+ { content: "Alphabet song French traditional song play by Finale NotePad", classes: "credit-name" },
+ { content: "sounds effects:", classes: "credit-title" },
+ { content: "Art4apps (voices)", classes: "credit-name" },
+ { content: "Charel Sytze from freesound (applause)", classes: "credit-name" },
+ { content: "Unchaz from freesound (disappointment)", classes: "credit-name" },
+ { content: "thanks to:", classes: "credit-title" },
+ { content: "OLPC France team: Antoine, Jonathan, Laura, Pierre, Sandra and others", classes: "credit-name" },
+ ],
+
+ // Constructor
+ create: function() {
+ this.inherited(arguments);
+ },
+
+ rendered: function() {
+ }
+}); \ No newline at end of file
diff --git a/html/depends.js b/html/depends.js
index b3e23ac..6c689b1 100644
--- a/html/depends.js
+++ b/html/depends.js
@@ -10,6 +10,7 @@
"theme.js",
"letter.js",
"buttons.js",
+ "credits.js",
"filter.js",
"learn.js",
"play.js",
diff --git a/html/filter.js b/html/filter.js
index b34f3e9..7940ba3 100644
--- a/html/filter.js
+++ b/html/filter.js
@@ -1,4 +1,4 @@
-
+
// Minimum number of entries to allow filtering
var minFilterEntries = 3;
diff --git a/html/images/class.png b/html/images/class.png
new file mode 100644
index 0000000..a21f83d
--- /dev/null
+++ b/html/images/class.png
Binary files differ
diff --git a/html/images/credit.png b/html/images/credit.png
index dbbadfe..956d9d2 100644
--- a/html/images/credit.png
+++ b/html/images/credit.png
Binary files differ
diff --git a/html/l10n.js b/html/l10n.js
index a0b0808..8d6eac7 100644
--- a/html/l10n.js
+++ b/html/l10n.js
@@ -2,7 +2,8 @@
// Change current language setting
-__$FC_l10n = Abcd.frTexts;
+__$FC_l10n = (Abcd.context !== undefined && Abcd.context.lang !== undefined && Abcd.context.lang == "fr" ) ? Abcd.frTexts : Abcd.enTexts;
+Abcd.letters = (Abcd.context !== undefined && Abcd.context.lang !== undefined && Abcd.context.lang == "fr" ) ? Abcd.frLetters : Abcd.enLetters;
__$FC_l10n_set = function(texts) {
__$FC_l10n = texts;
Abcd.context.lang = __$FC_l10n[0];
diff --git a/html/learn.js b/html/learn.js
index 6183e9b..cd54042 100644
--- a/html/learn.js
+++ b/html/learn.js
@@ -9,6 +9,9 @@ enyo.kind({
name: "Abcd.Learn",
kind: enyo.Control,
classes: "board",
+ published: {
+ context: null,
+ },
components: [
{components: [
{name: "colorBar", classes: "colorBar"},
@@ -30,12 +33,42 @@ enyo.kind({
// Constructor, save home
create: function() {
+ // Initialize
this.inherited(arguments);
- this.displayThemes();
- this.theme = this.collection = this.entry = -1;
+ this.theme = this.collection = this.entry = this.position = -1;
this.collections = [];
this.playing = null;
this.slideshowIndex = -1;
+
+ // Set previous context
+ this.restoreContext();
+ if (this.theme != -1) {
+ if (this.theme == 4)
+ this.displayLetters({letter: this.collection});
+ else if (this.collection != -1)
+ this.displayEntries({index: this.collection});
+ else
+ this.displayCollections({index: this.theme});
+ } else
+ this.displayThemes();
+ },
+
+ // Context handling
+ restoreContext: function() {
+ if (this.context == null || this.context == "")
+ return;
+ var values = this.context.split('|');
+ this.theme = values[0];
+ this.collection = values[1];
+ this.entry = parseInt(values[2]);
+ },
+
+ saveContext: function() {
+ var values = [];
+ values.push(this.theme);
+ values.push(this.collection);
+ values.push(this.position);
+ return values.join("|");
},
// Localization changed
@@ -43,10 +76,11 @@ enyo.kind({
// If on an entry, redisplay from the beginning to avoid displaying non translated text
var current = this.$.box.getControls()[0];
if (current.kind == "Abcd.Entry") {
- if (this.collection.kind === undefined)
+ this.entry = -1;
+ if (this.theme != 4)
this.displayEntries({index: Abcd.entries[current.index].coll});
else
- this.displayLetters(this.collection);
+ this.displayLetters({letter:this.collection});
return;
}
@@ -74,7 +108,7 @@ enyo.kind({
var length = Abcd.themes.length;
this.cleanBox();
this.$.box.addClass("box-4-theme");
- Abcd.changeVisibility(this, {home: true, back: false, prev: false, next: false, pageCount: false});
+ Abcd.changeVisibility(this, {home: true, back: false, prev: false, next: false, pageCount: false, startSlideshow: false, stopSlideshow: false});
this.$.colorBar.addClass("themeColor"+this.theme);
for (var i = 0 ; i < length ; i++) {
this.$.box.createComponent(
@@ -92,7 +126,7 @@ enyo.kind({
}
},
- // Display all collection
+ // Display all collection for a theme
displayCollections: function(inSender, inEvent) {
this.theme = inSender.index;
var length = Abcd.collections.length;
@@ -111,9 +145,10 @@ enyo.kind({
// Display entries in a collection
displayEntries: function(inSender, inEvent) {
// Get items in collection
- this.$.box.removeClass("box-4-collection");
+ this.$.box.removeClass("box-4-collection");
+ this.$.colorBar.addClass("themeColor"+this.theme);
var index = inSender.index;
- this.collection = Abcd.collections[index];
+ this.collection = index;
this.collections = [];
var length = Abcd.collections[index].entries.length;
for (var i = 0 ; i < length ; i++) {
@@ -123,25 +158,26 @@ enyo.kind({
}
// Display it
- this.displayEntriesFrom(0);
+ this.displayEntriesFrom(this.entry+1);
},
// Display entries from a letter
displayLetters: function(inSender, inEvent) {
// Play letter sound
- inSender.play(Abcd.sound);
+ if (inSender.kind !== undefined)
+ inSender.play(Abcd.sound);
// Get items with this letters
- if (Abcd.letters[inSender.letter] === undefined)
+ this.collection = inSender.letter;
+ if (Abcd.letters[this.collection] === undefined)
return;
- this.collection = inSender;
- this.collections = Abcd.letters[inSender.letter];
+ this.collections = Abcd.letters[this.collection];
// Display it
this.theme = 4;
this.$.colorBar.addClass("themeColor"+this.theme);
this.$.box.removeClass("box-4-theme");
- this.displayEntriesFrom(0);
+ this.displayEntriesFrom(this.entry+1);
},
displayEntriesFrom: function(position) {
@@ -170,6 +206,7 @@ enyo.kind({
else
this.$.next.hide();
this.$.pageCount.setContent(Math.ceil(i/entriesByScreen)+"/"+Math.ceil(length/entriesByScreen));
+ this.position = position-1;
},
displayNextEntries: function() {
@@ -184,7 +221,8 @@ enyo.kind({
backTaped: function() {
var current = this.$.box.getControls()[0];
- if (current.kind == "Abcd.Entry" && this.collection.kind === undefined) {
+ this.entry = -1;
+ if (current.kind == "Abcd.Entry" && this.theme != 4) {
this.displayCollections({index: this.theme});
this.$.box.removeClass("box-4-entry");
return;
diff --git a/html/letter.js b/html/letter.js
index e30014e..f6a8ab7 100644
--- a/html/letter.js
+++ b/html/letter.js
@@ -1,4 +1,4 @@
-// Theme component
+// Letter component
enyo.kind({
name: "Abcd.Letter",
kind: "Abcd.Item",
diff --git a/html/play.js b/html/play.js
index fbc964d..42ed6e8 100644
--- a/html/play.js
+++ b/html/play.js
@@ -1,4 +1,4 @@
-
+
// Collections size on the screen
var entriesByGame = 4;
@@ -9,6 +9,9 @@ enyo.kind({
name: "Abcd.Play",
kind: enyo.Control,
classes: "board",
+ published: {
+ context: null,
+ },
components: [
{kind: "Signals", onEndOfSound: "endSound"},
{components: [
@@ -43,7 +46,45 @@ enyo.kind({
this.forbidentry = false;
this.filter = null;
- this.displayButtons();
+ this.restoreContext();
+ this.filterChanged({filter: this.filter});
+ if (this.theme != -1)
+ this.doGame(this.themeButton);
+ else
+ this.displayButtons();
+ },
+
+ // Context handling
+ restoreContext: function() {
+ if (this.context == null || this.context == "")
+ return;
+ var values = this.context.split('|');
+ this.theme = values[0];
+ this.gamecount = parseInt(values[1]);
+ this.themeButton = { from: values[2], to: values[3] };
+ if (values[4] != "")
+ this.filter = { kind: values[4], index: values[5], letter: values[5] };
+ },
+
+ saveContext: function() {
+ var values = [];
+ values.push(this.theme);
+ values.push(this.gamecount);
+ if (this.themeButton != null) {
+ values.push(this.themeButton.from);
+ values.push(this.themeButton.to);
+ } else {
+ values.push("");
+ values.push("");
+ }
+ if (this.filter != null) {
+ values.push(this.filter.kind);
+ values.push(this.filter.kind == "Abcd.Letter"?this.filter.letter:this.filter.index)
+ } else {
+ values.push("");
+ values.push("");
+ }
+ return values.join("|");
},
// Delete all the box content
@@ -95,7 +136,7 @@ enyo.kind({
this.$.box.createComponent(
{ kind: "Abcd.PlayTypeButton", from: "listen", to: "letter"+Abcd.context.casevalue, ontap: "doGame", theme: "play-button-color3" },
{ owner: this }
- ).render();
+ ).render();
},
// Localization changed
@@ -133,7 +174,7 @@ enyo.kind({
// Process filter change
filterChanged: function(s, e) {
- this.filter = this.$.filterPopup.filter;
+ this.filter = s.filter;
this.$.filterLetter.hide();
this.$.filterCollection.hide();
if (this.filter != null) {
@@ -168,7 +209,6 @@ enyo.kind({
this.$.colorBar.addClass("themeColor"+this.theme);
// Compute game
- this.gamecount = 0;
this.computeGame();
},
@@ -246,6 +286,7 @@ enyo.kind({
backTaped: function() {
this.$.colorBar.removeClass("themeColor"+this.theme);
this.theme = -1;
+ this.gamecount = 0;
this.displayButtons();
},
@@ -287,9 +328,10 @@ enyo.kind({
this.selected = null;
// Next game or try another game
- if ( ++this.gamecount == entriesByGame )
+ if ( ++this.gamecount == entriesByGame ) {
+ this.gamecount = 0;
this.displayButtons();
- else
+ } else
this.computeGame();
}
}
diff --git a/html/styles.css b/html/styles.css
index 8bdddf2..258e7a6 100644
--- a/html/styles.css
+++ b/html/styles.css
@@ -461,4 +461,31 @@
height: 60px;
left: 1000px;
top: 540px;
+}
+
+.credits-popup {
+ width: 880px;
+ height: 550px;
+ color: black;
+}
+
+.credit-image {
+ position: absolute;
+ margin-top: 20px;
+ margin-left: 20px;
+ width: 220px;
+ height: 220px;
+}
+
+.credit-title {
+ font-size: 26px;
+ margin-top: 10px;
+ margin-left: 270px;
+ color: white;
+}
+
+.credit-name {
+ font-size: 16px;
+ margin-left: 300px;
+ color: white;
} \ No newline at end of file
diff --git a/html/util.js b/html/util.js
index 28d61f3..f4efec1 100644
--- a/html/util.js
+++ b/html/util.js
@@ -7,29 +7,47 @@ Abcd = {};
// Game context handling
Abcd.context = {
- screen: null,
+ home: null,
+ object: null,
+ screen: "",
lang: "fr",
casevalue: 0,
+ screenContext: null
};
Abcd.saveContext = function() {
- Abcd.sugar.sendMessage(
- "save-context", {});
+ var values = [];
+ values.push(Abcd.context.object!=null?Abcd.context.object.kindName:"");
+ values.push(Abcd.context.lang);
+ values.push(Abcd.context.casevalue);
+ values.push(Abcd.context.object!=null?Abcd.context.object.saveContext():"");
+ Abcd.sugar.sendMessage("save-context", {context:values.join("#")});
};
Abcd.loadContext = function(context) {
+ if (context == null || context == "" || !context.context)
+ return;
+ var values = context.context.split('#');
+ Abcd.context.screen = values[0];
+ Abcd.context.lang = values[1];
+ Abcd.context.casevalue = values[2];
+ Abcd.context.screenContext = values[3];
+ Abcd.setLocale(Abcd.context.lang);
};
// Init Sugar interface
-Abcd.setLocale = function(texts) {
+Abcd.setLocale = function(lang) {
+ var texts = Abcd.enTexts;
+ if (lang == "fr")
+ texts = Abcd.frTexts;
__$FC_l10n_set(texts);
- Abcd.letters = Abcd[Abcd.context.lang+"Letters"];
- if (Abcd.context.screen != null)
- Abcd.context.screen.setLocale();
+ Abcd.letters = Abcd[lang+"Letters"];
+ if (Abcd.context.object != null)
+ Abcd.context.object.setLocale();
}
Abcd.setCase = function(casevalue) {
Abcd.context.casevalue = casevalue;
- if (Abcd.context.screen != null)
- Abcd.context.screen.setCase();
+ if (Abcd.context.object != null)
+ Abcd.context.object.setCase();
}
Abcd.sugar = new Sugar();
Abcd.sugar.connect("localization", Abcd.setLocale);
@@ -44,6 +62,7 @@ Abcd.log = function(msg) {
// Home handling
Abcd.goHome = function() {
if (Abcd.context.home != null) {
+ Abcd.context.screen = "";
Abcd.context.home.renderInto(document.getElementById("body"));
Abcd.context.home.playTheme();
}