Compare commits

...

25 Commits

Author SHA1 Message Date
Le_dahut 03a24430d0 Version avec librairie déportée.. 2015-08-28 18:50:57 +02:00
Le_dahut dd55a1cfd8 -Changement du logo
-Création d'une nouvelle animation d'introduction
-Correction de la classe graphique
-Boucle pour la création de l'interface
-Curseurs nommés
2014-11-17 23:44:48 +01:00
Le_dahut 14a654d791 Amélioration de la classe abutton afin de permettre de créer des boutons avec texte et choisir le centrage et le redimensionnement ou non de l'icone. 2014-07-01 22:32:43 +02:00
Le_dahut 7f8b8236a0 -Correction d'un bug d'enregistrement
-Lancement de la classe game lorsqu'un niveau est selectionné.
2014-06-15 23:47:58 +02:00
Le_dahut 0636650edd -Gestion de la modification des conditions de victoire par la molette 2014-06-15 23:30:57 +02:00
Le_dahut 9c9ad68a88 Ajout des effets sonores 2014-06-15 19:29:21 +02:00
Le_dahut 4306452b89 -Regroupement des fonctions de chargment dans la classe io
-Ajout de la classe video qui lance la video au lancement du jeu
-Optimisation du rafraichissement de la fenêtre des mondes
2014-06-15 19:27:05 +02:00
Le_dahut 9c86d9ace9 -Ajout effets sonores dans le menu principal
-Enregistrement des mondes dans le "shelve" dbdata lors du click sur le logo2
-Suppression de l'affichage des évènements lors du monde édition
2014-06-13 18:22:13 +02:00
Le_dahut 1a0b6f9987 -Mise à jour du TODO
-Ajout des icônes qui définissent les conditions de victoire des niveaux dans le menu principal
-Modification de la classe arect pour une gestion de différents modes d'affichage et des couches
-Suspension de la musique en mode édition pour fluidifier
-Retirer le smoothing des lignes afin de fluidifier l'affichage
-Affichage du descriptif des niveaux
2014-06-13 16:54:42 +02:00
Le_dahut eee0cd6aab -Réindentation du code avec pycharm
-Gestion de l'enregistrement des modification faites dans les champs de texte des niveaux en mode edition.
2014-06-12 23:29:07 +02:00
Le_dahut e082379433 -Correction du bogue qui empeche le lien entre plusieurs mondes
-Centrage du nom des niveaux
-Positionnement du point chaud des curseurs.
2014-06-12 20:32:05 +02:00
Le_dahut 4613faa566 Ajout de nouveaux curseurs 2014-06-10 00:48:08 +02:00
Le_dahut e192e4ebd1 Ajout de l'édition des noms de niveaux 2014-06-09 23:04:30 +02:00
Le_dahut cab2e45517 -ajout de la gestion du redimensionnement de la fenetre
-correction de plusieurs bogues
2014-06-09 19:26:39 +02:00
Le_dahut 7b0656de07 Amélioration de l'édition des mondes 2014-06-09 17:23:50 +02:00
Le_dahut b9a993bb99 -Amelioration de l'édition des liens
-Liens debutant et terminant en dehors des images de niveau
2014-06-09 15:29:48 +02:00
Le_dahut 7684f46b39 Ajout d'un mode d'édition disponible depuis le mode debug en cliquant sur le logo
Il est possible de créer des liens entre les niveaux ou de les défaire et de bouger les niveaux ainsi que les suprimer et en créer de nouveaux (limite 10).
2014-06-08 22:06:19 +02:00
Le_dahut f3238217c7 -Ajout des nom de niveau et des éléments
-Gestion de la désactivation des niveau et affichage par le cadena
-Ajout du marquage des mondes spéciaux
2014-06-06 19:13:44 +02:00
Le_dahut 49d19509bc -Ajout de la mobilité du fond
-Tout les boutons passent en surbrillance lors du passage de la souris
-Detection du clic sur les niveaux et coloration de ceux-ci au survol de la souris
-Centralisation du lancement des évènements et gestion du regroupement des évènements
2014-06-05 16:03:33 +02:00
Le_dahut 87aa26a1c2 -Oubli des 2 fonds 2014-06-05 11:24:10 +02:00
Le_dahut 473764306e -Ajout de deux images de fond
-Affichage du fond a partir de textures tuilées
-Ajout de deux handler mouse_enter et mouse_leave sur la class abutton
-Ajout de la surbrillande du bouton exit
2014-06-05 11:22:41 +02:00
Le_dahut eb6494300b -Correction et ajouts sur la classe abutton
-Reprise de l'interface de wirechem en utilisant les abuttons
2014-06-04 22:26:06 +02:00
Le_dahut cd70c0f236 -Ajout de la classe abutton qui permet de générer un élément de menu depuis une image, une couleur ou une fonction. 2014-06-04 17:02:25 +02:00
Le_dahut 21d978f459 -Creation de deux classes pour les deux fenêtre : menu principal et plateau de jeu.
-Récupération des fonction de lecture et d'écriture de données dans les "shelves".
2014-05-22 20:29:26 +02:00
Le_dahut 107ab3ca56 reprise du code...du début 2014-05-21 23:40:41 +02:00
46 changed files with 1627 additions and 1974 deletions

466
GLclass.py Normal file
View File

@ -0,0 +1,466 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
------------------------------------------
Microlinux
Classes OpenGl
(C) Copyright 2013-2014 Nicolas Hordé
------------------------------------------
'''
import datetime
import math
import copy
import random
import time
import operator
import pyglet
from GLclass import *
from pyglet.gl import *
from pyglet.window import mouse
from pyglet.window import key
from pyglet import clock
from pyglet import image
''' *********************************************************************************************** '''
''' Classes graphiques '''
#Classe comme un label avec l'attribut visible
class alabel(pyglet.text.Label):
def __init__(self, window, xx, yy, visible=True, text="", font="Deja vu sans", size=16, group=None):
self.window = window
self.font=font
self.size=size
self.visible = visible
super(alabel, self).__init__(text,x=xx,y=yy,font_name=self.font,font_size=self.size,group=group,batch=self.window.batch)
self.update(0)
def update(self,dt):
if not self.visible:
if self.x!=10000:
self.xx=self.x
self.x=10000
else:
if self.x==10000:
self.x=self.xx
self.font_size=self.size
self.font_name=self.font
# Classe d'un rectangle
class arect(object):
def __init__(self, window, x, y, width, height, visible=True, typeof=0, color=(180, 180, 180, 255), group=None):
self.window = window
self.x = x
self.y = y
self.width = width
self.height = height
self.typeof = typeof
self.color = color
self.group = group
self.visible = visible
self.update(0)
def update(self,dt):
try:
self.vertex_list.delete()
except:
foo = 0
try:
self.vertex_list2.delete()
except:
foo = 0
if self.visible and (self.typeof == "face" or self.typeof == "both"):
self.vertex_list = self.window.batch.add(4, pyglet.gl.GL_QUADS, self.group, (
'v2i', [self.x, self.y, self.x+self.width, self.y, self.x+self.width, self.y+self.height, self.x, self.y+self.height]),
('c4B', self.color * 4))
if self.visible and self.typeof == "line" or self.typeof == "both":
self.vertex_list2 = self.window.batch.add(4, pyglet.gl.GL_LINE_LOOP, self.group,
('v2i',
[self.x, self.y, self.x+self.width, self.y, self.x+self.width, self.y+self.height, self.x, self.y+self.height]),
('c3B', [self.color[0], self.color[1], self.color[2]] * 4))
#Classe d'un texte editable
class atext(object):
def __init__(self, window, x, y, width, height, visible=True, text="", font="Deja vu sans", size=10, align="center", color=(180, 180, 180, 255)):
self.evalx = x
self.evaly = y
self.x = x
self.y = y
self.window = window
if type(self.evalx) is str:
self.x = eval(self.evalx)
if type(self.evaly) is str:
self.y = eval(self.evaly)
self.loaded = ''
self.align = align
self.font = font
self.size = size
self.text = text
self.color = color
self.height = height
self.visible = visible
self.document = pyglet.text.document.FormattedDocument(text.decode("utf8"))
self.document.set_style(0, len(self.document.text),dict(font_name=self.font, font_size=self.size, color=self.color, align=self.align,
background_color=(200, 200, 200, 0)))
if height == 0:
font = self.document.get_font(0)
height = font.ascent - font.descent
self.layout = pyglet.text.layout.IncrementalTextLayout(self.document, width, height, multiline=True,
batch=self.window.batch, group=self.window.p3)
self.layout.document.register_event_type('self.on_insert_text')
self.layout.on_layout_update = self.on_layout_update
self.caret = pyglet.text.caret.Caret(self.layout)
self.caret.visible = False
self.update(0)
def update(self,dt):
self.layout.begin_update()
if type(self.evalx) is str:
self.x = eval(self.evalx)
if type(self.evaly) is str:
self.y = eval(self.evaly)
if self.visible:
self.layout.x = self.x
else:
self.layout.x = 10000
self.layout.y = self.y
#self.layout.document.text = self.text.decode('utf8')
if len(self.layout.document.text) > 0:
self.layout.document.set_style(0, len(self.layout.document.text),
dict(font_name=self.font, font_size=self.size, color=self.color, align=self.align,
background_color=(200, 200, 200, 0)))
self.layout.end_update()
def on_layout_update(self):
if self.loaded != '':
#exec (self.loaded + '="' + self.layout.document.text + '"')
self.text = self.layout.document.text
def hit_test(self, x, y):
return (0 < x - self.layout.x < self.layout.width and 0 < y - self.layout.y < self.layout.height)
#Bouton sensible a plusieurs évènements, types: function, multicon, icon, color,
# et text in,left,top,bottom,right
class abutton(object):
def update(self, dt):
if not self.hilite and dt>0:
return
try:
self.vertex_list.delete()
except:
foo = 0
try:
self.vertex_list2.delete()
except:
foo = 0
try:
self.vertex_list3.delete()
except:
foo = 0
if type(self.evalx) is str:
self.x = eval(self.evalx)
if type(self.evaly) is str:
self.y = eval(self.evaly)
if self.typeof == 'color':
if self.isvisible():
if not self.isactive():
color = (self.content[0], self.content[1], self.content[2], 127)
else:
color = (self.content[0], self.content[1], self.content[2], 255)
self.vertex_list = self.window.batch.add(4, pyglet.gl.GL_QUADS, self.window.p1,
('v2i', (self.x, self.y, self.x + self.width, self.y,
self.x + self.width, self.y + self.height, self.x,
self.y + self.height)),
('c4B', color * 4))
elif self.typeof == 'function':
self.vertex_list = eval(self.content)
else:
if self.typeof == 'multicon':
self.sprite.image = self.content[self.index]
else:
self.sprite.image = self.content
self.sprite.visible=self.isvisible()
if self.width == 0:
self.width = self.sprite.image.width
if self.height == 0:
self.height = self.sprite.image.height
if self.text!='':
self.layout.begin_update()
self.layout.document.text=self.text
self.layout.document.set_style(0, len(self.layout.document.text),dict(font_name=self.font, font_size=self.size))
self.layout.end_update()
if self.align=="top" or self.align=="bottom":
font = self.layout.document.get_font(0)
self.height+= font.ascent - font.descent
elif self.align=="left" or self.align=="right":
self.width+=self.layout.content_width
if self.width / float(self.height) < self.sprite.image.width / float(self.sprite.image.height):
self.sprite.scale = float(self.width) / self.sprite.image.width
else:
self.sprite.scale = float(self.height) / self.sprite.image.height
self.sprite.x=self.x
self.sprite.y=self.y
if not self.isactive():
self.sprite.color = (60, 60, 60)
else:
self.sprite.color = (255, 255, 255)
if self.text != '':
self.layout.begin_update()
if not self.scale:
self.sprite.scale=1
picalign="center"
if not self.isvisible():
self.layout.x=10000
elif self.align=="right":
self.sprite.x=self.x
self.sprite.y=self.y+(self.height-self.sprite.height)/2
self.layout.x=self.sprite.x+self.sprite.width
self.layout.width=self.width-self.sprite.width
self.layout.y=self.y
self.layout.height=self.height
self.layout.content_valign='center'
picalign="left"
elif self.align=="left":
self.sprite.x=self.x+self.width-self.sprite.width
self.sprite.y=self.y+(self.height-self.sprite.height)/2
self.layout.x=self.x
self.layout.width=self.width-self.sprite.width
self.layout.y=self.y
self.layout.height=self.height
self.layout.content_valign='center'
picalign="right"
elif self.align=="bottom":
self.sprite.x=self.x+(self.width-self.sprite.width)/2
self.sprite.y=self.y+self.height-self.sprite.height
self.layout.x=self.x
self.layout.width=self.width
self.layout.y=self.y
self.layout.height=self.height-self.sprite.height
self.layout.content_valign='top'
elif self.align=="in":
self.sprite.x=self.x+(self.width-self.sprite.width)/2
self.sprite.y=self.y+(self.height-self.sprite.height)/2
self.layout.x=self.x
self.layout.y=self.y
self.layout.width=self.width
self.layout.height=self.height
self.layout.content_valign='center'
else:
self.sprite.x=self.x+(self.width-self.sprite.width)/2
self.sprite.y=self.y
self.layout.x=self.x
self.layout.width=self.width
self.layout.y=self.y+self.sprite.height
self.layout.height=self.height-self.sprite.height
self.layout.content_valign='bottom'
if len(self.layout.document.text)>0:
if type(self.selected) is not list:
if self.active:
piccolor=(90, 90, 90,255)
else:
piccolor=(180, 180, 180,255)
else:
piccolor=(self.selected[0], self.selected[1], self.selected[2], 255)
self.layout.document.set_style(0, len(self.layout.document.text),
dict(font_name=self.font, font_size=self.size, color=piccolor, align=picalign,
background_color=(200, 200, 200, 0)))
self.layout.end_update()
if type(self.selected) is tuple:
color = (self.selected[0], self.selected[1], self.selected[2], 255)
self.vertex_list2 = self.window.batch.add(4, pyglet.gl.GL_LINE_LOOP, self.window.p2,
('v2i', (
self.x, self.y, self.x + self.width, self.y, self.x + self.width,
self.y + self.height, self.x, self.y + self.height)),
('c4B', color * 4))
elif type(self.selected) is list and self.isactive():
self.sprite.color = (self.selected[0], self.selected[1], self.selected[2])
if self.hilite and int(time.time()) % 2 == 0:
color = (255, 0, 0, 128)
self.vertex_list3 = self.window.batch.add(4, pyglet.gl.GL_QUADS, self.window.p2,
('v2i', (
self.x, self.y, self.x + self.width, self.y, self.x + self.width,
self.y + self.height, self.x, self.y + self.height)),
('c4B', color * 4))
def __init__(self, window, x, y, width, height, name, active=True, hilite=False, visible=True, selected=False, content=None, hint="", typeof="icon",
text="", align="left", font="Deja vu sans", size=16, scale=False):
self.name = name
self.time = 0
self.index = 0
self.enter = 0
self.window = window
self.evalx = x
self.evaly = y
self.x = x
self.y = y
self.scale=scale
self.align=align
self.font=font
self.size=size
self.width = width
self.height = height
self.active = active
self.hilite = hilite
self.visible = visible
self.content = content
self.typeof = typeof
self.hint = hint
self.text = text
self.selected = selected
self.window.push_handlers(self.on_mouse_press)
self.window.push_handlers(self.on_mouse_motion)
self.window.push_handlers(self.on_mouse_drag)
self.window.push_handlers(self.on_mouse_release)
self.window.push_handlers(self.on_mouse_scroll)
self.updateclock = clock.schedule_interval(self.update, 1)
if self.typeof=='multicon' or self.typeof=='icon':
self.sprite = pyglet.sprite.Sprite(pyglet.image.Texture.create(1,1),x=-300,y=-300, batch=self.window.batch, group=self.window.p1)
if self.text!='' or self.typeof=="text":
self.layout = pyglet.text.layout.IncrementalTextLayout(pyglet.text.document.FormattedDocument(text), 10, 10, multiline=True, batch=self.window.batch, group=self.window.p2)
self.update(0)
def delete(self):
try:
self.vertex_list.delete()
except:
foo = 0
try:
self.vertex_list2.delete()
except:
foo = 0
try:
self.vertex_list3.delete()
except:
foo = 0
try:
self.sprite.delete()
except:
foo = 0
def launch(self, state):
name = self.name.split('_')
if len(name) > 1 and hasattr(self.window, "on_mouse_" + state['event'] + "_" + name[0]) and callable(
eval("self.window.on_mouse_" + state['event'] + "_" + name[0])):
eval("self.window.on_mouse_" + state['event'] + "_" + name[0] + "(" + str(name[1]) + "," + str(state) + ")")
#print state,self.name
if hasattr(self.window, "on_mouse_" + state['event'] + "_" + self.name) and callable(
eval("self.window.on_mouse_" + state['event'] + "_" + self.name)):
if self.typeof == 'multicon':
self.index += 1
if self.index >= len(self.content):
self.index = 0
self.update(0)
eval("self.window.on_mouse_" + state['event'] + "_" + self.name + "(" + str(state) + ")")
#print state,self.name
def on_mouse_press(self, x, y, button, modifiers):
if x > self.x and y > self.y and x < self.x + self.width and y < self.y + self.height and self.isactive() and self.isvisible():
if time.time() - self.time < 0.30:
state = {'x': x, 'y': y, 'dx': 0, 'dy': 0, 'buttons': button, 'modifiers': modifiers, 'event': 'double'}
self.launch(state)
self.time = time.time()
state = {'x': x, 'y': y, 'dx': 0, 'dy': 0, 'buttons': button, 'modifiers': modifiers, 'event': 'press'}
self.launch(state)
def on_mouse_release(self, x, y, button, modifiers):
if x > self.x and y > self.y and x < self.x + self.width and y < self.y + self.height and self.isactive() and self.isvisible():
state = {'x': x, 'y': y, 'dx': 0, 'dy': 0, 'buttons': button, 'modifiers': modifiers, 'event': 'release'}
self.launch(state)
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
if x > self.x and y > self.y and x < self.x + self.width and y < self.y + self.height and self.isactive() and self.isvisible():
state = {'x': x, 'y': y, 'dx': dx, 'dy': dy, 'buttons': buttons, 'modifiers': modifiers, 'event': 'drag'}
self.launch(state)
def on_mouse_scroll(self, x, y, scroll_x, scroll_y):
if x > self.x and y > self.y and x < self.x + self.width and y < self.y + self.height and self.isactive() and self.isvisible():
state = {'x': x, 'y': y, 'dx': scroll_x, 'dy': scroll_y, 'buttons': 0, 'modifiers': 0, 'event': 'scroll'}
self.launch(state)
def on_mouse_motion(self, x, y, dx, dy):
if x > self.x and y > self.y and x < self.x + self.width and y < self.y + self.height:
if self.isvisible() and self.isactive():
if self.enter == 0:
self.enter = 1
state = {'x': x, 'y': y, 'dx': dx, 'dy': dy, 'buttons': 0, 'modifiers': 0, 'event': 'enter'}
self.launch(state)
state = {'x': x, 'y': y, 'dx': dx, 'dy': dy, 'buttons': 0, 'modifiers': 0, 'event': 'motion'}
self.launch(state)
else:
if self.enter == 1:
self.enter = 0
state = {'x': x, 'y': y, 'dx': dx, 'dy': dy, 'buttons': 0, 'modifiers': 0, 'event': 'leave'}
self.launch(state)
def setselected(self, select):
self.selected = select
self.update(0)
def isvisible(self):
if type(self.visible) is bool:
return self.visible
else:
return eval(self.visible)
def isactive(self):
if type(self.active) is bool:
return self.active
else:
return eval(self.active)
def ishilite(self):
if type(self.hilite) is bool:
return self.hilite
else:
return eval(self.hilite)
def hide(self):
if type(self.visible) is bool:
self.visible = False
self.update(0)
def show(self):
if type(self.visible) is bool:
self.visible = True
self.update(0)
def activate(self):
if type(self.active) is bool:
self.active = True
self.update(0)
def unactivate(self):
if type(self.active) is bool:
self.active = False
self.update(0)
def hilitate(self):
if type(self.hilite) is bool:
self.hilite = True
self.update(0)
def unhilitate(self):
if type(self.hilite) is bool:
self.hilite = False
self.update(0)
# Classe interface
class ainter(abutton):
def __init__(self, window, x, y, icon, comment="", text="", cmd="", font="Deja vu"):
if window.width>1800:
super(ainter,self).__init__(window, x, y, 0, 0, "item_"+str(window.count), content=icon, hint=comment, typeof="icon", text=text, align="bottom", size=16, font=font, scale=False)
elif window.width>1600:
super(ainter,self).__init__(window, x, y, 96, 0, "item_"+str(window.count), content=icon, hint=comment, typeof="icon", text=text, align="bottom", size=14, font=font, scale=True)
elif window.width>1280:
super(ainter,self).__init__(window, x, y, 64, 0, "item_"+str(window.count), content=icon, hint=comment, typeof="icon", text=text, align="bottom", size=12, font=font, scale=True)
else:
super(ainter,self).__init__(window, x, y, 48, 0, "item_"+str(window.count), content=icon, hint=comment, typeof="icon", text=text, align="bottom", size=10, font=font, scale=True)
self.cmd=cmd
window.count+=1

BIN
GLclass.pyc Normal file

Binary file not shown.

24
TODO.md
View File

@ -37,16 +37,11 @@ achats et récapituler la situation.
en évidence avec un icone biohazard. Il est impossible d'enregistrer et
le temps est limité.
#### STRUCTURE/PROGRAMMATION
* Modifier la méthode d'accès aux variables "dat" & "art".
* Optimiser le code pour rendre l'usage d'OpenGL plus efficient en
utilisant les vertex list et les batch graphic.
* Repenser le mode simulation de façon orienté objet.
* Ajouter un makefile pour automatiser la construction du programme.
* Creer un gestionnaire de zones sensibles pour gérer le menu de
selection des labos et les bulles d'aide.
#### DEVELOPPEMENT
* Finir la version avec_class qui comporte les batchs, des classes, et
la gestion objet. Modifier le tutoriel en l'orientant objet.
#### STATISTIQUES
* Gérer le stockage des statistiques de victoire dans la base de donnée
@ -60,15 +55,10 @@ selection des labos et les bulles d'aide.
#### CONCEPTION
* Finir la conception du labo N°2.
* Créer le tutoriel pour chaque niveau du monde hydrogène.
#### FONCTIONNALITES
* Ajouter un mode création de niveau qui faciliterait l'ajout
et la configuration.
* Finir la fenêtre des préférences du jeu.
* Changer la forme du curseur lors de certaines actions.
* Utiliser la molette de la souris dans le jeu.
* Mettre en évidence les raccourcis clavier dans les bulles d'aide.
#### BOGUES
@ -87,7 +77,3 @@ selection des labos et les bulles d'aide.
* Ajouter des bruitages de jeu pour rendre les simulations plus immers-
ives.
#### DOCUMENTATION/COMMUNICATION
* Améliorer les textes des documentations.

File diff suppressed because it is too large Load Diff

BIN
cursor/create.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
cursor/cross.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
cursor/delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
cursor/move.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
cursor/pointer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
cursor/text.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
dbdata

Binary file not shown.

2
dbsrc
View File

@ -1158,7 +1158,7 @@ del
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0]]}]]
[0, 0, 0, 0, 0, 0, 0, 0, 0]]}],[],[],[]]
art={
196608: {'nrj': 0, 'cout': 0, 'temp': 0, 'nom': 'null', 'color': [0, 0, 0], 'text': '', 'value': 196608, 'cat': 0, 'tech': 0, 'activable': False},
196609: {'nrj': 0, 'cout': 60, 'temp': 0.05, 'nom': 'positiver', 'color': [255, 0, 0], 'text': '+', 'value': 196609, 'cat': 1, 'tech': 2, 'activable': True},

BIN
font/password.ttf Normal file

Binary file not shown.

10
infos.html Normal file
View File

@ -0,0 +1,10 @@
<html>
<head>
</head>
<body>
<b>Version de Wirechem: V0.2a</b>
Version de d&eacute;veloppement alpha.
</body>
</html>

10
init Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
export DISPLAY=":0"
su -c "startx" wirechem &
while true
do
launch=`ps ax|grep init.py|grep python`
if [ "$launch" == "" ]; then
su -c "python /srv/init.py" wirechem
fi
done

345
init.py Normal file
View File

@ -0,0 +1,345 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
------------------------------------------
Microlinux
Programme principal
(C) Copyright 2013-2014 Nicolas Hordé
------------------------------------------
'''
import subprocess
import datetime
import math
import copy
import random
import time
import operator
import os
import sys
import socket
import httplib
import urllib
import pyglet
from GLclass import *
from pyglet.gl import *
from pyglet.window import mouse
from pyglet.window import key
from pyglet import clock
from pyglet import image
from git import Git
''' *********************************************************************************************** '''
''' initialisation '''
global debug,user,hostname
hostname=socket.getfqdn()
user=""
debug = 1
animate = 0
''' *********************************************************************************************** '''
''' Gestion du menu principal '''
#Classe du menu principal
class menu(pyglet.window.Window):
def __init__(self, *args, **kwargs):
global debug, worlds, world
super(menu, self).__init__(resizable=True, fullscreen=True, visible=True,
caption="Microlinux - Lancement")
self.set_mouse_cursor(cursors['cross'])
self.batch = pyglet.graphics.Batch()
self.p0 = pyglet.graphics.OrderedGroup(0)
self.p1 = pyglet.graphics.OrderedGroup(1)
self.p2 = pyglet.graphics.OrderedGroup(2)
self.p3 = pyglet.graphics.OrderedGroup(3)
self.p4 = pyglet.graphics.OrderedGroup(4)
self.clocks = [clock.schedule(self.draw)]
self.count=0
self.focus = None
self.icons = [ainter(self, 20, self.height-185, pyglet.resource.image('picture/restart.png'), 'Redemarre la machine instantanement.', 'Redemarrer', 'sudo reboot',font="Mechanihan")]
self.icons.extend([ainter(self, 20+self.icons[0].width*1.4, self.height-185, pyglet.resource.image('picture/eteindre.png'), "Eteindre votre ordinateur.", 'Eteindre', 'sudo halt',font="Mechanihan"),
ainter(self, 20+2*self.icons[0].width*1.4, self.height-185, pyglet.resource.image('picture/terminal.png'), "Lancement d'un terminal.", 'Terminal', 'xterm',font="Mechanihan"),
ainter(self, self.width-20-self.icons[0].width*1.4, 60+self.icons[0].width*0.6, pyglet.resource.image('picture/web.png'), 'Site internet de WireChem...', 'Site WWW', 'netsurf http://evolving.fr',font="Mechanihan"),
ainter(self, self.width-20-2*self.icons[0].width*1.4, 60+self.icons[0].width*0.6, pyglet.resource.image('picture/bug.png'), 'Soumettre un bogue ou un rapport de bêta testeur.', 'Beta-test', 'netsurf http://evolving.fr/ecrire/special.php?login=pinon&pass=poppop&where=14',font="Mechanihan"),
ainter(self, self.width-20-3*self.icons[0].width*1.4, 60+self.icons[0].width*0.6, pyglet.resource.image('picture/compte.png'), 'Votre compte...', 'Mon compte', 'netsurf http://evolving.fr',font="Mechanihan"),
ainter(self, 20, 60+self.icons[0].width*0.6, pyglet.resource.image('picture/wirechem.png'), "Lancer le jeu WireChem", 'WireChem', '/srv/launch',font="Mechanihan"),
ainter(self, self.width-400-self.icons[0].width*1.4, self.height-185, pyglet.resource.image('picture/musique.png'), "Réglage du son.", 'Son...', 'gnome-alsamixer',font="Mechanihan"),
ainter(self, self.width-400-2*self.icons[0].width*1.4, self.height-185, pyglet.resource.image('picture/net.png'), "Réglage du Réseau.", 'Reseau...', '/srv/network',font="Mechanihan"),
ainter(self, self.width-400-3*self.icons[0].width*1.4, self.height-185, pyglet.resource.image('picture/ecran.png'), "Configuration des options vidéo.", 'Video...', 'arandr',font="Mechanihan"),
ainter(self, 20, self.height/2-40, pyglet.resource.image('picture/info.png'), "Information sur la version du logiciel WireChem.", 'Informations', 'netsurf file:///srv/infos.html',font="Mechanihan")])
self.rects=[arect(self,10, 10, self.width-20,125, typeof="both", color=(100,100,100,200), group=self.p3)]
self.hostname=alabel(self,10,self.height-15,text=hostname,font='Deja vu',size=12,group=self.p4)
self.dialog=[alabel(self,self.width-380,self.height-60,text='identifiant :',font='Deja vu',size=16,group=self.p4,visible=False),
alabel(self,self.width-380,self.height-120,text='mot de passe :',font='Deja vu',size=16,group=self.p4,visible=False),
atext(self,self.width-215,self.height-65,170,0,text="",font='Deja vu',align="left",size=16,visible=False),
atext(self,self.width-215,self.height-125,170,0,text="",font='password',align="left",size=16,visible=False),
abutton(self,self.width-190, self.height-195,0,0,"connect",content=pyglet.resource.image('picture/connexion.png'),typeof="icon",visible=False),
arect(self,self.width-400,self.height-230,390,220,typeof="face", color=(100,100,100,200), group=self.p3,visible=False),
arect(self,self.width-218,self.height-65,175,25,typeof="face", color=(150,150,150,255), group=self.p2,visible=False),
arect(self,self.width-218,self.height-125,175,25,typeof="face", color=(150,150,150,255), group=self.p2,visible=False)]
self.dialog[4].sprite.group=self.p4
self.dialog2=[alabel(self,0,0,text='',font='Deja vu',size=16,group=self.p4,visible=False),
abutton(self, 0, 0,0,0,"deconnect",content=pyglet.resource.image('picture/deconnexion.png'),typeof="icon",visible=False),
arect(self,0,0,290,90,typeof="face", color=(100,100,100,200), group=self.p2,visible=False)]
self.dialog2[1].sprite.group=self.p4
self.infos=[atext(self, 10, 10, self.width-10, 125, font="Mechanihan", size=18, align="left")]
self.fond = abutton(self, "(self.window.width-800)/2", "(self.window.height-175+125)/2", 0, 0,"fond",content=pyglet.resource.image('picture/logo3.png'),typeof='icon')
self.fond.sprite.group=self.p0
self.setfocus(self.dialog[2])
self.icons[4].visible=False
self.icons[5].visible=False
self.icons[4].update(0)
self.icons[5].update(0)
self.update(0)
self.geticons()
def geticons(self):
global user
ui = Git(".")
try:
version_temp=ui.ls_remote("git://github.com/dahut87/WireChem.git")
version=version_temp.replace('\n','\t').split('\t')
add=0
for i in range(len(version)):
if i%2==1 and version[i]!="HEAD" and '^' not in version[i]:
add+=1
self.icons.append(ainter(self, 20+add*(self.icons[0].width*1.4), 60+self.icons[0].width*0.6, pyglet.resource.image('picture/git.png'), "Lancer le jeu WireChem dans une version particulière de développement.", os.path.basename(version[i]), 'xterm -e /srv/launch '+os.path.basename(version[i]),font="Mechanihan"))
self.icons.append(ainter(self, self.width-20-self.icons[0].width*1.4, self.height/2-40, pyglet.resource.image('picture/connect.png'), "Le système est connecté au réseau et opérationnel, double cliquez pour rafraichir !", "Connecte", 'killall python',font="Mechanihan"))
except:
self.icons.append(ainter(self, self.width-20-self.icons[0].width*1.4, self.height/2-40, pyglet.resource.image('picture/disconnect.png'), "Le système n'est pas convenablement connecté au réseau, double cliquez pour réessayer !", "Deconnecte", 'killall python',font="Mechanihan"))
def update(self, what):
global user
if user!="":
self.hidemdp()
self.showlog()
else:
self.hidelog()
self.showmdp()
def connectsite(self, user, password):
print user,password
params = urllib.urlencode({'login': user, 'pass': password})
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn = httplib.HTTPConnection("wirechem.dahut.fr:80")
conn.request("POST", "/ecrire/special.php", params, headers)
response = conn.getresponse()
state=''
if response.status==200:
state = response.read()
conn.close()
if state=="1":
return True
else:
return False
def draw(self, dt):
glClear(GL_COLOR_BUFFER_BIT)
self.batch.draw()
def hidemdp(self):
for i in range(len(self.dialog)):
self.dialog[i].visible=False
self.dialog[i].update(0)
def showmdp(self):
for i in range(len(self.dialog)):
self.dialog[i].visible=True
self.dialog[i].update(0)
self.setfocus(self.dialog[2])
def showlog(self):
global user
self.dialog2[0].visible=True
self.dialog2[0].text=user
self.dialog2[0].x=self.width+(self.dialog2[0].content_width-300)/2-self.dialog2[0].content_width
self.dialog2[0].y=self.height-35
self.dialog2[1].visible=True
self.dialog2[1].x=self.width-self.dialog2[1].width-62
self.dialog2[1].y=self.height-85
self.dialog2[1].update(0)
self.dialog2[2].visible=True
self.dialog2[2].x=self.width-300
self.dialog2[2].y=self.height-100
self.dialog2[2].update(0)
def hidelog(self):
for i in range(len(self.dialog2)):
self.dialog2[i].visible=False
self.dialog2[i].update(0)
def anime(self,dt):
global animate
if animate==0:
self.infos[0].text="Mot de passe incorrect !! Veuillez retaper votre mot de passe s'il vous plait."
self.infos[0].update(0)
animate=16*math.pi
animate-=math.pi/4
if animate>0:
clock.schedule_once(self.anime,0.02)
else:
animate=0
self.infos[0].text=" "
self.infos[0].update(0)
for i in range(len(self.dialog)):
self.dialog[i].x+=int(5*math.sin(animate))
if hasattr(self.dialog[i],"update"):
self.dialog[i].update(0)
### Evenements ###
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
if self.focus:
self.focus.caret.on_mouse_drag(x, y, dx, dy, buttons, modifiers)
def on_mouse_press(self, x, y, button, modifiers):
for widget in [self.dialog[2],self.dialog[3]]:
if widget.hit_test(x, y):
self.setfocus(widget)
break
else:
self.setfocus(None)
if self.focus:
self.focus.caret.on_mouse_press(x, y, button, modifiers)
def on_mouse_motion(self, x, y, dx, dy):
for widget in [self.dialog[2],self.dialog[3]]:
if widget.hit_test(x, y):
self.set_mouse_cursor(cursors["text"])
break
else:
self.set_mouse_cursor(cursors["cross"])
def on_text(self, text):
if self.focus:
self.focus.caret.on_text(text)
def on_text_motion(self, motion):
if self.focus:
self.focus.caret.on_text_motion(motion)
def on_text_motion_select(self, motion):
if self.focus:
self.focus.caret.on_text_motion_select(motion)
def on_key_press(self, symbol, modifiers):
global user
if symbol == pyglet.window.key.TAB:
if modifiers & pyglet.window.key.MOD_SHIFT:
dir = -1
else:
dir = 1
all=(self.dialog[2],self.dialog[3])
if self.focus in all:
i = all.index(self.focus)
else:
i = 0
dir = 0
self.setfocus(all[(i + dir) % len(all)])
elif symbol == key.ESCAPE:
if debug==0:
return pyglet.event.EVENT_HANDLED
else:
pyglet.app.exit()
elif symbol == key.F5:
self.close()
launch()
elif symbol == key.ENTER:
if user=="":
self.on_mouse_press_connect([])
def setfocus(self, focus):
if self.focus:
self.focus.caret.visible = False
self.focus.caret.mark = self.focus.caret.position = 0
self.focus = focus
if self.focus:
self.focus.caret.visible = True
self.focus.caret.mark = 0
self.focus.caret.position = len(self.focus.document.text)
### Evenement générer par classe abutton ###
def on_mouse_press_deconnect(self, state):
global user
user=""
self.icons[len(self.icons)-1].content=pyglet.resource.image('picture/connect2.png')
self.icons[len(self.icons)-1].update(0)
self.update(0)
def on_mouse_press_connect(self, state):
global user
if animate>0:
return
if self.connectsite(self.dialog[2].layout.document.text,self.dialog[3].layout.document.text):
user=self.dialog[2].layout.document.text
self.icons[len(self.icons)-1].content=pyglet.resource.image('picture/connect2.png')
self.icons[len(self.icons)-1].update(0)
self.update(0)
else:
user=''
self.anime(0.02)
def on_mouse_enter_item(self, n, state):
self.infos[0].text=self.icons[n].hint
self.infos[0].update(0)
self.set_mouse_cursor(cursors['pointer'])
self.icons[n].setselected([255, 120, 120])
def on_mouse_leave_item(self, n, state):
self.infos[0].text=" "
self.infos[0].update(0)
self.set_mouse_cursor(cursors['cross'])
self.icons[n].setselected(False)
def on_mouse_release_item(self, n, state):
self.set_mouse_cursor(cursors['cross'])
def on_mouse_double_item(self, n, state):
process = subprocess.Popen(self.icons[n].cmd.split(" "))
self.close()
process.wait()
launch()
def on_mouse_drag_item(self, n, state):
self.set_mouse_cursor(cursors['move'])
self.icons[n].x += state['dx']
self.icons[n].y += state['dy']
if state['dx']<0 and self.icons[n].x<20 : self.icons[n].x=0
if state['dx']>0 and self.icons[n].x>self.width-self.icons[n].width-20 : self.icons[n].x=self.width-self.icons[n].width
if state['dy']<0 and self.icons[n].y<20-self.icons[n].height : self.icons[n].y=0
if state['dy']>0 and self.icons[n].y>self.height-self.icons[n].height-20 : self.icons[n].y=self.height-self.icons[n].height
print str(self.icons[n].y)+","+str(self.icons[n].x)
self.icons[n].update(0)
def launch():
menu_principal = menu()
menu_principal.set_minimum_size(1024, 768)
glEnable(GL_BLEND)
#glEnable(GL_LINE_SMOOTH)
#glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
pyglet.app.run()
''' *********************************************************************************************** '''
''' Lancement du menu principal
'''
pyglet.resource.add_font('font/Mecanihan.ttf')
pyglet.resource.add_font('font/password.ttf')
cursors = {'pointer':pyglet.window.ImageMouseCursor(pyglet.resource.image('cursor/pointer.png'), 15, 46),
'text':pyglet.window.ImageMouseCursor(pyglet.resource.image('cursor/text.png'), 24, 30),
'move':pyglet.window.ImageMouseCursor(pyglet.resource.image('cursor/move.png'), 24, 24),
'create':pyglet.window.ImageMouseCursor(pyglet.resource.image('cursor/create.png'), 12, 17),
'cross':pyglet.window.ImageMouseCursor(pyglet.resource.image('cursor/cross.png'), 24, 33),
'delete':pyglet.window.ImageMouseCursor(pyglet.resource.image('cursor/delete.png'), 24, 32)}
launch()

9
launch Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ "$1" == "" ]; then
cd /srv/WireChem
python WireChem.py
else
git clone -b $1 git://github.com/dahut87/WireChem.git /srv/_version_$1
cd /srv/_version_$1
python WireChem.py
fi

BIN
logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 20 KiB

79
menu.py
View File

@ -1,79 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
------------------------------------------
WireChem - The new chemistry game
Programme lancement
(C) Copyright 2013-2014 Nicolas Hordé
Licence GPL V3.0
------------------------------------------
'''
import os;
while True:
os.system("clear")
print'''-------------------------------------------
WireChem - The new chemistry game
Menu principal
(C) Copyright 2013-2014 Nicolas Hordé
Licence GPL V3.0
------------------------------------------
1) Lancer Wirechem depuis le CD/DVD
2) Récupérer une version depuis le réseau
3) Lancer une autre version
4) Eteindre l'ordinateur
5) Redemarrer l'ordinateur
'''
alocal=raw_input('Que souhaitez vous faire ? : ')
if alocal=="1":
os.system('python WireChem.py')
elif alocal=="2":
os.system("clear")
print "vérifiez que vous êtes bien connecté à internet..."
print "Récupération des version depuis https://github.com/dahut87/WireChem.git..."
tag=['master']
tags=os.popen('git ls-remote --tags https://github.com/dahut87/WireChem.git').read().split('\n')
for i in range(len(tags)):
if tags[i][41:51]=='refs/tags/': tag.append(tags[i][51:].replace('^{}',''))
tag=sorted(list(set(tag)),None,None,True)
for i in range(len(tag)):
print str(i)+") "+tag[i]
alocal=raw_input(str(len(tag))+" versions trouvées, choisissez celle que vous souhaitez récupérer: ")
if alocal=="": continue
version=tag[int(alocal)]
if os.system('git clone -b '+version+' https://github.com/dahut87/WireChem.git _version_'+version)==0:
os.system("cd _version_"+version+" && python WireChem.py")
else:
alocal=raw_input("Une erreur est apparue, le dossier existe déjà ou vous n'êtes plus connecté ! Appuyer sur O pour essayer de lancer.")
if alocal.lower()=="o":
os.system("cd _version_"+version+" && python WireChem.py")
elif alocal=="3":
os.system("clear")
print "Recherche des version déjà récupérée..."
dir=os.listdir(".")
num=0
vers=[]
for i in range(len(dir)):
if dir[i][:9]=="_version_":
vers.append(dir[i])
print str(num)+") "+dir[i][9:]
num+=1
if num==0:
print "aucune version installée...<appuyez sur une touche>"
raw_input()
else:
alocal=raw_input(str(num)+" versions trouvées, choisissez celle que vous souhaitez récupérer: ")
if alocal=="": continue
os.system("cd "+vers[int(alocal)]+" && python WireChem.py")
elif alocal=="4":
os.system("halt")
elif alocal=="5":
os.system("reboot")

BIN
movie/intro.mp4 Normal file → Executable file

Binary file not shown.

Binary file not shown.

5
network Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
export XAUTHORITY="/home/wirechem/.Xauthority"
export DISPLAY=":0"
sudo network-config

BIN
picture/bug.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
picture/compte.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
picture/connect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
picture/connect2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
picture/connexion.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
picture/deconnexion.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
picture/disconnect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
picture/ecran.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
picture/eteindre.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
picture/fond.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

BIN
picture/fond2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

BIN
picture/git.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

BIN
picture/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
picture/logo3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
picture/musique.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
picture/net.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
picture/restart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
picture/terminal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
picture/web.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

BIN
picture/wirechem.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
sound/lightning1.wav Normal file

Binary file not shown.

BIN
sound/lightning3.wav Normal file

Binary file not shown.

BIN
sound/pickup1.wav Normal file

Binary file not shown.