Some tweaks to the HUD
This commit is contained in:
parent
4aceb65559
commit
8f20c73d62
|
@ -345,8 +345,11 @@ class ModuleHUD (object):
|
||||||
bar_width = 106
|
bar_width = 106
|
||||||
i = 0
|
i = 0
|
||||||
for module_name, module_info in self._info_text.items():
|
for module_name, module_info in self._info_text.items():
|
||||||
|
if not module_info:
|
||||||
|
continue
|
||||||
surface = self._header_font.render(module_name, True, COLOR_ALUMINIUM_0).convert_alpha()
|
surface = self._header_font.render(module_name, True, COLOR_ALUMINIUM_0).convert_alpha()
|
||||||
display.blit(surface, (8 + bar_width / 2, 18 * i + v_offset))
|
display.blit(surface, (8 + bar_width / 2, 18 * i + v_offset))
|
||||||
|
v_offset += 12
|
||||||
i += 1
|
i += 1
|
||||||
for item in module_info:
|
for item in module_info:
|
||||||
if v_offset + 18 > self.dim[1]:
|
if v_offset + 18 > self.dim[1]:
|
||||||
|
@ -356,7 +359,6 @@ class ModuleHUD (object):
|
||||||
points = [(x + 8, v_offset + 8 + (1.0 - y) * 30) for x, y in enumerate(item)]
|
points = [(x + 8, v_offset + 8 + (1.0 - y) * 30) for x, y in enumerate(item)]
|
||||||
pygame.draw.lines(display, (255, 136, 0), False, points, 2)
|
pygame.draw.lines(display, (255, 136, 0), False, points, 2)
|
||||||
item = None
|
item = None
|
||||||
v_offset += 18
|
|
||||||
elif isinstance(item, tuple):
|
elif isinstance(item, tuple):
|
||||||
if isinstance(item[1], bool):
|
if isinstance(item[1], bool):
|
||||||
rect = pygame.Rect((bar_h_offset, v_offset + 8), (6, 6))
|
rect = pygame.Rect((bar_h_offset, v_offset + 8), (6, 6))
|
||||||
|
@ -375,6 +377,7 @@ class ModuleHUD (object):
|
||||||
surface = self._font_mono.render(item, True, COLOR_ALUMINIUM_0).convert_alpha()
|
surface = self._font_mono.render(item, True, COLOR_ALUMINIUM_0).convert_alpha()
|
||||||
display.blit(surface, (8, 18 * i + v_offset))
|
display.blit(surface, (8, 18 * i + v_offset))
|
||||||
v_offset += 18
|
v_offset += 18
|
||||||
|
v_offset += 24
|
||||||
self._notifications.render(display)
|
self._notifications.render(display)
|
||||||
self.help.render(display)
|
self.help.render(display)
|
||||||
|
|
||||||
|
@ -676,9 +679,6 @@ class ModuleWorld(object):
|
||||||
def update_hud_info(self, clock):
|
def update_hud_info(self, clock):
|
||||||
hero_mode_text = []
|
hero_mode_text = []
|
||||||
if self.hero_actor is not None:
|
if self.hero_actor is not None:
|
||||||
vehicle_name, vehicle_brand, vehicle_model = self.hero_actor.type_id.split('.')
|
|
||||||
type_id_text = vehicle_brand + ' ' + vehicle_model
|
|
||||||
|
|
||||||
hero_speed = self.hero_actor.get_velocity()
|
hero_speed = self.hero_actor.get_velocity()
|
||||||
hero_speed_text = 3.6 * math.sqrt(hero_speed.x ** 2 + hero_speed.y ** 2 + hero_speed.z ** 2)
|
hero_speed_text = 3.6 * math.sqrt(hero_speed.x ** 2 + hero_speed.y ** 2 + hero_speed.z ** 2)
|
||||||
|
|
||||||
|
@ -695,11 +695,11 @@ class ModuleWorld(object):
|
||||||
|
|
||||||
hero_mode_text = [
|
hero_mode_text = [
|
||||||
'Hero Mode: ON',
|
'Hero Mode: ON',
|
||||||
'Hero ID: %4d' % self.hero_actor.id,
|
'Hero ID: %7d' % self.hero_actor.id,
|
||||||
'Hero Type ID:%12s' % type_id_text,
|
'Hero Vehicle: %14s' % get_actor_display_name(self.hero_actor, truncate=14),
|
||||||
'Hero speed: %3d km/h' % hero_speed_text,
|
'Hero Speed: %3d km/h' % hero_speed_text,
|
||||||
'Hero Affected by:',
|
'Hero Affected by:',
|
||||||
' Traffic Light:%12s' % affected_traffic_light,
|
' Traffic Light: %12s' % affected_traffic_light,
|
||||||
' Speed Limit: %3d km/h' % affected_speed_limit
|
' Speed Limit: %3d km/h' % affected_speed_limit
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
|
@ -709,13 +709,14 @@ class ModuleWorld(object):
|
||||||
module_info_text = [
|
module_info_text = [
|
||||||
'Server: % 16s FPS' % round(self.server_fps),
|
'Server: % 16s FPS' % round(self.server_fps),
|
||||||
'Client: % 16s FPS' % round(clock.get_fps()),
|
'Client: % 16s FPS' % round(clock.get_fps()),
|
||||||
'Simulation time: % 12s' % datetime.timedelta(seconds=int(self.simulation_time)),
|
'Simulation Time: % 12s' % datetime.timedelta(seconds=int(self.simulation_time)),
|
||||||
'Map Name: %10s' % self.world.map_name,
|
'Map Name: %10s' % self.world.map_name,
|
||||||
]
|
]
|
||||||
|
|
||||||
module_info_text = module_info_text + hero_mode_text
|
module_info_text = module_info_text
|
||||||
module_hud = module_manager.get_module(MODULE_HUD)
|
module_hud = module_manager.get_module(MODULE_HUD)
|
||||||
module_hud.add_info(self.name, module_info_text)
|
module_hud.add_info(self.name, module_info_text)
|
||||||
|
module_hud.add_info('HERO', hero_mode_text)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def on_world_tick(weak_self, timestamp):
|
def on_world_tick(weak_self, timestamp):
|
||||||
|
@ -746,13 +747,13 @@ class ModuleWorld(object):
|
||||||
elif 'walker' in actor.type_id:
|
elif 'walker' in actor.type_id:
|
||||||
walkers.append(actor)
|
walkers.append(actor)
|
||||||
|
|
||||||
if self.hero_actor is not None and len(vehicles) > 1:
|
|
||||||
info_text = []
|
info_text = []
|
||||||
|
if self.hero_actor is not None and len(vehicles) > 1:
|
||||||
location = self.hero_actor.get_location()
|
location = self.hero_actor.get_location()
|
||||||
vehicle_list = [x for x in vehicles if x.id != self.hero_actor.id]
|
vehicle_list = [x for x in vehicles if x.id != self.hero_actor.id]
|
||||||
distance = lambda v: location.distance(v.get_location())
|
distance = lambda v: location.distance(v.get_location())
|
||||||
for n, vehicle in enumerate(sorted(vehicle_list, key=distance)):
|
for n, vehicle in enumerate(sorted(vehicle_list, key=distance)):
|
||||||
if n > 10:
|
if n > 15:
|
||||||
break
|
break
|
||||||
vehicle_type = get_actor_display_name(vehicle, truncate=22)
|
vehicle_type = get_actor_display_name(vehicle, truncate=22)
|
||||||
info_text.append('% 5d %s' % (vehicle.id, vehicle_type))
|
info_text.append('% 5d %s' % (vehicle.id, vehicle_type))
|
||||||
|
|
Loading…
Reference in New Issue