Commit 0480e25d authored by Bruno Coudoin's avatar Bruno Coudoin

copy from other indian flag created by Alexey Lubimov remade by Franck

	* boards/flags/pa.png: copy from other indian flag
	* boards/gletters/gletters.ru: created by Alexey Lubimov
	* boards/skins/babytoy/button_large2.png: remade by Franck Doucet
	* boards/sounds/ru/alphabet/Makefile.am: created. uncomplete yet
	* boards/sounds/ru/colors/Makefile.am: -
	* boards/sounds/ru/geography/Makefile.am: -
	* boards/sounds/ru/misc/Makefile.am: -
	* docs/fr/gcompris.texi: fixed by de Colombel Renaud <renaud.decolombel@free.fr>
	* src/boards/reading.c: added support for utf8, fixed memory leaks by Alexey Lubimov <avl@l14.ru>
	* src/boards/click_on_letter.c: (repeat), (sounds_are_fine),
	(click_on_letter_next_level), (click_on_letter_create_item),
	(item_event), (highlight_selected): fixed to use utf8 by Alexey Lubimov
	* src/gcompris/Makefile.am: added remove gcompris-marshal.* in cleanup
	* src/gcompris/assetml.c: (dump_asset), (assetml_add_xml_to_data),
	(matching), (free_asset): improved to support a name field by Alexey Lubimov
	* src/gcompris/assetml.h: -
parent 3b5c1cd9
2004-11-04 Bruno coudoin <bruno.coudoin@free.fr>
* boards/flags/pa.png: copy from other indian flag
* boards/gletters/gletters.ru: created by Alexey Lubimov
* boards/skins/babytoy/button_large2.png: remade by Franck Doucet
* boards/sounds/ru/alphabet/Makefile.am: created. uncomplete yet
* boards/sounds/ru/colors/Makefile.am: -
* boards/sounds/ru/geography/Makefile.am: -
* boards/sounds/ru/misc/Makefile.am: -
* docs/fr/gcompris.texi: fixed by de Colombel Renaud <renaud.decolombel@free.fr>
* src/boards/reading.c: added support for utf8, fixed memory leaks by Alexey Lubimov <avl@l14.ru>
* src/boards/click_on_letter.c: (repeat), (sounds_are_fine),
(click_on_letter_next_level), (click_on_letter_create_item),
(item_event), (highlight_selected): fixed to use utf8 by Alexey Lubimov
* src/gcompris/Makefile.am: added remove gcompris-marshal.* in cleanup
* src/gcompris/assetml.c: (dump_asset), (assetml_add_xml_to_data),
(matching), (free_asset): improved to support a name field by Alexey Lubimov
* src/gcompris/assetml.h: -
2004-11-03 Bruno coudoin <bruno.coudoin@free.fr>
* boards/flags/gcompris_flags.assetml.in: added ga.png
......
# commands can appear in any order
# comments begin with '#'
# blank lines are ignored
# all items in this file are optional and have program defaults
# levels define the characters to be dropped for that level of play
# note that the gletters keyboard is case-insensitive so the A key
# will "pop" both A and a, no shifting or mapping is necessary
level 1 АПРО
level 2 ВАПРОЛД
level 3 ЫВАПРОЛДЖ
level 4 ФЫВАПРОЛДЖЭ
level 5 ФЫВАПРОЛДЖЭГЕНТМИ
level 6 ФЫВАПРОЛДЖЭГЕНТМИКШУЩСЬЧБ
level 7 ФЫВАПРОЛДЖЭГЕНТМИКШУЩСЬЧБЗЦХЙ
level 8 ФЫВАПРОЛДЖЭГЕНТМИКШУЩСЬЧБЗЦХЙЯЧСЮБЬ
level 9 АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЭЮЯЪЬабвгдеёжзийклмнопрстуфхцчшщэюяъь0123456789
# key maps map keys on the keyboard to characters that are dropped
# so for example for this japanese keyboard, we map the lower case
# keys letters (a-z0-9) and some punctuation to hiragana and katakana
# gcompris at this point does not recognize alternate input methods
# so kana input has to be done via mapping the romaji keyboard
key qй
key wц
key eу
key rк
key tе
key yн
key uг
key iш
key oщ
key pз
key [х
key ]ъ
key aф
key sы
key dв
key fа
key gп
key hр
key jо
key kл
key lд
key ;ж
key
key zя
key xч
key cс
key vм
key bи
key nт
key mь
key ,б
key .ю
# the fallrate is the rate at which letters fall
# the smaller the numbers, the faster they fall
# the first number is the base
# the second number is the variability by level
# the sum of the numbers should be around 140
# use a slower fall rate for beginning typists
# use a faster rate to keep the challenge for more
# skilled typists
fallrate 40 100
# the droprate is the rate at which letters are dropped
# the smaller the numbers, the more letters drop
# the first number is the base
# the second number is the variability by level
# the sum of the numbers should be around 9000
droprate 1000 8000
%.assetml: %.assetml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -x -u -c $(top_builddir)/po/.intltool-merge-cache
assetmldir = $(prefix)/$(DATADIRNAME)/$(ASSETML_DIR)
assetml_in_files = \
gcompris_alphabet_ru.assetml.in
assetml_DATA = $(assetml_in_files:.assetml.in=.assetml)
@INTLTOOL_XML_RULE@
%.assetml: %.assetml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -x -u -c $(top_builddir)/po/.intltool-merge-cache
assetmldir = $(prefix)/$(DATADIRNAME)/$(ASSETML_DIR)
assetml_in_files = \
gcompris_colors_ru.assetml.in
assetml_DATA = $(assetml_in_files:.assetml.in=.assetml)
@INTLTOOL_XML_RULE@
%.assetml: %.assetml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -x -u -c $(top_builddir)/po/.intltool-merge-cache
assetmldir = $(prefix)/$(DATADIRNAME)/$(ASSETML_DIR)
assetml_in_files = \
gcompris_geography_ru.assetml.in
assetml_DATA = $(assetml_in_files:.assetml.in=.assetml)
@INTLTOOL_XML_RULE@
%.assetml: %.assetml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -x -u -c $(top_builddir)/po/.intltool-merge-cache
assetmldir = $(prefix)/$(DATADIRNAME)/$(ASSETML_DIR)
assetml_in_files = \
gcompris_misc_ru.assetml.in
assetml_DATA = $(assetml_in_files:.assetml.in=.assetml)
@INTLTOOL_XML_RULE@
This diff is collapsed.
......@@ -20,9 +20,12 @@
#include <ctype.h>
#include <math.h>
#include <assert.h>
#include <glib.h>
#include "gcompris/gcompris.h"
#define SOUNDLISTFILE PACKAGE
static GcomprisBoard *gcomprisBoard = NULL;
......@@ -46,15 +49,18 @@ static void repeat(void);
#define NUMBER_OF_SUBLEVELS 3
#define NUMBER_OF_LEVELS 5
#define MAX_NUMBER_OF_LETTERS 4
#define TEXT_COLOR "white"
static GnomeCanvasGroup *boardRootItem = NULL;
static GnomeCanvasItem *l1_item = NULL, *l2_item = NULL, *l3_item = NULL, *l4_item = NULL;
static GnomeCanvasItem *button1 = NULL, *button2 = NULL, *button3 = NULL, *button4 = NULL, *selected_button = NULL;
static GnomeCanvasItem *l_items[MAX_NUMBER_OF_LETTERS];
static GnomeCanvasItem *buttons[MAX_NUMBER_OF_LETTERS];
static GnomeCanvasItem *selected_button = NULL;
static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent);
static void click_on_letter_destroy_all_items(void);
static void click_on_letter_next_level(void);
static gint item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data);
......@@ -62,7 +68,9 @@ static gint phone_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data);
static gboolean sounds_are_fine(gchar* letter);
static int right_position;
static char right_letter[2] = "";
static int number_of_letters=MAX_NUMBER_OF_LETTERS;
static gchar *right_letter;
/* Description of this plugin */
static BoardPlugin menu_bp =
......@@ -187,21 +195,21 @@ static gboolean is_our_board (GcomprisBoard *gcomprisBoard)
/* ======================================= */
static void repeat ()
{
if(gcomprisBoard!=NULL)
if(gcomprisBoard!=NULL)
{
char *str1 = NULL;
char *str2 = NULL;
str1 = g_strdup_printf("%s%s", right_letter, ".ogg");
str2 = gcompris_get_asset_file("gcompris alphabet", NULL, "audio/x-ogg", str1);
gchar *str1 = NULL;
gchar *right_letter_ogg = NULL;
if(str2) {
gcompris_play_ogg(str2, NULL);
right_letter_ogg = g_strdup_printf("%s%s",right_letter,".ogg");
str1 = gcompris_get_asset_file("gcompris alphabet", NULL, "audio/x-ogg", right_letter_ogg);
if(str1) {
gcompris_play_ogg(str1, NULL);
}
g_free(str1);
g_free(str2);
g_free(right_letter_ogg);
}
}
......@@ -210,11 +218,10 @@ static gboolean sounds_are_fine (gchar* letter)
char *str1 = NULL;
char *str2 = NULL;
GcomprisProperties *properties = gcompris_get_properties();
char locale[3];
gchar *locale;
gboolean fine = TRUE;
strncpy( locale, gcompris_get_locale(), 2 );
locale[2] = 0; // because strncpy does not put a '\0' at the end of the string
locale= g_strndup(gcompris_get_locale(), 2);
str1 = g_strdup_printf("%s%s", letter, ".ogg");
str2 = gcompris_get_asset_file("gcompris alphabet", NULL, "audio/x-ogg", str1);
......@@ -232,6 +239,7 @@ static gboolean sounds_are_fine (gchar* letter)
}
}
g_free(locale);
g_free(str1);
g_free(str2);
......@@ -250,7 +258,7 @@ static void click_on_letter_next_level()
gamewon = FALSE;
selected_button = NULL;
gcompris_score_set(gcomprisBoard->sublevel);
g_free (right_letter);
/* Try the next level */
click_on_letter_create_item(gnome_canvas_root(gcomprisBoard->canvas));
}
......@@ -266,58 +274,62 @@ static void click_on_letter_destroy_all_items()
/* ==================================== */
static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent)
{
int xOffset,yOffset,i,j;
GdkPixbuf *button_pixmap = NULL;
char *str[4];
char l[4];
int numberOfLetters = 4;
char *str1 = NULL;
char *str2 = NULL;
char *str3 = NULL;
gchar *alphabet=_("abcdefghijklmnopqrstufw");
assert(g_utf8_validate(alphabet,-1,NULL)); // require by all utf8-functions
/* */
right_position = ((int)(((float)numberOfLetters)*rand()/(RAND_MAX+1.0))) +1;
assert(right_position >= 1 && right_position <= numberOfLetters);
/* set up letters, the right one is at position right_position */
/* level 1 : min letters, level 2 : cap letters, level 3 : mix of both */
for (i=0; i<numberOfLetters; i++) {
switch (gcomprisBoard->level) {
case 1 : l[i] = 'a' + ((char)( 26.0 * rand() / (RAND_MAX+1.0)));
break;
case 2 : l[i] = 'A' + ((char)( 26.0 * rand() / (RAND_MAX+1.0)));
break;
default :
if ( rand() > (RAND_MAX/2) )
l[i] = 'a' + ((char)( 26.0 * rand() / (RAND_MAX+1.0)));
else
l[i] = 'A' + ((char)( 26.0 * rand() / (RAND_MAX+1.0)));
break;
}
// check that the letter has not been taken yet (beware that 'a' == 'A' is to be avoided)
for(j=0; j<i; j++) {
if (l[j] == l[i] || abs(l[j] - l[i]) == 'a' - 'A' ) {
int length_of_aphabet=g_utf8_strlen (alphabet,-1);
number_of_letters=gcomprisBoard->level+1;
if (number_of_letters>MAX_NUMBER_OF_LETTERS) number_of_letters=MAX_NUMBER_OF_LETTERS;
int numbers[number_of_letters];
gchar *letters[number_of_letters];
assert(number_of_letters<=length_of_aphabet); // because we must set unique letter on every "vagon"
for (i=0;i<number_of_letters;i++){
numbers[i]=((int)(((float)length_of_aphabet)*rand()/(RAND_MAX+1.0)));
// check that the letter has not been taken yet
for(j=0;j<i;j++){
if (numbers[i]==numbers[j]) {
i--;
continue;
}
}
}
right_letter[0] = l[right_position-1];
right_letter[1] = 0;
g_strdown(right_letter);
/* Get the sounds to play from assetml */
str1 = gcompris_get_asset_file("gcompris misc", NULL, "audio/x-ogg", "click_on_letter.ogg");
str2 = g_strdup_printf("%s%s", right_letter, ".ogg");
str3 = gcompris_get_asset_file("gcompris alphabet", NULL, "audio/x-ogg", str2);
gcompris_play_ogg(str1, str3, NULL);
for (i=0;i<number_of_letters;i++){
gchar *copy_from=g_utf8_offset_to_pointer(alphabet, numbers[i]);
gchar *copy_to=g_utf8_offset_to_pointer(alphabet, numbers[i]+1);
letters[i]=g_strndup(copy_from,copy_to-copy_from);
switch (gcomprisBoard->level) {
case 1 :
case 2 : letters[i]=g_strndup(copy_from,copy_to-copy_from); break;
case 3 : letters[i]=g_utf8_strup(copy_from,copy_to-copy_from); break;
default :
if ( rand() > (RAND_MAX/2) )
letters[i]=g_strndup(copy_from,copy_to-copy_from);
else
letters[i]=g_utf8_strup(copy_from,copy_to-copy_from);
}
g_free(str1);
g_free(str2);
g_free(str3);
}
/* */
right_position = ((int)(((float)number_of_letters)*rand()/(RAND_MAX+1.0)));
assert(right_position >= 0 && right_position < number_of_letters);
right_letter = g_utf8_strdown(letters[right_position],-1);
repeat();
boardRootItem = GNOME_CANVAS_GROUP(
gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
......@@ -325,113 +337,43 @@ static GnomeCanvasItem *click_on_letter_create_item(GnomeCanvasGroup *parent)
"x", (double) 0,
"y", (double) 0,
NULL));
for (i=0; i<numberOfLetters; i++) {
str[i] =g_strdup_printf("%c", l[i]);
}
button_pixmap = gcompris_load_pixmap("images/wagon-yellow.png");
yOffset = VERTICAL_SEPARATION;
xOffset = 5;
button1 = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
"pixbuf", button_pixmap,
"x", (double) xOffset,
"y", (double) yOffset,
NULL);
l1_item = gnome_canvas_item_new (boardRootItem,
gnome_canvas_text_get_type (),
"text", str[0],
"font", gcompris_skin_font_board_huge_bold,
"anchor", GTK_ANCHOR_CENTER,
"fill_color_rgba", 0x0000ffff,
"x", (double) xOffset + gdk_pixbuf_get_width(button_pixmap)/2,
"y", (double) yOffset + gdk_pixbuf_get_height(button_pixmap)/2 - 5,
NULL);
xOffset +=HORIZONTAL_SEPARATION +gdk_pixbuf_get_width(button_pixmap);
for (i=0; i< number_of_letters; i++) {
button2 = gnome_canvas_item_new (boardRootItem,
buttons[i] = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
"pixbuf", button_pixmap,
"x", (double) xOffset,
"y", (double) yOffset,
NULL);
l2_item = gnome_canvas_item_new (boardRootItem,
gnome_canvas_text_get_type (),
"text", str[1],
"font", gcompris_skin_font_board_huge_bold,
"anchor", GTK_ANCHOR_CENTER,
"fill_color_rgba", 0x0000ffff,
"x", (double) xOffset + gdk_pixbuf_get_width(button_pixmap)/2,
"y", (double) yOffset + gdk_pixbuf_get_height(button_pixmap)/2 - 5,
NULL);
xOffset +=HORIZONTAL_SEPARATION +gdk_pixbuf_get_width(button_pixmap);
button3 = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
"pixbuf", button_pixmap,
"x", (double) xOffset,
"y", (double) yOffset,
NULL);
l3_item = gnome_canvas_item_new (boardRootItem,
l_items[i] = gnome_canvas_item_new (boardRootItem,
gnome_canvas_text_get_type (),
"text", str[2],
"text", letters[i] ,
"font", gcompris_skin_font_board_huge_bold,
"anchor", GTK_ANCHOR_CENTER,
"fill_color_rgba", 0x0000ffff,
"x", (double) xOffset + gdk_pixbuf_get_width(button_pixmap)/2,
"y", (double) yOffset + gdk_pixbuf_get_height(button_pixmap)/2 - 5,
NULL);
g_free(letters[i]);
xOffset +=HORIZONTAL_SEPARATION +gdk_pixbuf_get_width(button_pixmap);
button4 = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
"pixbuf", button_pixmap,
"x", (double) xOffset,
"y", (double) yOffset,
NULL);
l4_item = gnome_canvas_item_new (boardRootItem,
gnome_canvas_text_get_type (),
"text", str[3],
"font", gcompris_skin_font_board_huge_bold,
"anchor", GTK_ANCHOR_CENTER,
"fill_color_rgba", 0x0000ffff,
"x", (double) xOffset + gdk_pixbuf_get_width(button_pixmap)/2,
"y", (double) yOffset + gdk_pixbuf_get_height(button_pixmap)/2 - 5,
NULL);
for (i=0; i<numberOfLetters; i++) {
g_free(str[i]);
gtk_signal_connect(GTK_OBJECT(l_items[i]), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(i));
gtk_signal_connect(GTK_OBJECT(buttons[i]), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(i));
gtk_signal_connect(GTK_OBJECT(buttons[i]), "event", (GtkSignalFunc) gcompris_item_event_focus, NULL);
}
gdk_pixbuf_unref(button_pixmap);
gtk_signal_connect(GTK_OBJECT(l1_item), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(1));
gtk_signal_connect(GTK_OBJECT(l2_item), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(2));
gtk_signal_connect(GTK_OBJECT(l3_item), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(3));
gtk_signal_connect(GTK_OBJECT(l4_item), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(4));
gtk_signal_connect(GTK_OBJECT(button1), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(1));
gtk_signal_connect(GTK_OBJECT(button1), "event",
(GtkSignalFunc) gcompris_item_event_focus,
NULL);
gtk_signal_connect(GTK_OBJECT(button2), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(2));
gtk_signal_connect(GTK_OBJECT(button2), "event",
(GtkSignalFunc) gcompris_item_event_focus,
NULL);
gtk_signal_connect(GTK_OBJECT(button3), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(3));
gtk_signal_connect(GTK_OBJECT(button3), "event",
(GtkSignalFunc) gcompris_item_event_focus,
NULL);
gtk_signal_connect(GTK_OBJECT(button4), "event", (GtkSignalFunc) item_event, GINT_TO_POINTER(4));
gtk_signal_connect(GTK_OBJECT(button4), "event",
(GtkSignalFunc) gcompris_item_event_focus,
NULL);
gdk_pixbuf_unref(button_pixmap);
return NULL;
}
......@@ -498,7 +440,7 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
} else {
gamewon = FALSE;
}
highlight_selected(item);
highlight_selected(item);
process_ok();
break;
......@@ -511,17 +453,15 @@ item_event(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
static void highlight_selected(GnomeCanvasItem * item) {
GdkPixbuf *button_pixmap_selected = NULL, *button_pixmap = NULL;
GnomeCanvasItem *button;
int i;
/* Replace text item by button item */
button = item;
if ( button == l1_item ) {
button = button1;
} else if ( item == l2_item ) {
button = button2;
} else if ( item == l3_item ) {
button = button3;
} else if ( item == l4_item ) {
button = button4;
for (i=0; i<number_of_letters;i++) {
if ( l_items[i] == item ) {
button = buttons[i];
}
}
if (selected_button != NULL && selected_button != button) {
......
......@@ -29,13 +29,17 @@
#define SOUNDLISTFILE PACKAGE
#define MAXWORDSLENGTH 50
#define MAX_WORDS 100
static GPtrArray *words=NULL;
static GcomprisBoard *gcomprisBoard = NULL;
static gint drop_items_id = 0;
static gint next_level_timer = 0;
static char *textToFind = NULL;
static gchar *textToFind = NULL;
static gint textToFindIndex = 0;
#define NOT_THERE -1000
......@@ -86,7 +90,8 @@ static gint reading_next_level(void);
static void player_win(void);
static void player_loose(void);
static char *get_random_word();
static gchar *get_random_word(gboolean);
static gboolean read_wordfile();
static GnomeCanvasItem *display_what_to_do(GnomeCanvasGroup *parent);
static void ask_ready(gboolean status);
static void ask_yes_no(void);
......@@ -232,6 +237,7 @@ is_our_board (GcomprisBoard *gcomprisBoard)
/* set initial values for the next level */
static gint reading_next_level()
{
gcompris_bar_set_level(gcomprisBoard);
gamewon = FALSE;
......@@ -264,9 +270,9 @@ static gint reading_next_level()
gcomprisBoard->number_of_sublevel=1;
gcomprisBoard->sublevel=1;
read_wordfile();
display_what_to_do(boardRootItem);
ask_ready(TRUE);
return (FALSE);
}
......@@ -288,27 +294,45 @@ static void reading_destroy_all_items()
gtk_object_destroy (GTK_OBJECT(boardRootItem));
boardRootItem = NULL;
textToFind = NULL;
previousFocus.rootItem = NULL;
toDeleteFocus.rootItem = NULL;
if (textToFind!=NULL)
{
g_free(textToFind);
textToFind=NULL;
}
if (words!=NULL)
{
g_ptr_array_free (words, TRUE);
words=NULL;
}
}
static GnomeCanvasItem *display_what_to_do(GnomeCanvasGroup *parent)
{
gint base_Y = 110;
gint base_X = 580;
gint i;
/* Free the previous text to find */
if(textToFind)
g_free(textToFind);
/* Load the text to find */
textToFind = "*";
textToFind = get_random_word();
textToFind = get_random_word(TRUE);
if(textToFind==NULL)
return;
assert(textToFind != NULL);
/* Decide now if this time we will display the text to find */
/* Use this formula to have a better random number see 'man 3 rand' */
i=((int)(2.0*rand()/(RAND_MAX+1.0)));
if(i==0)
textToFindIndex = rand() % numberOfLine;
else
textToFindIndex = NOT_THERE;
gnome_canvas_item_new (parent,
gnome_canvas_text_get_type (),
......@@ -340,13 +364,6 @@ static GnomeCanvasItem *display_what_to_do(GnomeCanvasGroup *parent)
"fill_color", "white",
NULL);
/* Decide now if this time we will display the text to find */
/* Use this formula to have a better random number see 'man 3 rand' */
i=((int)(2.0*rand()/(RAND_MAX+1.0)));
if(i==0)
textToFindIndex = rand() % numberOfLine;
else
textToFindIndex = NOT_THERE;
return NULL;
}
......@@ -358,8 +375,7 @@ static gboolean reading_create_item(GnomeCanvasGroup *parent)
gchar *word;
gchar *overword;
if(textToFind==NULL)
return FALSE;
assert(textToFind!=NULL);
if(toDeleteFocus.rootItem)
{
......@@ -382,27 +398,24 @@ static gboolean reading_create_item(GnomeCanvasGroup *parent)
return FALSE;
}
if(textToFindIndex!=0)
{
word = get_random_word();
word = get_random_word(FALSE);
}
else
{
word = g_strdup(textToFind);
word = textToFind;
}
if(word==NULL)
return FALSE;
assert(word!=NULL);
if(textToFindIndex>=0)
textToFindIndex--;
/* fill up the overword with X */
overword = g_malloc(strlen(word));
for(i=0; i<strlen(word); i++)
overword[i] = 'x';
overword[i]='\0';
overword = g_strnfill (g_utf8_strlen(word,-1)-1,'x');
previousFocus.rootItem = \
GNOME_CANVAS_GROUP( gnome_canvas_item_new (parent,
......@@ -424,7 +437,6 @@ static gboolean reading_create_item(GnomeCanvasGroup *parent)
"anchor", anchor,
"fill_color", "black",
NULL);
g_free(word);
previousFocus.overwriteItem = \
gnome_canvas_item_new (GNOME_CANVAS_GROUP(previousFocus.rootItem),
......@@ -684,109 +696,85 @@ item_event_valid(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
}
static FILE *get_wordfile(const char *locale)
{
char *filename;
gchar *filename;
FILE *wordsfd = NULL;
/* First Try to find a file matching the level and the locale */
filename = g_strdup_printf("%s%s%d.%.2s",
PACKAGE_DATA_DIR, "/wordsgame/wordslevel",
gcomprisBoard->level, locale);
filename = g_strdup_printf("%s%s%d.%.2s",
PACKAGE_DATA_DIR, "/wordsgame/wordslevel",
gcomprisBoard->level, locale);
// g_message("Trying to open file %s ", filename);
wordsfd = fopen (filename, "r");
if(wordsfd==NULL)
{
/* Second Try to find a file matching the 'max' and the locale */
sprintf(filename, "%s%s%.2s",
PACKAGE_DATA_DIR, "/wordsgame/wordslevelmax.",
locale);
g_sprintf(filename, "%s%s%.2s",
PACKAGE_DATA_DIR, "/wordsgame/wordslevelmax.",
locale);
// g_message("Trying to open file %s ", filename);
wordsfd = fopen (filename, "r");
}
g_free(filename);
return wordsfd;