mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
prompt window with logs on raised exception; minor UI updates; minor fixes
This commit is contained in:
@@ -9,6 +9,7 @@ from game.event import *
|
||||
UNITTYPES_FOR_EVENTS = {
|
||||
FrontlineAttackEvent: [CAS, PinpointStrike],
|
||||
FrontlinePatrolEvent: [CAP, PinpointStrike],
|
||||
BaseAttackEvent: [CAP, CAS, PinpointStrike],
|
||||
InterceptEvent: [CAP],
|
||||
InsurgentAttackEvent: [CAS],
|
||||
NavalInterceptEvent: [CAS],
|
||||
|
||||
@@ -22,21 +22,20 @@ class EventResultsMenu(Menu):
|
||||
self.window.clear_right_pane()
|
||||
|
||||
if not self.finished:
|
||||
"""
|
||||
For debugging purposes
|
||||
|
||||
Button(self.frame, text="no losses, succ", command=self.simulate_result(0, 1)).grid()
|
||||
Button(self.frame, text="no losses, fail", command=self.simulate_result(0, 1)).grid(row=1, column=1)
|
||||
|
||||
Button(self.frame, text="half losses, succ", command=self.simulate_result(0.5, 0.5)).grid(row=2, )
|
||||
Button(self.frame, text="half losses, fail", command=self.simulate_result(0.5, 0.5)).grid(row=2, column=1)
|
||||
|
||||
Button(self.frame, text="full losses, succ", command=self.simulate_result(1, 0)).grid(row=3, )
|
||||
Button(self.frame, text="full losses, fail", command=self.simulate_result(1, 0)).grid(row=3, column=1)
|
||||
"""
|
||||
|
||||
Label(self.frame, text="Play the mission and save debriefing to").grid(row=0, column=0)
|
||||
Label(self.frame, text=debriefing_directory_location()).grid(row=1, column=0)
|
||||
|
||||
"""
|
||||
For debugging purposes
|
||||
"""
|
||||
|
||||
row = 3
|
||||
Separator(self.frame, orient=HORIZONTAL).grid(row=row, sticky=EW); row += 1
|
||||
Label(self.frame, text="Cheat operation results: ").grid(row=row); row += 1
|
||||
Button(self.frame, text="full enemy losses", command=self.simulate_result(0, 1)).grid(row=row); row += 1
|
||||
Button(self.frame, text="full player losses", command=self.simulate_result(1, 0)).grid(row=row); row += 1
|
||||
Button(self.frame, text="some enemy losses", command=self.simulate_result(0, 0.8)).grid(row=row); row += 1
|
||||
Button(self.frame, text="some player losses", command=self.simulate_result(0.8, 0)).grid(row=row); row += 1
|
||||
else:
|
||||
row = 0
|
||||
if self.event.is_successfull(self.debriefing):
|
||||
@@ -81,27 +80,53 @@ class EventResultsMenu(Menu):
|
||||
def action():
|
||||
debriefing = Debriefing({})
|
||||
|
||||
def count_planes(groups: typing.List[FlyingGroup], mult: float) -> typing.Dict[UnitType, int]:
|
||||
def count(country: Country) -> typing.Dict[UnitType, int]:
|
||||
result = {}
|
||||
for group in groups:
|
||||
for g in country.plane_group + country.vehicle_group + country.helicopter_group + country.ship_group:
|
||||
group = g # type: Group
|
||||
for unit in group.units:
|
||||
result[unit.unit_type] = result.get(unit.unit_type, 0) + 1 * mult
|
||||
unit_type = None
|
||||
if isinstance(unit, Vehicle):
|
||||
unit_type = vehicle_map[unit.type]
|
||||
elif isinstance(unit, Ship):
|
||||
unit_type = ship_map[unit.type]
|
||||
else:
|
||||
unit_type = unit.unit_type
|
||||
|
||||
return {x: math.ceil(y) for x, y in result.items() if y >= 1}
|
||||
if unit_type in db.EXTRA_AA.values():
|
||||
continue
|
||||
|
||||
player_planes = self.event.operation.mission.country(self.game.player).plane_group
|
||||
enemy_planes = self.event.operation.mission.country(self.game.enemy).plane_group
|
||||
result[unit_type] = result.get(unit_type, 0) + 1
|
||||
|
||||
self.player_losses = count_planes(player_planes, player_factor)
|
||||
self.enemy_losses = count_planes(enemy_planes, enemy_factor)
|
||||
return result
|
||||
|
||||
player = self.event.operation.mission.country(self.game.player)
|
||||
enemy = self.event.operation.mission.country(self.game.enemy)
|
||||
|
||||
alive_player_units = count(player)
|
||||
alive_enemy_units = count(enemy)
|
||||
|
||||
destroyed_player_units = db.unitdict_restrict_count(alive_player_units, math.ceil(sum(alive_player_units.values()) * player_factor))
|
||||
destroyed_enemy_units = db.unitdict_restrict_count(alive_enemy_units, math.ceil(sum(alive_enemy_units.values()) * enemy_factor))
|
||||
|
||||
alive_player_units = {k: v - destroyed_player_units.get(k, 0) for k, v in alive_player_units.items()}
|
||||
alive_enemy_units = {k: v - destroyed_enemy_units.get(k, 0) for k, v in alive_enemy_units.items()}
|
||||
|
||||
debriefing.alive_units = {
|
||||
enemy.name: alive_enemy_units,
|
||||
player.name: alive_player_units,
|
||||
}
|
||||
|
||||
debriefing.destroyed_units = {
|
||||
self.game.player: self.player_losses,
|
||||
self.game.enemy: self.enemy_losses,
|
||||
player.name: destroyed_player_units,
|
||||
enemy.name: destroyed_enemy_units,
|
||||
}
|
||||
|
||||
self.finished = True
|
||||
self.debriefing = debriefing
|
||||
self.player_losses = debriefing.destroyed_units.get(self.game.player, {})
|
||||
self.enemy_losses = debriefing.destroyed_units.get(self.game.enemy, {})
|
||||
|
||||
self.game.finish_event(self.event, debriefing)
|
||||
self.display()
|
||||
self.game.pass_turn()
|
||||
|
||||
@@ -34,13 +34,18 @@ class MainMenu(Menu):
|
||||
|
||||
def event_button(event):
|
||||
nonlocal row
|
||||
Message(self.frame, text="{}{}".format(
|
||||
Message(self.frame, text="{}{} at {}".format(
|
||||
event.defender_name == self.game.player and "Enemy attacking: " or "",
|
||||
event
|
||||
event,
|
||||
event.to_cp,
|
||||
), aspect=1600).grid(column=0, row=row, sticky=NW)
|
||||
Button(self.frame, text=">", command=self.start_event(event)).grid(column=0, row=row, sticky=NE+S)
|
||||
row += 1
|
||||
Separator(self.frame, orient='horizontal').grid(row=row, sticky=EW); row += 1
|
||||
Button(self.frame, text=">", command=self.start_event(event)).grid(column=0, row=row, sticky=NE+S); row += 1
|
||||
|
||||
def destination_header(text, separator=True):
|
||||
nonlocal row
|
||||
if separator:
|
||||
Separator(self.frame, orient=HORIZONTAL).grid(row=row, sticky=EW); row += 1
|
||||
Label(self.frame, text=text).grid(column=0, row=row, sticky=N); row += 1
|
||||
|
||||
Button(self.frame, text="Configuration", command=self.configuration_menu).grid(column=0, row=0, sticky=NE)
|
||||
Button(self.frame, text="Pass turn", command=self.pass_turn).grid(column=0, row=0, sticky=NW)
|
||||
@@ -48,9 +53,20 @@ class MainMenu(Menu):
|
||||
Separator(self.frame, orient='horizontal').grid(row=row, sticky=EW); row += 1
|
||||
|
||||
events = self.game.events
|
||||
events.sort(key=lambda x: x.from_cp.name)
|
||||
events.sort(key=lambda x: x.informational and 2 or (self.game.is_player_attack(x) and 1 or 0))
|
||||
|
||||
destination = None
|
||||
for event in events:
|
||||
if not event.informational:
|
||||
if self.game.is_player_attack(event):
|
||||
new_destination = event.from_cp.name
|
||||
else:
|
||||
new_destination = "Enemy attack"
|
||||
if destination != new_destination:
|
||||
destination_header(new_destination, destination is not None)
|
||||
destination = new_destination
|
||||
|
||||
if event.informational:
|
||||
label(str(event))
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user