How to use eventToString method in fMBT

Best Python code snippet using fMBT_python

menugui.py

Source:menugui.py Github

copy

Full Screen

1import bgui2import aud3from bge import render as rd4from bge import events as ev5from bge import logic as gl6import confParser7from collections import deque8import logs9from vehicleLinker import vehicleLinker10import sound11cont = gl.getCurrentController()12own = cont.owner13class BaseGui(bgui.System):14 """15 Classe de base pour le gui (pour conserver la meme methode main)16 """17 def __init__(self, ch):18 bgui.System.__init__(self, ch)19 self.dialogue = None20 self.ouvert = True21 def main(self):22 """A high-level method to be run every frame"""23 #self.update()24 sound.musicPlayer()25 if hasattr(gl, 'testMotorSound'):26 gl.testMotorSound.step()27 # Handle the mouse28 mouse = gl.mouse29 pos = list(mouse.position)30 pos[0] *= rd.getWindowWidth()31 pos[1] = rd.getWindowHeight() - (rd.getWindowHeight() * pos[1])32 mouse_state = bgui.BGUI_MOUSE_NONE33 mouse_events = mouse.events34 if mouse_events[ev.LEFTMOUSE] == gl.KX_INPUT_JUST_ACTIVATED:35 mouse_state = bgui.BGUI_MOUSE_CLICK36 handle_buffered = gl.device.play(gl.factory_buffered)37 elif mouse_events[ev.LEFTMOUSE] == gl.KX_INPUT_JUST_RELEASED:38 mouse_state = bgui.BGUI_MOUSE_RELEASE39 elif mouse_events[ev.LEFTMOUSE] == gl.KX_INPUT_ACTIVE:40 mouse_state = bgui.BGUI_MOUSE_ACTIVE41 self.update_mouse(pos, mouse_state)42 # Handle the keyboard43 keyboard = gl.keyboard44 key_events = keyboard.events45 is_shifted = key_events[ev.LEFTSHIFTKEY] == gl.KX_INPUT_ACTIVE or \46 key_events[ev.RIGHTSHIFTKEY] == gl.KX_INPUT_ACTIVE47 # Keymap pour la correspondance entre bge.events et bgui48 self.keymap = {getattr(ev, val): getattr(bgui, val) for val in dir(ev) if (val.endswith('KEY') or val.startswith('PAD')) and hasattr(bgui, val)}49 for key, state in keyboard.events.items():50 if state == gl.KX_INPUT_JUST_ACTIVATED:51 self.update_keyboard(self.keymap[key], is_shifted)52 if gl.status == "MenuCommandes" :53 own["sys"].updateKeys(key)54 # Now setup the scene callback so we can draw55 gl.getCurrentScene().post_draw = [self.render]56class FondGui(BaseGui):57 """58 Fond des pages du menu59 """60 def __init__(self):61 # Initiate the system62 BaseGui.__init__(self, gl.skin)63 # Fenetre principale64 self.mainframe = bgui.Frame(self, 'window', border=0, size=[1, 1], pos=[0, 0])65 # Fond66 self.frame = bgui.Frame(self.mainframe, 'fond', size=[1, 1], pos=[0, 0], options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)67 self.frame.img = bgui.Image(self.frame, 'menuItems/menu.jpg', size=[1.0, 1.0],68 options = bgui.BGUI_DEFAULT|bgui.BGUI_CACHE)69#############bouton quitter/retour############################70 if gl.status == "MenuEcranSpliter" :71 self.retour_button = bgui.ImageButton(self.frame, 'quitter', sub_theme='menu', size=[0.10, 0.05], pos=[0.45, 0.44])72 self.retour_label = bgui.Label(self.retour_button, 'retour', text="RETOUR", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)73 else:74 self.retour_button = bgui.ImageButton(self.frame, 'quitter', sub_theme='menu', size=[0.24, 0.08], pos=[0.75, 0.08])75 self.retour_label = bgui.Label(self.retour_button, 'retour', text="RETOUR", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)76 # Setup an on_click callback77 self.retour_button.on_click = self.retour_clic78 # Autres attributs79 self.action = None80 # Keymap pour la correspondance entre bge.events et bgui81 self.keymap = {getattr(ev, val): getattr(bgui, val) for val in dir(ev) if (val.endswith('KEY') or val.startswith('PAD')) and hasattr(bgui, val)}82 def retour_clic(self, widget) :83 """Methode appelée lors du clic sur le bouton Retour"""84 self.action = "retour"85 self.ouvert = False86 def detruire(self) :87 """Détruit les widgets"""88 self.frame.parent._remove_widget(self.frame)89 def reinit(self) :90 """Remet les repères d'ouverture et d'action à leur valeur par défaut"""91 self.ouvert = True92 self.action = None93 def main(self) :94 """Refresh des events et de l'affichage"""95 BaseGui.main(self)96class MenuOptionsGui(BaseGui):97 """98 Gui pour le menu des options99 """100 def __init__(self, parent):101 # Initiate the system102 BaseGui.__init__(self, gl.skin)103 # Cadre général104 self.frame = bgui.Frame(parent, 'frame', size=[1, 1], pos=[0, 0],105 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)106#############bouton affichage############################107 self.affichage_button = bgui.ImageButton(self.frame, 'affichage', sub_theme='menu', size=[0.24, 0.08], pos=[0.45, 0.60])108 self.affichage_label = bgui.Label(self.affichage_button, 'affichage', text="AFFICHAGE", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)109 # Setup an on_click callback110 self.affichage_button.on_click = self.affichageM111#############bouton commande############################112 self.commande_button = bgui.ImageButton(self.frame, 'commande', sub_theme='menu', size=[0.24, 0.08], pos=[0.45, 0.50])113 self.commande_label = bgui.Label(self.commande_button, 'commande', text="CONTROLE", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)114 # Setup an on_click callback115 self.commande_button.on_click = self.commandeM116#############bouton son############################117 self.son_button = bgui.ImageButton(self.frame, 'son', sub_theme='menu', size=[0.24, 0.08], pos=[0.45, 0.40])118 self.son_label = bgui.Label(self.son_button, 'son', text="AUDIO", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)119 # Setup an on_click callback120 self.son_button.on_click = self.sonM121#############bouton joueurs############################122 self.joueurs_button = bgui.ImageButton(self.frame, 'joueurs', sub_theme='menu', size=[0.24, 0.08], pos=[0.45, 0.30])123 self.joueurs_label = bgui.Label(self.joueurs_button, 'joueurs', text="JOUEURS", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)124 # Setup an on_click callback125 self.joueurs_button.on_click = self.joueursM126 # Autres attributs127 self.action = None128 def detruire(self) :129 """Détruit les widgets"""130 self.frame.parent._remove_widget(self.frame)131 def affichageM(self, widget) :132 self.detruire()133 self.action = "Affichage"134 self.ouvert = False135 def joueursM(self, widget) :136 self.detruire()137 self.action = "joueurs"138 self.ouvert = False139 def sonM(self, widget) :140 self.detruire()141 self.action = "son"142 self.ouvert = False143 def commandeM(self, widget) :144 self.detruire()145 self.action = "commandes"146 self.ouvert = False147 def main(self) :148 """Refresh des events et de l'affichage"""149 BaseGui.main(self)150class MenuSelectionCircuitGui(BaseGui):151 """152 Gui pour la selection du circuit153 """154 def __init__(self, parent):155 # Initiate the system156 BaseGui.__init__(self, gl.skin)157 # Fond158 self.frame = bgui.Frame(parent, 'fond', size=[1, 1], pos=[0, 0],159 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)160#############bouton validercircuit############################161 self.validercircuit_button = bgui.ImageButton(self.frame, 'circuitD', sub_theme='menu', size=[0.24, 0.08], pos=[0.45, 0.08])162 self.retour_label = bgui.Label(self.validercircuit_button, 'circuitD', text="VALIDER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)163 # Setup an on_click callback164 self.validercircuit_button.on_click = self.departSolo165#############bouton ajouter ia############################166 self.ajouterIA_button = bgui.ImageButton(self.frame, 'ajouterIA', sub_theme='menu', size=[0.12, 0.06], pos=[0.82, 0.68])167 self.ajouterIA_label = bgui.Label(self.ajouterIA_button, 'ajouterIA', text="ajouter IA", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)168 # Setup an on_click callback169 self.ajouterIA_button.on_click = self.addIA170#############bouton enlever ia############################171 self.enleverIA_button = bgui.ImageButton(self.frame, 'enleverIA', sub_theme='menu', size=[0.12, 0.06], pos=[0.82, 0.6])172 self.enleverIA_label = bgui.Label(self.enleverIA_button, 'enleverIA', text="enlever IA", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)173 # Setup an on_click callback174 self.enleverIA_button.on_click = self.removeIA175############///////////selection_circuit video \\\\\\\\\\\\\\#################176 self.circuit_label = bgui.Label(self.frame, 'circuit_text', text="nom du circuit:"+str(gl.mapName), pt_size=30, pos=[0.10, 0.8], options=bgui.BGUI_DEFAULT)177 self.selection_circuit = bgui.Frame(self.frame, 'selection_circuit', sub_theme='ecran', border=1, size=[0.2, 0.3], pos=[0.10, 0.48], options=bgui.BGUI_DEFAULT)178 self.selection_circuitVideo = bgui.Video(self.selection_circuit, 'menuItems/vidNonTrouver.avi', play_audio=False, repeat=-1, size=[1, 1], pos=[0, 0], options=bgui.BGUI_DEFAULT)179#############bouton flecheVideoDR############################180 self.flecheVdDR_button = bgui.ImageButton(self.frame, 'flecheVdDR', sub_theme='selFleche', size=[0.05, 0.30], pos=[0.30, 0.48])181 # Setup an on_click callback182 self.flecheVdDR_button.on_click = self.rightMap183#############bouton flecheVideoGA############################184 self.flecheVdGA_button = bgui.ImageButton(self.frame, 'flecheVdGA', sub_theme='selFlecheG', size=[0.05, 0.30], pos=[0.05, 0.48])185 # Setup an on_click callback186 self.flecheVdGA_button.on_click = self.leftMap187############///////////selection_circuit nombre de tours \\\\\\\\\\\\\\#################188 self.nbToursText_label = bgui.Label(self.frame, 'circuit_nbTours', text="nombre de tours:", pt_size=30, pos=[0.11, 0.38], options=bgui.BGUI_DEFAULT)189 self.fondNbTours = bgui.Frame(self.frame, 'fondNbTours', sub_theme='fondDigit', border=1, size=[0.05, 0.05], pos=[0.14, 0.32], options=bgui.BGUI_DEFAULT)190 self.nbTours_label = bgui.Label(self.fondNbTours, 'nbTours_label', sub_theme='fondDigit', text=str(gl.nbLaps), pt_size=30, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)191#############bouton flechetoursDR############################192 self.flecheToursDR_button = bgui.ImageButton(self.frame, 'flecheToursDR', sub_theme='selFleche',193 size=[0.02, 0.05], pos=[0.19, 0.32])194 # Setup an on_click callback195 self.flecheToursDR_button.on_click = self.rightTours196#############bouton flechetoursGA############################197 self.flecheToursGA_button = bgui.ImageButton(self.frame, 'flecheToursGA', sub_theme='selFlecheG',198 size=[0.02, 0.05], pos=[0.12, 0.32])199 # Setup an on_click callback200 self.flecheToursGA_button.on_click = self.leftTours201############///////////climat \\\\\\\\\\\\\\#################202 self.climatText_label = bgui.Label(self.frame, 'climatTextL', text="climat:", pt_size=30, pos=[0.11, 0.26], options=bgui.BGUI_DEFAULT)203 self.climatText = bgui.Frame(self.frame, 'climatText', sub_theme='Invisible', border=1, size=[0.06, 0.07], pos=[0.13, 0.18], options=bgui.BGUI_DEFAULT)204 self.climatText.img = bgui.Image(self.climatText , 'menuItems/' + gl.generalConf[4] + '.png', size=[1.0, 1.0], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)205#############bouton flecheClimatDR############################206 self.flecheClimatDR_button = bgui.ImageButton(self.frame, 'flecheClimatDR', sub_theme='selFleche',207 size=[0.02, 0.07], pos=[0.19, 0.18])208 # Setup an on_click callback209 self.flecheClimatDR_button.on_click = self.rightClimat210#############bouton flechetoursGA############################211 self.flecheClimatGA_button = bgui.ImageButton(self.frame, 'flecheClimatGA', sub_theme='selFlecheG',212 size=[0.02, 0.07], pos=[0.11, 0.18])213 # Setup an on_click callback214 self.flecheClimatGA_button.on_click = self.leftClimat215############/////////// grillePosJoueurs \\\\\\\\\\\\\\#################216 self.grillePosJoueurs = bgui.Frame(self.frame, 'grillePosJoueurs', sub_theme='ecran', border=1, size=[0.19, 0.55], pos=[0.6, 0.22], options=bgui.BGUI_DEFAULT)217 self.grillePosJoueurs.img = bgui.Image(self.grillePosJoueurs , 'menuItems/grille de depart.jpg', size=[1.0, 1.0], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)218 self.grillePosJoueurs_label = bgui.Label(self.frame, 'grillePosJoueurs_label', text="position des joueurs", pt_size=24, pos=[0.6, 0.78], options=bgui.BGUI_DEFAULT)219############|||||||position 1||||||||########################220 self.gPosJoueur1 = bgui.Frame(self.grillePosJoueurs, 'gPosJoueur1', sub_theme='ecran', border=3, size=[0.21, 0.16], pos=[0.16, 0.75], options=bgui.BGUI_DEFAULT)221 self.gPosJoueur1.img = bgui.Image(self.gPosJoueur1 , 'menuItems/departjoueurs.png', size=[1.0, 1.0], texco=[(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)222############|||||||position 2||||||||########################223 self.gPosJoueur2 = bgui.Frame(self.grillePosJoueurs, 'gPosJoueur2', sub_theme='ecran', border=3, size=[0.21, 0.16], pos=[0.64, 0.63], options=bgui.BGUI_DEFAULT)224 self.gPosJoueur2.img = bgui.Image(self.gPosJoueur2 , 'menuItems/departjoueurs.png', size=[1.0, 1.0], texco=[(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)225############|||||||position 3||||||||########################226 self.gPosJoueur3 = bgui.Frame(self.grillePosJoueurs, 'gPosJoueur3', sub_theme='ecran', border=3, size=[0.21, 0.16], pos=[0.16, 0.49], options=bgui.BGUI_DEFAULT)227 self.gPosJoueur3.img = bgui.Image(self.gPosJoueur3 , 'menuItems/departjoueurs.png', size=[1.0, 1.0], texco=[(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)228############|||||||position 4||||||||########################229 self.gPosJoueur4 = bgui.Frame(self.grillePosJoueurs, 'gPosJoueur4', sub_theme='ecran', border=3, size=[0.21, 0.16], pos=[0.64, 0.36], options=bgui.BGUI_DEFAULT)230 self.gPosJoueur4.img = bgui.Image(self.gPosJoueur4 , 'menuItems/departjoueurs.png', size=[1.0, 1.0], texco=[(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)231############|||||||position 5||||||||########################232 self.gPosJoueur5 = bgui.Frame(self.grillePosJoueurs, 'gPosJoueur5', sub_theme='ecran', border=3, size=[0.21, 0.16], pos=[0.16, 0.23], options=bgui.BGUI_DEFAULT)233 self.gPosJoueur5.img = bgui.Image(self.gPosJoueur5 , 'menuItems/departjoueurs.png', size=[1.0, 1.0], texco=[(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)234############|||||||position 6||||||||########################235 self.gPosJoueur6 = bgui.Frame(self.grillePosJoueurs, 'gPosJoueur6', sub_theme='ecran', border=3, size=[0.21, 0.16], pos=[0.64, 0.09], options=bgui.BGUI_DEFAULT)236 self.gPosJoueur6.img = bgui.Image(self.gPosJoueur6 , 'menuItems/departjoueurs.png', size=[1.0, 1.0], texco=[(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)], options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)237 ### fonctions du menu circuit solo238 def rightMap(self, widget):239 gl.listMaps.rotate(1)240 gl.mapName = gl.listMaps[0]241 self.circuit_label.text = "nom du circuit:"+str(gl.mapName)242 def leftMap(self, widget):243 gl.listMaps.rotate(-1)244 gl.mapName = gl.listMaps[0]245 self.circuit_label.text = "nom du circuit:"+str(gl.mapName)246 def rightTours(self, widget):247 if gl.nbLaps <= 8:248 gl.nbLaps += 1249 else:250 gl.nbLaps = 1251 self.nbTours_label.text = str(gl.nbLaps)252 def leftTours(self, widget):253 if gl.nbLaps >= 2:254 gl.nbLaps -= 1255 else:256 gl.nbLaps = 9257 self.nbTours_label.text = str(gl.nbLaps)258 def rightClimat(self, widget):259 if gl.generalConf[4] == 'sun':260 gl.generalConf[4] = 'cloud'261 elif gl.generalConf[4] == 'cloud':262 gl.generalConf[4] = 'rain'263 elif gl.generalConf[4] == 'rain':264 gl.generalConf[4] = 'sun'265 self.climatText.img.update_image('menuItems/' + gl.generalConf[4] + '.png')266 def leftClimat(self, widget):267 if gl.generalConf[4] == 'sun':268 gl.generalConf[4] = 'rain'269 elif gl.generalConf[4] == 'rain':270 gl.generalConf[4] = 'cloud'271 elif gl.generalConf[4] == 'cloud':272 gl.generalConf[4] = 'sun'273 self.climatText.img.update_image('menuItems/' + gl.generalConf[4] + '.png')274 def addIA(self, widget):275 if gl.dispPlayers[0] == 0 and len(gl.IA)< 5:276 gl.IA.append('ia')277 if len(gl.IA) == 1:278 own["sys"].gPosJoueur2.img.texco = [(0,0), (0.5,0.0), (0.5,0.5), (0,0.5)]279 if len(gl.IA) == 2:280 own["sys"].gPosJoueur3.img.texco = [(0,0), (0.5,0.0), (0.5,0.5), (0,0.5)]281 if len(gl.IA) == 3:282 own["sys"].gPosJoueur4.img.texco = [(0,0), (0.5,0.0), (0.5,0.5), (0,0.5)]283 if len(gl.IA) == 4:284 own["sys"].gPosJoueur5.img.texco = [(0,0), (0.5,0.0), (0.5,0.5), (0,0.5)]285 if len(gl.IA) == 5:286 own["sys"].gPosJoueur6.img.texco = [(0,0), (0.5,0.0), (0.5,0.5), (0,0.5)]287 def removeIA(self, widget):288 if gl.dispPlayers[0] == 0 and len(gl.IA)> 0:289 gl.IA.remove('ia')290 if len(gl.IA) == 0:291 own["sys"].gPosJoueur2.img.texco = [(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)]292 if len(gl.IA) == 1:293 own["sys"].gPosJoueur3.img.texco = [(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)]294 if len(gl.IA) == 2:295 own["sys"].gPosJoueur4.img.texco = [(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)]296 if len(gl.IA) == 3:297 own["sys"].gPosJoueur5.img.texco = [(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)]298 if len(gl.IA) == 4:299 own["sys"].gPosJoueur6.img.texco = [(0.5, 0.5), (1, 0.5), (1, 1), (0.5, 1)]300 def departSolo(self, widget):301 rd.showMouse(0)302 self.action = "depart"303 self.ouvert = False304 def detruire(self) :305 """Détruit les widgets"""306 self.frame.parent._remove_widget(self.frame)307 def main(self) :308 """Refresh des events et de l'affichage"""309 BaseGui.main(self)310class MenuEcranSpliterGui(BaseGui):311 """312 Gui pour la gestion multijoueurs ecran spliter313 """314 def __init__(self, parent):315 # Initiate the system316 BaseGui.__init__(self, gl.skin)317 # Cadre général318 self.frame = bgui.Frame(parent, 'cadre', size=[1, 1], pos=[0, 0],319 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)320#############bouton nombreJoueurs############################321 self.nombreJoueurs_button = bgui.ImageButton(self.frame, 'nombreJoueurs', sub_theme='menu', size=[0.22, 0.08], pos=[0.55, 0.58])322 self.nombreJoueurs_label = bgui.Label(self.nombreJoueurs_button, 'nombreJoueurs', text= str(len(gl.dispPlayers)) + " JOUEURS", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)323 # Setup an on_click callback324 self.nombreJoueurs_button.on_release = self.nombreJoueur325#############bouton disposition############################326 self.disposition_button = bgui.ImageButton(self.frame, 'disposition', sub_theme='menu', size=[0.22, 0.08], pos=[0.55, 0.38])327 self.disposition_label = bgui.Label(self.disposition_button, 'disposition', text="DISPOSITION", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)328 # Setup an on_click callback329 self.disposition_button.on_click = self.ecranDisposition330#############bouton placementJoueur############################331 self.placementJoueur_button = bgui.ImageButton(self.frame, 'placementJoueur', sub_theme='menu', size=[0.22, 0.08], pos=[0.55, 0.48])332 self.placementJoueur_label = bgui.Label(self.placementJoueur_button, 'placementJoueur', text="PLACE J", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)333 # Setup an on_click callback334 self.placementJoueur_button.on_click = self.placementJoueurs335#############bouton valider############################336 self.validerplacementJoueur_button = bgui.ImageButton(self.frame, 'validerplacementJoueur', sub_theme='menu', size=[0.22, 0.08], pos=[0.55, 0.28])337 self.validerplacementJoueur_label = bgui.Label(self.validerplacementJoueur_button, 'validerplacementJoueur', text="VALIDER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)338 # Setup an on_click callback339 self.validerplacementJoueur_button.on_click = self.valider340 #Horizontal341 self.deuxjoueurs_ecranHorizontal = bgui.Frame(self.frame, 'deuxjoueurs_ecranHorizontal', sub_theme='ecran', border=1, size=[0.4, 0.45], pos=[0.13, 0.19], options=bgui.BGUI_DEFAULT)342 self.deuxjoueurs_ecranHorizontal.img = bgui.Image(self.deuxjoueurs_ecranHorizontal, 'menuItems/ecranJoueur.png', size=[1.0, 0.5], pos=[0.0, 0.0], options=bgui.BGUI_DEFAULT)343 self.deuxjoueurs_ecranHorizontal.img2 = bgui.Image(self.deuxjoueurs_ecranHorizontal, 'menuItems/ecranJoueur.png', size=[1.0, 0.5], pos=[0.0, 0.5], options=bgui.BGUI_DEFAULT)344 self.posJoueurHH_label = bgui.Label(self.deuxjoueurs_ecranHorizontal, 'posJoueurHH', text=str(gl.conf[0][0][0]), pt_size=24, pos=[0.5, 0.9], options=bgui.BGUI_DEFAULT)345 self.posJoueurHB_label = bgui.Label(self.deuxjoueurs_ecranHorizontal, 'posJoueurHB', text=str(gl.conf[0][1][0]), pt_size=24, pos=[0.5, 0.4], options=bgui.BGUI_DEFAULT)346 #Vertical347 self.deuxjoueurs_ecranVertical = bgui.Frame(self.frame, 'deuxjoueurs_ecranVertical', sub_theme='ecran', border=1, size=[0.4, 0.45], pos=[0.13, 0.19], options=bgui.BGUI_DEFAULT)348 self.deuxjoueurs_ecranVertical.img = bgui.Image(self.deuxjoueurs_ecranVertical, 'menuItems/ecranJoueur.png', size=[0.5, 1.0], pos=[0.0, 0.0], options=bgui.BGUI_DEFAULT)349 self.deuxjoueurs_ecranVertical.img2 = bgui.Image(self.deuxjoueurs_ecranVertical, 'menuItems/ecranJoueur.png', size=[0.5, 1.0], pos=[0.5, 0.0], options=bgui.BGUI_DEFAULT)350 self.posJoueurVH_label = bgui.Label(self.deuxjoueurs_ecranVertical, 'posJoueurVH', text=str(gl.conf[0][0][0]), pt_size=24, pos=[0.25, 0.9], options=bgui.BGUI_DEFAULT)351 self.posJoueurVB_label = bgui.Label(self.deuxjoueurs_ecranVertical, 'posJoueurVB', text=str(gl.conf[0][1][0]), pt_size=24, pos=[0.75, 0.9], options=bgui.BGUI_DEFAULT)352 self.deuxjoueurs_ecranVertical.visible = False353############///////////frame ecran 4 joueurs\\\\\\\\\\\\\\#################354 self.quatrejoueurs_ecran = bgui.Frame(self.frame, 'quatrejoueurs_ecran', sub_theme='ecran', border=1, size=[0.4, 0.45], pos=[0.13, 0.19], options=bgui.BGUI_DEFAULT)355 self.quatrejoueurs_ecran.z_index = 1356 self.quatrejoueurs_ecran.img1 = bgui.Image(self.quatrejoueurs_ecran, 'menuItems/ecranJoueur.png', size=[0.5, 0.5], pos=[0.0, 0.5], options=bgui.BGUI_DEFAULT)357 self.posJoueurHG_label = bgui.Label(self.quatrejoueurs_ecran, 'posJoueurHG', text=str(gl.conf[0][0][0]), pt_size=24, pos=[0.25, 0.9], options=bgui.BGUI_DEFAULT)358 self.quatrejoueurs_ecran.img2 = bgui.Image(self.quatrejoueurs_ecran, 'menuItems/ecranJoueur.png', size=[0.5, 0.5], pos=[0.5, 0.5], options=bgui.BGUI_DEFAULT)359 self.posJoueurHD_label = bgui.Label(self.quatrejoueurs_ecran, 'posJoueurHD', text=str(gl.conf[0][1][0]), pt_size=24, pos=[0.75, 0.9], options=bgui.BGUI_DEFAULT)360 self.quatrejoueurs_ecran.img3 = bgui.Image(self.quatrejoueurs_ecran, 'menuItems/ecranJoueur.png', size=[0.5, 0.5], pos=[0.0, 0.0], options=bgui.BGUI_DEFAULT)361 self.posJoueurBG_label = bgui.Label(self.quatrejoueurs_ecran, 'posJoueurBG', text=str(gl.conf[0][2][0]), pt_size=24, pos=[0.25, 0.4], options=bgui.BGUI_DEFAULT)362 self.quatrejoueurs_ecran.img4 = bgui.Image(self.quatrejoueurs_ecran, 'menuItems/ecranJoueur.png', size=[0.5, 0.5], pos=[0.5, 0.0], options=bgui.BGUI_DEFAULT)363 self.posJoueurBD_label = bgui.Label(self.quatrejoueurs_ecran, 'posJoueurBD', text=str(gl.conf[0][3][0]), pt_size=24, pos=[0.75, 0.4], options=bgui.BGUI_DEFAULT)364 #cache 3 joueurs365 self.cacheTroisJoueursHG_ecran = bgui.Frame(self.quatrejoueurs_ecran, 'cacheTroisJoueursHG_ecran', sub_theme='ecran', border=1, size=[0.5, 0.5], pos=[0.0, 0.5], options=bgui.BGUI_DEFAULT)366 self.cacheTroisJoueursHG_ecran.z_index = 2367 self.cacheTroisJoueursHD_ecran = bgui.Frame(self.quatrejoueurs_ecran, 'cacheTroisJoueursHD_ecran', sub_theme='ecran', border=1, size=[0.5, 0.5], pos=[0.5, 0.5], options=bgui.BGUI_DEFAULT)368 self.cacheTroisJoueursHD_ecran.z_index = 2369 self.cacheTroisJoueursBG_ecran = bgui.Frame(self.quatrejoueurs_ecran, 'cacheTroisJoueursBG_ecran', sub_theme='ecran', border=1, size=[0.5, 0.5], pos=[0.0, 0.0], options=bgui.BGUI_DEFAULT)370 self.cacheTroisJoueursBG_ecran.z_index = 2371 self.cacheTroisJoueursBD_ecran = bgui.Frame(self.quatrejoueurs_ecran, 'cacheTroisJoueursBD_ecran', sub_theme='ecran', border=1, size=[0.5, 0.5], pos=[0.5, 0.0], options=bgui.BGUI_DEFAULT)372 self.cacheTroisJoueursBD_ecran.z_index = 2373 self.quatrejoueurs_ecran.visible = False374 def detruire(self) :375 """Détruit les widgets"""376 self.frame.parent._remove_widget(self.frame)377 def ecranDisposition(self, widget):378 if gl.dispPlayers[0] == 1:379 gl.dispPlayers[0] = 2380 self.deuxjoueurs_ecranHorizontal.visible = False381 self.deuxjoueurs_ecranVertical.visible = True382 elif gl.dispPlayers[0] == 2:383 self.deuxjoueurs_ecranHorizontal.visible = True384 self.deuxjoueurs_ecranVertical.visible = False385 gl.dispPlayers[0] = 1386 elif gl.dispPlayers[0] == 4:387 gl.dispPlayers[0] = 5388 self.cacheTroisJoueursHD_ecran.visible = True389 self.cacheTroisJoueursHG_ecran.visible = False390 elif gl.dispPlayers[0] == 5:391 gl.dispPlayers[0] = 6392 self.cacheTroisJoueursBD_ecran.visible = True393 self.cacheTroisJoueursHD_ecran.visible = False394 elif gl.dispPlayers[0] == 6:395 gl.dispPlayers[0] = 7396 self.cacheTroisJoueursBG_ecran.visible = True397 self.cacheTroisJoueursBD_ecran.visible = False398 elif gl.dispPlayers[0] == 7:399 gl.dispPlayers[0] = 4400 self.cacheTroisJoueursHG_ecran.visible = True401 self.cacheTroisJoueursBG_ecran.visible = False402 def placementJoueurs(self, widget):403 if gl.dispPlayers[0] == 1 or 2:404 if self.posJoueurHH_label.text == str(gl.conf[0][0][0]):405 self.posJoueurHH_label.text = self.posJoueurVH_label.text = gl.dispPlayers[1] = str(gl.conf[0][1][0])406 self.posJoueurHB_label.text = self.posJoueurVB_label.text = gl.dispPlayers[2] = str(gl.conf[0][0][0])407 else:408 self.posJoueurHH_label.text = self.posJoueurVH_label.text = gl.dispPlayers[1] = str(gl.conf[0][0][0])409 self.posJoueurHB_label.text = self.posJoueurVB_label.text = gl.dispPlayers[2] = str(gl.conf[0][1][0])410 if gl.dispPlayers[0] == 3:411 gl.lstPlayers.rotate(1)412 print(gl.lstPlayers)413 self.posJoueurHG_label.text = gl.lstPlayers[0]414 self.posJoueurHD_label.text = gl.lstPlayers[1]415 self.posJoueurBG_label.text = gl.lstPlayers[2]416 self.posJoueurBD_label.text = gl.lstPlayers[3]417 del gl.dispPlayers[1:]418 gl.dispPlayers.append(gl.lstPlayers[0])419 gl.dispPlayers.append(gl.lstPlayers[1])420 gl.dispPlayers.append(gl.lstPlayers[2])421 gl.dispPlayers.append(gl.lstPlayers[3])422 #print(gl.dispPlayers)423 if gl.dispPlayers[0] == 4:424 gl.lstPlayers.rotate(1)425 self.posJoueurHD_label.text = gl.lstPlayers[0]426 self.posJoueurBG_label.text = gl.lstPlayers[1]427 self.posJoueurBD_label.text = gl.lstPlayers[2]428 del gl.dispPlayers[1:]429 gl.dispPlayers.append(gl.lstPlayers[0])430 gl.dispPlayers.append(gl.lstPlayers[1])431 gl.dispPlayers.append(gl.lstPlayers[2])432 #print(gl.dispPlayers)433 if gl.dispPlayers[0] == 5:434 gl.lstPlayers.rotate(1)435 self.posJoueurHG_label.text = gl.lstPlayers[0]436 self.posJoueurBG_label.text = gl.lstPlayers[1]437 self.posJoueurBD_label.text = gl.lstPlayers[2]438 del gl.dispPlayers[1:]439 gl.dispPlayers.append(gl.lstPlayers[0])440 gl.dispPlayers.append(gl.lstPlayers[1])441 gl.dispPlayers.append(gl.lstPlayers[2])442 #print(gl.dispPlayers)443 if gl.dispPlayers[0] == 6:444 gl.lstPlayers.rotate(1)445 self.posJoueurHG_label.text = gl.lstPlayers[0]446 self.posJoueurBG_label.text = gl.lstPlayers[1]447 self.posJoueurHD_label.text = gl.lstPlayers[2]448 del gl.dispPlayers[1:]449 gl.dispPlayers.append(gl.lstPlayers[0])450 gl.dispPlayers.append(gl.lstPlayers[1])451 gl.dispPlayers.append(gl.lstPlayers[2])452 #print(gl.dispPlayers)453 if gl.dispPlayers[0] == 7:454 gl.lstPlayers.rotate(1)455 self.posJoueurHG_label.text = gl.lstPlayers[0]456 self.posJoueurBD_label.text = gl.lstPlayers[1]457 self.posJoueurHD_label.text = gl.lstPlayers[2]458 del gl.dispPlayers[1:]459 gl.dispPlayers.append(gl.lstPlayers[0])460 gl.dispPlayers.append(gl.lstPlayers[1])461 gl.dispPlayers.append(gl.lstPlayers[2])462 #print(gl.dispPlayers)463 def nombreJoueur(self, widget):464 if len(gl.dispPlayers) == 3:465 gl.dispPlayers.append(gl.conf[0][2][0])466 self.nombreJoueurs_label.text = str(len(gl.dispPlayers)-1) + " JOUEURS"467 self.cacheTroisJoueursHD_ecran.visible = self.cacheTroisJoueursBG_ecran.visible = self.cacheTroisJoueursBD_ecran.visible = False468 self.cacheTroisJoueursHG_ecran.visible = self.quatrejoueurs_ecran.visible = True469 self.deuxjoueurs_ecranHorizontal.visible = self.deuxjoueurs_ecranVertical.visible = False470 gl.dispPlayers[0] = 4471 gl.lstPlayers = coll.deque(gl.dispPlayers[1:])472 elif len(gl.dispPlayers) == 4:473 gl.dispPlayers.append(gl.conf[0][3][0])474 self.nombreJoueurs_label.text = str(len(gl.dispPlayers)-1) + " JOUEURS"475 self.cacheTroisJoueursHG_ecran.visible = self.cacheTroisJoueursHD_ecran.visible = self.cacheTroisJoueursBG_ecran.visible = self.cacheTroisJoueursBD_ecran.visible = False476 gl.dispPlayers[0] = 3477 gl.lstPlayers = coll.deque(gl.dispPlayers[1:])478 elif len(gl.dispPlayers) == 5:479 gl.dispPlayers.remove(gl.conf[0][3][0])480 gl.dispPlayers.remove(gl.conf[0][2][0])481 self.nombreJoueurs_label.text = str(len(gl.dispPlayers)-1) + " JOUEURS"482 self.quatrejoueurs_ecran.visible = False483 self.deuxjoueurs_ecranHorizontal.visible = True484 gl.dispPlayers[0] = 1485 gl.lstPlayers = coll.deque(gl.dispPlayers[1:])486 def valider(self, widget):487 #self.detruire()488 self.action = "valider"489 self.ouvert = False490 def main(self) :491 """Refresh des events et de l'affichage"""492 BaseGui.main(self)493class MenuTelechargementGui(BaseGui):494 """495 Gui pour la visualisation d'un serveur496 :note: Ne pas oublier de retirer le bouton Retour !497 """498 def __init__(self, parent):499 # Initiate the system500 BaseGui.__init__(self, gl.skin)501 # Cadre général502 self.frame = bgui.Frame(parent, 'cadre', size=[1, 1], pos=[0, 0],503 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)504 # Titre505 self.titre = bgui.Label(self.frame, 'titre', text="TELECHARGEMENT", pt_size=32, pos=[0, .935],506 options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX)507 def detruire(self) :508 """Détruit les widgets"""509 self.frame.parent._remove_widget(self.frame)510 def main(self) :511 """Refresh des events et de l'affichage"""512 BaseGui.main(self)513class MenuMultijoueursGui(BaseGui):514 """515 Gui le choix du type de multijoueurs516 """517 def __init__(self, parent):518 # Initiate the system519 BaseGui.__init__(self, gl.skin)520 # Cadre général521 self.frame = bgui.Frame(parent, 'cadre', size=[1, 1], pos=[0, 0],522 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)523#############bouton ecransplitter############################524 self.ecransplitter_button = bgui.ImageButton(self.frame, 'ecransplitter', sub_theme='menu', size=[0.24, 0.08], pos=[0.4, 0.55])525 self.ecransplitter_label = bgui.Label(self.ecransplitter_button, 'ecransplitter', text="ECRAN SPLITTER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)526 # Setup an on_click callback527 self.ecransplitter_button.on_click = self.ecranSplitM528#############bouton reseaulocal############################529 self.reseauLocal_button = bgui.ImageButton(self.frame, 'reseauLocal', sub_theme='menu', size=[0.24, 0.08], pos=[0.4, 0.45])530 self.reseauLocal_label = bgui.Label(self.reseauLocal_button, 'reseauLocal', text="RESEAU LOCAL", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)531#############bouton reseauinternet############################532 self.reseauInternet_button = bgui.ImageButton(self.frame, 'reseauInternet', sub_theme='menu', size=[0.24, 0.08], pos=[0.4, 0.35])533 self.reseauInternet_label = bgui.Label(self.reseauInternet_button, 'reseauInternet', text="RESEAU INTERNET", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)534 # Autres attributs535 self.action = None536 def detruire(self) :537 """Détruit les widgets"""538 self.frame.parent._remove_widget(self.frame)539 def ecranSplitM(self, widget) :540 self.detruire()541 self.action = "MenuEcranSpliter"542 self.ouvert = False543 def main(self) :544 """Refresh des events et de l'affichage"""545 BaseGui.main(self)546class MenuPrincipalGui(BaseGui):547 """548 Gui pour la liste des profils549 """550 def __init__(self, parent):551 # Initiate the system552 BaseGui.__init__(self, gl.skin)553 # Fond554 self.frame = bgui.Frame(parent, 'fond', size=[1, 1], pos=[0, 0],555 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)556############///////////frame info \\\\\\\\\\\\\\#################557 self.info_ecran = bgui.Frame(self.frame, 'info_ecran', sub_theme='Invisible', border=1, size=[0.44, 0.75], pos=[0.06, 0.02], options=bgui.BGUI_DEFAULT)558 self.info_label = bgui.Label(self.info_ecran, 'info_label', text=gl.word[1]+" " + str(gl.conf[0][0][0]), pt_size=24, pos=[0.02, 0.84], options=bgui.BGUI_DEFAULT)559#############bouton joueursolo ############################560 self.joueursolo_button = bgui.ImageButton(self.frame, 'joueursolo', sub_theme='menu', size=[0.24, 0.08], pos=[0.75, 0.48])561 self.joueursolo_label = bgui.Label(self.joueursolo_button, 'joueursolo', text=gl.word[2], pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)562 # Setup an on_click callback563 self.joueursolo_button.on_click = self.joueurSoloM564#############bouton multijoueur ############################565 self.multijoueur_button = bgui.ImageButton(self.frame, 'multijoueur', sub_theme='menu', size=[0.24, 0.08], pos=[0.75, 0.38])566 self.multijoueur_label = bgui.Label(self.multijoueur_button, 'multijoueur', text=gl.word[3], pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)567 # Setup an on_click callback568 self.multijoueur_button.on_click = self.multijoueurM569#############bouton telechargements ############################570 self.telechargements_button = bgui.ImageButton(self.frame, 'telechargements', sub_theme='menu', size=[0.24, 0.08], pos=[0.75, 0.28])571 self.telechargements_label = bgui.Label(self.telechargements_button, 'telechargements', text=gl.word[4], pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)572 # Setup an on_click callback573 self.telechargements_button.on_click = self.telechargementM574#############bouton options############################575 self.options_button = bgui.ImageButton(self.frame, 'options', sub_theme='menu', size=[0.24, 0.08], pos=[0.75, 0.18])576 self.options_label = bgui.Label(self.options_button, 'options', text=gl.word[5], pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)577 # Setup an on_click callback578 self.options_button.on_click = self.optionsM579#############bouton choix de la langue############################580 self.langueC = bgui.Label(self.frame, 'langue_choise', text=gl.word[0]+": ", pt_size=24, pos=[0.72, 0.94], options=bgui.BGUI_DEFAULT)581 self.langue_button = bgui.FrameButton(self.frame, 'langue_button', base_color=(0.4, 0.4, 0.4, 0.3), size=[0.108, 0.025], pos=[0.84, 0.94])582 self.langue_label = bgui.Label(self.langue_button, 'buttonL', text=gl.generalConf[5], pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)583 # Setup an on_click callback584 self.langue_button.on_click = self.langue585 586 # Autres attributs587 self.action = None588 self.selection = None589 def detruire(self) :590 """Détruit les widgets"""591 self.frame.parent._remove_widget(self.frame)592 def joueurSoloM(self, widget) :593 self.detruire()594 self.action = "joueurSolo"595 self.ouvert = False596 def multijoueurM(self, widget) :597 self.detruire()598 self.action = "MenuMultijoueurs"599 self.ouvert = False600 def telechargementM(self, widget) :601 self.detruire()602 self.action = "MenuTelechargement"603 self.ouvert = False604 def optionsM(self, widget) :605 self.detruire()606 self.action = "MenuOptions"607 self.ouvert = False608 def langue(self, widget) :609 if gl.generalConf[5] == "Francais":610 gl.generalConf[5] = "English"611 elif gl.generalConf[5] == "English":612 gl.generalConf[5] = "Deutsch"613 elif gl.generalConf[5] == "Deutsch":614 gl.generalConf[5] = "Francais"615 confParser.saveConf()616 gl.restartGame()617 def main(self) :618 """Refresh des events et de l'affichage"""619 BaseGui.main(self)620class jouerSoloGui(BaseGui):621 """622 Gui pour le choix de la voiture en mode 1 joueur623 """624 def __init__(self, parent):625 # Initiate the system626 BaseGui.__init__(self, gl.skin)627 # Cadre général628 self.frame = bgui.Frame(parent, 'cadre', size=[1, 1], pos=[0, 0],629 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)630 self.introVoiture_label = bgui.Label(self.frame, 'introVoiture_label', text="Voiture:", pt_size=31, pos=[0.64, 0.82], options=bgui.BGUI_DEFAULT)631 self.voiture_label = bgui.Label(self.frame, 'voiture_label', sub_theme='MenuInfo', text="voiture", pt_size=31, pos=[0.73, 0.82], options=bgui.BGUI_DEFAULT)632 self.introRoue_label = bgui.Label(self.frame, 'introRoue_label', text="Roue:", pt_size=31, pos=[0.64, 0.77], options=bgui.BGUI_DEFAULT)633 self.roue_label = bgui.Label(self.frame, 'roue_label', sub_theme='MenuInfo', text="Roue", pt_size=31, pos=[0.73, 0.77], options=bgui.BGUI_DEFAULT)634#############bouton testSound############################635 self.Sound_label = bgui.Label(self.frame, 'Sound', text="Sound:", pt_size=31, pos=[0.64, 0.6], options=bgui.BGUI_DEFAULT)636 self.testSound_button = bgui.ImageButton(self.frame, 'testSound', sub_theme='menu', size=[0.10, 0.05], pos=[0.73, 0.6])637 self.testSound_label = bgui.Label(self.testSound_button, 'testSound', text="play", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)638 # Setup an on_click callback639 self.testSound_button.on_click = self.testSound640#############bouton couleurs############################641 self.peinture_label = bgui.Label(self.frame, 'peinture', text="peinture:", pt_size=31, pos=[0.64, 0.51], options=bgui.BGUI_DEFAULT)642 self.peinture_button = bgui.FrameButton(self.frame, 'peintureB', base_color=(0.4, 0.4, 0.4, 0.0), size=[0.188, 0.05], pos=[0.73, 0.482])643 # Setup an on_click callback644 self.peinture_button.on_click = self.colorCar645 self.vitre_label = bgui.Label(self.frame, 'vitre', text="vitre:", pt_size=31, pos=[0.64, 0.38], options=bgui.BGUI_DEFAULT)646 self.vitre_button = bgui.FrameButton(self.frame, 'vitreB', base_color=(0.4, 0.4, 0.4, 0.0), size=[0.188, 0.052], pos=[0.73, 0.359])647 # Setup an on_click callback648 self.vitre_button.on_click = self.colorGlass649#############bouton flecheG############################650 self.flecheG_button = bgui.ImageButton(self.frame, 'flecheG', sub_theme='selFlecheG', size=[0.05, 0.26], pos=[0.03, 0.40])651 # Setup an on_click callback652 self.flecheG_button.on_click = self.leftcar653#############bouton fleche############################654 self.fleche_button = bgui.ImageButton(self.frame, 'fleche', sub_theme='selFleche', size=[0.05, 0.26], pos=[0.57, 0.40])655 # Setup an on_click callback656 self.fleche_button.on_click = self.rightcar657#############bouton flecheGRoue############################658 self.flecheGRoue_button = bgui.ImageButton(self.frame, 'flecheGRoue', sub_theme='selFlecheG', size=[0.05, 0.12], pos=[0.03, 0.27])659 # Setup an on_click callback660 self.flecheGRoue_button.on_click = self.leftwheels661#############bouton flecheRoue############################662 self.flecheRoue_button = bgui.ImageButton(self.frame, 'flecheRoue', sub_theme='selFleche', size=[0.05, 0.12], pos=[0.57, 0.27])663 # Setup an on_click callback664 self.flecheRoue_button.on_click = self.rightwheels665#############bouton testerVoiture############################666 self.testerVoiture_button = bgui.ImageButton(self.frame, 'testerVoiture', sub_theme='menu', size=[0.24, 0.08], pos=[0.15, 0.08])667 self.testerVoiture_label = bgui.Label(self.testerVoiture_button, 'testerVoiture', text="TESTER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)668 # Setup an on_click callback669 self.testerVoiture_button.on_click = self.testerVoiture670#############bouton validerVoiture############################671 self.validerVoiture_button = bgui.ImageButton(self.frame, 'validerVoiture', sub_theme='menu', size=[0.24, 0.08], pos=[0.45, 0.08])672 self.valider_label = bgui.Label(self.validerVoiture_button, 'validerVoiture', text="VALIDER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)673 # Setup an on_click callback674 self.validerVoiture_button.on_click = self.circuitMenu675 # Autres attributs676 self.action = None677 def detruire(self) :678 """Détruit les widgets"""679 self.frame.parent._remove_widget(self.frame)680 def leftwheels(self, widget):681 gl.lstRoue.rotate(-1)682 gl.conf[0][0][4] = gl.lstRoue[gl.posRoueJun]683 gl.voiture.setWheels( str(gl.conf[0][0][4]) )684 self.roue_label.text = str(gl.conf[0][0][4])685 def rightwheels(self, widget):686 gl.lstRoue.rotate(1)687 gl.conf[0][0][4] = gl.lstRoue[gl.posRoueJun]688 gl.voiture.setWheels( str(gl.conf[0][0][4]) )689 self.roue_label.text = str(gl.conf[0][0][4])690 def leftcar(self, widget):691 gl.lstVoiture.rotate(-1)692 gl.conf[0][0][3] = gl.lstVoiture[gl.posVoitureJun]693 gl.voiture.setVehicle( str(gl.conf[0][0][3]) )694 self.voiture_label.text = str(gl.conf[0][0][3])695 def rightcar(self, widget):696 gl.lstVoiture.rotate(1)697 gl.conf[0][0][3] = gl.lstVoiture[gl.posVoitureJun]698 gl.voiture.setVehicle( str(gl.conf[0][0][3]) )699 self.voiture_label.text = str(gl.conf[0][0][3])700 def testSound(self, widget):701 if self.testSound_label.text == "play":702 gl.voiture.startSound()703 self.testSound_label.text = "stop"704 elif self.testSound_label.text == "stop":705 gl.voiture.stopSound()706 self.testSound_label.text = "play"707 def colorCar(self, widget):708 gl.conf[0][0][5] = [gl.CurrentColor[0], gl.CurrentColor[1], gl.CurrentColor[2]]709 gl.voiture.setVehicleColor(*gl.conf[0][0][5])710 def colorGlass(self, widget):711 gl.conf[0][0][6] = [gl.CurrentColor[0], gl.CurrentColor[1], gl.CurrentColor[2]]712 gl.voiture.setWindowsColor(*gl.conf[0][0][6])713 def testerVoiture(self, widget):714 rd.showMouse(0)715 gl.dispPlayers=[0, gl.conf[0][0][0]]716 del(gl.CurrentColor, gl.listMaps, gl.lstRoue, gl.listeRadio, gl.posRoueJun, gl.voiture)717 confParser.savePlayer()718 gl.mapName = "anneauDeTest"719 scene = gl.getCurrentScene()720 for lib in gl.LibList():721 gl.LibFree(lib)722 scene.replace('game')723 def circuitMenu(self, widget):724 self.detruire()725 self.action = "MenuSelectionCircuit"726 self.ouvert = False727 def main(self) :728 """Refresh des events et de l'affichage"""729 BaseGui.main(self)730class MenuAffichageGui(BaseGui):731 """732 Gui pour l'affichage733 """734 def __init__(self, parent):735 # Initiate the system736 BaseGui.__init__(self, gl.skin)737 # Fond738 self.frame = bgui.Frame(parent, 'cadre', size=[1, 1], pos=[0, 0],739 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)740#############bouton activate mirror############################741 self.mirror_button = bgui.ImageButton(self.frame, 'mirrorbt', sub_theme='check', size=[0.04, 0.04], pos=[0.42, 0.80])742 # Setup an on_click callback743 self.mirror_button.on_click = self.enableMirror744 ##mirror label745 self.affichage_label = bgui.Label(self.frame, 'mirror', text="activation des reflets temp reel", pt_size=24, pos=[0.03, 0.80], options=bgui.BGUI_DEFAULT)746#############bouton activate AnisotropicFiltering############################747 self.AnisotropicFiltering_button = bgui.Frame(self.frame, 'AnisotropicFiltering_button', border=1, size=[0.04, 0.04], pos=[0.42, 0.70], options=bgui.BGUI_DEFAULT)748 self.AnisotropicFiltering_label_value = bgui.Label(self.AnisotropicFiltering_button, 'AnisotropicFiltering', text=str(gl.generalConf[1]), pt_size=20, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)749 # Setup an on_click callback750 self.AnisotropicFiltering_button.on_click = self.AnisotropicFilteringLevel751 ##label AnisotropicFiltering752 self.AnisotropicFiltering_label = bgui.Label(self.frame, 'AnisotropicFiltering', text="Anisotropic Filtering", pt_size=24, pos=[0.03, 0.70], options=bgui.BGUI_DEFAULT)753 def detruire(self) :754 """Détruit les widgets"""755 self.frame.parent._remove_widget(self.frame)756 def enableMirror(self, widget):757 print(self.mirror_button.state)758 def AnisotropicFilteringLevel(self, widget):759 if gl.generalConf[1] >= 16:760 gl.generalConf[1] = 1761 else:762 gl.generalConf[1] = gl.generalConf[1]*2763 self.AnisotropicFiltering_label_value.text = str(gl.generalConf[1])764 def main(self) :765 """Refresh des events et de l'affichage"""766 BaseGui.main(self)767class MenuNomsJoueursGui(BaseGui):768 """769 Gui pour le choix du nom des joueurs770 """771 def __init__(self, parent):772 # Initiate the system773 BaseGui.__init__(self, gl.skin)774 # Fond775 self.frame = bgui.Frame(parent, 'cadre', size=[1, 1], pos=[0, 0],776 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)777#############input joueur 1############################778 self.joueur1_label = bgui.Label(self.frame, 'joueur1', text="le premier joueur s\'appelle:", pt_size=30, pos=[0.02, 0.8], options=bgui.BGUI_DEFAULT)779 self.joueur1_input = bgui.TextInput(self.frame, 'joueur1_input', str(gl.conf[0][0][0]), pt_size=30, size=[.2, .05], pos=[0.02, 0.73], input_options = bgui.BGUI_INPUT_NONE, options = bgui.BGUI_DEFAULT)780 self.joueur1_input.activate()781 self.joueur1_input.on_enter_key = self.joueur1_on_input_enter782#############input joueur 2############################783 self.joueur2_label = bgui.Label(self.frame, 'joueur2', text="le second joueur s\'appelle:", pt_size=30, pos=[0.02, 0.6], options=bgui.BGUI_DEFAULT)784 self.joueur2_input = bgui.TextInput(self.frame, 'joueur2_input', str(gl.conf[0][1][0]), pt_size=30, size=[.2, .05], pos=[0.02, 0.53], input_options = bgui.BGUI_INPUT_NONE, options = bgui.BGUI_DEFAULT)785 self.joueur2_input.activate()786 self.joueur2_input.on_enter_key = self.joueur2_on_input_enter787#############input joueur 3############################788 self.joueur3_label = bgui.Label(self.frame, 'joueur3', text="le troisieme joueur s\'appelle:", pt_size=30, pos=[0.02, 0.4], options=bgui.BGUI_DEFAULT)789 self.joueur3_input = bgui.TextInput(self.frame, 'joueur3_input', str(gl.conf[0][2][0]), pt_size=30, size=[.2, .05], pos=[0.02, 0.33],input_options = bgui.BGUI_INPUT_NONE, options = bgui.BGUI_DEFAULT)790 self.joueur3_input.activate()791 self.joueur3_input.on_enter_key = self.joueur3_on_input_enter792#############input joueur 4############################793 self.joueur4_label = bgui.Label(self.frame, 'joueur4', text="le quatrieme joueur s\'appelle:", pt_size=30, pos=[0.02, 0.2], options=bgui.BGUI_DEFAULT)794 self.joueur4_input = bgui.TextInput(self.frame, 'joueur4_input', str(gl.conf[0][3][0]), pt_size=30, size=[.2, .05], pos=[0.02, 0.13], input_options = bgui.BGUI_INPUT_NONE, options = bgui.BGUI_DEFAULT)795 self.joueur4_input.activate()796 self.joueur4_input.on_enter_key = self.joueur4_on_input_enter797 def detruire(self) :798 """Détruit les widgets"""799 self.frame.parent._remove_widget(self.frame)800 def joueur1_on_input_enter(self, widget):801 widget.deactivate()802 gl.conf[0][0][0] = widget.text803 confParser.savePlayer()804 def joueur2_on_input_enter(self, widget):805 widget.deactivate()806 gl.conf[0][1][0] = widget.text807 confParser.savePlayer()808 def joueur3_on_input_enter(self, widget):809 widget.deactivate()810 gl.conf[0][2][0] = widget.text811 confParser.savePlayer()812 def joueur4_on_input_enter(self, widget):813 widget.deactivate()814 gl.conf[0][3][0] = widget.text815 confParser.savePlayer()816 def main(self) :817 """Refresh des events et de l'affichage"""818 BaseGui.main(self)819class MenuCommandesGui(BaseGui):820 """821 Gui pour le choix du nom des joueurs822 """823 def __init__(self, parent):824 # Initiate the system825 BaseGui.__init__(self, gl.skin)826 # Fond827 self.frame = bgui.Frame(parent, 'cadre', size=[1, 1], pos=[0, 0],828 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)829 # nom du joueur en cour830 self.intituler_joueur_label = bgui.Label(self.frame, 'intituler_joueur', text="nom du joueur courant: ", pt_size=45, pos=[0.05, 0.85], options=bgui.BGUI_DEFAULT)831 self.joueur_label = bgui.Label(self.frame, 'joueur', text=gl.configurablePlayers[0], pt_size=36, pos=[0.1, 0.8], options=bgui.BGUI_DEFAULT)832 # changement de joueur833#############bouton flechejoueurDR############################834 self.flechejoueurDR_button = bgui.ImageButton(self.frame, 'flechejoueurDR', sub_theme='selFleche',835 size=[0.02, 0.05], pos=[0.2, 0.79])836 # Setup an on_click callback837 self.flechejoueurDR_button.on_click = self.rightjoueur838#############bouton flechejoueurGA############################839 self.flechejoueurGA_button = bgui.ImageButton(self.frame, 'flechejoueurGA', sub_theme='selFlecheG',840 size=[0.02, 0.05], pos=[0.04, 0.79])841 # Setup an on_click callback842 self.flechejoueurGA_button.on_click = self.leftjoueur843 # intituler des touches844 self.accelerateur_label = bgui.Label(self.frame, 'accelerateur', text=" accelerateur: ", pt_size=40, pos=[0.15, 0.65], options=bgui.BGUI_DEFAULT)845 self.frein_label = bgui.Label(self.frame, 'frein', text=" frein: ", pt_size=40, pos=[0.15, 0.60], options=bgui.BGUI_DEFAULT)846 self.droite_label = bgui.Label(self.frame, 'droite', text=" droite: ", pt_size=40, pos=[0.15, 0.55], options=bgui.BGUI_DEFAULT)847 self.gauche_label = bgui.Label(self.frame, 'gauche', text=" gauche: ", pt_size=40, pos=[0.15, 0.50], options=bgui.BGUI_DEFAULT)848 self.freinMain_label = bgui.Label(self.frame, 'freinMain', text="frein a main: ", pt_size=40, pos=[0.15, 0.45], options=bgui.BGUI_DEFAULT)849 self.nitro_label = bgui.Label(self.frame, 'nitro', text=" nitro: ", pt_size=40, pos=[0.15, 0.40], options=bgui.BGUI_DEFAULT)850 self.passerVitesse_label = bgui.Label(self.frame, 'passerVitesse', text="passer Vitesse: ", pt_size=40, pos=[0.15, 0.35], options=bgui.BGUI_DEFAULT)851 self.retrograder_label = bgui.Label(self.frame, 'retrograder', text="retrograder: ", pt_size=40, pos=[0.15, 0.30], options=bgui.BGUI_DEFAULT)852 self.respawn_label = bgui.Label(self.frame, 'respawn', text="reapparaitre: ", pt_size=40, pos=[0.15, 0.25], options=bgui.BGUI_DEFAULT)853 self.upcam_label = bgui.Label(self.frame, 'upcam', text="changer de camera: ", pt_size=40, pos=[0.15, 0.20], options=bgui.BGUI_DEFAULT)854 # touche courante855 self.cur_accelerateur_label = bgui.Label(self.frame, 'cur_accelerateur', text=ev.EventToString(int(gl.conf[0][0][2][0][1])), pt_size=40, pos=[0.35, 0.65], options=bgui.BGUI_DEFAULT)856 self.cur_accelerateur_label.state = 0857 self.cur_frein_label = bgui.Label(self.frame, 'cur_frein', text=ev.EventToString(int(gl.conf[0][0][2][1][1])), pt_size=40, pos=[0.35, 0.60], options=bgui.BGUI_DEFAULT)858 self.cur_frein_label.state = 0859 self.cur_droite_label = bgui.Label(self.frame, 'cur_droite', text=ev.EventToString(int(gl.conf[0][0][2][2][1])), pt_size=40, pos=[0.35, 0.55], options=bgui.BGUI_DEFAULT)860 self.cur_droite_label.state = 0861 self.cur_gauche_label = bgui.Label(self.frame, 'cur_gauche', text=ev.EventToString(int(gl.conf[0][0][2][3][1])), pt_size=40, pos=[0.35, 0.50], options=bgui.BGUI_DEFAULT)862 self.cur_gauche_label.state = 0863 self.cur_freinMain_label = bgui.Label(self.frame, 'cur_freinMain', text=ev.EventToString(int(gl.conf[0][0][2][4][1])), pt_size=40, pos=[0.35, 0.45], options=bgui.BGUI_DEFAULT)864 self.cur_freinMain_label.state = 0865 self.cur_nitro_label = bgui.Label(self.frame, 'cur_nitro', text=ev.EventToString(int(gl.conf[0][0][2][5][1])), pt_size=40, pos=[0.35, 0.40], options=bgui.BGUI_DEFAULT)866 self.cur_nitro_label.state = 0867 self.cur_passerVitesse_label = bgui.Label(self.frame, 'cur_passerVitesse', text=ev.EventToString(int(gl.conf[0][0][2][6][1])), pt_size=40, pos=[0.35, 0.35], options=bgui.BGUI_DEFAULT)868 self.cur_passerVitesse_label.state = 0869 self.cur_retrograder_label = bgui.Label(self.frame, 'cur_retrograder', text=ev.EventToString(int(gl.conf[0][0][2][7][1])), pt_size=40, pos=[0.35, 0.30], options=bgui.BGUI_DEFAULT)870 self.cur_retrograder_label.state = 0871 self.cur_respawn_label = bgui.Label(self.frame, 'cur_respawn', text=ev.EventToString(int(gl.conf[0][0][2][8][1])), pt_size=40, pos=[0.35, 0.25], options=bgui.BGUI_DEFAULT)872 self.cur_respawn_label.state = 0873 self.cur_upcam_label = bgui.Label(self.frame, 'cur_upcam', text=ev.EventToString(int(gl.conf[0][0][2][9][1])), pt_size=40, pos=[0.35, 0.20], options=bgui.BGUI_DEFAULT)874 self.cur_upcam_label.state = 0875 # bouton modifier876 self.ModifierAccelerateur_button = bgui.ImageButton(self.frame, 'ModifierAccelerateur', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.65])877 self.ModifierAccelerateur_label = bgui.Label(self.ModifierAccelerateur_button, 'ModifierAccelerateur', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)878 # Setup an on_click callback879 self.ModifierAccelerateur_button.on_click = self.ModifierAccelerateur880 self.Modifierfrein_button = bgui.ImageButton(self.frame, 'Modifierfrein', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.60])881 self.Modifierfrein_label = bgui.Label(self.Modifierfrein_button, 'Modifierfrein', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)882 # Setup an on_click callback883 self.Modifierfrein_button.on_click = self.Modifierfrein884 self.Modifierdroite_button = bgui.ImageButton(self.frame, 'Modifierdroite', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.55])885 self.Modifierdroite_label = bgui.Label(self.Modifierdroite_button, 'Modifierdroite', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)886 # Setup an on_click callback887 self.Modifierdroite_button.on_click = self.Modifierdroite888 self.Modifiergauche_button = bgui.ImageButton(self.frame, 'Modifiergauche', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.50])889 self.Modifiergauche_label = bgui.Label(self.Modifiergauche_button, 'Modifiergauche', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)890 # Setup an on_click callback891 self.Modifiergauche_button.on_click = self.Modifiergauche892 self.ModifierfreinMain_button = bgui.ImageButton(self.frame, 'ModifierfreinMain', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.45])893 self.ModifierfreinMain_label = bgui.Label(self.ModifierfreinMain_button, 'ModifierfreinMain', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)894 # Setup an on_click callback895 self.ModifierfreinMain_button.on_click = self.ModifierfreinMain896 self.Modifiernitro_button = bgui.ImageButton(self.frame, 'Modifiernitro', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.40])897 self.Modifiernitro_label = bgui.Label(self.Modifiernitro_button, 'Modifiernitro', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)898 # Setup an on_click callback899 self.Modifiernitro_button.on_click = self.Modifiernitro900 self.ModifierpasserVitesse_button = bgui.ImageButton(self.frame, 'ModifierpasserVitesse', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.35])901 self.ModifierpasserVitesse_label = bgui.Label(self.ModifierpasserVitesse_button, 'ModifierpasserVitesse', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)902 # Setup an on_click callback903 self.ModifierpasserVitesse_button.on_click = self.ModifierpasserVitesse904 self.Modifierretrograder_button = bgui.ImageButton(self.frame, 'Modifierretrograder', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.30])905 self.Modifierretrograder_label = bgui.Label(self.Modifierretrograder_button, 'Modifierretrograder', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)906 # Setup an on_click callback907 self.Modifierretrograder_button.on_click = self.Modifierretrograder908 self.Modifierrespawn_button = bgui.ImageButton(self.frame, 'Modifierrespawn', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.25])909 self.Modifierrespawn_label = bgui.Label(self.Modifierrespawn_button, 'Modifierrespawn', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)910 # Setup an on_click callback911 self.Modifierrespawn_button.on_click = self.Modifierrespawn912 self.Modifierupcam_button = bgui.ImageButton(self.frame, 'Modifierupcam', sub_theme='menu', size=[0.14, 0.04], pos=[0.56, 0.20])913 self.Modifierupcam_label = bgui.Label(self.Modifierupcam_button, 'Modifierupcam', text="MODIFIER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)914 # Setup an on_click callback915 self.Modifierupcam_button.on_click = self.Modifierupcam916#############bouton sauvgarderComm############################917 self.sauvgarderComm_button = bgui.ImageButton(self.frame, 'sauvgarderComm', sub_theme='menu', size=[0.24, 0.08], pos=[0.45, 0.08])918 self.sauvgarderComm_label = bgui.Label(self.sauvgarderComm_button, 'sauvgarderComm', text="SAUVEGARDER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)919 # Setup an on_click callback920 #self.sauvgarderComm_button.on_click = self.sauvgarderComm921 def rightjoueur(self, widget):922 if self.joueur_label.text == gl.configurablePlayers[0]:923 self.joueur_label.text = gl.configurablePlayers[1]924 self.cur_accelerateur_label.text = ev.EventToString(int(gl.conf[0][1][2][0][1]))925 self.cur_frein_label.text = ev.EventToString(int(gl.conf[0][1][2][1][1]))926 self.cur_droite_label.text = ev.EventToString(int(gl.conf[0][1][2][2][1]))927 self.cur_gauche_label.text = ev.EventToString(int(gl.conf[0][1][2][3][1]))928 self.cur_freinMain_label.text = ev.EventToString(int(gl.conf[0][1][2][4][1]))929 self.cur_nitro_label.text = ev.EventToString(int(gl.conf[0][1][2][5][1]))930 self.cur_passerVitesse_label.text = ev.EventToString(int(gl.conf[0][1][2][6][1]))931 self.cur_retrograder_label.text = ev.EventToString(int(gl.conf[0][1][2][7][1]))932 self.cur_respawn_label.text = ev.EventToString(int(gl.conf[0][1][2][8][1]))933 self.cur_upcam_label.text = ev.EventToString(int(gl.conf[0][1][2][9][1]))934 elif self.joueur_label.text == gl.configurablePlayers[1]:935 self.joueur_label.text = gl.configurablePlayers[2]936 self.cur_accelerateur_label.text = ev.EventToString(int(gl.conf[0][2][2][0][1]))937 self.cur_frein_label.text = ev.EventToString(int(gl.conf[0][2][2][1][1]))938 self.cur_droite_label.text = ev.EventToString(int(gl.conf[0][2][2][2][1]))939 self.cur_gauche_label.text = ev.EventToString(int(gl.conf[0][2][2][3][1]))940 self.cur_freinMain_label.text = ev.EventToString(int(gl.conf[0][2][2][4][1]))941 self.cur_nitro_label.text = ev.EventToString(int(gl.conf[0][2][2][5][1]))942 self.cur_passerVitesse_label.text = ev.EventToString(int(gl.conf[0][2][2][6][1]))943 self.cur_retrograder_label.text = ev.EventToString(int(gl.conf[0][2][2][7][1]))944 self.cur_respawn_label.text = ev.EventToString(int(gl.conf[0][2][2][8][1]))945 self.cur_upcam_label.text = ev.EventToString(int(gl.conf[0][2][2][9][1]))946 elif self.joueur_label.text == gl.configurablePlayers[2]:947 self.joueur_label.text = gl.configurablePlayers[3]948 self.cur_accelerateur_label.text = ev.EventToString(int(gl.conf[0][3][2][0][1]))949 self.cur_frein_label.text = ev.EventToString(int(gl.conf[0][3][2][1][1]))950 self.cur_droite_label.text = ev.EventToString(int(gl.conf[0][3][2][2][1]))951 self.cur_gauche_label.text = ev.EventToString(int(gl.conf[0][3][2][3][1]))952 self.cur_freinMain_label.text = ev.EventToString(int(gl.conf[0][3][2][4][1]))953 self.cur_nitro_label.text = ev.EventToString(int(gl.conf[0][3][2][5][1]))954 self.cur_passerVitesse_label.text = ev.EventToString(int(gl.conf[0][3][2][6][1]))955 self.cur_retrograder_label.text = ev.EventToString(int(gl.conf[0][3][2][7][1]))956 self.cur_respawn_label.text = ev.EventToString(int(gl.conf[0][3][2][8][1]))957 self.cur_upcam_label.text = ev.EventToString(int(gl.conf[0][3][2][9][1]))958 elif self.joueur_label.text == gl.configurablePlayers[3]:959 self.joueur_label.text = gl.configurablePlayers[0]960 self.cur_accelerateur_label.text = ev.EventToString(int(gl.conf[0][0][2][0][1]))961 self.cur_frein_label.text = ev.EventToString(int(gl.conf[0][0][2][1][1]))962 self.cur_droite_label.text = ev.EventToString(int(gl.conf[0][0][2][2][1]))963 self.cur_gauche_label.text = ev.EventToString(int(gl.conf[0][0][2][3][1]))964 self.cur_freinMain_label.text = ev.EventToString(int(gl.conf[0][0][2][4][1]))965 self.cur_nitro_label.text = ev.EventToString(int(gl.conf[0][0][2][5][1]))966 self.cur_passerVitesse_label.text = ev.EventToString(int(gl.conf[0][0][2][6][1]))967 self.cur_retrograder_label.text = ev.EventToString(int(gl.conf[0][0][2][7][1]))968 self.cur_respawn_label.text = ev.EventToString(int(gl.conf[0][0][2][8][1]))969 self.cur_upcam_label.text = ev.EventToString(int(gl.conf[0][0][2][9][1]))970 def leftjoueur(self, widget):971 if self.joueur_label.text == gl.configurablePlayers[0]:972 self.joueur_label.text = gl.configurablePlayers[3]973 self.cur_accelerateur_label.text = ev.EventToString(int(gl.conf[0][3][2][0][1]))974 self.cur_frein_label.text = ev.EventToString(int(gl.conf[0][3][2][1][1]))975 self.cur_droite_label.text = ev.EventToString(int(gl.conf[0][3][2][2][1]))976 self.cur_gauche_label.text = ev.EventToString(int(gl.conf[0][3][2][3][1]))977 self.cur_freinMain_label.text = ev.EventToString(int(gl.conf[0][3][2][4][1]))978 self.cur_nitro_label.text = ev.EventToString(int(gl.conf[0][3][2][5][1]))979 self.cur_passerVitesse_label.text = ev.EventToString(int(gl.conf[0][3][2][6][1]))980 self.cur_retrograder_label.text = ev.EventToString(int(gl.conf[0][3][2][7][1]))981 self.cur_respawn_label.text = ev.EventToString(int(gl.conf[0][0][2][8][1]))982 self.cur_upcam_label.text = ev.EventToString(int(gl.conf[0][3][2][9][1]))983 elif self.joueur_label.text == gl.configurablePlayers[1]:984 self.joueur_label.text = gl.configurablePlayers[0]985 self.cur_accelerateur_label.text = ev.EventToString(int(gl.conf[0][0][2][0][1]))986 self.cur_frein_label.text = ev.EventToString(int(gl.conf[0][0][2][1][1]))987 self.cur_droite_label.text = ev.EventToString(int(gl.conf[0][0][2][2][1]))988 self.cur_gauche_label.text = ev.EventToString(int(gl.conf[0][0][2][3][1]))989 self.cur_freinMain_label.text = ev.EventToString(int(gl.conf[0][0][2][4][1]))990 self.cur_nitro_label.text = ev.EventToString(int(gl.conf[0][0][2][5][1]))991 self.cur_passerVitesse_label.text = ev.EventToString(int(gl.conf[0][0][2][6][1]))992 self.cur_retrograder_label.text = ev.EventToString(int(gl.conf[0][0][2][7][1]))993 self.cur_respawn_label.text = ev.EventToString(int(gl.conf[0][0][2][8][1]))994 self.cur_upcam_label.text = ev.EventToString(int(gl.conf[0][0][2][9][1]))995 elif self.joueur_label.text == gl.configurablePlayers[2]:996 self.joueur_label.text = gl.configurablePlayers[1]997 self.cur_accelerateur_label.text = ev.EventToString(int(gl.conf[0][1][2][0][1]))998 self.cur_frein_label.text = ev.EventToString(int(gl.conf[0][1][2][1][1]))999 self.cur_droite_label.text = ev.EventToString(int(gl.conf[0][1][2][2][1]))1000 self.cur_gauche_label.text = ev.EventToString(int(gl.conf[0][1][2][3][1]))1001 self.cur_freinMain_label.text = ev.EventToString(int(gl.conf[0][1][2][4][1]))1002 self.cur_nitro_label.text = ev.EventToString(int(gl.conf[0][1][2][5][1]))1003 self.cur_passerVitesse_label.text = ev.EventToString(int(gl.conf[0][1][2][6][1]))1004 self.cur_retrograder_label.text = ev.EventToString(int(gl.conf[0][1][2][7][1]))1005 self.cur_respawn_label.text = ev.EventToString(int(gl.conf[0][0][2][8][1]))1006 self.cur_upcam_label.text = ev.EventToString(int(gl.conf[0][1][2][9][1]))1007 elif self.joueur_label.text == gl.configurablePlayers[3]:1008 self.joueur_label.text = gl.configurablePlayers[2]1009 self.cur_accelerateur_label.text = ev.EventToString(int(gl.conf[0][2][2][0][1]))1010 self.cur_frein_label.text = ev.EventToString(int(gl.conf[0][2][2][1][1]))1011 self.cur_droite_label.text = ev.EventToString(int(gl.conf[0][2][2][2][1]))1012 self.cur_gauche_label.text = ev.EventToString(int(gl.conf[0][2][2][3][1]))1013 self.cur_freinMain_label.text = ev.EventToString(int(gl.conf[0][2][2][4][1]))1014 self.cur_nitro_label.text = ev.EventToString(int(gl.conf[0][2][2][5][1]))1015 self.cur_passerVitesse_label.text = ev.EventToString(int(gl.conf[0][2][2][6][1]))1016 self.cur_retrograder_label.text = ev.EventToString(int(gl.conf[0][2][2][7][1]))1017 self.cur_respawn_label.text = ev.EventToString(int(gl.conf[0][0][2][8][1]))1018 self.cur_upcam_label.text = ev.EventToString(int(gl.conf[0][2][2][9][1]))1019 def ModifierAccelerateur(self, widget):1020 if self.cur_accelerateur_label.state == 0:1021 self.cur_accelerateur_label.color = 0.95,0.23,1.0,11022 self.cur_accelerateur_label.state = 11023 self.cur_respawn_label.color = self.cur_upcam_label.color = self.cur_retrograder_label.color = self.cur_passerVitesse_label.color = self.cur_nitro_label.color = self.cur_freinMain_label.color = self.cur_gauche_label.color = self.cur_droite_label.color = self.cur_frein_label.color = 0.95,0.23,0.0,11024 self.cur_respawn_label.state = self.cur_upcam_label.state = self.cur_retrograder_label.state = self.cur_passerVitesse_label.state = self.cur_nitro_label.state = self.cur_freinMain_label.state = self.cur_frein_label.state = self.cur_droite_label.state = self.cur_frein_label.state = 01025 elif self.cur_accelerateur_label.state == 1:1026 self.cur_accelerateur_label.color = 0.95,0.23,0.0,11027 self.cur_accelerateur_label.state = 01028 def Modifierfrein(self, widget):1029 if self.cur_frein_label.state == 0:1030 self.cur_frein_label.color = 0.95,0.23,1.0,11031 self.cur_frein_label.state = 11032 self.cur_respawn_label.color = self.cur_upcam_label.color = self.cur_retrograder_label.color = self.cur_passerVitesse_label.color = self.cur_nitro_label.color = self.cur_freinMain_label.color = self.cur_gauche_label.color = self.cur_droite_label.color = self.cur_accelerateur_label.color = 0.95,0.23,0.0,11033 self.cur_respawn_label.state = self.cur_upcam_label.state = self.cur_retrograder_label.state = self.cur_passerVitesse_label.state = self.cur_nitro_label.state = self.cur_freinMain_label.state = self.cur_gauche_label.state = self.cur_droite_label.state = self.cur_accelerateur_label.state = 01034 elif self.cur_frein_label.state == 1:1035 self.cur_frein_label.color = 0.95,0.23,0.0,11036 self.cur_frein_label.state = 01037 def Modifierdroite(self, widget):1038 if self.cur_droite_label.state == 0:1039 self.cur_droite_label.color = 0.95,0.23,1.0,11040 self.cur_droite_label.state = 11041 self.cur_respawn_label.color = self.cur_upcam_label.color = self.cur_retrograder_label.color = self.cur_passerVitesse_label.color = self.cur_nitro_label.color = self.cur_freinMain_label.color = self.cur_gauche_label.color = self.cur_frein_label.color = self.cur_accelerateur_label.color = 0.95,0.23,0.0,11042 self.cur_respawn_label.state = self.cur_upcam_label.state = self.cur_retrograder_label.state = self.cur_passerVitesse_label.state = self.cur_nitro_label.state = self.cur_freinMain_label.state = self.cur_frein_label.state = self.cur_frein_label.state = self.cur_accelerateur_label.state = 01043 elif self.cur_droite_label.state == 1:1044 self.cur_droite_label.color = 0.95,0.23,0.0,11045 self.cur_droite_label.state = 01046 def Modifiergauche(self, widget):1047 if self.cur_gauche_label.state == 0:1048 self.cur_gauche_label.color = 0.95,0.23,1.0,11049 self.cur_gauche_label.state = 11050 self.cur_respawn_label.color = self.cur_upcam_label.color = self.cur_retrograder_label.color = self.cur_passerVitesse_label.color = self.cur_nitro_label.color = self.cur_freinMain_label.color = self.cur_droite_label.color = self.cur_frein_label.color = self.cur_accelerateur_label.color = 0.95,0.23,0.0,11051 self.cur_respawn_label.state = self.cur_upcam_label.state = self.cur_retrograder_label.state = self.cur_passerVitesse_label.state = self.cur_nitro_label.state = self.cur_freinMain_label.state = self.cur_droite_label.state = self.cur_frein_label.state = self.cur_accelerateur_label.state = 01052 elif self.cur_gauche_label.state == 1:1053 self.cur_gauche_label.color = 0.95,0.23,0.0,11054 self.cur_gauche_label.state = 01055 def ModifierfreinMain(self, widget):1056 if self.cur_freinMain_label.state == 0:1057 self.cur_freinMain_label.color = 0.95,0.23,1.0,11058 self.cur_freinMain_label.state = 11059 self.cur_respawn_label.color = self.cur_upcam_label.color = self.cur_retrograder_label.color = self.cur_passerVitesse_label.color = self.cur_nitro_label.color = self.cur_gauche_label.color = self.cur_droite_label.color = self.cur_frein_label.color = self.cur_accelerateur_label.color = 0.95,0.23,0.0,11060 self.cur_respawn_label.state = self.cur_upcam_label.state = self.cur_retrograder_label.state = self.cur_passerVitesse_label.state = self.cur_nitro_label.state = self.cur_gauche_label.state = self.cur_droite_label.state = self.cur_frein_label.state = self.cur_accelerateur_label.state = 01061 elif self.cur_freinMain_label.state == 1:1062 self.cur_freinMain_label.color = 0.95,0.23,0.0,11063 self.cur_freinMain_label.state = 01064 def Modifiernitro(self, widget):1065 if self.cur_nitro_label.state == 0:1066 self.cur_nitro_label.color = 0.95,0.23,1.0,11067 self.cur_nitro_label.state = 11068 self.cur_respawn_label.color = self.cur_upcam_label.color = self.cur_retrograder_label.color = self.cur_passerVitesse_label.color = self.cur_freinMain_label.color = self.cur_gauche_label.color = self.cur_droite_label.color = self.cur_frein_label.color = self.cur_accelerateur_label.color = 0.95,0.23,0.0,11069 self.cur_respawn_label.state = self.cur_upcam_label.state = self.cur_retrograder_label.state = self.cur_passerVitesse_label.state = self.cur_freinMain_label.state = self.cur_gauche_label.state = self.cur_droite_label.state = self.cur_frein_label.state = self.cur_accelerateur_label.state = 01070 elif self.cur_nitro_label.state == 1:1071 self.cur_nitro_label.color = 0.95,0.23,0.0,11072 self.cur_nitro_label.state = 01073 def ModifierpasserVitesse(self, widget):1074 if self.cur_passerVitesse_label.state == 0:1075 self.cur_passerVitesse_label.color = 0.95,0.23,1.0,11076 self.cur_passerVitesse_label.state = 11077 self.cur_respawn_label.color = self.cur_upcam_label.color = self.cur_retrograder_label.color = self.cur_nitro_label.color = self.cur_freinMain_label.color = self.cur_gauche_label.color = self.cur_droite_label.color = self.cur_frein_label.color = self.cur_accelerateur_label.color = 0.95,0.23,0.0,11078 self.cur_respawn_label.state = self.cur_upcam_label.state = self.cur_retrograder_label.state = self.cur_nitro_label.state = self.cur_freinMain_label.state = self.cur_gauche_label.state = self.cur_droite_label.state = self.cur_frein_label.state = self.cur_accelerateur_label.state = 01079 elif self.cur_passerVitesse_label.state == 1:1080 self.cur_passerVitesse_label.color = 0.95,0.23,0.0,11081 self.cur_passerVitesse_label.state = 01082 def Modifierretrograder(self, widget):1083 if self.cur_retrograder_label.state == 0:1084 self.cur_retrograder_label.color = 0.95,0.23,1.0,11085 self.cur_retrograder_label.state = 11086 self.cur_respawn_label.color = self.cur_upcam_label.color = self.cur_passerVitesse_label.color = self.cur_nitro_label.color = self.cur_freinMain_label.color = self.cur_gauche_label.color = self.cur_droite_label.color = self.cur_frein_label.color = self.cur_accelerateur_label.color = 0.95,0.23,0.0,11087 self.cur_respawn_label.state = self.cur_upcam_label.state = self.cur_passerVitesse_label.state = self.cur_nitro_label.state = self.cur_freinMain_label.state = self.cur_gauche_label.state = self.cur_droite_label.state = self.cur_frein_label.state = self.cur_accelerateur_label.state = 01088 elif self.cur_retrograder_label.state == 1:1089 self.cur_retrograder_label.color = 0.95,0.23,0.0,11090 self.cur_retrograder_label.state = 01091 def Modifierupcam(self, widget):1092 if self.cur_upcam_label.state == 0:1093 self.cur_upcam_label.color = 0.95,0.23,1.0,11094 self.cur_upcam_label.state = 11095 self.cur_respawn_label.color = self.cur_retrograder_label.color = self.cur_passerVitesse_label.color = self.cur_nitro_label.color = self.cur_freinMain_label.color = self.cur_gauche_label.color = self.cur_droite_label.color = self.cur_frein_label.color = self.cur_accelerateur_label.color = 0.95,0.23,0.0,11096 self.cur_respawn_label.state = self.cur_retrograder_label.state = self.cur_passerVitesse_label.state = self.cur_nitro_label.state = self.cur_freinMain_label.state = self.cur_gauche_label.state = self.cur_droite_label.state = self.cur_frein_label.state = self.cur_accelerateur_label.state = 01097 elif self.cur_upcam_label.state == 1:1098 self.cur_upcam_label.color = 0.95,0.23,0.0,11099 self.cur_upcam_label.state = 01100 def Modifierrespawn(self, widget):1101 if self.cur_respawn_label.state == 0:1102 self.cur_respawn_label.color = 0.95,0.23,1.0,11103 self.cur_respawn_label.state = 11104 self.cur_upcam_label.color = self.cur_retrograder_label.color = self.cur_passerVitesse_label.color = self.cur_nitro_label.color = self.cur_freinMain_label.color = self.cur_gauche_label.color = self.cur_droite_label.color = self.cur_frein_label.color = self.cur_accelerateur_label.color = 0.95,0.23,0.0,11105 self.cur_upcam_label.state = self.cur_retrograder_label.state = self.cur_passerVitesse_label.state = self.cur_nitro_label.state = self.cur_freinMain_label.state = self.cur_gauche_label.state = self.cur_droite_label.state = self.cur_frein_label.state = self.cur_accelerateur_label.state = 01106 elif self.cur_upcam_label.state == 1:1107 self.cur_respawn_label.color = 0.95,0.23,0.0,11108 self.cur_respawn_label.state = 01109 def updateKeys(self, key) :1110 #print(self.cur_respawn_label.state, ev.EventToString(key))1111 if self.cur_accelerateur_label.state == 1:1112 self.cur_accelerateur_label.text = ev.EventToString(key)1113 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][0][1] = key1114 if self.cur_frein_label.state == 1:1115 self.cur_frein_label.text = ev.EventToString(key)1116 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][1][1] = key1117 if self.cur_droite_label.state == 1:1118 self.cur_droite_label.text = ev.EventToString(key)1119 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][2][1] = key1120 if self.cur_gauche_label.state == 1:1121 self.cur_gauche_label.text = ev.EventToString(key)1122 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][3][1] = key1123 if self.cur_freinMain_label.state == 1:1124 self.cur_freinMain_label.text = ev.EventToString(key)1125 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][4][1] = key1126 if self.cur_nitro_label.state == 1:1127 self.cur_nitro_label.text = ev.EventToString(key)1128 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][5][1] = key1129 if self.cur_passerVitesse_label.state == 1:1130 self.cur_passerVitesse_label.text = ev.EventToString(key)1131 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][6][1] = key1132 if self.cur_retrograder_label.state == 1:1133 self.cur_retrograder_label.text = ev.EventToString(key)1134 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][7][1] = key1135 if self.cur_upcam_label.state == 1:1136 self.cur_upcam_label.text = ev.EventToString(key)1137 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][9][1] = key1138 if self.cur_respawn_label.state == 1:1139 self.cur_respawn_label.text = ev.EventToString(key)1140 gl.conf[0][gl.configurablePlayers.index(self.joueur_label.text)][2][8][1] = key1141 def sauvgarderComm(self, widget):1142 confParser.savePlayer()1143 def detruire(self) :1144 """Détruit les widgets"""1145 self.frame.parent._remove_widget(self.frame)1146 def main(self) :1147 """Refresh des events et de l'affichage"""1148 BaseGui.main(self)1149class MenuVoitureMultijoueursGui(BaseGui):1150 """1151 Gui pour le choix du nom des joueurs1152 """1153 def __init__(self, parent):1154 # initialiation des variables pour les groupe de boutons en mode 3 et 4 joueurs1155 groupeHautGauche = False1156 groupeHautDroit = False1157 groupeBasGauche = False1158 groupeBasDroit = False1159 # Initiate the system1160 BaseGui.__init__(self, gl.skin)1161 # Fond1162 self.frame = bgui.Frame(parent, 'cadre', size=[1, 1], pos=[0, 0],1163 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)1164 if gl.dispPlayers[0] == 1:1165 #############bouton flecheGJ1############################1166 self.flecheGJ1_button = bgui.ImageButton(self.frame, 'flecheGJ1', sub_theme='selFlecheG', size=[0.04, 0.26], pos=[0.32, 0.72])1167 # Setup an on_click callback1168 #self.flecheGJ1_button.on_click = self.leftcar1169 #############bouton flecheJ1############################1170 self.flecheJ1_button = bgui.ImageButton(self.frame, 'flecheJ1', sub_theme='selFleche', size=[0.04, 0.26], pos=[0.64, 0.72])1171 # Setup an on_click callback1172 #self.flecheJ1_button.on_click = self.rightcar1173 #############bouton flecheGJ1Roue############################1174 self.flecheGJ2Roue_button = bgui.ImageButton(self.frame, 'flecheGRoueJ1', sub_theme='selFlecheG', size=[0.04, 0.18], pos=[0.32, 0.52])1175 # Setup an on_click callback1176 #self.flecheGJ1Roue_button.on_click = self.leftwheels1177 #############bouton flecheJ1Roue############################1178 self.flecheJ1Roue_button = bgui.ImageButton(self.frame, 'flecheRoueJ1', sub_theme='selFleche', size=[0.04, 0.18], pos=[0.64, 0.52])1179 # Setup an on_click callback1180 #self.flecheJ1Roue_button.on_click = self.rightwheels1181 #############bouton flecheGJ2############################1182 self.flecheGJ2_button = bgui.ImageButton(self.frame, 'flecheGJ2', sub_theme='selFlecheG', size=[0.04, 0.26], pos=[0.32, 0.22])1183 # Setup an on_click callback1184 #self.flecheGJ2_button.on_click = self.leftcar1185 #############bouton flecheJ2############################1186 self.flecheJ2_button = bgui.ImageButton(self.frame, 'flecheJ2', sub_theme='selFleche', size=[0.04, 0.26], pos=[0.64, 0.22])1187 # Setup an on_click callback1188 #self.flecheJ2_button.on_click = self.rightcar1189 #############bouton flecheGJ2Roue############################1190 self.flecheGJ2Roue_button = bgui.ImageButton(self.frame, 'flecheGRoueJ2', sub_theme='selFlecheG', size=[0.04, 0.18], pos=[0.32, 0.02])1191 # Setup an on_click callback1192 #self.flecheGJ1Roue_button.on_click = self.leftwheels1193 #############bouton flecheJ2Roue############################1194 self.flecheJ2Roue_button = bgui.ImageButton(self.frame, 'flecheRoueJ2', sub_theme='selFleche', size=[0.04, 0.18], pos=[0.64, 0.02])1195 # Setup an on_click callback1196 #self.flecheJ2Roue_button.on_click = self.rightwheels1197 if gl.dispPlayers[0] == 2:1198 #############bouton flecheGJ1############################1199 self.flecheGJ1_button = bgui.ImageButton(self.frame, 'flecheGJ1', sub_theme='selFlecheG', size=[0.04, 0.26], pos=[0.06, 0.54])1200 # Setup an on_click callback1201 #self.flecheGJ1_button.on_click = self.leftcar1202 #############bouton flecheJ1############################1203 self.flecheJ1_button = bgui.ImageButton(self.frame, 'flecheJ1', sub_theme='selFleche', size=[0.04, 0.26], pos=[0.4, 0.54])1204 # Setup an on_click callback1205 #self.flecheJ1_button.on_click = self.rightcar1206 #############bouton flecheGJ1Roue############################1207 self.flecheGJ2Roue_button = bgui.ImageButton(self.frame, 'flecheGRoueJ1', sub_theme='selFlecheG', size=[0.04, 0.18], pos=[0.06, 0.32])1208 # Setup an on_click callback1209 #self.flecheGJ1Roue_button.on_click = self.leftwheels1210 #############bouton flecheJ1Roue############################1211 self.flecheJ1Roue_button = bgui.ImageButton(self.frame, 'flecheRoueJ1', sub_theme='selFleche', size=[0.04, 0.18], pos=[0.4, 0.32])1212 # Setup an on_click callback1213 #self.flecheJ1Roue_button.on_click = self.rightwheels1214 #############bouton flecheGJ2############################1215 self.flecheGJ2_button = bgui.ImageButton(self.frame, 'flecheGJ2', sub_theme='selFlecheG', size=[0.04, 0.26], pos=[0.56, 0.54])1216 # Setup an on_click callback1217 #self.flecheGJ2_button.on_click = self.leftcar1218 #############bouton flecheJ2############################1219 self.flecheJ2_button = bgui.ImageButton(self.frame, 'flecheJ2', sub_theme='selFleche', size=[0.04, 0.26], pos=[0.9, 0.54])1220 # Setup an on_click callback1221 #self.flecheJ2_button.on_click = self.rightcar1222 #############bouton flecheGJ2Roue############################1223 self.flecheGJ2Roue_button = bgui.ImageButton(self.frame, 'flecheGRoueJ2', sub_theme='selFlecheG', size=[0.04, 0.18], pos=[0.56, 0.32])1224 # Setup an on_click callback1225 #self.flecheGJ1Roue_button.on_click = self.leftwheels1226 #############bouton flecheJ2Roue############################1227 self.flecheJ2Roue_button = bgui.ImageButton(self.frame, 'flecheRoueJ2', sub_theme='selFleche', size=[0.04, 0.18], pos=[0.9, 0.32])1228 # Setup an on_click callback1229 #self.flecheJ2Roue_button.on_click = self.rightwheels1230 if gl.dispPlayers[0] == 3:1231 groupeHautGauche = groupeHautDroit = groupeBasGauche = groupeBasDroit = True1232 if gl.dispPlayers[0] == 4:1233 groupeHautDroit = groupeBasGauche = groupeBasDroit = True1234 if gl.dispPlayers[0] == 5:1235 groupeHautGauche = groupeBasGauche = groupeBasDroit = True1236 if gl.dispPlayers[0] == 6:1237 groupeHautGauche = groupeHautDroit = groupeBasGauche = True1238 if gl.dispPlayers[0] == 7:1239 groupeHautGauche = groupeHautDroit = groupeBasDroit = True1240 if groupeHautGauche == True:1241 #############bouton flecheGJ1############################1242 self.flecheGJ1_button = bgui.ImageButton(self.frame, 'flecheGJ1', sub_theme='selFlecheG', size=[0.04, 0.26], pos=[0.06, 0.72])1243 # Setup an on_click callback1244 #self.flecheGJ1_button.on_click = self.leftcar1245 #############bouton flecheJ1############################1246 self.flecheJ1_button = bgui.ImageButton(self.frame, 'flecheJ1', sub_theme='selFleche', size=[0.04, 0.26], pos=[0.4, 0.72])1247 # Setup an on_click callback1248 #self.flecheJ1_button.on_click = self.rightcar1249 #############bouton flecheGJ1Roue############################1250 self.flecheGJ1Roue_button = bgui.ImageButton(self.frame, 'flecheGRoueJ1', sub_theme='selFlecheG', size=[0.04, 0.18], pos=[0.06, 0.52])1251 # Setup an on_click callback1252 #self.flecheGJ1Roue_button.on_click = self.leftwheels1253 #############bouton flecheJ1Roue############################1254 self.flecheJ1Roue_button = bgui.ImageButton(self.frame, 'flecheRoueJ1', sub_theme='selFleche', size=[0.04, 0.18], pos=[0.4, 0.52])1255 # Setup an on_click callback1256 #self.flecheJ1Roue_button.on_click = self.rightwheels1257 if groupeHautDroit == True:1258 #############bouton flecheGJ2############################1259 self.flecheGJ2_button = bgui.ImageButton(self.frame, 'flecheGJ2', sub_theme='selFlecheG', size=[0.04, 0.26], pos=[0.56, 0.72])1260 # Setup an on_click callback1261 #self.flecheGJ2_button.on_click = self.leftcar1262 #############bouton flecheJ2############################1263 self.flecheJ2_button = bgui.ImageButton(self.frame, 'flecheJ2', sub_theme='selFleche', size=[0.04, 0.26], pos=[0.9, 0.72])1264 # Setup an on_click callback1265 #self.flecheJ2_button.on_click = self.rightcar1266 #############bouton flecheGJ2Roue############################1267 self.flecheGJ2Roue_button = bgui.ImageButton(self.frame, 'flecheGRoueJ2', sub_theme='selFlecheG', size=[0.04, 0.18], pos=[0.56, 0.52])1268 # Setup an on_click callback1269 #self.flecheGJ2Roue_button.on_click = self.leftwheels1270 #############bouton flecheJ2Roue############################1271 self.flecheJ2Roue_button = bgui.ImageButton(self.frame, 'flecheRoueJ2', sub_theme='selFleche', size=[0.04, 0.18], pos=[0.9, 0.52])1272 # Setup an on_click callback1273 #self.flecheJ2Roue_button.on_click = self.rightwheels1274 if groupeBasGauche == True:1275 #############bouton flecheGJ3############################1276 self.flecheGJ3_button = bgui.ImageButton(self.frame, 'flecheGJ3', sub_theme='selFlecheG', size=[0.04, 0.26], pos=[0.06, 0.22])1277 # Setup an on_click callback1278 #self.flecheGJ3_button.on_click = self.leftcar1279 #############bouton flecheJ3############################1280 self.flecheJ3_button = bgui.ImageButton(self.frame, 'flecheJ3', sub_theme='selFleche', size=[0.04, 0.26], pos=[0.4, 0.22])1281 # Setup an on_click callback1282 #self.flecheJ3_button.on_click = self.rightcar1283 #############bouton flecheGJ3Roue############################1284 self.flecheGJ3Roue_button = bgui.ImageButton(self.frame, 'flecheGRoueJ3', sub_theme='selFlecheG', size=[0.04, 0.18], pos=[0.06, 0.02])1285 # Setup an on_click callback1286 #self.flecheGJ3Roue_button.on_click = self.leftwheels1287 #############bouton flecheJ3Roue############################1288 self.flecheJ3Roue_button = bgui.ImageButton(self.frame, 'flecheRoueJ3', sub_theme='selFleche', size=[0.04, 0.18], pos=[0.4, 0.02])1289 # Setup an on_click callback1290 #self.flecheJ3Roue_button.on_click = self.rightwheels1291 if groupeBasDroit == True:1292 #############bouton flecheGJ4############################1293 self.flecheGJ4_button = bgui.ImageButton(self.frame, 'flecheGJ4', sub_theme='selFlecheG', size=[0.04, 0.26], pos=[0.56, 0.22])1294 # Setup an on_click callback1295 #self.flecheGJ4_button.on_click = self.leftcar1296 #############bouton flecheJ4############################1297 self.flecheJ4_button = bgui.ImageButton(self.frame, 'flecheJ4', sub_theme='selFleche', size=[0.04, 0.26], pos=[0.9, 0.22])1298 # Setup an on_click callback1299 #self.flecheJ4_button.on_click = self.rightcar1300 #############bouton flecheGJ4Roue############################1301 self.flecheGJ4Roue_button = bgui.ImageButton(self.frame, 'flecheGRoueJ4', sub_theme='selFlecheG', size=[0.04, 0.18], pos=[0.56, 0.02])1302 # Setup an on_click callback1303 #self.flecheGJ4Roue_button.on_click = self.leftwheels1304 #############bouton flecheJ4Roue############################1305 self.flecheJ4Roue_button = bgui.ImageButton(self.frame, 'flecheRoueJ4', sub_theme='selFleche', size=[0.04, 0.18], pos=[0.9, 0.02])1306 # Setup an on_click callback1307 #self.flecheJ4Roue_button.on_click = self.rightwheels1308 #############bouton valider############################1309 self.valider_button = bgui.ImageButton(self.frame, 'valider', sub_theme='menu', size=[0.10, 0.05], pos=[0.45, 0.51])1310 self.valider_label = bgui.Label(self.valider_button, 'validertext', text="VALIDER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)1311 def detruire(self) :1312 """Détruit les widgets"""1313 self.frame.parent._remove_widget(self.frame)1314 def main(self) :1315 """Refresh des events et de l'affichage"""1316 BaseGui.main(self)1317class MenuOptionsSon(BaseGui):1318 """1319 Gui pour la gestion du son1320 """1321 def __init__(self, parent):1322 # Initiate the system1323 BaseGui.__init__(self, gl.skin)1324 gl.testMotorSound = sound.TestSoundVolume()1325 gl.testMotorSound.start()1326 # Cadre général1327 self.frame = bgui.Frame(parent, 'frame', size=[1, 1], pos=[0, 0],1328 sub_theme="Invisible", options = bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)1329 self.radio_label = bgui.Label(self.frame, 'radio', text="radio par défaut:", pt_size=38, pos=[0.05, 0.90])1330 #fleche radio gauche1331 self.flecheRadioGauche_button = bgui.ImageButton(self.frame, 'flecheRadioGauche', sub_theme='selFlecheG', size=[0.04, 0.06], pos=[0.04, 0.80])1332 # Setup an on_click callback1333 self.flecheRadioGauche_button.on_click = self.flecheRadioGauche1334 # affichage de la radio1335 self.radio_frame = bgui.Frame(self.frame, 'fond', sub_theme='fondDigit', size=[0.20, 0.06], pos=[0.08, 0.80])1336 self.radio_name_label = bgui.Label(self.radio_frame, 'radio_name_label', text=gl.sound[2], pt_size=35, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)1337 #fleche radio droite1338 self.flecheRadioDroite_button = bgui.ImageButton(self.frame, 'flecheRadioDroite', sub_theme='selFleche', size=[0.04, 0.06], pos=[0.28, 0.80])1339 # Setup an on_click callback1340 self.flecheRadioDroite_button.on_click = self.flecheRadioDroite1341#############bouton saveAudio############################1342 self.saveAudio_button = bgui.ImageButton(self.frame, 'saveAudio', sub_theme='menu', size=[0.24, 0.08], pos=[0.45, 0.08])1343 self.saveAudio_label = bgui.Label(self.saveAudio_button, 'saveAudioL', text="SAUVEGARDER", pt_size=24, options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)1344 # Setup an on_click callback1345 self.saveAudio_button.on_click = self.saveRadio1346 # Autres attributs1347 self.action = None1348 def flecheRadioGauche(self, widget):1349 gl.listeRadio.rotate(1)1350 gl.sound[2] = gl.listeRadio[0]1351 self.radio_name_label.text = gl.sound[2]1352 del gl.music1353 def flecheRadioDroite(self, widget):1354 gl.listeRadio.rotate(-1)1355 gl.sound[2] = gl.listeRadio[0]1356 self.radio_name_label.text = gl.sound[2]1357 del gl.music1358 def saveRadio(self, widjet):1359 confParser.saveConf()1360 def detruire(self) :1361 """Détruit les widgets"""1362 self.frame.parent._remove_widget(self.frame)1363 def main(self) :1364 """Refresh des events et de l'affichage"""1365 BaseGui.main(self)1366 def __del__(self):...

Full Screen

Full Screen

hooker_analysis.py

Source:hooker_analysis.py Github

copy

Full Screen

...36#ES_IP = "192.168.0.16"37ES_IP = "127.0.0.1"38ES_PORT = 920039logger = Logger.getLogger(__name__)40def eventToString(event):41 result = []42 result.append("Event {0}".format(event.HookerName))43 result.append("ClassName: {0}".format(event.ClassName))44 result.append("MethodName: {0}".format(event.MethodName))45 result.append("InstanceID: {0}".format(event.InstanceID))46 if event.Parameters is not None and len(event.Parameters) > 0:47 result.append("Parameters:")48 for parameter in event.Parameters:49 if parameter is not None and "ParameterType" in parameter.keys() and "ParameterValue" in parameter.keys():50 result.append("- {0} ({1})".format(parameter["ParameterValue"], parameter["ParameterType"]))51 if event.Return is not None:52 result.append("Return: {0}".format(event.Return))53 return "\n".join(result)54def filterEvents(events, className=None, methodName=None):55 result = []56 for event in events:57 insert = True58 if className is not None and event.ClassName != className:59 insert = False60 if methodName is not None and event.MethodName != methodName:61 insert = False62 if insert:63 result.append(event)64 return result65def macroAnalyzeTelephony(esInterrogator):66 logger.warn("Macro Analysis of Telephony")67 logger.warn("------------------------------------------------")68 telEvents = esInterrogator.getAllEvents(HookerName="Telephony")69 telPerXP = dict()70 for event in telEvents:71 method = event.MethodName72 if method not in telPerXP:73 telPerXP[method]=[]74 if event.Parent not in telPerXP[method]:75 telPerXP[method].append(event.Parent)76 77 logger.info("{0} events related to Telephony".format(len(telEvents)))78 for method, occ in telPerXP.iteritems():79 logger.info("{0}\t\t\t:{1}".format(method, len(occ)))80def macroAnalyzeNetwork(esInterrogator):81 logger.warn("Macro Analysis of Network")82 logger.warn("------------------------------------------------")83 telEvents = esInterrogator.getAllEvents(HookerName="Network")84 telPerXP = dict()85 for event in telEvents:86 method = event.MethodName87 if method not in telPerXP:88 telPerXP[method]=[]89 if event.Parent not in telPerXP[method]:90 telPerXP[method].append(event.Parent)91 92 logger.info("{0} events related to Network".format(len(telEvents)))93 for method, occ in telPerXP.iteritems():94 logger.info("{0}\t\t\t:{1}".format(method, len(occ)))95def macroAnalyzeIPC(esInterrogator):96 logger.warn("Macro Analysis of IPC")97 logger.warn("------------------------------------------------")98 telEvents = esInterrogator.getAllEvents(HookerName="IPC", ClassName="android.content.intent", MethodName="Intent")99 for event in telEvents:100 if len(event.Parameters)>=1 and "ParameterType" in event.Parameters[0].keys() and event.Parameters[0]['ParameterType'] == "java.lang.String":101 logger.info(eventToString(event))102def macroAnalyzeX509CustomVerification(esInterrogator):103 logger.warn("Macro Analysis of x509 custom verification")104 logger.warn("------------------------------------------------")105 initEvents = esInterrogator.getAllEvents(HookerName="Network", ClassName="javax.net.ssl.SSLContext", MethodName="init")106 customTrustManagers = dict()107 108 for event in initEvents:109 logger.debug(eventToString(event))110 if len(event.Parameters)>=1 and len(event.Parameters)<4:111 if "ParameterType" in event.Parameters[1].keys() and event.Parameters[1]['ParameterType'] == "[Ljavax.net.ssl.TrustManager;":112 tmp_trustManager = event.Parameters[1]['ParameterValue']113 114 trustManager = tmp_trustManager.split('{')[1].split('}')[0].split('@')[0]115 116 logger.warn(trustManager)117 if not "org.apache.harmony" in trustManager:118 if trustManager not in customTrustManagers.keys():119 customTrustManagers[trustManager] = []120 if event.Parent not in customTrustManagers[trustManager]:121 customTrustManagers[trustManager].append(event.Parent)122 123 logger.fatal("Found custom TrustManager: {0}".format(eventToString(event)))124 else:125 logger.info("Found apache TrustManager: {0}".format(eventToString(event)))126 for k, v in customTrustManagers.iteritems():127 logger.warn("TrustManager: {0}".format(k))128 for w in v:129 apk = esInterrogator.getAPKInXP(w)130 logger.info("APK : {0}, market={1}, sha1={2}".format(apk.Name, apk.Market, apk.Filesha1))131 # # Finally, check if first and last parameters are different from null132 # if len(event.Parameters[0]) > 0:133 # logger.info("Found client authentication: {0}".format(eventToString(event)))134 # if len(event.Parameters[2]) > 0:135 # logger.info("Found random different from default: {0}".format(eventToString(event)))136def macroAnalyzeWebview(esInterrogator):137 logger.warn("Macro Analysis of Webview components")138 logger.warn("------------------------------------------------")139 eventsPerXP = []140 141 initEvents = esInterrogator.getAllEvents(HookerName="Network", ClassName="android.webkit.WebView", MethodName="addJavascriptInterface")142 for event in initEvents:143 if event.Parent not in eventsPerXP:144 eventsPerXP.append(event.Parent) 145 logger.info(eventToString(event))146 logger.warn("List of XP :")147 for xp in eventsPerXP:148 apk = esInterrogator.getAPKInXP(xp)149 logger.warn("{0}: {1} {2} ({3})".format(xp, apk.Name, apk.Market, apk.Filesha1))150 logger.warn("{0} XP founds.".format(len(eventsPerXP)))151def macroAnalyzeSocketListening(esInterrogator):152 logger.warn("Macro Analysis of socket listening on network")153 logger.warn("------------------------------------------------")154 eventsPerXP = []155 156 initEvents = esInterrogator.getAllEvents(HookerName="Network", ClassName="java.net.SocketServer", MethodName="SocketServer")157 for event in initEvents:158 if event.Parent not in eventsPerXP:159 eventsPerXP.append(event.Parent) 160 logger.info(eventToString(event))161 logger.warn("List of XP :")162 for xp in eventsPerXP:163 apk = esInterrogator.getAPKInXP(xp)164 logger.warn("{0}: {1} {2} ({3})".format(xp, apk.Name, apk.Market, apk.Filesha1))165 logger.warn("{0} XP founds.".format(len(eventsPerXP)))166def macroAnalyzeGeolocation(esInterrogator):167 logger.warn("Macro Analysis of geolocation requests")168 logger.warn("------------------------------------------------")169 eventsPerXP = []170 171 initEvents = esInterrogator.getAllEvents(HookerName="Geolocation", ClassName="android.location.locationmanager", MethodName="getlastknownlocation")172 for event in initEvents:173 if event.Parent not in eventsPerXP:174 eventsPerXP.append(event.Parent) 175 logger.info(eventToString(event))176 initEvents = esInterrogator.getAllEvents(HookerName="Geolocation", ClassName="android.location.location", MethodName="getlongitude")177 for event in initEvents:178 if event.Parent not in eventsPerXP:179 eventsPerXP.append(event.Parent) 180 logger.info(eventToString(event))181 182 initEvents = esInterrogator.getAllEvents(HookerName="Geolocation", ClassName="android.location.location", MethodName="getlatitude")183 for event in initEvents:184 if event.Parent not in eventsPerXP:185 eventsPerXP.append(event.Parent) 186 logger.info(eventToString(event))187 logger.warn("List of XP :")188 for xp in eventsPerXP:189 apk = esInterrogator.getAPKInXP(xp)190 logger.warn("{0}: {1} ({2})".format(xp, apk.Name, apk.Filesha1))191 logger.warn("{0} XP founds.".format(len(eventsPerXP)))192def macroAnalyzeConnectTo(esInterrogator):193 logger.warn("Macro Analysis of IP where APK are connecting")194 logger.warn("------------------------------------------------")195 connectIPs = dict()196 connectPorts = dict()197 connectURLs = dict()198 199 initEvents = esInterrogator.getAllEvents(HookerName="Network", ClassName="java.net.Socket", MethodName="connect")200 for event in initEvents:201 if "ParameterType" in event.Parameters[0].keys() and event.Parameters[0]['ParameterType'] == "java.net.InetSocketAddress":202 tmp = event.Parameters[0]['ParameterValue'].split('/')203 url = tmp[0]204 tmp = tmp[1].split(':')205 ip = tmp[0]206 port = tmp[1]207 #logger.info("url: {0}, ip: {1}, port: {2}".format(url, ip, port))208 # Get URLs209 if url not in connectURLs:210 connectURLs[url] = []211 if event.Parent not in connectURLs[url]:212 connectURLs[url].append(event.Parent)213 # Get IPs214 if ip not in connectIPs:215 connectIPs[ip] = []216 if event.Parent not in connectIPs[ip]:217 connectIPs[ip].append(event.Parent)218 # Get ports219 if port not in connectPorts:220 connectPorts[port] = []221 if event.Parent not in connectPorts[port]:222 connectPorts[port].append(event.Parent)223 224 logger.warn("------------------------------------------------")225 logger.warn("List of URLs and number XP associated :")226 for url, xp in connectURLs.iteritems():227 logger.info("URL: {0} -> number of xp: {1}".format(url, len(xp)))228 logger.warn("------------------------------------------------")229 logger.warn("List of ports and number XP associated :")230 for port, xp in connectPorts.iteritems():231 logger.info("Port: {0} -> number of xp: {1}".format(port, len(xp)))232 if port!='80' and port !='443':233 for _xp in xp:234 apk = esInterrogator.getAPKInXP(_xp)235 logger.warn("Port {0} APK: {1} {2} {3}".format(port, apk.Name, apk.Market, apk.Filesha1))236 237 logger.warn("------------------------------------------------")238 gic = pygeoip.GeoIP('GeoLiteCity.dat')239 connectCities = dict()240 for ip, xp in connectIPs.iteritems():241 city = gic.time_zone_by_addr(ip)242 if city not in connectCities:243 connectCities[city] = []244 if xp not in connectCities[city]:245 connectCities[city].append(xp)246 247 logger.warn("List of cities and XP associated :")248 for city, xp in connectCities.iteritems():249 logger.info("{0} -> number of xp: {1}".format(city, len(xp)))250 251def macroAnalyzeDeviceLockBypass(esInterrogator):252 logger.warn("Macro Analysis of Device Lock Bypass (CVE-2013-6271)")253 logger.warn("------------------------------------------------")254 initEvents = esInterrogator.getAllEvents(HookerName="IPC", ClassName="android.content.intent", MethodName="putExtra")255 for event in initEvents:256 257 if len(event.Parameters)==2:258 # TODO : do this better if we have interesting results...259 if "ParameterType" in event.Parameters[0].keys() and event.Parameters[0]['ParameterType'] == "java.lang.String":260 param = event.Parameters[0]['ParameterValue']261 if "command" in param or "imei" in param or "sms" in param or "PrivateUrls" in param: 262 logger.info(eventToString(event))263 # if "confirm_credentials" in params:264 # # TODO if necessary: check value of the second param265 # logger.fatal(eventToString(event))266def macroAnalyzeCrypto(esInterrogator):267 logger.warn("Macro Analysis of Crypto Events")268 logger.warn("------------------------------------------------") 269 270 logger.warn("------------------------------------------------")271 logger.warn("Base 64")272 logger.warn("------------------------------------------------") 273 b64Events = esInterrogator.getAllEvents(HookerName="Crypto", ClassName="android.util.Base64")274 for event in b64Events:275 logger.info(eventToString(event))276 logger.info("{0} events related to Base 64".format(len(b64Events)))277 logger.warn("------------------------------------------------")278 logger.warn("Cipher")279 logger.warn("------------------------------------------------")280 # Retrieves all the events related to the getInstance call in javax.Crypto.Cipher Class281 cipherEvents = esInterrogator.getAllEvents(HookerName="Crypto", ClassName="javax.crypto.Cipher", MethodName="getInstance")282 algosPerXP = dict()283 for event in cipherEvents:284 # Stores the firt parameter of this method call (the algorithm used)285 algo = event.Parameters[0]["ParameterValue"]286 if algo not in algosPerXP:287 algosPerXP[algo]=[]288 289 if event.Parent not in algosPerXP[algo]:290 algosPerXP[algo].append(event.Parent)291 # List the Android applications that triggered each type of Cipher algorithm292 for algo, xps in algosPerXP.iteritems():293 apks = [esInterrogator.getAPKInXP(xp) for xp in xps]294 logger.warn("{0} ({1} apks): ".format(algo, len(xps)))295 for apk in apks:296 logger.info("\t- {0} ({1})".format(apk.Name, apk.Filesha1))297 logger.warn("------------------------------------------------")298 logger.warn("Mac")299 logger.warn("------------------------------------------------") 300 cipherEvents = esInterrogator.getAllEvents(HookerName="Crypto", ClassName="javax.crypto.Mac", MethodName="getInstance")301 algosPerXP = dict()302 for event in cipherEvents:303 algo = event.Parameters[0]["ParameterValue"]304 if algo not in algosPerXP:305 algosPerXP[algo]=[]306 if event.Parent not in algosPerXP[algo]:307 algosPerXP[algo].append(event.Parent)308 309 logger.info("{0} events related to Mac".format(len(cipherEvents)))310 for algo, occ in algosPerXP.iteritems():311 logger.info("{0}\t\t\t:{1}".format(algo, len(occ)))312 logger.warn("------------------------------------------------")313 logger.warn("MessageDigest")314 logger.warn("------------------------------------------------") 315 cipherEvents = esInterrogator.getAllEvents(HookerName="Crypto", ClassName="java.security.MessageDigest", MethodName="getInstance")316 algosPerXP = dict()317 for event in cipherEvents:318 algo = event.Parameters[0]["ParameterValue"]319 if algo not in algosPerXP:320 algosPerXP[algo]=[]321 if event.Parent not in algosPerXP[algo]:322 algosPerXP[algo].append(event.Parent)323 324 logger.info("{0} events related to MessageDigest".format(len(cipherEvents)))325 # List the Android applications that triggered each type of Cipher algorithm326 for algo, xps in algosPerXP.iteritems():327 apks = [esInterrogator.getAPKInXP(xp) for xp in xps]328 logger.warn("{0} ({1} apks): ".format(algo, len(xps)))329 for apk in apks:330 logger.info("\t- {0} ({1})".format(apk.Name, apk.Filesha1))331 for algo, occ in algosPerXP.iteritems():332 logger.info("{0}\t\t\t:{1}".format(algo, len(occ)))333 334def deleteDuplicatedAPK(esInterrogator):335 logger.info("Register unknown APK")336 # search for all the experiments337 experiments = esInterrogator.getAllExperiments()338 logger.debug("{0} experiments found".format(len(experiments)))339 errorXp = []340 experimentToAPK = dict()341 # check if an apk is registered for each experiment342 for experiment in experiments:343 apk = esInterrogator.getAPKInXP(experiment.IDXP)344 experimentToAPK[experiment] = apk345 if apk is None:346 errorXp.append(experiment)347 for experiment, apk in experimentToAPK.iteritems():348 if apk is None:349 raise "An APK is missing."350 elif isinstance(apk, list):351 # multiple apk, we delete last inserted352 logger.debug(apk)353 toDeleteApk = []354 keptApk = None355 for a in apk:356 if keptApk is None or a.Timestamp < keptApk.Timestamp:357 if keptApk is not None:358 toDeleteApk.append(keptApk)359 keptApk = a360 else:361 toDeleteApk.append(a)362 logger.warn("We delete the APK : ")363 logger.warn(toDeleteApk)364 for apk in toDeleteApk:365 try:366 esInterrogator.es.deleteAPK(apk)367 except Exception, e:368 logger.warn("An occured and prevented the suppression of the APK, {0}".format(e))369 370 logger.debug("{0}: {1}".format(experiment.IDXP, apk))371 logger.warn("{0} experiment has an invalid number of APK".format(len(errorXp)))372 373def main():374 """Main function that execute the various post-analysis functions"""375 logger.info("Execution of the Post-Analysis functions")376 # Initialization of the connection to an ES database377 es = Es([{"host":ES_IP, 'port':ES_PORT}])378 esInterrogator = EsInterrogator(es)379 # ====================================================== 380 # Activate here the kind of analysis you want to perform381 # ======================================================382 # macroAnalyzeConnectTo(esInterrogator) 383 # macroAnalyzeCrypto(esInterrogator)384 # macroAnalyzeTelephony(esInterrogator)385 # macroAnalyzeNetwork(esInterrogator)386 # macroAnalyzeIPC(esInterrogator)387 # macroAnalyzeWebview(esInterrogator)388 # macroAnalyzeX509CustomVerification(esInterrogator)389 # macroAnalyzeDeviceLockBypass(esInterrogator)390 # macroAnalyzeGeolocation(esInterrogator)391 392 # # Retrieve all the known APKs (analyzed or not)393 # # =============================================394 # logger.warn("List of APKs")395 # logger.warn("------------------------------------------------")396 # apks = esInterrogator.getAllAPKs()397 # for apk in apks:398 # logger.info("Name:{0} - Market:{1} - Downloaded Date:{2} - Filesha1:{3} - Filename:{4}".format(apk.Name, apk.Market, apk.Timestamp, apk.Filesha1, apk.Filename))399 400 # logger.warn("> We found {0} apks.".format(len(apks)))401 # logger.warn("------------------------------------------------")402 # # Retrieve all the known experimentations403 # # =======================================404 # logger.warn("List of Experimentations")405 # logger.warn("------------------------------------------------")406 # experiments = esInterrogator.getAllExperiments()407 # for experiment in experiments:408 # logger.info("IDXP:{0} - Filename:{1} - Filesha1:{2} - Emulator:{3}".format(experiment.IDXP, experiment.Filename, experiment.Filesha1, experiment.Emulator))409 410 # logger.warn("> We found {0} experiments.".format(len(experiments)))411 # logger.warn("------------------------------------------------")412 # Now we list the experimentations that cover each APK413 # ====================================================414 # logger.warn("List of Experimentations per APK")415 # logger.warn("------------------------------------------------")416 # for apk in apks:417 # logger.info("APK {0} (sha1 = {1})".format(apk.Name, apk.Filesha1))418 # experiments = esInterrogator.getExperimentsWithAPKSha1(apk.Filesha1)419 # for experiment in experiments:420 # events = esInterrogator.getAllEventsOfExperiment(experiment.IDXP)421 # logger.warn("\t- XP {0} : {1} events captured.".format(experiment.IDXP, len(events)))422 # logger.warn("------------------------------------------------") 423 424 # Retrieve all the events associated with one Experiment425 # ======================================================426 # idXp = "93deb34a13c8a958d75dea4beaea7718"427 # logger.warn("List of events related to XP {0}".format(idXp))428 # logger.warn("------------------------------------------------") 429 # events = esInterrogator.getAllEventsOfExperiment(idXp)430 431 # for event in events:432 # logger.info("{0} - {1} - {2} - {3}".format(event.HookerName, event.ClassName, event.MethodName, event.PackageName))433 # if event.Parameters is not None:434 # for parameter in event.Parameters:435 # logger.debug("Parameter: "+str(parameter))436 437 # logger.error("> We found {0} events.".format(len(events)))438 # logger.warn("------------------------------------------------") 439 # logger.warn("Events by Hooker")440 # logger.warn("------------------------------------------------") 441 442 # logger.warn("DynamicCodeLoader Events")443 # logger.warn("------------------------------------------------") 444 # dynEvents = esInterrogator.getAllEvents(HookerName="Account")445 # for event in dynEvents:446 # logger.info(eventToString(event))447 # logger.warn("Telephony Events")448 # logger.warn("------------------------------------------------") 449 # telephonyEvents = esInterrogator.getAllEvents(HookerName="Telephony")450 # for event in telephonyEvents:451 # logger.info(eventToString(event))452 453 # logger.warn("Runtime Events")454 # logger.warn("------------------------------------------------") 455 # runtimeEvents = esInterrogator.getAllEvents(HookerName="RunTime")456 # for event in runtimeEvents:457 # logger.info(eventToString(event))458 # logger.warn("System Events")459 # logger.warn("------------------------------------------------") 460 # systemEvents = esInterrogator.getAllEvents(HookerName="System")461 # for event in systemEvents:462 # logger.info(eventToString(event))463 # logger.warn("Network Events")464 # logger.warn("------------------------------------------------") 465 # networkEvents = esInterrogator.getAllEvents(HookerName="Network")466 # for event in networkEvents:467 # logger.info(eventToString(event))468 469 # Lets retrieve only java.net.URL:URL method calss470 # logger.warn("List of URLs")471 # logger.warn("------------------------------------------------") 472 # listOfURLs = dict()473 # urlEvents = esInterrogator.getAllEvents(ClassName="java.net.URL", MethodName="URL")474 # for urlEvent in urlEvents:475 # if urlEvent.Parameters is not None and len(urlEvent.Parameters) == 1:476 # url = urlEvent.Parameters[0]["ParameterValue"]477 # if url not in listOfURLs.keys():478 # listOfURLs[url] = 0479 # listOfURLs[url] += 1480 # else:481 # logger.warn(eventToString(urlEvent))482 # for url, nbDef in listOfURLs.iteritems():483 # logger.info("{0} ({1})".format(url, nbDef))484 485 486 # Let's find all the apks487 #apks = es.getAllAPKs()488 489# CLI entry point 490if __name__ == "__main__":491 main()492 ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful