Commit b0674a02 authored by Bruno Coudoin's avatar Bruno Coudoin

- Improved letters icons in crane

	- Removed a memory leak in crane related to pixmaps not freed
	- added a dialog box when gnucap is not found / or spawn fails
	- added help in electric.xml.in
parent af98bd8d
2006-01-17 Bruno coudoin <bruno.coudoin@free.fr>
- Improved letters icons in crane
- Removed a memory leak in crane related to pixmaps not freed
- added a dialog box when gnucap is not found / or spawn fails
- added help in electric.xml.in
* boards/awele.xml.in:
* boards/crane/arrow_down.png:
* boards/crane/arrow_left.png:
* boards/crane/arrow_right.png:
* boards/crane/arrow_up.png:
* boards/crane/letter-a.png:
* boards/crane/letter-b.png:
* boards/crane/letter-c.png:
* boards/electric.xml.in:
* src/boards/crane.c: (draw_arrow), (place_item):
* src/boards/python/electric.py:
* src/boards/python/tuxpaint.py:
2006-01-14 Bruno coudoin <bruno.coudoin@free.fr>
Implemented a short circuit feedback by changing the battery
......
......@@ -4,7 +4,7 @@
name="awele"
type="awele"
section="/boards"
difficulty="0"
difficulty="2"
icon="boardicons/awele.png"
author="Frédéric Mazzarol"
boarddir="awele">
......
boards/crane/letter-a.png

1.36 KB | W: | H:

boards/crane/letter-a.png

2.51 KB | W: | H:

boards/crane/letter-a.png
boards/crane/letter-a.png
boards/crane/letter-a.png
boards/crane/letter-a.png
  • 2-up
  • Swipe
  • Onion skin
boards/crane/letter-b.png

1.45 KB | W: | H:

boards/crane/letter-b.png

2.78 KB | W: | H:

boards/crane/letter-b.png
boards/crane/letter-b.png
boards/crane/letter-b.png
boards/crane/letter-b.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -3,16 +3,17 @@
<Board
name="electric"
type="python:electric"
section="/"
section="/experience"
icon="boardicons/electric.png"
difficulty="0"
difficulty="5"
author="Bruno Coudoin (bruno.coudoin@free.fr)"
boarddir="">
<_title>Electric</_title>
<_description>Create and simulate electric schema</_description>
<_prerequisite></_prerequisite>
<_goal></_goal>
<_credit></_credit>
<_title>Electricity</_title>
<_description>Create and simulate an electric schema</_description>
<_prerequisite>Need some basic understanding on the electricity concept.</_prerequisite>
<_goal>Freely create an electric schema with a real time simulation of it.</_goal>
<_credit>GCompris uses the Gnucap electric simulator as a backend (&lt;http://geda.seul.org/tools/gnucap/&gt;)</_credit>
<_manual>Drag electrical component from the selector and drop them on the working area. Create wires by clicking on a connection spot and dropping on another one. You can move components by dragging them. You can delete wires by clicking on them. To delete a component, select the deletion tool on the top of the component selector. The simulation is updated in real time on any user action.</_manual>
</Board>
<Data directory=""/>
</GCompris>
......@@ -56,8 +56,30 @@
#define LEFT 2
#define RIGHT 3
#define MAX_LEVEL 6 // Don't raise this number except if putting more values in pixmap[] array, in place_item function
#define NB_ELEMENT (2 * MAX_LEVEL) + 2
#define MAX_LEVEL 6 /* Don't raise this number except if putting more values
* in pixmap[] array, in place_item function
*/
// List of images to use in the game
static gchar *imageList[] =
{
"crane/water_spot1.png",
"crane/water_spot2.png",
"crane/water_drop1.png",
"crane/water_drop2.png",
"crane/tux.png",
"crane/triangle1.png",
"crane/triangle2.png",
"crane/rectangle1.png",
"crane/rectangle2.png",
"crane/square1.png",
"crane/square2.png",
"crane/bulb.png",
"crane/letter-a.png",
"crane/letter-b.png"
};
#define NB_ELEMENT G_N_ELEMENTS(imageList)
// Types
......@@ -454,19 +476,19 @@ static void draw_arrow() {
int i;
crane_object arrow[4];
arrow[0].pixmap = gcompris_load_pixmap("crane/arrow_b.png");
arrow[0].pixmap = gcompris_load_pixmap("crane/arrow_down.png");
arrow[0].x = CRANE_BUTTON_DOWN_X;
arrow[0].y = CRANE_BUTTON_DOWN_Y;
arrow[1].pixmap = gcompris_load_pixmap("crane/arrow_u.png");
arrow[1].pixmap = gcompris_load_pixmap("crane/arrow_up.png");
arrow[1].x = CRANE_BUTTON_UP_X;
arrow[1].y = CRANE_BUTTON_UP_Y;
arrow[2].pixmap = gcompris_load_pixmap("crane/arrow_l.png");
arrow[2].pixmap = gcompris_load_pixmap("crane/arrow_left.png");
arrow[2].x = CRANE_BUTTON_LEFT_X;
arrow[2].y = CRANE_BUTTON_LEFT_Y + 2;
arrow[3].pixmap = gcompris_load_pixmap("crane/arrow_r.png");
arrow[3].pixmap = gcompris_load_pixmap("crane/arrow_right.png");
arrow[3].x = CRANE_BUTTON_RIGHT_X;
arrow[3].y = CRANE_BUTTON_RIGHT_Y - 2;
......@@ -577,26 +599,11 @@ static void draw_frame(int x, int y) {
// if active is off, the elements are unmovable, that's for the top right model
static void place_item(int x, int y, int active) {
GdkPixbuf *pixmap[NB_ELEMENT];
GdkPixbuf *pixmap;
GnomeCanvasItem *item_image = NULL;
int i;
int valeur;
pixmap[0] = gcompris_load_pixmap("crane/water_spot1.png");
pixmap[1] = gcompris_load_pixmap("crane/water_spot2.png");
pixmap[2] = gcompris_load_pixmap("crane/water_drop1.png");
pixmap[3] = gcompris_load_pixmap("crane/water_drop2.png");
pixmap[4] = gcompris_load_pixmap("crane/tux.png");
pixmap[5] = gcompris_load_pixmap("crane/triangle1.png");
pixmap[6] = gcompris_load_pixmap("crane/triangle2.png");
pixmap[7] = gcompris_load_pixmap("crane/rectangle1.png");
pixmap[8] = gcompris_load_pixmap("crane/rectangle2.png");
pixmap[9] = gcompris_load_pixmap("crane/square1.png");
pixmap[10] = gcompris_load_pixmap("crane/square2.png");
pixmap[11] = gcompris_load_pixmap("crane/bulb.png");
pixmap[12] = gcompris_load_pixmap("crane/letter-a.png");
pixmap[13] = gcompris_load_pixmap("crane/letter-b.png");
for (i = 0 ; i < CRANE_FRAME_LINE * CRANE_FRAME_COLUMN ; i ++) {
if (active) {
......@@ -609,13 +616,14 @@ static void place_item(int x, int y, int active) {
if (valeur == -1)
continue;
pixmap = gcompris_load_pixmap(imageList[valeur]);
item_image = gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
"pixbuf", pixmap[valeur],
"pixbuf", pixmap,
"x", (double) (x + 5 + ((i % CRANE_FRAME_COLUMN) * CRANE_FRAME_CELL)),
"y", (double) (y + 5 + (floor(i / CRANE_FRAME_COLUMN) * CRANE_FRAME_CELL)),
NULL);
gdk_pixbuf_unref( pixmap[valeur]);
gdk_pixbuf_unref( pixmap);
if (active)
gtk_signal_connect(GTK_OBJECT(item_image), "event", (GtkSignalFunc) item_event, NULL);
......
......@@ -113,12 +113,6 @@ class Gcompris_electric:
def pause(self, pause):
self.board_paused = pause
# Hack for widget that can't be covered by bonus and/or help
if pause:
self.entry.hide()
else:
self.entry.show()
# When the bonus is displayed, it call us first with pause(1) and then
# with pause(0)
# the game is won
......@@ -159,6 +153,11 @@ class Gcompris_electric:
# ---------------------
#
# ------------------------------------------------------------
# ------------------------------------------------------------
# ------------------------------------------------------------
# ------------------------------------------------------------
# Code that increments the sublevel and level
# And bail out if no more levels are available
# return 1 if continue, 0 if bail out
......@@ -300,8 +299,14 @@ class Gcompris_electric:
print gnucap
f.writelines(gnucap)
f.close()
output = subprocess.Popen(["/usr/bin/gnucap", "-b", filename ],
stdout=subprocess.PIPE).communicate()[0]
try:
output = subprocess.Popen(["/usr/bin/gnucap", "-b", filename ],
stdout=subprocess.PIPE).communicate()[0]
except:
gcompris.utils.dialog(_("Cannot find the 'gnucap' electric simulator.\nYou can download and install it from:\n<http://geda.seul.org/tools/gnucap/>\nInstall it to use this activity !"),
stop_board)
return
print "---------------- GNUCAP OUTPUT -----------------------------"
print output
print "------------------------------------------------------------"
......@@ -1012,7 +1017,7 @@ class Rheostat(Component):
self.item_values_x = 20
self.item_values_y = 70
self.item_values.set(fill_color="blue")
self.move(x, y)
# The wiper wire
......@@ -1042,25 +1047,37 @@ class Rheostat(Component):
self.x + 55,
self.y + 65))
def move_wiper(self, new_y):
if(new_y>self.y+self.wiper_ofset_max_y):
self.wiper_ofset_y = self.wiper_ofset_max_y
elif(new_y<self.y+self.wiper_ofset_min_y):
self.wiper_ofset_y = self.wiper_ofset_min_y
else:
self.wiper_ofset_y = new_y - self.y
self.wiper_item.set(
y = self.y + self.wiper_ofset_y,
)
self.update_wiper_wire()
self.electric.run_simulation()
# Fixme: can't connect "scroll-event" to this function
def component_scroll(self, widget, event):
if event.type == gtk.gdk.SCROLL:
if event.direction == gtk.gdk.SCROLL_UP:
self.move_wiper(self.y - 5)
elif event.type == gtk.gdk.SCROLL_DOWN:
self.move_wiper(self.y + 5)
return True
# Callback event on the wiper
def component_click(self, widget, event):
# drag and drop
if event.type == gtk.gdk.MOTION_NOTIFY:
if event.state & gtk.gdk.BUTTON1_MASK:
if(event.y>self.y+self.wiper_ofset_max_y):
self.wiper_ofset_y = self.wiper_ofset_max_y
elif(event.y<self.y+self.wiper_ofset_min_y):
self.wiper_ofset_y = self.wiper_ofset_min_y
else:
self.wiper_ofset_y = event.y - self.y
self.wiper_item.set(
y = self.y + self.wiper_ofset_y,
)
self.update_wiper_wire()
self.electric.run_simulation()
return False
self.move_wiper(event.y)
return True
# Callback event to move the component
def component_move(self, widget, event, component):
......@@ -1350,4 +1367,12 @@ class Selector:
self.offset_x = self.offset_y = 0
return True
# ------------------------------------------------------------
# ------------------------------------------------------------
# ------------------------------------------------------------
def stop_board():
gcompris.bonus.board_finished(gcompris.bonus.FINISHED_RANDOM)
......@@ -112,7 +112,7 @@ class Gcompris_tuxpaint:
pid,stdin, stdout, stderr = gcompris.spawn_async(
options, flags=2|4)
except:
gcompris.utils.dialog(_("Cannot find Tuxpaint. \n Install it to use this board !"),stop_board)
gcompris.utils.dialog(_("Cannot find Tuxpaint.\nInstall it to use this activity !"),stop_board)
return
gcompris.child_watch_add(pid, child_callback, None)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment