mirror of
https://forge.apps.education.fr/blender-edutech/ropy.git
synced 2024-01-27 08:23:20 +01:00
Bugfix : affichage du texte de la documentation : duplication complète des objets
This commit is contained in:
parent
70e02bd59f
commit
b51099e1ac
BIN
ropy-30.blend
BIN
ropy-30.blend
Binary file not shown.
BIN
ropy-30.blend1
Normal file
BIN
ropy-30.blend1
Normal file
Binary file not shown.
BIN
ropy-31.blend
Normal file
BIN
ropy-31.blend
Normal file
Binary file not shown.
8
rp.py
8
rp.py
@ -133,7 +133,9 @@ def points_maj (cont):
|
||||
# Initialisation lors du chargement du terrain
|
||||
##
|
||||
|
||||
def terrain_init ():
|
||||
def terrain_init (cont):
|
||||
if cont.sensors['Init'].positive == False:
|
||||
return False
|
||||
|
||||
# Ajout du Hud
|
||||
scene.active_camera = scene.objects["Camera"]
|
||||
@ -391,7 +393,9 @@ color_cmd_hl = (0.8, 0.619, 0.021, 1) # Jaune
|
||||
# Init
|
||||
##
|
||||
|
||||
def cmd_init():
|
||||
def cmd_init(cont):
|
||||
if cont.sensors['Init'].positive == False:
|
||||
return False
|
||||
|
||||
# Taille de la fenêtre
|
||||
# Read config (screen size : data/config/screen/width-> [0][3][0].text)
|
||||
|
@ -3,9 +3,9 @@
|
||||
<speed>1.0</speed>
|
||||
<sound>False</sound>
|
||||
<cam>
|
||||
<worldPosition.x>-1.8592177629470825</worldPosition.x>
|
||||
<worldPosition.y>-33.43065643310547</worldPosition.y>
|
||||
<worldPosition.z>27.0482177734375</worldPosition.z>
|
||||
<worldPosition.x>0.0057830810546875</worldPosition.x>
|
||||
<worldPosition.y>-26.440298080444336</worldPosition.y>
|
||||
<worldPosition.z>20.22315788269043</worldPosition.z>
|
||||
</cam>
|
||||
<screen>
|
||||
<width>1280</width>
|
||||
|
218
rp_doc.py
218
rp_doc.py
@ -1,6 +1,7 @@
|
||||
import bge # Bibliothèque Blender Game Engine (UPBGE)
|
||||
import rp_map1 # Map definition
|
||||
import webbrowser
|
||||
import time
|
||||
|
||||
###############################################################################
|
||||
# rp_doc.py
|
||||
@ -256,6 +257,10 @@ def init():
|
||||
scene.objects["mission_"+str(scene.objects['Points']['mission'])+"-card-icon"].color = color_doc_mission
|
||||
scene.objects["mission_"+str(scene.objects['Points']['mission'])+"-card-text"].color = color_doc_mission
|
||||
|
||||
# Chargement du texte
|
||||
text_load()
|
||||
text_load2()
|
||||
|
||||
# Mémorisation de la position des pages
|
||||
chap=("general", "missions", "rover", "python")
|
||||
for page in chap:
|
||||
@ -277,10 +282,6 @@ def open():
|
||||
scene.objects['Doc'].worldPosition = [0, -21, 15.8]
|
||||
scene.objects['Doc_close'].color = color_doc_chap
|
||||
scene.objects['Doc'].setVisible(True,True)
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
text_clear()
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
|
||||
# Placer le nouveau chapitre
|
||||
name_chap = scene.objects['Doc']['page_chap']
|
||||
@ -289,6 +290,9 @@ def open():
|
||||
scene.objects['Doc_chap-'+name_chap].worldPosition = scene.objects['Doc'].worldPosition
|
||||
scene.objects['Doc_chap-'+name_chap].setVisible(True,True)
|
||||
|
||||
# scene.objects['Doc_text-l1-forward-card'].setVisible(True, False)
|
||||
# scene.objects['Doc_text-l1-ref'].setVisible(True, False)
|
||||
|
||||
# Affichage ou pas du bouton de selection de la mission
|
||||
if name_chap == "missions":
|
||||
name_fct = scene.objects['Doc_chap-missions']['page_fct']
|
||||
@ -325,22 +329,62 @@ def open():
|
||||
scene.objects['Book_python_url'+str(i)].setVisible(True,True)
|
||||
|
||||
# Afficher le texte de la carte active
|
||||
if name_chap != "general":
|
||||
if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
|
||||
name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_update(card_description[name_fct][1])
|
||||
else:
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
if name_chap != "general" and scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
|
||||
name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_show(name_fct)
|
||||
else:
|
||||
if name_chap != "missions":
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
else:
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
|
||||
scene.objects['Doc_text-l1-ref'].setVisible(True, False)
|
||||
print (scene.objects['Doc_text-l1-forward-card']['Text'])
|
||||
scene.objects['Doc_text-l1-forward-card'].setVisible(True, False)
|
||||
scene.objects['Doc_text-l1-forward-card'].worldPosition.x = scene.objects['Doc_text-l1-ref'].worldPosition.x
|
||||
scene.objects['Doc_text-l1-forward-card'].worldPosition.y = scene.objects['Doc_text-l1-ref'].worldPosition.y
|
||||
scene.objects['Doc_text-l1-forward-card'].worldPosition.z = scene.objects['Doc_text-l1-ref'].worldPosition.z
|
||||
|
||||
# text_load2()
|
||||
# scene.objects['Doc_text-l1-forward-card']['text_def']= scene.objects['Doc_text-l1-forward-card']['Text']
|
||||
# scene.objects['Doc_text-l1-forward-card']['redraw']=True
|
||||
|
||||
# print (scene.objects['Doc_text-l1-forward-card']['Text'])
|
||||
# old_text=scene.objects['Doc_text-l1-forward-card']['Text']
|
||||
# print (old_text)
|
||||
# scene.objects['Doc_text-l1-forward-card']['Text']="eeee"
|
||||
# scene.objects['Doc_text-l1-forward-card']['Text']=old_text
|
||||
# scene.objects['Doc_text-l1-forward-card']['Text']=" rp_avancer()"
|
||||
# scene.objects['Doc_text-l1-forward-card']['Text']=old_text
|
||||
|
||||
# doc_tempo (0.1)
|
||||
# scene.objects['Doc_text-l1-forward-card'].setVisible(False, False)
|
||||
# rp_tempo(0.1)
|
||||
# scene.objects['Doc_text-l1-forward-card'].setVisible(False, False)
|
||||
# scene.objects['Doc_text-l1-forward-card']['Text']="eeee"
|
||||
|
||||
def text_redraw(cont):
|
||||
print ("text_redraw")
|
||||
obj = cont.owner
|
||||
print (obj['text_def'] +":" + obj['Text'])
|
||||
obj['Text']= obj['text_def']
|
||||
obj.setVisible(True, False)
|
||||
print (obj['Text'])
|
||||
scene.objects['Doc_text-l1-forward-card']['redraw']=False
|
||||
scene.objects['Doc_text-l1-sleep-card']['Text']="rr"
|
||||
|
||||
# scene.objects['Doc_text-l1-forward-card']['Text']="eeee"
|
||||
# if card is None:
|
||||
# for card in card_description:
|
||||
# print ("hide:", card)
|
||||
# for i in range (13):
|
||||
# scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)].setVisible(False, False)
|
||||
# else:
|
||||
# print ("hide:", card)
|
||||
# for i in range (13):
|
||||
# scene.objects['Doc_text-l'+str(i+1)+'-'+card].setVisible(False, False)
|
||||
|
||||
|
||||
##
|
||||
# Fermeture du livre
|
||||
@ -439,7 +483,6 @@ def chapter(cont):
|
||||
# sound_play (sndbuff_book_flip)
|
||||
obj = cont.owner
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
text_clear()
|
||||
|
||||
# Enlever l'ancien chapitre
|
||||
scene.objects['Doc-'+scene.objects['Doc']['page_chap']].color = color_doc_chap
|
||||
@ -492,16 +535,13 @@ def chapter(cont):
|
||||
scene.objects['Book_python_url'+str(i)].setVisible(True,True)
|
||||
|
||||
# Afficher le texte de la carte active
|
||||
if name_chap != "general":
|
||||
if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
|
||||
name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_update(card_description[name_fct][1])
|
||||
else:
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
if name_chap != "general" and scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
|
||||
name_fct = scene.objects['Doc_chap-'+name_chap]['page_fct']
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_show(name_fct)
|
||||
else:
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
scene.objects['Doc_title'].setVisible(False,True)
|
||||
text_hide()
|
||||
|
||||
@ -509,35 +549,85 @@ def chapter(cont):
|
||||
# Cacher le texte
|
||||
##
|
||||
|
||||
def text_hide():
|
||||
for i in range (13):
|
||||
scene.objects['Doc_text-l'+str(i+1)].setVisible(False, False)
|
||||
|
||||
##
|
||||
# Effacer le texte
|
||||
##
|
||||
|
||||
def text_clear():
|
||||
for i in range (13):
|
||||
scene.objects['Doc_text-l'+str(i+1)]['Text'] = ""
|
||||
def text_hide(card=None):
|
||||
if card is None:
|
||||
for card in card_description:
|
||||
print ("hide:", card)
|
||||
for i in range (13):
|
||||
scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)].setVisible(False, False)
|
||||
else:
|
||||
print ("hide:", card)
|
||||
for i in range (13):
|
||||
scene.objects['Doc_text-l'+str(i+1)+'-'+card].setVisible(False, False)
|
||||
|
||||
##
|
||||
# Afficher le texte
|
||||
##
|
||||
|
||||
def text_update(text):
|
||||
lines = text.split("\n")
|
||||
for i in range (13):
|
||||
if i >= len(lines):
|
||||
scene.objects['Doc_text-l'+str(i+1)]['Text'] = ""
|
||||
scene.objects['Doc_text-l'+str(i+1)].setVisible(False, False)
|
||||
else:
|
||||
if len(lines[i]) ==0:
|
||||
scene.objects['Doc_text-l'+str(i+1)]['Text'] = ""
|
||||
scene.objects['Doc_text-l'+str(i+1)].setVisible(False, False)
|
||||
def text_show(card=None):
|
||||
if card is None:
|
||||
for card in card_description:
|
||||
# print ("show:", card)
|
||||
for i in range (13):
|
||||
scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)].setVisible(True, False)
|
||||
else:
|
||||
# print ("show:", card)
|
||||
lines = card_description[card][1].split("\n")
|
||||
for i in range (13):
|
||||
# print ("show avant:", scene.objects['Doc_text-l'+str(i+1)+'-'+card].name, scene.objects['Doc_text-l'+str(i+1)+'-'+card]['Text'])
|
||||
if i >= len(lines):
|
||||
text=""
|
||||
else:
|
||||
scene.objects['Doc_text-l'+str(i+1)]['Text'] = lines[i]
|
||||
scene.objects['Doc_text-l'+str(i+1)].setVisible(True, False)
|
||||
if len(lines[i]) ==0:
|
||||
text=""
|
||||
else:
|
||||
text=lines[i]
|
||||
# if scene.objects['Doc_text-l'+str(i+1)+'-'+card]['Text'] != text:
|
||||
# scene.objects['Doc_text-l'+str(i+1)+'-'+card]['Text'] = text
|
||||
print ("text", text)
|
||||
# text="hh"
|
||||
idcard="Doc_text-l"+str(i+1)+"-"+card
|
||||
scene.objects[idcard]['Text'] = str(text)
|
||||
scene.objects[idcard].setVisible(True, False)
|
||||
# print ("show après:", scene.objects['Doc_text-l'+str(i+1)+'-'+card].name, scene.objects['Doc_text-l'+str(i+1)+'-'+card]['Text'])
|
||||
|
||||
##
|
||||
# Préchargement des textes
|
||||
##
|
||||
|
||||
def text_load():
|
||||
# for i in range (13):
|
||||
# scene.objects['Doc_text-l'+str(i+1)+'-ref']['Text'] = ""
|
||||
|
||||
# Création des objets 3D
|
||||
for card in card_description:
|
||||
print ("create:", card)
|
||||
for i in range (13):
|
||||
doc_text= scene.addObject('Doc_text-l'+str(i+1), None, 0.00, True)
|
||||
# doc_text= scene.addObject('Doc_text-l'+str(i+1), scene.objects['Terrain'])
|
||||
# doc_text= scene.addObject('Doc_text-l'+str(i+1), scene.objects['Doc'] )
|
||||
doc_text.setParent(scene.objects['Doc'])
|
||||
doc_text.name = 'Doc_text-l'+str(i+1)+'-'+str(card)
|
||||
doc_text.worldPosition.x = scene.objects['Doc_text-l'+str(i+1)+'-ref'].worldPosition.x
|
||||
doc_text.worldPosition.y = scene.objects['Doc_text-l'+str(i+1)+'-ref'].worldPosition.y
|
||||
doc_text.worldPosition.z = scene.objects['Doc_text-l'+str(i+1)+'-ref'].worldPosition.z
|
||||
doc_text.setVisible(False, False)
|
||||
print ("create:", doc_text.name)
|
||||
|
||||
def text_load2():
|
||||
for card in card_description:
|
||||
lines = card_description[card][1].split("\n")
|
||||
print ("load:", lines)
|
||||
for i in range (13):
|
||||
if i >= len(lines):
|
||||
scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=""
|
||||
else:
|
||||
if len(lines[i]) ==0:
|
||||
scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=""
|
||||
else:
|
||||
scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=lines[i]
|
||||
# scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text']=str(card)
|
||||
print ("load:", scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)].name, scene.objects['Doc_text-l'+str(i+1)+'-'+str(card)]['Text'])
|
||||
|
||||
##
|
||||
# Afficher les details de la fonction à partir d'une carte
|
||||
@ -550,7 +640,6 @@ def card (cont):
|
||||
name_chap = scene.objects['Doc']['page_chap']
|
||||
name_fct= obj.name[:-7]
|
||||
scene.objects['Doc_title']['Text'] = " "
|
||||
text_clear()
|
||||
|
||||
# Enlever l'ancienne carte
|
||||
if scene.objects['Doc_chap-'+name_chap]['page_fct'] !="":
|
||||
@ -572,7 +661,7 @@ def card (cont):
|
||||
scene.objects[name_fct+'-text'].color = color_doc_activate
|
||||
scene.objects['Doc_title']['Text'] = card_description[name_fct][0]
|
||||
scene.objects['Doc_title'].setVisible(True, False)
|
||||
text_update(card_description[name_fct][1])
|
||||
text_show(name_fct)
|
||||
|
||||
# URL Python
|
||||
if name_chap == "python":
|
||||
@ -643,9 +732,26 @@ def upgrade_talk (card):
|
||||
else:
|
||||
return ""
|
||||
|
||||
##
|
||||
|
||||
###############################################################################
|
||||
# Temporisation
|
||||
###############################################################################
|
||||
|
||||
# Temporisation basée sur l'horloge de l'OS
|
||||
def doc_sleep (duration):
|
||||
time.sleep(duration)
|
||||
|
||||
# Temporisation basée par l'horloge de UPBGE
|
||||
def doc_tempo (duration):
|
||||
# time.sleep(duration*(1/scene.objects['Commands']['speed']))
|
||||
scene.objects['Commands']['time']=0
|
||||
while scene.objects['Commands']['time']<duration*(1/scene.objects['Commands']['speed']):
|
||||
print (scene.objects['Commands']['time'])
|
||||
# time.sleep(0.001)
|
||||
|
||||
###############################################################################
|
||||
# Sounds
|
||||
##
|
||||
###############################################################################
|
||||
|
||||
def sound_play (sound):
|
||||
pass # FIXME
|
||||
|
@ -1096,10 +1096,9 @@ def rp_sleep (duration):
|
||||
|
||||
# Temporisation basée par l'horloge de UPBGE
|
||||
def rp_tempo (duration):
|
||||
# time.sleep(duration*(1/scene.objects['Commands']['speed']))
|
||||
scene.objects['Commands']['time']=0
|
||||
while scene.objects['Commands']['time']<duration*(1/scene.objects['Commands']['speed']):
|
||||
# print("Temporization commands :",scene.objects['Terrain']['delay_cmd'])
|
||||
# print (scene.objects['Commands']['time']
|
||||
time.sleep(0.001)
|
||||
|
||||
###############################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user