diff options
39 files changed, 657 insertions, 20 deletions
@@ -1,3 +1,64 @@ +2005-04-18 Bruno coudoin <bruno.coudoin@free.fr> + + + Yves added a new board called bargame. The manual is: + Put balls in the holes. You win if the computer play the last one. + If you want Tux to begin, just click on him. + Bruno Created the background image, Yves did the rest of the game. + + Serveral changes in the computer menu. Now there is a submenu for the + mouse activity. I redid the erase activity icons to be more precse. + The mouse comes from openclipart. + + I redid the tux teacher image as found in bargame and connect4 + + Some minor fixes for win32 compilation + + log format is now generic and does not need to be localised. + + * Makefile.am: + * boards/Makefile.am: + * boards/bargame.xml.in: + * boards/bargame/blue_ball.png: + * boards/bargame/board.png: + * boards/bargame/case.png: + * boards/bargame/case_last.png: + * boards/bargame/green_ball.png: + * boards/bargame/mask.png: + * boards/bargame/mask_last.png: + * boards/bargame/ombre.png: + * boards/boardicons/bargame.png: + * boards/boardicons/connect4.png: + * boards/boardicons/erase.png: + * boards/boardicons/erase_clic.png: + * boards/boardicons/erase_double_clic.png: + * boards/boardicons/mouse.png: + * boards/boardicons/mouse_move.png: + * boards/clickgame.xml.in: + * boards/connect4/prof.png: + * boards/followline.xml.in: + * boards/images/scenery6_background.png: + * boards/images/superbrain_background.jpg: + * boards/images/tux-teacher.png: + * boards/mouse.xml.in: + * configure.in: + * po/POTFILES.in: + * src/boards/chess.c: + * src/boards/erase.c: + * src/boards/py-mod-anim.c: (AnimCanvas_free), + (py_gcompris_animcanvas_setstate), + (py_gcompris_animcanvas_swapanim), + (py_gcompris_animcanvas_destroy): + * src/boards/python/Makefile.am: + * src/boards/python/bargame.py: + * src/boards/python/connect4.py: + * src/boards/python/gcompris/score/.cvsignore: + * src/gcompris/anim.c: (gcompris_load_animation), + (gcompris_activate_animation), (gcompris_swap_animation): + * src/gcompris/file_selector.c: (create_rootdir): + * src/gcompris/log.c: (gcompris_log_end): + * src/gcompris/properties.c: (create_rootdir): + 2005-04-15 Bruno coudoin <bruno.coudoin@free.fr> * src/boards/erase.c: (start_board), (end_board), (set_level), diff --git a/Makefile.am b/Makefile.am index 6a33b3b..d439c42 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,12 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = po src docs boards +if TEXINFO +DOCS_SUBDIR=docs +else +DOCS_SUBDIR= +endif + +SUBDIRS = po src boards $(DOCS_SUBDIR) icondir=$(datadir)/pixmaps icon_DATA = gcompris.png gcompris-edit.png diff --git a/boards/Makefile.am b/boards/Makefile.am index 96d24d0..50f4c9f 100644 --- a/boards/Makefile.am +++ b/boards/Makefile.am @@ -14,6 +14,7 @@ xml_in_files = \ anim.xml.in \ babymatch.xml.in \ babyshapes.xml.in \ + bargame.xml.in \ billard.xml.in \ ballcatch.xml.in \ boards.xml.in \ diff --git a/boards/bargame.xml.in b/boards/bargame.xml.in new file mode 100644 index 0000000..a67d949 --- /dev/null +++ b/boards/bargame.xml.in @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<GCompris> + <Board + name="bargame" + type="python:bargame" + section="/boards/." + difficulty="2" + icon="boardicons/bargame.png" + author="Yves Combe" + boarddir="bargame"> + <_title>bar game</_title> + <_description>Do not put the last ball</_description> + <_prerequisite>Brain</_prerequisite> + <_goal>Logic training activity</_goal> + <_manual>Put balls in the holes. You win if the computer play the last one. +If you want Tux to begin, just click on him. + </_manual> + </Board> +</GCompris> + diff --git a/boards/bargame/blue_ball.png b/boards/bargame/blue_ball.png Binary files differnew file mode 100644 index 0000000..85a88cb --- /dev/null +++ b/boards/bargame/blue_ball.png diff --git a/boards/bargame/board.png b/boards/bargame/board.png Binary files differnew file mode 100644 index 0000000..68e53bf --- /dev/null +++ b/boards/bargame/board.png diff --git a/boards/bargame/case.png b/boards/bargame/case.png Binary files differnew file mode 100644 index 0000000..0378ba4 --- /dev/null +++ b/boards/bargame/case.png diff --git a/boards/bargame/case_last.png b/boards/bargame/case_last.png Binary files differnew file mode 100644 index 0000000..7e2aaa5 --- /dev/null +++ b/boards/bargame/case_last.png diff --git a/boards/bargame/green_ball.png b/boards/bargame/green_ball.png Binary files differnew file mode 100644 index 0000000..23d698d --- /dev/null +++ b/boards/bargame/green_ball.png diff --git a/boards/bargame/mask.png b/boards/bargame/mask.png Binary files differnew file mode 100644 index 0000000..3961946 --- /dev/null +++ b/boards/bargame/mask.png diff --git a/boards/bargame/mask_last.png b/boards/bargame/mask_last.png Binary files differnew file mode 100644 index 0000000..26e9140 --- /dev/null +++ b/boards/bargame/mask_last.png diff --git a/boards/bargame/ombre.png b/boards/bargame/ombre.png Binary files differnew file mode 100644 index 0000000..fa97de1 --- /dev/null +++ b/boards/bargame/ombre.png diff --git a/boards/boardicons/bargame.png b/boards/boardicons/bargame.png Binary files differnew file mode 100644 index 0000000..e782483 --- /dev/null +++ b/boards/boardicons/bargame.png diff --git a/boards/boardicons/connect4.png b/boards/boardicons/connect4.png Binary files differindex 9fe3da0..91a35be 100644 --- a/boards/boardicons/connect4.png +++ b/boards/boardicons/connect4.png diff --git a/boards/boardicons/erase.png b/boards/boardicons/erase.png Binary files differindex cc47fbe..bbdc8dc 100644 --- a/boards/boardicons/erase.png +++ b/boards/boardicons/erase.png diff --git a/boards/boardicons/erase_clic.png b/boards/boardicons/erase_clic.png Binary files differindex da6ff2a..93e5bd1 100644 --- a/boards/boardicons/erase_clic.png +++ b/boards/boardicons/erase_clic.png diff --git a/boards/boardicons/erase_double_clic.png b/boards/boardicons/erase_double_clic.png Binary files differindex 880f44c..af53223 100644 --- a/boards/boardicons/erase_double_clic.png +++ b/boards/boardicons/erase_double_clic.png diff --git a/boards/boardicons/mouse.png b/boards/boardicons/mouse.png Binary files differnew file mode 100644 index 0000000..ed17e8f --- /dev/null +++ b/boards/boardicons/mouse.png diff --git a/boards/boardicons/mouse_move.png b/boards/boardicons/mouse_move.png Binary files differnew file mode 100644 index 0000000..50b12b0 --- /dev/null +++ b/boards/boardicons/mouse_move.png diff --git a/boards/clickgame.xml.in b/boards/clickgame.xml.in index a26c5c2..f2b1e15 100644 --- a/boards/clickgame.xml.in +++ b/boards/clickgame.xml.in @@ -3,7 +3,7 @@ <Board name="clickgame" type="clickgame" - section="/computer/." + section="/computer/mouse/." icon="boardicons/clickgame.png" difficulty="1" author="Bruno Coudoin (bruno.coudoin@free.fr)" diff --git a/boards/connect4/prof.png b/boards/connect4/prof.png Binary files differdeleted file mode 100644 index 9fe3da0..0000000 --- a/boards/connect4/prof.png +++ /dev/null diff --git a/boards/followline.xml.in b/boards/followline.xml.in index e837112..f226c0b 100644 --- a/boards/followline.xml.in +++ b/boards/followline.xml.in @@ -3,7 +3,7 @@ <Board name="followline" type="python:followline" - section="/computer/." + section="/computer/mouse/." icon="boardicons/followline.png" difficulty="1" author="Bruno Coudoin (bruno.coudoin@free.fr)" diff --git a/boards/images/scenery6_background.png b/boards/images/scenery6_background.png Binary files differnew file mode 100644 index 0000000..a4b851b --- /dev/null +++ b/boards/images/scenery6_background.png diff --git a/boards/images/superbrain_background.jpg b/boards/images/superbrain_background.jpg Binary files differindex 24e5254..4788c46 100644 --- a/boards/images/superbrain_background.jpg +++ b/boards/images/superbrain_background.jpg diff --git a/boards/images/tux-teacher.png b/boards/images/tux-teacher.png Binary files differnew file mode 100644 index 0000000..e258768 --- /dev/null +++ b/boards/images/tux-teacher.png diff --git a/boards/mouse.xml.in b/boards/mouse.xml.in index 84774c1..597dee9 100644 --- a/boards/mouse.xml.in +++ b/boards/mouse.xml.in @@ -4,7 +4,7 @@ name="mouse" type="menu" section="/computer/mouse" - icon="boardicons/erase.png" + icon="boardicons/mouse.png" author=""> <_title>Mouse manipulation boards</_title> <_description>Left-Click with the mouse to select an activity</_description> diff --git a/configure.in b/configure.in index addbd72..e59a10e 100644 --- a/configure.in +++ b/configure.in @@ -264,8 +264,9 @@ AC_DEFINE_UNQUOTED(GNUCHESS, "$GNUCHESS", Defines where GNU Chess resides on the AC_PATH_PROG(TEXINFO, makeinfo,no) if test x$TEXINFO = xno; then - AC_MSG_ERROR(Couldn't find texinfo, please install the texinfo package) + AC_MSG_WARN(Couldn't find texinfo, docs are not compiled. please install the texinfo package) fi +AM_CONDITIONAL(TEXINFO, test x$TEXINFO = xyes) AC_PATH_PROG(TETEX, texi2html,no) if test x$TETEX = xno; then diff --git a/po/POTFILES.in b/po/POTFILES.in index 6c47c61..8a02abf 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -36,6 +36,7 @@ boards/babyshapes/board5_0.xml.in boards/babyshapes/board6_0.xml.in boards/babyshapes/board7_0.xml.in boards/ballcatch.xml.in +boards/bargame.xml.in boards/billard.xml.in boards/boards.xml.in boards/canal_lock.xml.in diff --git a/src/boards/chess.c b/src/boards/chess.c index 672fba4..65ebf3c 100644 --- a/src/boards/chess.c +++ b/src/boards/chess.c @@ -28,8 +28,6 @@ #include <unistd.h> #include <signal.h> -#include "sys/wait.h" - #include "chess_notation.h" #include "gcompris/gcompris.h" diff --git a/src/boards/erase.c b/src/boards/erase.c index c275b02..bcc4f4f 100644 --- a/src/boards/erase.c +++ b/src/boards/erase.c @@ -50,15 +50,15 @@ static int number_of_item_y = 0; static gint timer_id = 0; // Default Double clic distance to restore on exit. -gint DefaultDoubleClicDistance; +static gint DefaultDoubleClicDistance; + +static gint DoubleClicLevel[6]= { 1000, 750, 600, 500, 400, 250}; -gint DoubleClicLevel[6]= { 1000, 750, 600, 500, 400, 250}; - 1000, 750, 600, 500, 400, 25 #define NORMAL 0 #define CLIC 1 #define DOUBLECLIC 2 -gint board_mode = NORMAL; +static gint board_mode = NORMAL; // List of images to use in the game static gchar *imageList[] = diff --git a/src/boards/py-mod-anim.c b/src/boards/py-mod-anim.c index dc2586f..0e86dfe 100644 --- a/src/boards/py-mod-anim.c +++ b/src/boards/py-mod-anim.c @@ -4,6 +4,13 @@ #include "py-gcompris-board.h" #include "py-mod-anim.h" +#define THROW_INACTIVE_ANIMATION \ +{ \ + PyErr_SetString(PyExc_RuntimeError, "Tried to access an inactive " \ + "AnimCanvas"); \ + return NULL; \ +} + static int Animation_init(py_GcomprisAnimation *self, PyObject*, PyObject*); static void Animation_free(py_GcomprisAnimation *self); @@ -13,10 +20,16 @@ static PyObject *AnimCanvas_getattr(py_GcomprisAnimCanvas*, char*); /* AnimCanvas methods */ static PyObject *py_gcompris_animcanvas_setstate(PyObject*, PyObject*); +static PyObject *py_gcompris_animcanvas_swapanim(PyObject*, PyObject*); +static PyObject *py_gcompris_animcanvas_destroy(PyObject*, PyObject*); static PyMethodDef AnimCanvasMethods[] = { {"setState", py_gcompris_animcanvas_setstate, METH_VARARGS, "gcompris_animcanvas_setstate"}, + {"swapAnimation", py_gcompris_animcanvas_swapanim, METH_VARARGS, + "gcompris_animcanvas_swapanim"}, + {"destroy", py_gcompris_animcanvas_destroy, METH_VARARGS, + "gcompris_animcanvas_destroy"}, {NULL, NULL, 0, NULL} }; @@ -185,8 +198,13 @@ static void AnimCanvas_free(py_GcomprisAnimCanvas *self) { printf("*** garbage collecting AnimCanvas ***\n"); - gcompris_deactivate_animation(self->item); - Py_DECREF(self->anim); + if(self->item) + { + g_warning("You should really call destroy() on an AnimCanvas " + "instead of relying on the refcounter\n"); + gcompris_deactivate_animation(self->item); + Py_DECREF(self->anim); + } PyObject_DEL(self); } @@ -206,6 +224,8 @@ py_gcompris_animcanvas_setstate(PyObject *self, PyObject *args) int state; GcomprisAnimCanvasItem *item = ( (py_GcomprisAnimCanvas*)self )->item; + if(!item) THROW_INACTIVE_ANIMATION; + if(!PyArg_ParseTuple(args, "i:gcompris_animcanvas_setstate", &state)) return NULL; @@ -215,6 +235,44 @@ py_gcompris_animcanvas_setstate(PyObject *self, PyObject *args) return Py_None; } +static PyObject* +py_gcompris_animcanvas_swapanim(PyObject *self, PyObject *args) +{ + py_GcomprisAnimCanvas *s = (py_GcomprisAnimCanvas*)self; + py_GcomprisAnimation *new_anim; + py_GcomprisAnimation *old_anim = (py_GcomprisAnimation*)s->anim; + GcomprisAnimCanvasItem *item = s->item; + + if(!item) THROW_INACTIVE_ANIMATION; + + if(!PyArg_ParseTuple(args, "O:AnimCanvas_swapAnim", (PyObject**)&new_anim)) + return NULL; + + gcompris_swap_animation(item, new_anim->a); + Py_INCREF(new_anim); + s->anim = (PyObject*)new_anim; + Py_DECREF(old_anim); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject* +py_gcompris_animcanvas_destroy(PyObject *self, PyObject *args) +{ + py_GcomprisAnimCanvas *s = (py_GcomprisAnimCanvas*)self; + + if(!s->item) THROW_INACTIVE_ANIMATION; + + gcompris_deactivate_animation(s->item); + Py_DECREF(s->anim); + s->item = NULL; + s->anim = NULL; + + Py_INCREF(Py_None); + return Py_None; +} + #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ #define PyMODINIT_FUNC void #endif diff --git a/src/boards/python/Makefile.am b/src/boards/python/Makefile.am index a65b0cb..dd712b7 100644 --- a/src/boards/python/Makefile.am +++ b/src/boards/python/Makefile.am @@ -6,6 +6,7 @@ dist_python_DATA= \ algorithm.py \ anim.py \ ballcatch.py \ + bargame.py \ connect4.py \ followline.py \ hexagon.py \ diff --git a/src/boards/python/bargame.py b/src/boards/python/bargame.py new file mode 100644 index 0000000..9ed1794 --- /dev/null +++ b/src/boards/python/bargame.py @@ -0,0 +1,473 @@ +# gcompris - BarGame +# +# +# +# Copyright (C) 2004 Christof Petig and Ingo Konrad +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +import gnome +import gnome.canvas +import gcompris +import gcompris.utils +import gcompris.bonus +import gcompris.skin +import pygtk +import gtk +import gtk.gdk +import random +import math + +class Gcompris_bargame: + """The Bar Game""" + + def __init__(self, gcomprisBoard): + random.seed() + self.gcomprisBoard = gcomprisBoard + self.rootitem = None + + # To display the bonus, we need to pause the board. + self.board_paused = 0 + self.number_balls = [[1,4],[2,6],[3,6]] + self.board_size = [15,19,29] + self.gcomprisBoard.level=1 + self.gcomprisBoard.maxlevel=4 + self.gcomprisBoard.sublevel=1 + self.gcomprisBoard.number_of_sublevel=3 + self.rootitem = None + + def start(self): + # load pixmaps for the ui. + self.pixmap_blue_ball = gcompris.utils.load_pixmap("bargame/blue_ball.png") + self.pixmap_green_ball = gcompris.utils.load_pixmap("bargame/green_ball.png") + self.pixmap_case = gcompris.utils.load_pixmap("bargame/case.png") + self.pixmap_case_last = gcompris.utils.load_pixmap("bargame/case_last.png") + self.pixmap_ombre = gcompris.utils.load_pixmap("bargame/ombre.png") + self.pixmap_mask = gcompris.utils.load_pixmap("bargame/mask.png") + self.pixmap_mask_last = gcompris.utils.load_pixmap("bargame/mask_last.png") + + self.pixmap_answer = gcompris.utils.load_pixmap("images/enumerate_answer.png") + self.pixmap_answer_focus = gcompris.utils.load_pixmap("images/enumerate_answer_focus.png") + self.pixmap_background = gcompris.utils.load_pixmap("images/scenery6_background.png") + + self.ANSWER_X = gcompris.BOARD_WIDTH - 200 + self.ANSWER_Y = gcompris.BOARD_HEIGHT - self.pixmap_answer.get_height() - 5 + self.ANSWER_WIDTH = self.pixmap_answer.get_width() + self.ANSWER_HEIGHT = self.pixmap_answer.get_height() + + self.pixmap_prof = gcompris.utils.load_pixmap("images/tux-teacher.png") + + # + pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("button_reload.png")) + if(pixmap): + gcompris.bar_set_repeat_icon(pixmap) + gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_OK|gcompris.BAR_REPEAT_ICON) + else: + gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_OK|gcompris.BAR_REPEAT) + gcompris.bar_set_level(self.gcomprisBoard) + + # + self.newGame() + + def end(self): + self.rootitem.destroy() + pass + + def set_level(self,level): + print 'set_level', level + self.gcomprisBoard.level = level + self.gcomprisBoard.sublevel = 1 + gcompris.bar_set_level(self.gcomprisBoard) + self.newGame() + pass + + def ok(self): + self.answer.has_focus() + self.play(self.answer.value,True) + pass + + def key_press(self, keyval): + #print("got key %i" % keyval) + return gtk.FALSE + + def repeat(self): + self.newGame() + + def pause(self, pause): + self.board_paused = pause + + # When the bonus is displayed, it call us first with pause(1) and then with pause(0) + # the game is won + if(pause == 0): + self.set_sublevel(self.gcomprisBoard.sublevel+1) + return 0 + + + #------------------------------------------------- + #------------------------------------------------- + #------------------------------------------------- + + def set_sublevel(self, sublevel): + print 'set_sublevel', sublevel + + #sublevel change only in game_won + if sublevel > self.gcomprisBoard.number_of_sublevel: + if self.game_won: + if self.gcomprisBoard.level == self.gcomprisBoard.maxlevel: + gcompris.bonus.board_finished(gcompris.bonus.FINISHED_RANDOM) + return 0 + else: + self.set_level(self.gcomprisBoard.level+1) + else: + self.gcomprisBoard.sublevel = 1 + self.newGame() + else: + self.gcomprisBoard.sublevel = sublevel + self.newGame() + + + def scale_pixbuf(self,pixbuf, scale): + return pixbuf.scale_simple(pixbuf.get_width()*scale, + pixbuf.get_height()*scale, + gtk.gdk.INTERP_HYPER) + + def calculate_win_places(self): + winners = [] + + min = self.number_balls[self.gcomprisBoard.sublevel-1][0] + max = self.number_balls[self.gcomprisBoard.sublevel-1][1] + period = (min + max) + + winners_list = [(self.board_size[self.gcomprisBoard.sublevel-1] -1 -x)% period for x in range(min)] + for i in range(self.board_size[self.gcomprisBoard.sublevel-1]): + if ((i+1) % period) in winners_list: + winners.append(i) + + level_win = (self.gcomprisBoard.level -1) * min + + if level_win == 0: + winners = [] + else: + winners = winners[-level_win:] + + print 'winners', winners + + return winners + + def newGame(self): + if self.rootitem: + self.rootitem.destroy() + + self.scale = gcompris.BOARD_WIDTH/(float(self.board_size[self.gcomprisBoard.sublevel-1])*self.pixmap_case.get_width()) + print "scale :", self.scale + + self.px_case = self.scale_pixbuf(self.pixmap_case,self.scale) + self.px_mask = self.scale_pixbuf(self.pixmap_mask,self.scale) + self.px_case_last = self.scale_pixbuf(self.pixmap_case_last,self.scale) + self.px_mask_last = self.scale_pixbuf(self.pixmap_mask_last,self.scale) + self.px_ombre = self.scale_pixbuf(self.pixmap_ombre,self.scale) + self.px_green_ball = self.scale_pixbuf(self.pixmap_green_ball,self.scale) + self.px_blue_ball = self.scale_pixbuf(self.pixmap_blue_ball,self.scale) + + self.holes = [] + self.last_played = -1 + self.game_won = False + self.list_win = self.calculate_win_places() + + + # Create root item canvas for the board + self.rootitem = self.gcomprisBoard.canvas.root().add( + gnome.canvas.CanvasGroup, + x=0, + y=0 + ) + + # background + self.background = self.rootitem.add( + gnome.canvas.CanvasPixbuf, + pixbuf = self.pixmap_background, + x=0, + y=0 + ) + + self.prof = self.prof_button(self, + self.rootitem, + (gcompris.BOARD_WIDTH - self.pixmap_prof.get_width())/2 - 90 , + 230 + ) + + + for i in range(self.board_size[self.gcomprisBoard.sublevel-1]): + self.holes.append(self.hole(self, + self.rootitem, + i*self.px_case.get_width(), + gcompris.BOARD_HEIGHT - 120,i)) + + for i in range(self.number_balls[self.gcomprisBoard.sublevel-1][1]): + self.ball(self.rootitem, + i*self.px_case.get_width()+ 150, + gcompris.BOARD_HEIGHT - 160, + self.px_blue_ball) + self.ball(self.rootitem, + i*self.px_case.get_width()+150, + gcompris.BOARD_HEIGHT-70, + self.px_green_ball) + + self.answer = self.answer_button(self, + self.rootitem, + self.ANSWER_X, + self.ANSWER_Y, + self.px_green_ball) + + def play(self, value, human): + print 'play:', value + for i in range(1,value+1): + self.last_played += 1 + if human: + self.holes[self.last_played].isGreen() + else: + self.holes[self.last_played].isBlue() + + if self.last_played == self.board_size[self.gcomprisBoard.sublevel-1] - 1 : + self.gamelost(human) + return + + if human: + self.machine_play() + + + def machine_play(self): + print 'machine_play' + + def accessible(x): + if ((x + self.last_played) in self.list_win): + return True + return False + + playable = filter(accessible, range(self.number_balls[self.gcomprisBoard.sublevel-1][0], self.number_balls[self.gcomprisBoard.sublevel-1][1]+1)) + + print 'playable', playable + + if playable != []: + self.play(random.choice(playable),False) + else: + self.play(random.choice(range(self.number_balls[self.gcomprisBoard.sublevel-1][0], + self.number_balls[self.gcomprisBoard.sublevel-1][1]+1)), + False) + + self.answer.new_value(self.number_balls[self.gcomprisBoard.sublevel-1][0]) + + def gamelost(self,human): + if human: + print 'Lost !' + gcompris.bonus.display(gcompris.bonus.LOOSE, gcompris.bonus.GNU) + else: + print 'Won !' + self.game_won = True + gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.GNU) + + + class hole: + def __init__(self, board, root, x, y, index): + self.board = board + self.itemgroup = root.add( + gnome.canvas.CanvasGroup, + x=x, + y=y + ) + + if (index == (self.board.board_size[self.board.gcomprisBoard.sublevel-1]-1)): + pixbuf_case = self.board.px_case_last + pixbuf_mask = self.board.px_mask_last + else: + pixbuf_case = self.board.px_case + pixbuf_mask = self.board.px_mask + + + self.base = self.itemgroup.add( + gnome.canvas.CanvasPixbuf, + pixbuf = pixbuf_case, + x=0, + y=0 + ) + + self.ombre = self.itemgroup.add( + gnome.canvas.CanvasPixbuf, + pixbuf = self.board.px_ombre, + x=0, + y=0 + ) + self.ombre.hide() + + self.blue = self.itemgroup.add( + gnome.canvas.CanvasPixbuf, + pixbuf = self.board.px_blue_ball, + x=0, + y=0 + ) + self.blue.hide() + + self.green = self.itemgroup.add( + gnome.canvas.CanvasPixbuf, + pixbuf = self.board.px_green_ball, + x=0, + y=0 + ) + self.green.hide() + + self.mask = self.itemgroup.add( + gnome.canvas.CanvasPixbuf, + pixbuf = pixbuf_mask, + x=0, + y=0, + ) + + if ((index+1)%5 == 0): + self.text= self.itemgroup.add( + gnome.canvas.CanvasText, + x=self.board.px_case.get_width()/2, + y=-10, + fill_color_rgba=0x000000ffL, + font=gcompris.skin.get_font("gcompris/board/small bold"), + anchor=gtk.ANCHOR_CENTER, + text = index + 1 + ) + + + def isBlue(self): + self.blue.show() + self.ombre.show() + + def isGreen(self): + self.green.show() + self.ombre.show() + + + class ball: + def __init__(self, root, x, y, pixbuf): + + self.ball = root.add( + gnome.canvas.CanvasPixbuf, + pixbuf = pixbuf, + x=x, + y=y + ) + + class answer_button: + def __init__(self, board, root, x, y, pixbuf): + self.board = board + self.focus = False + + self.itemgroup = root.add( + gnome.canvas.CanvasGroup, + x=x, + y=y + ) + + self.background = self.itemgroup.add( + gnome.canvas.CanvasPixbuf, + pixbuf = self.board.pixmap_answer, + x=0, + y=0 + ) + + self.background_focused = self.itemgroup.add( + gnome.canvas.CanvasPixbuf, + pixbuf = self.board.pixmap_answer_focus, + x=0, + y=0 + ) + self.background_focused.hide() + + self.icone = self.itemgroup.add( + gnome.canvas.CanvasPixbuf, + pixbuf = pixbuf, + x=10, + y=20 + ) + + self.value = self.board.number_balls[self.board.gcomprisBoard.sublevel-1][0] + + self.text = self.itemgroup.add( + gnome.canvas.CanvasText, + x=self.board.ANSWER_WIDTH - 50, + y=40, + fill_color_rgba=0xff0000ffL, + font=gcompris.skin.get_font("gcompris/board/huge bold"), + anchor=gtk.ANCHOR_CENTER, + text = self.value + ) + + self.background.connect("event",self.answer_event) + self.background_focused.connect("event",self.answer_event) + self.icone.connect("event",self.answer_event) + self.text.connect("event",self.answer_event) + + + def new_value(self, value): + self.value = value + self.text.set_property('text',value) + + def has_focus(self): + self.background_focused.show() + self.focus = True + + + def answer_event(self, item, event): + if ((event.type != gtk.gdk.BUTTON_PRESS) or + (event.button != 1)): + return gtk.FALSE + + self.has_focus() + + value = ( (self.value + + 1 + - self.board.number_balls[self.board.gcomprisBoard.sublevel-1][0]) + % (self.board.number_balls[self.board.gcomprisBoard.sublevel-1][1] + + 1 + - self.board.number_balls[self.board.gcomprisBoard.sublevel-1][0]) + + self.board.number_balls[self.board.gcomprisBoard.sublevel-1][0] + ) + self.new_value(value) + + return gtk.TRUE + + class prof_button: + def __init__(self, board, root, x, y): + self.board = board + + self.prof_image = root.add( + gnome.canvas.CanvasPixbuf, + pixbuf = self.board.pixmap_prof, + x=x, + y=y + ) + + self.prof_image.connect("event",self.event_play) + # This item is clickeable and it must be seen + self.prof_image.connect("event", gcompris.utils.item_event_focus) + + def event_play(self, item, event): + if ((event.type != gtk.gdk.BUTTON_PRESS) or + (event.button != 1)): + return gtk.FALSE + + # if answer button has been clicked, that play the human turn + if self.board.last_played == -1 : + self.board.machine_play() + return gtk.TRUE + + return gtk.FALSE + diff --git a/src/boards/python/connect4.py b/src/boards/python/connect4.py index 302a9ed..aa654d8 100644 --- a/src/boards/python/connect4.py +++ b/src/boards/python/connect4.py @@ -110,7 +110,7 @@ class Gcompris_connect4: self.prof = self.rootitem.add( gnome.canvas.CanvasPixbuf, - pixbuf = gcompris.utils.load_pixmap("connect4/prof.png"), + pixbuf = gcompris.utils.load_pixmap("images/tux-teacher.png"), x=10, y=350.0 ) diff --git a/src/boards/python/gcompris/score/.cvsignore b/src/boards/python/gcompris/score/.cvsignore index 2f6c4a6..8042824 100644 --- a/src/boards/python/gcompris/score/.cvsignore +++ b/src/boards/python/gcompris/score/.cvsignore @@ -5,3 +5,4 @@ .libs Makefile Makefile.in +*.pyc diff --git a/src/gcompris/anim.c b/src/gcompris/anim.c index 8ddd3e0..686c20f 100644 --- a/src/gcompris/anim.c +++ b/src/gcompris/anim.c @@ -39,14 +39,15 @@ GcomprisAnimation *gcompris_load_animation(char *filename) } else { - gchar *tmp = g_strdup_printf("%s/%s", PACKAGE_DATA_DIR, filename); + GcomprisBoard *gcomprisBoard = get_current_gcompris_board(); + gchar *tmp = g_strdup_printf("%s/%s", gcomprisBoard->board_dir, filename); f = fopen(tmp, "r"); g_free(tmp); } if(!f) { - g_warning("Couldn't open animation-spec file\n"); + g_warning("Couldn't open animation-spec file '%s'\n", filename); return NULL; } @@ -57,8 +58,9 @@ GcomprisAnimation *gcompris_load_animation(char *filename) /* read filenames, one per line, from the animation spec-file */ while(fscanf(f, "%99s", tmp) == 1) { + GcomprisBoard *gcomprisBoard = get_current_gcompris_board(); files = g_slist_append(files, - g_strdup_printf("%s/%s", PACKAGE_DATA_DIR, tmp)); + g_strdup_printf("%s/%s", gcomprisBoard->board_dir, tmp)); } anim = g_malloc(sizeof(GcomprisAnimation)); @@ -123,6 +125,12 @@ GcomprisAnimCanvasItem *gcompris_activate_animation(GnomeCanvasGroup *parent, return item; } +void gcompris_swap_animation(GcomprisAnimCanvasItem *item, GcomprisAnimation *new_anim) +{ + item->anim = new_anim; + gcompris_set_anim_state(item, 0); +} + void gcompris_deactivate_animation(GcomprisAnimCanvasItem *item) { GSList *node = g_slist_find( active, item ); diff --git a/src/gcompris/file_selector.c b/src/gcompris/file_selector.c index d1e7a20..bffbc85 100644 --- a/src/gcompris/file_selector.c +++ b/src/gcompris/file_selector.c @@ -1,6 +1,6 @@ /* gcompris - file_selector.c * - * Time-stamp: <2005/04/05 23:49:59 bruno> + * Time-stamp: <2005/04/17 16:01:23 bruno> * * Copyright (C) 2000 Bruno Coudoin * @@ -424,7 +424,11 @@ create_rootdir (gchar *rootdir) return 0; } +#if defined WIN32 + return(mkdir(rootdir)); +#else return(mkdir(rootdir, 0755)); +#endif } static void diff --git a/src/gcompris/log.c b/src/gcompris/log.c index 0882a5a..908b240 100644 --- a/src/gcompris/log.c +++ b/src/gcompris/log.c @@ -154,7 +154,7 @@ void gcompris_log_end (GcomprisBoard *gcomprisBoard, gchar *status) { /* Prepare our log */ /* The default format for time represenation. See strftime(3) */ - char *fmt = _("%a %b %d %H:%M:%S %Z %Y"); + char *fmt = "%F %T"; char buf[256]; diff --git a/src/gcompris/properties.c b/src/gcompris/properties.c index 54bd842..b9768a3 100644 --- a/src/gcompris/properties.c +++ b/src/gcompris/properties.c @@ -1,6 +1,6 @@ /* gcompris - properties.c * - * Time-stamp: <2005/04/10 23:46:00 bruno> + * Time-stamp: <2005/04/17 16:50:21 bruno> * * Copyright (C) 2000,2003 Bruno Coudoin * @@ -92,7 +92,11 @@ create_rootdir (gchar *rootdir) return 0; } +#if defined WIN32 + return(mkdir(rootdir)); +#else return(mkdir(rootdir, 0755)); +#endif } GcomprisProperties *gcompris_properties_new () |