~ubuntu-branches/ubuntu/lucid/gbrainy/lucid

« back to all changes in this revision

Viewing changes to src/VerbalAnalogies/AnalogiesPairOfWordsOptions.cs

  • Committer: Bazaar Package Importer
  • Author(s): Siegfried-Angel Gevatter Pujals, Jo Shields, Siegfried-Angel Gevatter Pujals
  • Date: 2009-11-17 19:23:40 UTC
  • mfrom: (1.3.1 upstream) (9.1.8 karmic)
  • Revision ID: james.westby@ubuntu.com-20091117192340-ek9lvn4ag5913tg7
Tags: 1.20-1
[ Jo Shields ]
* debian/rules
  + Policy-compliant location for get-orig-source rule
  + Remove spurious call to --repack in get-orig-source rule

[ Siegfried-Angel Gevatter Pujals ]
* New upstream release:
  + Six new games, including a new game type (verbal analogies).
  + Bug fixes and new translations.
* Bump Standards-Version to 3.8.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009 Jordi Mas i Hernàndez <jmas@softcatala.org>
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License as
 
6
 * published by the Free Software Foundation; either version 2 of the
 
7
 * License, or (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public
 
15
 * License along with this program; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
using System;
 
21
using System.IO;
 
22
using System.Collections.Generic;
 
23
 
 
24
using Cairo;
 
25
using Mono.Unix;
 
26
using Gtk;
 
27
 
 
28
public class AnalogiesPairOfWordsOptions : Analogies
 
29
{
 
30
        static protected Dictionary <int, Analogy> analogies;
 
31
        static protected ArrayListIndicesRandom analogies_indices;
 
32
        static protected int analogies_index = 0;
 
33
 
 
34
        public AnalogiesPairOfWordsOptions ()
 
35
        {
 
36
                if (analogies == null)
 
37
                        analogies = AnalogiesFactory. Get (Analogy.Type.PairOfWordsOptions);
 
38
        }
 
39
 
 
40
        public override string Name {
 
41
                get { return Catalog.GetString ("Pair of words");}
 
42
        }
 
43
 
 
44
        public override ArrayListIndicesRandom Indices {
 
45
                get { return analogies_indices; }
 
46
                set { analogies_indices = value; }
 
47
        }
 
48
 
 
49
        public override int CurrentIndex {
 
50
                get { return analogies_index; }
 
51
                set { analogies_index = value; }
 
52
        }
 
53
 
 
54
        public override Dictionary <int, Analogy> List {
 
55
                get { return analogies; }
 
56
        }
 
57
 
 
58
        public override string Question {
 
59
                get {
 
60
                        string str = string.Empty;
 
61
        
 
62
                        if (current == null)
 
63
                                return string.Empty;
 
64
 
 
65
                        if (current.answers == null)
 
66
                                return current.question;
 
67
 
 
68
                        for (int n = 0; n < current.answers.Length; n++)
 
69
                        {
 
70
                                str+= GetPossibleAnswer (n);
 
71
 
 
72
                                if (n +1 < current.answers.Length) {
 
73
                                        // Translators: this the separator used when concatenating possible options for answering verbal analogies
 
74
                                        // For example: "Possible correct answers are: a, b, c, d."                                             
 
75
                                        str += Catalog.GetString (", ");
 
76
                                }
 
77
                        }
 
78
 
 
79
                        return String.Format (Catalog.GetString (
 
80
                                "Given the pair of words '{0}', which of the possible answers has the closest in relationship to the given pair? Answer {1}."),
 
81
                                current.question,
 
82
                                str);
 
83
                }
 
84
        }
 
85
 
 
86
        public override void Initialize ()
 
87
        {
 
88
                current = GetNext ();
 
89
 
 
90
                if (current == null || current.answers == null)
 
91
                        return;
 
92
 
 
93
                right_answer = GetPossibleAnswer (current.right);
 
94
        }
 
95
 
 
96
        public override void Draw (CairoContextEx gr, int area_width, int area_height)
 
97
        {
 
98
                double x = DrawAreaX, y = DrawAreaY + 0.1;
 
99
 
 
100
                base.Draw (gr, area_width, area_height);
 
101
 
 
102
                if (current == null || current.answers == null || current.answers.Length <= 1)
 
103
                        return;
 
104
 
 
105
                gr.SetPangoLargeFontSize ();
 
106
                gr.MoveTo (0.1, y);
 
107
                gr.ShowPangoText (Catalog.GetString ("Possible answers are:"));
 
108
                y += 0.12;
 
109
                x += 0.05;
 
110
                for (int n = 0; n < current.answers.Length; n++)
 
111
                {
 
112
                        gr.MoveTo (x, y);
 
113
                        gr.ShowPangoText (String.Format ("{0}) {1}", GetPossibleAnswer (n), current.answers[n].ToString ()));
 
114
                        gr.Stroke ();
 
115
                        y += 0.15;
 
116
                }
 
117
        }
 
118
}