Intégration du système de documentation

This commit is contained in:
Philippe Roy 2022-12-16 02:09:03 +01:00
parent 387c36d2ec
commit 187668152b
3 changed files with 43 additions and 70 deletions

View File

@ -19,32 +19,32 @@ card_description ={}
# Avancer et reculer
rp_forward_title="Avancer et reculer"
rp_forward_text=" rp_avancer() \n -> Avance d'un pas en avant. \n \n rp_reculer() \n -> Recule d'un pas."
rp_forward_type="standard"
card_description.update({"forward-card" : [rp_forward_title, rp_forward_text, rp_forward_type]})
rp_forward_url=[]
card_description.update({"forward-card" : [rp_forward_title, rp_forward_text, rp_forward_url]})
# Tourner
rp_turn_title="Tourner"
rp_turn_text=" rp_gauche() \n -> Tourne à gauche (90°).\n \n rp_droite() \n -> Tourne à droite (90°)."
rp_turn_type="standard"
card_description.update({"turn-card" : [rp_turn_title, rp_turn_text, rp_turn_type]})
rp_turn_url=[]
card_description.update({"turn-card" : [rp_turn_title, rp_turn_text, rp_turn_url]})
# Baliser
rp_delineate_title="Baliser"
rp_delineate_text=" rp_marquer() \n -> Place une balise sur la case. \n \n Ropy possède que 20 balises, il ne \n peut pas en poser une de plus.\n\n Avec l'amélioration \"Balise +\", le \n nombre de balise transportées est \n étendu à 200."
rp_delineate_type="standard"
card_description.update({"delineate-card" : [rp_delineate_title, rp_delineate_text, rp_delineate_type]})
rp_delineate_url=[]
card_description.update({"delineate-card" : [rp_delineate_title, rp_delineate_text, rp_delineate_url]})
# Détecter
rp_detect_title="Détecter"
rp_detect_text=" rp_detect() \n -> Détecte un obstacle.\n \n La fonction retourne : \n - \"True\" si il a un obstacle, \n - \"False\" si il n'y a pas d'obstacle."
rp_detect_type="standard"
card_description.update({"detect-card" : [rp_detect_title, rp_detect_text, rp_detect_type]})
rp_detect_url=[]
card_description.update({"detect-card" : [rp_detect_title, rp_detect_text, rp_detect_url]})
# Radar
rp_radar_title="Radar"
rp_radar_text=" Le radar n'est toujours pas \n opérationnel ! \n \n Mais où est donc encore passé Thomas !"
rp_radar_type="mission"
card_description.update({"radar-card" : [rp_radar_title, rp_radar_text, rp_radar_type]})
rp_radar_url=[]
card_description.update({"radar-card" : [rp_radar_title, rp_radar_text, rp_radar_url]})
# Jumeau numérique
rp_twins_title="Jumeau numérique"
@ -53,18 +53,16 @@ rp_twins_text=""" Via une liaison série, Ropy peut être \n le jumeau numériqu
rp_serie_msg(texte) \n -> Envoi un message \n \n texte=rp_serie_rcpt() \n -> Reçoit un message"""
# Message envoyé (asynchrone) : \n avancer : a, reculer : r, droite : d, \n gauche g, marquer : m et forer : f \n\n\n """
rp_twins_type="standard"
card_description.update({"twins-card" : [rp_twins_title, rp_twins_text, rp_twins_type]})
rp_twins_url=[]
card_description.update({"twins-card" : [rp_twins_title, rp_twins_text, rp_twins_url]})
# Speed - Vitesse
rp_speed_title="Vitesse"
rp_speed_text=" L'amélioration \"Vitesse\" permet de \n changer la vitesse des déplacements \n par l'interface (en bas à gauche).\n\n"
rp_speed_text=rp_speed_text + " La vitesse est modifiable par codage : \n"
rp_speed_text=rp_speed_text + " rp_vitesse(nouvelle_vitesse), où \n la vitesse est une valeur de 0,1 à 10.\n\n La fonction rp_vitesse() retourne la \n vitesse actuelle."
rp_speed_store="Permet de modifier\nla vitesse des \ndéplacements."
rp_speed_purchased="Je vois ... \n l'efficacité, hein ! \n Vous verrez avec \n ces moteurs,\n c'est autre vie."
rp_speed_type="upgrade"
card_description.update({"speed-card" : [rp_speed_title, rp_speed_text, rp_speed_store, rp_speed_purchased, rp_speed_type]})
rp_speed_url=[]
card_description.update({"speed-card" : [rp_speed_title, rp_speed_text, rp_speed_url]})
# Paint - Peinture
rp_paint_title="Peinture"
@ -72,28 +70,22 @@ rp_paint_text=" rp_couleur(objets, couleur) \n -> Change la couleur du groupe \n
rp_paint_text=rp_paint_text + " - La couleur est un tuple au format \n (R,V,B,Alpha) avec des valeurs de 0 à 1.\n"
rp_paint_text=rp_paint_text + " - objets peut être : \"Rover 1\",\n \"Rover 2\", \"Rover 3\", \"Station 1\", \n \"Station 2\", \"Station 3\", \"Station 4\", \n \"Balises\" ou \"Balise 1\" à \"Balise 200\".\n\n"
rp_paint_text=rp_paint_text + " rp_couleur_init(objets) \n -> Réinitialise la couleur des objets.\n rp_couleur_init() réinitialise tout !"
rp_paint_store="On refait la déco ?"
rp_paint_purchased="Rien de tel qu'un \n peu de couleur \n dans ce monde \n de brute !"
rp_paint_type="upgrade"
card_description.update({"paint-card" : [rp_paint_title, rp_paint_text, rp_paint_store, rp_paint_purchased, rp_paint_type]})
rp_paint_url=[]
card_description.update({"paint-card" : [rp_paint_title, rp_paint_text, rp_paint_url]})
# Battery + - Batterie +
rp_battery_title="Batterie +"
rp_battery_text=" L'amélioration \"Batterie +\" permet \n d'augmenter la capacité de la batterie \n du Rover à 200 pas (contre 20 pas). \n\n"
rp_battery_text=rp_battery_text + " La fonction rp_batterie() retourne \n la charge actuelle de la batterie \n (valeur de 0 à 100 %)."
rp_battery_store="Augmente la capacité \nde la batterie à 200 \nmouvements (contre \n20, plutôt faible ...).\n\n"
rp_battery_purchased="Très bon choix ! \n Cette batterie \n vous va comme \n un gant."
rp_battery_type="upgrade"
card_description.update({"battery-card" : [rp_battery_title, rp_battery_text, rp_battery_store, rp_battery_purchased, rp_battery_type]})
rp_battery_url=[]
card_description.update({"battery-card" : [rp_battery_title, rp_battery_text, rp_battery_url]})
# Beacon + - Balise +
rp_beacon_title="Balise +"
rp_beacon_text=" L'amélioration \"Balise +\" permet \n d'augmenter le nombre de balises \n pouvant être posées à 200 (contre 20). \n\n"
rp_beacon_text=rp_beacon_text + " La fonction rp_balise() retourne \n le nombre de balises dejà posées \n lors du trajet."
rp_beacon_store="Porte le nombre de \nbalises transportées\nà 200 (contre 20)."
rp_beacon_purchased="Les colis viennent \n tout juste d'être \n livrés. Un vrai sapin de Noël, \nce terrain !"
rp_beacon_type="upgrade"
card_description.update({"beacon-card" : [rp_beacon_title, rp_beacon_text, rp_beacon_store, rp_beacon_purchased, rp_beacon_type]})
rp_beacon_url=[]
card_description.update({"beacon-card" : [rp_beacon_title, rp_beacon_text, rp_beacon_url]})
##
# Envoi des données

View File

@ -23,7 +23,9 @@ scene = bge.logic.getCurrentScene()
color_doc_chap = (0.198, 0.109, 0.8, 1) # Violet
color_doc_fct = (0.198, 0.109, 0.8, 1) # Violet
color_doc_hl = (0.8, 0.005, 0.315, 1) # Magenta
color_doc_activate = (0.936, 0.033, 1, 1) # Activé : Rose
# color_doc_activate = (0.936, 0.033, 1, 1) # Activé : Rose
color_doc_activate = (0.051, 0.270, 0.279,1) # Turquoise
# color_doc_activate = (0.936, 0.033, 1, 1) # Activé : Rose
# UPBGE constants
JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
@ -43,8 +45,8 @@ card_description.update(system.get_card_description())
# Documentation Python
###############################################################################
# python_card=["function-card", "alternative-card", "loop-card", "flow-card", "text-card", "list-card", "dict-card", "oop-card", "console-card", "sleep-card"]
python_card=["function-card", "alternative-card", "loop-card", "flow-card", "console-card", "sleep-card"]
python_card=["function-card", "alternative-card", "loop-card", "flow-card", "text-card", "list-card", "dict-card", "oop-card", "console-card", "sleep-card"]
# python_card=["function-card", "alternative-card", "loop-card", "flow-card", "console-card", "sleep-card"]
# Fonction
rp_function_title="Fonction"
@ -158,8 +160,10 @@ def init():
scene.objects['Doc_chap-python-url_title'].setVisible(False,True)
for i in range(3):
scene.objects['Doc_chap-python-url'+str(i)].setVisible(False,True)
scene.objects['Doc_chap-python-url'+str(i)+'-colbox'].suspendPhysics()
scene.objects['Doc_chap-python-url'+str(i)].color = color_doc_chap
scene.objects['Doc_chap-system-url'+str(i)].setVisible(False,True)
scene.objects['Doc_chap-system-url'+str(i)+'-colbox'].suspendPhysics()
scene.objects['Doc_chap-system-url'+str(i)].color = color_doc_chap
# Chargement du texte
@ -199,11 +203,14 @@ def open():
scene.objects['Doc_chap-'+name_chap+'-url_title'].setVisible(False,True)
for i in range(3):
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)].setVisible(False,True)
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox'].suspendPhysics()
if name_fct !="":
scene.objects['Doc_chap-'+name_chap+'-url_title'].setVisible(True,True)
for i in range(len(card_description[name_fct][2])):
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)]['Text'] = card_description[name_fct][2][i][0]
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)].setVisible(True,True)
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox'].restorePhysics()
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox']['Url'] = card_description[name_fct][2][i][1]
# Afficher le texte de la carte active
if name_chap != "general" and scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
@ -279,11 +286,11 @@ def hl (cont):
# Close ou lien
if name == "Doc_close" :
scene.objects[name].color = color_doc_hl
scene.objects[name].color = color_doc_fct
elif name == "Doc_chap-python-url0" or name == "Doc_chap-python-url1" or name == "Doc_chap-python-url2":
scene.objects[name].color = color_doc_hl
scene.objects[name].color = color_doc_fct
elif name == "Doc_chap-system-url0" or name == "Doc_chap-system-url1" or name == "Doc_chap-system-url2":
scene.objects[name].color = color_doc_hl
scene.objects[name].color = color_doc_fct
else:
if "Doc-" in name : # Chapitre
if name[4:] == scene.objects['Doc']['page_chap']:
@ -335,11 +342,14 @@ def chapter(cont):
scene.objects['Doc_chap-'+name_chap+'-url_title'].setVisible(False,True)
for i in range(3):
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)].setVisible(False,True)
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox'].suspendPhysics()
if name_fct !="":
scene.objects['Doc_chap-'+name_chap+'-url_title'].setVisible(True,True)
for i in range(len(card_description[name_fct][2])):
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)]['Text'] = card_description[name_fct][2][i][0]
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)].setVisible(True,True)
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox'].restorePhysics()
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox']['Url'] = card_description[name_fct][2][i][1]
# Afficher le texte de la carte active
if name_chap != "general" and scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
@ -419,6 +429,9 @@ def card (cont):
# Enlever l'ancienne carte
if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
text_hide(scene.objects['Doc_chap-'+name_chap]['page_fct'])
scene.objects[scene.objects['Doc_chap-'+name_chap]['page_fct']].color = color_doc_fct
scene.objects[scene.objects['Doc_chap-'+name_chap]['page_fct']+'-text'].color = color_doc_fct
scene.objects[scene.objects['Doc_chap-'+name_chap]['page_fct']+'-icon'].color = color_doc_fct
# Afficher le texte de la carte
scene.objects['Doc_chap-'+name_chap]['page_fct'] = name_fct
@ -435,11 +448,14 @@ def card (cont):
scene.objects['Doc_chap-'+name_chap+'-url_title'].setVisible(False,True)
for i in range(3):
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)].setVisible(False,True)
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox'].suspendPhysics()
if name_fct !="":
scene.objects['Doc_chap-'+name_chap+'-url_title'].setVisible(True,True)
for i in range(len(card_description[name_fct][2])):
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)]['Text'] = card_description[name_fct][2][i][0]
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)].setVisible(True,True)
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox'].restorePhysics()
scene.objects['Doc_chap-'+name_chap+'-url'+str(i)+'-colbox']['Url'] = card_description[name_fct][2][i][1]
##
# Aller à la page internet
@ -447,39 +463,4 @@ def card (cont):
def link (cont):
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
name_chap = scene.objects['Doc']['page_chap']
name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
if name_fct !="":
print (cont.owner.name[15:-7])
i= cont.owner.name[15:-7]
print (i)
webbrowser.open(card_description[name_fct][2][int(i)][1])
##
# Ouverture
##
# def open():
# scene.active_camera = scene.objects["Camera-Doc"]
# scene.objects['Doc_close'].color= color_link
# scene.objects['Doc'].setVisible(True,True)
# def close(cont):
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
# scene.active_camera = scene.objects["Camera"]
# scene.objects['Doc'].setVisible(False,True)
##
# Highlight
##
# def hl(cont):
# if cont.sensors['MO'].status == JUST_ACTIVATED:
# obj = cont.owner
# name=obj.name[:-7]
# scene.objects[name].color = color_link_hl
# if cont.sensors['MO'].status == JUST_RELEASED:
# obj = cont.owner
# name=obj.name[:-7]
# scene.objects[name].color = color_link
webbrowser.open(cont.owner['Url'])