Skip to content

Commit

Permalink
modifications
Browse files Browse the repository at this point in the history
les avions peuvent être modifier après leur apparition via une fenêtre dédiée
  • Loading branch information
MaelkMaelk committed Oct 19, 2024
1 parent 227ec7f commit e7217b9
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 50 deletions.
22 changes: 11 additions & 11 deletions Python/XML/simu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
<avions>
<avion heure="100200">
<indicatif>FCACA</indicatif>
<aircraft>A339</aircraft>
<route>ABISA-NEV</route>
<aircraft>B738</aircraft>
<route>ABISA-RAPID</route>
<altitude>30000</altitude>
<arrival>False</arrival>
<x>1375</x>
<y>1644</y>
<x>1375.0</x>
<y>1644.0</y>
<PFL>300</PFL>
<CPDLC>True</CPDLC>
<ExRVSM>True</ExRVSM>
<CPDLC>False</CPDLC>
<ExRVSM>False</ExRVSM>
</avion>
<avion heure="100200">
<indicatif>FCACA</indicatif>
<indicatif>AFR1563</indicatif>
<aircraft>B738</aircraft>
<route>BIELA-GAI</route>
<route>GAI-JUVEN</route>
<altitude>30000</altitude>
<arrival>False</arrival>
<x>2229</x>
<y>944</y>
<x>699.0</x>
<y>1341.0</y>
<PFL>300</PFL>
<CPDLC>True</CPDLC>
<ExRVSM>False</ExRVSM>
<ExRVSM>True</ExRVSM>
</avion>
</avions>
</simu>
26 changes: 21 additions & 5 deletions Python/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def main(server_ip: str):
game = packet.game
dictAvionsAff = {}
dictAvions = packet.dictAvions
dict_avion_spawn = packet.listeTotale

# Map
carte = packet.map
Expand All @@ -101,7 +102,7 @@ def main(server_ip: str):

# scroll and zoom
zoomDef = 0.5
scrollDef = [width / 4, height/4]
scrollDef: list[float] = [width / 4, height/4]
zoom = zoomDef
scroll = scrollDef
drag = [0, 0]
Expand Down Expand Up @@ -148,15 +149,17 @@ def main(server_ip: str):
# 2em boucle pour supprimer, car on ne peut pas delete en pleine iteration
dictAvionsAff[avionId].kill()
dictAvionsAff.pop(avionId)

carte = packet.map
game = packet.game
dictAvions = packet.dictAvions
if packet.listeTotale is not None:
dict_avion_spawn = packet.listeTotale

for sep in sepDict.values():
sep.calculation(carte)

for event in pygame.event.get():

if event.type == pygame.QUIT:
run = False
pygame.quit()
Expand Down Expand Up @@ -238,8 +241,8 @@ def main(server_ip: str):
localRequests.append((len(dictAvions), "DelayedAdd", action))
else:
localRequests.append((len(dictAvions), "Add", action))
for avion in dictAvionsAff.values():
avion.conflitSelected = False
for avion in dictAvionsAff.values():
avion.conflitSelected = False
conflitBool = False
conflitGen = None

Expand Down Expand Up @@ -275,6 +278,9 @@ def main(server_ip: str):
elif action == 'menuATC' and menuATC is None:
menuATC = interface.menuATC(avion, pygame.mouse.get_pos())

elif action == 'modifier':
nouvelAvionWin = interface.nouvelAvionWindow(carte['routes'], perfos, dict_avion_spawn[avion.Id])

elif menuValeurs is None and action is not None:
# si on a renvoyé autre chose alors c'est une valeur pour ouvrir un menu
menuValeurs = interface.menuValeurs(avion, pygame.mouse.get_pos(), action, pilote)
Expand All @@ -286,7 +292,10 @@ def main(server_ip: str):
newPlaneData = nouvelAvionWin.checkEvent(event)

# on vérifie que newPlane n'est pas None (les valeurs ont été renvoyés)
if newPlaneData:
if newPlaneData is not None and nouvelAvionWin.avion is not None:
localRequests.append((nouvelAvionWin.avion.Id, 'Modifier', newPlaneData))

elif newPlaneData:

# on crée alors un nouvel avion
FL = None
Expand Down Expand Up @@ -435,12 +444,15 @@ def main(server_ip: str):
pressing = True
delaiPressage = pygame.time.get_ticks()
if keys[pygame.K_LEFT]:
pressing = True
localRequests.append((0, 'Slower'))
delaiPressage = pygame.time.get_ticks()
if keys[pygame.K_RIGHT]:
pressing = True
localRequests.append((0, 'Faster'))
delaiPressage = pygame.time.get_ticks()
if keys[pygame.K_s]:
pressing = True
localRequests.append((0, 'Save'))
delaiPressage = pygame.time.get_ticks()

Expand Down Expand Up @@ -543,6 +555,10 @@ def main(server_ip: str):
img = font.render("gelé", True, (255, 105, 180))
win.blit(img, (20, 50))

if game.accelerationTemporelle != 1:
img = font.render(str(game.accelerationTemporelle), True, (255, 105, 180))
win.blit(img, (20, 70))

# dessin Heure
heureDisplay = horloge.affichageHeure(game.heure)

Expand Down
6 changes: 3 additions & 3 deletions Python/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def calculateDistance(x1: int | float, y1: int | float, x2: int | float, y2: int
return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)


def calculateShortestPoint(pointDroite1: list[float, float] | tuple[float, float],
pointDroite2: list[float, float] | tuple[float, float],
point: list[float, float] | tuple[float, float],
def calculateShortestPoint(pointDroite1: list[float] | tuple[float, float],
pointDroite2: list[float] | tuple[float, float],
point: list[float] | tuple[float, float],
segment=False
):
"""
Expand Down
36 changes: 35 additions & 1 deletion Python/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def scrollListGen(valueList, rect, container, sliderBool=True, sliderDroite=Fals

class nouvelAvionWindow:

def __init__(self, routes, avions):
def __init__(self, routes, avions, avion_tuple=None):

# le dictionnaire utilisé pour renvoyer les valeurs sélectionnées par nos boutons
self.returnValues = {'indicatif': 'FCACA',
Expand All @@ -75,6 +75,8 @@ def __init__(self, routes, avions):
'conflit': False,
'CPDLC': False,
'ExRVSM': False}
avion = avion_tuple[1]
self.avion = avion

# la fenêtre du menu
self.window = pygame_gui.elements.UIWindow(pygame.Rect((250, 250), (600, 400)))
Expand Down Expand Up @@ -167,6 +169,38 @@ def __init__(self, routes, avions):
anchors={'top': 'top', 'top_target': self.CPDLC, 'left': 'left',
'left_target': self.conflitsBouton})

if avion is not None:

self.returnValues = {'indicatif': avion.indicatif,
'avion': avion.aircraft,
'arrival': avion.arrival,
'conflit': False,
'CPDLC': avion.CPDLC,
'altitude': avion.altitude,
'PFL': avion.PFL,
'ExRVSM': avion.ExRVSM}

for bouton in self.routeBoutonListe:
if bouton.text == avion.route['name']:
bouton.select()

for bouton in self.typeAvionBoutonListe:
if bouton.text == avion.aircraft:
bouton.select()

if avion.ExRVSM:
self.ExRVSM.select()

if avion.CPDLC:
self.CPDLC.select()

if avion.arrival:
self.arrivalBouton.select()

self.indicatifinput.set_text(avion.indicatif)
self.FLinput.set_text(str(round(avion.altitude / 100)))
self.PFLinput.set_text(str(avion.PFL))

def checkEvent(self, event):

"""
Expand Down
14 changes: 12 additions & 2 deletions Python/loadXML.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ def loadAvionXML(avionXML, carte: dict, perfos: dict, heure: float, planeId: int
else:
spawnFL = None

if 'CPDLC' in avionDict:
CPDLC = avionDict['CPDLC'] == 'True'
else:
CPDLC = False

if 'ExRVSM' in avionDict:
ExRVSM = avionDict['ExRVSM'] == 'True'
else:
ExRVSM = False

avionPack = AvionPacket(
carte,
planeId,
Expand All @@ -115,8 +125,8 @@ def loadAvionXML(avionXML, carte: dict, perfos: dict, heure: float, planeId: int
avionDict['arrival'] == 'True',
heure,
FL=spawnFL,
CPDLC=avionDict['CPDLC'] == 'True',
ExRVSM=avionDict['ExRVSM'] == 'True',
CPDLC=CPDLC,
ExRVSM=ExRVSM,
x=avionDict['x'],
y=avionDict['y'])

Expand Down
11 changes: 7 additions & 4 deletions Python/paquets_avion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import math

# Native imports
import random

Expand All @@ -14,16 +14,18 @@ def __init__(self, heure):
self.ready = False
self.paused = False # on commence avec la situation en pause
self.heure = heure
self.accelerationTemporelle = 1


class Packet:
def __init__(self, Id, game=None, dictAvions=None, requests=None, carte=None, perfos=None):
def __init__(self, Id, game=None, dictAvions=None, requests=None, carte=None, perfos=None, listeTotale=None):
self.Id = Id
self.game = game
self.dictAvions = dictAvions
self.requests = requests
self.map = carte
self.perfos = perfos
self.listeTotale = listeTotale


class AvionPacket:
Expand Down Expand Up @@ -104,7 +106,7 @@ def __init__(self, gameMap, Id, indicatif, aircraft, perfos, route, arrival, heu
self.modeA = str(random.randint(1000, 9999))

if medevac:
self.medevac = 'MEDEVAC' # TODO ajouter le noW
self.medevac = 'MEDEVAC'
else:
self.medevac = ''

Expand All @@ -127,7 +129,7 @@ def __init__(self, gameMap, Id, indicatif, aircraft, perfos, route, arrival, heu

self.headingMode = False

self.nextPoint = None
self.nextPoint: dict = self.route['points'][0]
self.findNextPoint(gameMap)

if PFL is not None:
Expand Down Expand Up @@ -469,6 +471,7 @@ def calculeEstimate(self, points: dict, pointVoulu: str) -> float:
x1 = self.x
y1 = self.y

point = {}
for point in self.route['points']:
if point['name'] == self.DCT:
break
Expand Down
5 changes: 4 additions & 1 deletion Python/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Avion:
global timeConstant
global plotSize

def __init__(self, Id: int, papa, zoom: float, scroll: list[float, float]):
def __init__(self, Id: int, papa, zoom: float, scroll: list[float]):
self.Id = Id
self.papa = papa
clicks = frozenset([pygame.BUTTON_LEFT, pygame.BUTTON_RIGHT, pygame.BUTTON_MIDDLE])
Expand Down Expand Up @@ -475,6 +475,9 @@ def checkEvent(self, event, pilote, conflitBool):
elif event.mouse_button == 1 and not pilote:
return 'menuATC'

elif event.mouse_button == 2 and pilote:
return 'modifier'

elif event.mouse_button == 3 and (
self.etiquette.indicatif.get_object_ids()[1] in ['@etiquetteBold', '@etiquetteBoldBlue']):

Expand Down
Loading

0 comments on commit e7217b9

Please sign in to comment.