Transport du fichier de configuration dans le répertoire de travail

This commit is contained in:
Philippe Roy 2023-02-06 14:40:00 +01:00
parent 53c7cac39b
commit b42038b61a
7 changed files with 162 additions and 151 deletions

Binary file not shown.

295
rp.py
View File

@ -3,11 +3,9 @@ import bpy # Blender
import aud # Sounds import aud # Sounds
import math import math
import mathutils import mathutils
# import numpy as np
import time import time
import sys import sys
import os import os
# import webbrowser # Lien internet
import threading # Multithreading import threading # Multithreading
import subprocess # Multiprocessus import subprocess # Multiprocessus
import xml.etree.ElementTree as ET # Creating/parsing XML file import xml.etree.ElementTree as ET # Creating/parsing XML file
@ -37,17 +35,17 @@ import rp_about # About
# 3D scene manipulation : manip_* # 3D scene manipulation : manip_*
############################################################################### ###############################################################################
# Debug flag # UPBGE scene
scene = bge.logic.getCurrentScene() scene = bge.logic.getCurrentScene()
scene.objects['Commands']['debug_fps']=False eevee = bpy.context.scene.eevee
scene.objects['Commands']['script'] = os.path.join(os.getcwd(), "rp_cmd.py") # Script par défaut scene.objects['Commands']['script'] = os.path.join(os.getcwd(), "rp_cmd.py") # Script par défaut
# Memory # Memory
sys.setrecursionlimit(10**5) # Limite sur la récursivité (valeur par défaut : 1000) -> segfault de Blender sys.setrecursionlimit(10**5) # Limite sur la récursivité (valeur par défaut : 1000) -> segfault de Blender
# UPBGE scene # FPS
eevee = bpy.context.scene.eevee
fps_time=0.0 fps_time=0.0
scene.objects['Commands']['debug_fps']=False
# Config file # Config file
rp_config = ET.parse('rp_config.xml') rp_config = ET.parse('rp_config.xml')
@ -108,11 +106,10 @@ def points_maj (cont):
scene.objects['Book_level']['Text'] = "Niveau actuel : "+str(scene.objects['Points']['level']) scene.objects['Book_level']['Text'] = "Niveau actuel : "+str(scene.objects['Points']['level'])
# Maj du fichier de config (sound : data/mission/level -> [1][1].text) lors d'une augmentation de niveau # Maj du fichier de config (sound : data/mission/level -> [1][1].text) lors d'une augmentation de niveau
if scene.objects['Points']['level']>int(rp_config_tree[1][1].text): if scene.objects['Points']['level']>int(rp_config_tree[1][1].text) and scene.objects['Points']['level_new_flag']:
rp_config_tree[1][1].text=str(scene.objects['Points']['level']) rp_config_tree[1][1].text=str(scene.objects['Points']['level'])
buffer_xml = ET.tostring(rp_config_tree) config_save()
with open("rp_config.xml", "wb") as f: scene.objects['Points']['level_new_flag']=False
f.write(buffer_xml)
# Nbligne # Nbligne
if scene.objects['Points-Nbligne-text']['Text']!=str(scene.objects['Points']['nbligne']): if scene.objects['Points-Nbligne-text']['Text']!=str(scene.objects['Points']['nbligne']):
@ -121,7 +118,7 @@ def points_maj (cont):
# Position du Rover # Position du Rover
obj=scene.objects['Rover'] obj=scene.objects['Rover']
obj['w_position']=str(round(obj.worldPosition.x,3))+","+str(round(obj.worldPosition.y,3))+","+str(round(obj.worldPosition.z,3)) obj['w_position']=str(round(obj.worldPosition.x,3))+","+str(round(obj.worldPosition.y,3))+","+str(round(obj.worldPosition.z,3))
############################################################################### ###############################################################################
# Terrain # Terrain
############################################################################### ###############################################################################
@ -233,6 +230,10 @@ def python_validation(file):
scene.objects['Cmd-text'].setVisible(False,False) scene.objects['Cmd-text'].setVisible(False,False)
return True return True
##
# Exécuter le script
##
def terrain_run (): def terrain_run ():
# Pause # Pause
@ -316,12 +317,6 @@ def terrain_speed (obj):
scene.objects['Commands']['speed']=speed_mode[i-1] scene.objects['Commands']['speed']=speed_mode[i-1]
scene.objects['Text_speed']['Text']=speed_mode_txt[i-1] scene.objects['Text_speed']['Text']=speed_mode_txt[i-1]
# Maj du fichier de config (vitesse du jeu : data/config/speed -> [0][0].text)
rp_config_tree[0][0].text=str(scene.objects['Commands']['speed'])
buffer_xml = ET.tostring(rp_config_tree)
with open("rp_config.xml", "wb") as f:
f.write(buffer_xml)
## ##
# Grille # Grille
## ##
@ -375,12 +370,6 @@ def sound_set ():
scene.objects['Cmd-text']['Text']= "Muet" scene.objects['Cmd-text']['Text']= "Muet"
# scene.objects['Cmd-text'].setVisible(True,False) # scene.objects['Cmd-text'].setVisible(True,False)
# Maj du fichier de config (sound : data/config/sound -> [0][1].text)
rp_config_tree[0][1].text=str(scene.objects['Commands']['sound'])
buffer_xml = ET.tostring(rp_config_tree)
with open("rp_config.xml", "wb") as f:
f.write(buffer_xml)
def sound_unset (): def sound_unset ():
scene.objects['Sound-cmd'].suspendPhysics() scene.objects['Sound-cmd'].suspendPhysics()
scene.objects['Sound-cmd'].setVisible(False,False) scene.objects['Sound-cmd'].setVisible(False,False)
@ -392,12 +381,6 @@ def sound_unset ():
scene.objects['Cmd-text']['Text']= "Rétablir le son" scene.objects['Cmd-text']['Text']= "Rétablir le son"
# scene.objects['Cmd-text'].setVisible(True,False) # scene.objects['Cmd-text'].setVisible(True,False)
# Maj du fichier de config (sound : data/config/sound -> [0][1].text)
rp_config_tree[0][1].text=str(scene.objects['Commands']['sound'])
buffer_xml = ET.tostring(rp_config_tree)
with open("rp_config.xml", "wb") as f:
f.write(buffer_xml)
############################################################################### ###############################################################################
# Commandes # Commandes
############################################################################### ###############################################################################
@ -478,17 +461,6 @@ def cmd_init(cont):
scene.objects['Mouse_main'].setVisible(False,False) scene.objects['Mouse_main'].setVisible(False,False)
bge.render.showMouse(True) bge.render.showMouse(True)
# Speed
# Read config (game speed : data/config/speed -> [0][0].text)
speed_mode=[0.25, 0.5, 1,2,4,10]
speed_mode_txt=["1/4", "1/2", "1", "2","4","10"]
if scene.objects['Points']['upgrade_speed'] :
scene.objects['Commands']['speed']=float(rp_config_tree[0][0].text)
else:
scene.objects['Commands']['speed']=1.00
i=speed_mode.index(scene.objects['Commands']['speed'])
scene.objects['Text_speed']['Text']=speed_mode_txt[i]
# Missions # Missions
# Read config (mission actuelle : data/mission/current -> [1][0].text) # Read config (mission actuelle : data/mission/current -> [1][0].text)
# Read config (niveau atteint : data/mission/level -> [1][1].text) # Read config (niveau atteint : data/mission/level -> [1][1].text)
@ -500,8 +472,28 @@ def cmd_init(cont):
scene.objects['Book_level']['Text'] = "Niveau actuel : "+str(scene.objects['Points']['level']) scene.objects['Book_level']['Text'] = "Niveau actuel : "+str(scene.objects['Points']['level'])
# Upgrade # Upgrade
# Read config (upgrades choisis : data/upgrade/ -> [2][i].text)
upgrade_card=("battery", "beacon", "paint", "speed")
scene.objects['Points']['upgrade_nb'] =0
for i in range(len(upgrade_card)):
if rp_config_tree[2][i].text == "True":
scene.objects['Points']['upgrade_'+upgrade_card[i]]=True
scene.objects['Points']['upgrade_nb'] +=1
scene.objects["Store-"+upgrade_card[i]+"-card"]['upgraded'] = True
scene.objects['Points']['upgrade_credit']= scene.objects['Points']['level']- 1 - scene.objects['Points']['upgrade_nb']
upgrade_maj() upgrade_maj()
# Speed
# Read config (game speed : data/config/speed -> [0][0].text)
speed_mode=[0.25, 0.5, 1,2,4,10]
speed_mode_txt=["1/4", "1/2", "1", "2","4","10"]
if scene.objects['Points']['upgrade_speed'] :
scene.objects['Commands']['speed']=float(rp_config_tree[0][0].text)
else:
scene.objects['Commands']['speed']=1.00
i=speed_mode.index(scene.objects['Commands']['speed'])
scene.objects['Text_speed']['Text']=speed_mode_txt[i]
# Windows # Windows
windows=("Doc", "Doc_chap-general", "Doc_chap-missions", "Doc_chap-rover", "Doc_chap-python", "About", "Task") windows=("Doc", "Doc_chap-general", "Doc_chap-missions", "Doc_chap-rover", "Doc_chap-python", "About", "Task")
for window in windows: for window in windows:
@ -711,21 +703,25 @@ def mode(cont):
else: # Sortir du jeu else: # Sortir du jeu
terrain_stop () terrain_stop ()
# Maj du fichier de config (position de la camera : data/config/cam_x,y,z -> [0][2][0].text, [0][2][1].text, [0][2][2].text) # MAJ du fichier de config
# Position de la camera : data/config/cam_x,y,z -> [0][2][0].text, [0][2][1].text, [0][2][2].text)
rp_config_tree[0][2][0].text=str(scene.objects['Camera']['current_lx']) rp_config_tree[0][2][0].text=str(scene.objects['Camera']['current_lx'])
rp_config_tree[0][2][1].text=str(scene.objects['Camera']['current_ly']) rp_config_tree[0][2][1].text=str(scene.objects['Camera']['current_ly'])
rp_config_tree[0][2][2].text=str(scene.objects['Camera']['current_lz']) rp_config_tree[0][2][2].text=str(scene.objects['Camera']['current_lz'])
# Ecran : data/config/screen/width, height, quality-> [0][3][0].text, [0][3][1].text, [0][3][2].text)
# Maj du fichier de config (screen size : data/config/screen/width, height, quality-> [0][3][0].text, [0][3][1].text, [0][3][2].text)
screen_width = bge.render.getWindowWidth() screen_width = bge.render.getWindowWidth()
screen_height = bge.render.getWindowHeight() screen_height = bge.render.getWindowHeight()
rp_config_tree[0][3][0].text=str(screen_width) rp_config_tree[0][3][0].text=str(screen_width)
rp_config_tree[0][3][1].text=str(screen_height) rp_config_tree[0][3][1].text=str(screen_height)
rp_config_tree[0][3][2].text=str(scene.objects['About']['quality']) rp_config_tree[0][3][2].text=str(scene.objects['About']['quality'])
# Son : data/config/sound -> [0][1].text
buffer_xml = ET.tostring(rp_config_tree) rp_config_tree[0][1].text=str(scene.objects['Commands']['sound'])
with open("rp_config.xml", "wb") as f: # Vitesse du jeu : data/config/speed -> [0][0].text)
f.write(buffer_xml) rp_config_tree[0][0].text=str(scene.objects['Commands']['speed'])
# Mission et level : data/mission/level -> [1][0].text, [1][1].text)
rp_config_tree[1][0].text=str(scene.objects['Points']['mission'])
rp_config_tree[1][1].text=str(scene.objects['Points']['level'])
config_save()
# Sortir # Sortir
bge.logic.endGame() bge.logic.endGame()
@ -1039,7 +1035,6 @@ def tablet_open ():
scene.objects['Commands'].setVisible(False,True) scene.objects['Commands'].setVisible(False,True)
scene.active_camera = scene.objects["Camera-Hud"] scene.active_camera = scene.objects["Camera-Hud"]
scene.objects['Camera'].setVisible(False,True) scene.objects['Camera'].setVisible(False,True)
scene.objects['Doc-cmd-colbox'].suspendPhysics (True) scene.objects['Doc-cmd-colbox'].suspendPhysics (True)
# Ouvrir la tablette # Ouvrir la tablette
@ -1055,9 +1050,8 @@ def tablet_close ():
# Maj du fichier de config (mission actuelle : data/mission/current -> [1][0].text) # Maj du fichier de config (mission actuelle : data/mission/current -> [1][0].text)
rp_config_tree[1][0].text=str(scene.objects['Points']['mission']) rp_config_tree[1][0].text=str(scene.objects['Points']['mission'])
buffer_xml = ET.tostring(rp_config_tree) print ("tablet close")
with open("rp_config.xml", "wb") as f: config_save()
f.write(buffer_xml)
# Overlay # Overlay
scene.objects['Points'].setVisible(True,True) scene.objects['Points'].setVisible(True,True)
@ -1234,16 +1228,9 @@ def task_close_click(cont):
def upgrade_maj(): def upgrade_maj():
# Read config (upgrades choisis : data/upgrade/ -> [2][i].text) print ("upgrade_maj")
upgrade_card=("battery", "beacon", "paint", "speed") print ("speed : ", scene.objects['Points']['upgrade_speed'])
scene.objects['Points']['upgrade_nb'] =0
for i in range(len(upgrade_card)):
if rp_config_tree[2][i].text == "True":
scene.objects['Points']['upgrade_'+upgrade_card[i]]=True
scene.objects['Points']['upgrade_nb'] +=1
scene.objects["Store-"+upgrade_card[i]+"-card"]['upgraded'] = True
scene.objects['Points']['upgrade_credit']= scene.objects['Points']['level']- 1 - scene.objects['Points']['upgrade_nb']
# Batterie # Batterie
if scene.objects['Points']['upgrade_battery'] : if scene.objects['Points']['upgrade_battery'] :
scene.objects['St-Panels-3'].setVisible(True,True) scene.objects['St-Panels-3'].setVisible(True,True)
@ -1294,7 +1281,6 @@ def store_open ():
def store_close(): def store_close():
rp_store.close() rp_store.close()
scene.objects['Terrain']['manip_mode']=0 # Enlever la fenêtre modale scene.objects['Terrain']['manip_mode']=0 # Enlever la fenêtre modale
# Maj du fichier de config (upgrade : data/upgrade/i -> [2][i].text) # Maj du fichier de config (upgrade : data/upgrade/i -> [2][i].text)
upgrade_card=("battery", "beacon", "paint", "speed") upgrade_card=("battery", "beacon", "paint", "speed")
for i in range(len(upgrade_card)): for i in range(len(upgrade_card)):
@ -1302,9 +1288,8 @@ def store_close():
rp_config_tree[2][i].text="True" rp_config_tree[2][i].text="True"
else: else:
rp_config_tree[2][i].text="False" rp_config_tree[2][i].text="False"
buffer_xml = ET.tostring(rp_config_tree) print ("store close")
with open("rp_config.xml", "wb") as f: config_save()
f.write(buffer_xml)
# Overlay # Overlay
scene.objects['Points'].setVisible(True,True) scene.objects['Points'].setVisible(True,True)
@ -1351,7 +1336,6 @@ def store_close():
scene.objects['Task-cmd'].restorePhysics() scene.objects['Task-cmd'].restorePhysics()
scene.objects['Task-cmd-Hl'].setVisible(False,True) scene.objects['Task-cmd-Hl'].setVisible(False,True)
# Maj de l'interface # Maj de l'interface
upgrade_maj() upgrade_maj()
@ -1372,6 +1356,10 @@ def store_close_click(cont):
# Fichier # Fichier
############################################################################### ###############################################################################
##
# Sélectionner le fichier de commandes
##
def file_open(): def file_open():
# Terminer le processus file précédent # Terminer le processus file précédent
@ -1385,11 +1373,106 @@ def file_open():
else: # Qt5 ne s'installe pas bien sur Windows -> wxPython else: # Qt5 ne s'installe pas bien sur Windows -> wxPython
scene.objects['Commands']['file_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "rp_file_wx.py")], stdout=subprocess.PIPE, encoding = 'utf8') scene.objects['Commands']['file_proc'] = subprocess.Popen([sys.executable, os.path.join(os.getcwd(), "rp_file_wx.py")], stdout=subprocess.PIPE, encoding = 'utf8')
# Récupérer le nom du fchier
stout = scene.objects['Commands']['file_proc'].communicate() stout = scene.objects['Commands']['file_proc'].communicate()
if stout[0][:-1] != 'None': if stout[0][:-1] != 'None':
scene.objects['Commands']['script'] = stout[0][:-1] scene.objects['Commands']['script'] = stout[0][:-1]
scene.objects['Script-text']['Text']=scene.objects['Commands']['script'] scene.objects['Script-text']['Text']=scene.objects['Commands']['script']
config_load()
##
# Sauvegarder la configuration
##
def config_save():
buffer_xml = ET.tostring(rp_config_tree)
fichier_xml=os.path.join(os.path.split((scene.objects['Commands']['script']))[0], "rp_config.xml")
with open(fichier_xml, "wb") as f:
f.write(buffer_xml)
##
# Chargement de la configuration
##
def config_load():
print ("config load")
fichier_xml=os.path.join(os.path.split((scene.objects['Commands']['script']))[0], "rp_config.xml")
rp_config2 = ET.parse(fichier_xml)
rp_config_tree2 = rp_config2.getroot()
print (rp_config_tree2[2][0].text)
print (rp_config_tree2[2][1].text)
print (rp_config_tree2[2][2].text)
print (rp_config_tree2[2][3].text)
# Configuration de l'écran
bge.render.setWindowSize(int(rp_config_tree2[0][3][0].text),int(rp_config_tree2[0][3][1].text))
quality_eevee=('NOSMAA', 'LOW', 'MEDIUM','HIGH','ULTRA')
scene.objects['About']['quality'] = int(rp_config_tree2[0][3][2].text)
if quality_eevee[scene.objects['About']['quality']] == 'NOSMAA':
eevee.smaa_quality= 'LOW'
eevee.use_eevee_smaa = False
else:
eevee.use_eevee_smaa = True
eevee.smaa_quality= quality_eevee[scene.objects['About']['quality']]
# Init de la carte
# Read config (mission actuelle : data/mission/current -> [1][0].text)
scene.objects['Points']['mission']=int(rp_config_tree2[1][0].text)
rp_map.map_init()
scene.objects['Terrain']['thread_cmd']=False
rp_map.map_reset()
# Récupération de la position de la caméra
scene.objects['Camera']['current_lx'] = float(rp_config_tree2[0][2][0].text)
scene.objects['Camera']['current_ly'] = float(rp_config_tree2[0][2][1].text)
scene.objects['Camera']['current_lz'] = float(rp_config_tree2[0][2][2].text)
scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['current_lx']
scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['current_ly']
scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['current_lz']
# UI : Sounds
# Read config (sound : data/config/sound -> [0][1].text)
if rp_config_tree2[0][1].text == "True":
sound_set ()
else:
sound_unset ()
# audiodev.unlock()
# Missions
# Read config (mission actuelle : data/mission/current -> [1][0].text)
# Read config (niveau atteint : data/mission/level -> [1][1].text)
scene.objects['Points']['mission']=int(rp_config_tree2[1][0].text)
scene.objects['Points']['mission_init']= scene.objects['Points']['mission']
scene.objects['Points']['level']=int(rp_config_tree2[1][1].text)
scene.objects['Points-Map-text']['Text']="Mission "+str(scene.objects['Points']['mission'])
scene.objects['Book_mission']['Text'] = "Mission en cours : "+str(scene.objects['Points']['mission'])
scene.objects['Book_level']['Text'] = "Niveau actuel : "+str(scene.objects['Points']['level'])
# Upgrade
upgrade_card=("battery", "beacon", "paint", "speed")
scene.objects['Points']['upgrade_nb'] =0
for i in range(len(upgrade_card)):
if rp_config_tree2[2][i].text == "True":
scene.objects['Points']['upgrade_'+upgrade_card[i]]=True
scene.objects['Points']['upgrade_nb'] +=1
scene.objects["Store-"+upgrade_card[i]+"-card"]['upgraded'] = True
else:
scene.objects['Points']['upgrade_'+upgrade_card[i]]=False
scene.objects["Store-"+upgrade_card[i]+"-card"]['upgraded'] = False
scene.objects['Points']['upgrade_credit']= scene.objects['Points']['level']- 1 - scene.objects['Points']['upgrade_nb']
upgrade_maj()
# Speed
# Read config (game speed : data/config/speed -> [0][0].text)
speed_mode=[0.25, 0.5, 1,2,4,10]
speed_mode_txt=["1/4", "1/2", "1", "2","4","10"]
if scene.objects['Points']['upgrade_speed'] :
scene.objects['Commands']['speed']=float(rp_config_tree2[0][0].text)
else:
scene.objects['Commands']['speed']=1.00
i=speed_mode.index(scene.objects['Commands']['speed'])
scene.objects['Text_speed']['Text']=speed_mode_txt[i]
############################################################################### ###############################################################################
# About # About
############################################################################### ###############################################################################
@ -1421,6 +1504,8 @@ def about_close():
scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['current_lx'] scene.objects['Camera'].worldPosition.x = scene.objects['Camera']['current_lx']
scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['current_ly'] scene.objects['Camera'].worldPosition.y = scene.objects['Camera']['current_ly']
scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['current_lz'] scene.objects['Camera'].worldPosition.z = scene.objects['Camera']['current_lz']
print ("about close")
config_save()
## ##
# Click pour fermer le about # Click pour fermer le about
@ -1430,79 +1515,3 @@ def about_close_click(cont):
if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive : if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
sound_play (snd_close) sound_play (snd_close)
about_close() about_close()
# ##
# # Configuration de l'écran
# ##
# def get_near_pos(array,value):
# array = np.asarray(array)
# idx = (np.abs(array-value)).argmin()
# return idx
# def about_screen_up(cont):
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
# screen_width_mode=[640, 960, 1280, 1920]
# screen_height_mode=[360, 540, 720,1080]
# screen_mode_txt=["640x360", "960x540", "1280x720", "1920x1080"]
# i = get_near_pos(screen_width_mode, bge.render.getWindowWidth())
# if i>=0 and i<3 :
# screen_width=screen_width_mode[i+1]
# screen_height=screen_height_mode[i+1]
# scene.objects['About_screen']['Text']= "SCREEN SIZE : "+str(screen_width) +" x "+str(screen_height)
# bge.render.setWindowSize(screen_width,screen_height)
# # Boutons < et >
# if screen_width <=640:
# scene.objects['About_screen-down'].setVisible(False,True)
# scene.objects['About_screen-down-colbox'].suspendPhysics (True)
# else:
# scene.objects['About_screen-down'].setVisible(True,True)
# scene.objects['About_screen-down-colbox'].restorePhysics()
# if screen_width >= 1920:
# scene.objects['About_screen-up'].setVisible(False,True)
# scene.objects['About_screen-up-colbox'].suspendPhysics (True)
# else:
# scene.objects['About_screen-up'].setVisible(True,True)
# scene.objects['About_screen-up-colbox'].restorePhysics()
# # Maj du fichier de config (screen size : data/config/screen/width-> [0][3][0].text)
# rp_config_tree[0][3][0].text=str(screen_width)
# rp_config_tree[0][3][1].text=str(screen_height)
# buffer_xml = ET.tostring(rp_config_tree)
# with open("rp_config.xml", "wb") as f:
# f.write(buffer_xml)
# def about_screen_down(cont):
# if cont.sensors['Click'].status == JUST_ACTIVATED and cont.sensors['MO'].positive :
# screen_width_mode=[640, 960, 1280, 1920]
# screen_height_mode=[360, 540, 720,1080]
# screen_mode_txt=["640x360", "960x540", "1280x720", "1920x1080"]
# i = get_near_pos(screen_width_mode, bge.render.getWindowWidth())
# if i>0 and i<=3 :
# screen_width=screen_width_mode[i-1]
# screen_height=screen_height_mode[i-1]
# scene.objects['About_screen']['Text']= "SCREEN SIZE : "+str(screen_width) +" x "+str(screen_height)
# bge.render.setWindowSize(screen_width,screen_height)
# # Boutons < et >
# if screen_width <=640:
# scene.objects['About_screen-down'].setVisible(False,True)
# scene.objects['About_screen-down-colbox'].suspendPhysics (True)
# else:
# scene.objects['About_screen-down'].setVisible(True,True)
# scene.objects['About_screen-down-colbox'].restorePhysics()
# if screen_width >= 1920:
# scene.objects['About_screen-up'].setVisible(False,True)
# scene.objects['About_screen-up-colbox'].suspendPhysics (True)
# else:
# scene.objects['About_screen-up'].setVisible(True,True)
# scene.objects['About_screen-up-colbox'].restorePhysics()
# # Maj du fichier de config (screen size : data/config/screen/width-> [0][3][0].text)
# rp_config_tree[0][3][0].text=str(screen_width)
# rp_config_tree[0][3][1].text=str(screen_height)
# buffer_xml = ET.tostring(rp_config_tree)
# with open("rp_config.xml", "wb") as f:
# f.write(buffer_xml)

View File

@ -8,8 +8,8 @@
<worldPosition.z>20.22315788269043</worldPosition.z> <worldPosition.z>20.22315788269043</worldPosition.z>
</cam> </cam>
<screen> <screen>
<width>1632</width> <width>1641</width>
<height>918</height> <height>924</height>
<quality>1</quality> <quality>1</quality>
</screen> </screen>
</config> </config>

View File

@ -3,9 +3,9 @@ from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QFileDialog from PyQt5.QtWidgets import QApplication, QFileDialog
############################################################################### ###############################################################################
# twin_file_qt.py # rp_file_qt.py
# @title: Selecteur de fichier (pyQt5) # @title: Selecteur de fichier (pyQt5)
# @project: Blender-EduTech # @project: Ropy (Blender-EduTech)
# @lang: fr # @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr> # @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2023 Philippe Roy # @copyright: Copyright (C) 2023 Philippe Roy

View File

@ -1,9 +1,9 @@
import wx import wx
############################################################################### ###############################################################################
# twin_file_wx.py # rp_file_wx.py
# @title: Selecteur de fichier (wxPython) # @title: Selecteur de fichier (wxPython)
# @project: Blender-EduTech # @project: Ropy (Blender-EduTech)
# @lang: fr # @lang: fr
# @authors: Philippe Roy <philippe.roy@ac-grenoble.fr> # @authors: Philippe Roy <philippe.roy@ac-grenoble.fr>
# @copyright: Copyright (C) 2023 Philippe Roy # @copyright: Copyright (C) 2023 Philippe Roy
@ -19,4 +19,4 @@ openFileDialog = wx.FileDialog(frame, "Sélection du fichier de commande", "", "
openFileDialog.ShowModal() openFileDialog.ShowModal()
print(openFileDialog.GetPath()) print(openFileDialog.GetPath())
openFileDialog.Destroy() openFileDialog.Destroy()

View File

@ -952,6 +952,7 @@ def rover_goal ():
# Level # Level
if scene.objects['Points']['mission']==scene.objects['Points']['level']: if scene.objects['Points']['mission']==scene.objects['Points']['level']:
scene.objects['Points']['level']+=1 scene.objects['Points']['level']+=1
scene.objects['Points']['level_new_flag']=True
## ##
# Forage # Forage

View File

@ -392,7 +392,8 @@ def objectif_control(x,y):
def rp_cmd_txtcount (text_list, n): def rp_cmd_txtcount (text_list, n):
# print (os.getcwd()) # print (os.getcwd())
file = open('rp_cmd.py', 'r') # file = open('rp_cmd.py', 'r')
file = open(scene.objects['Commands']['script'], 'r')
file_txt = file.read() file_txt = file.read()
for text in text_list: for text in text_list:
if file_txt.count (text) >= n: if file_txt.count (text) >= n: