def scene_create_lines_for_cp(self, cp: ControlPoint, playerColor, enemyColor): scene = self.scene() pos = self._transform_point(cp.position) for connected_cp in cp.connected_points: pos2 = self._transform_point(connected_cp.position) if not cp.captured: color = CONST.COLORS["dark_"+enemyColor] elif cp.captured: color = CONST.COLORS["dark_"+playerColor] else: color = CONST.COLORS["dark_"+enemyColor] pen = QPen(brush=color) pen.setColor(color) pen.setWidth(6) if cp.captured and not connected_cp.captured and Conflict.has_frontline_between(cp, connected_cp): if not cp.captured: scene.addLine(pos[0], pos[1], pos2[0], pos2[1], pen=pen) else: posx, h = Conflict.frontline_position(self.game.theater, cp, connected_cp) pos2 = self._transform_point(posx) scene.addLine(pos[0], pos[1], pos2[0], pos2[1], pen=pen) p1 = point_from_heading(pos2[0], pos2[1], h+180, 25) p2 = point_from_heading(pos2[0], pos2[1], h, 25) frontline_pen = QPen(brush=CONST.COLORS["bright_red"]) frontline_pen.setColor(CONST.COLORS["orange"]) frontline_pen.setWidth(8) scene.addLine(p1[0], p1[1], p2[0], p2[1], pen=frontline_pen) else: scene.addLine(pos[0], pos[1], pos2[0], pos2[1], pen=pen)
def find_possible_waypoints(self): self.wpts = [] model = QStandardItemModel() i = 0 def add_model_item(i, model, name, wpt): item = QStandardItem(name) model.setItem(i, 0, item) self.wpts.append(wpt) return i + 1 if self.include_frontlines: for cp in self.game.theater.controlpoints: if cp.captured: enemy_cp = [ ecp for ecp in cp.connected_points if ecp.captured != cp.captured ] for ecp in enemy_cp: pos = Conflict.frontline_position( cp, ecp, self.game.theater)[0] wpt = FlightWaypoint( FlightWaypointType.CUSTOM, pos.x, pos.y, Distance.from_meters(800), ) wpt.name = "Frontline " + cp.name + "/" + ecp.name + " [CAS]" wpt.alt_type = "RADIO" wpt.pretty_name = wpt.name wpt.description = "Frontline" i = add_model_item(i, model, wpt.pretty_name, wpt) if self.include_targets: for cp in self.game.theater.controlpoints: if (self.include_enemy and not cp.captured) or (self.include_friendly and cp.captured): for ground_object in cp.ground_objects: if not ground_object.is_dead and isinstance( ground_object, BuildingGroundObject): wpt = FlightWaypoint( FlightWaypointType.CUSTOM, ground_object.position.x, ground_object.position.y, Distance.from_meters(0), ) wpt.alt_type = "RADIO" wpt.name = ground_object.waypoint_name wpt.pretty_name = wpt.name wpt.obj_name = ground_object.obj_name wpt.targets.append(ground_object) if cp.captured: wpt.description = "Friendly Building" else: wpt.description = "Enemy Building" i = add_model_item(i, model, wpt.pretty_name, wpt) if self.include_units: for cp in self.game.theater.controlpoints: if (self.include_enemy and not cp.captured) or (self.include_friendly and cp.captured): for ground_object in cp.ground_objects: if (not ground_object.is_dead and ground_object.dcs_identifier == "AA"): for g in ground_object.groups: for j, u in enumerate(g.units): wpt = FlightWaypoint( FlightWaypointType.CUSTOM, u.position.x, u.position.y, Distance.from_meters(0), ) wpt.alt_type = "RADIO" wpt.name = wpt.name = ( "[" + str(ground_object.obj_name) + "] : " + u.type + " #" + str(j)) wpt.pretty_name = wpt.name wpt.targets.append(u) wpt.obj_name = ground_object.obj_name wpt.waypoint_type = FlightWaypointType.CUSTOM if cp.captured: wpt.description = "Friendly unit : " + u.type else: wpt.description = "Enemy unit : " + u.type i = add_model_item(i, model, wpt.pretty_name, wpt) if self.include_airbases: for cp in self.game.theater.controlpoints: if (self.include_enemy and not cp.captured) or (self.include_friendly and cp.captured): wpt = FlightWaypoint( FlightWaypointType.CUSTOM, cp.position.x, cp.position.y, Distance.from_meters(0), ) wpt.alt_type = "RADIO" wpt.name = cp.name if cp.captured: wpt.description = ("Position of " + cp.name + " [Friendly Airbase]") else: wpt.description = "Position of " + cp.name + " [Enemy Airbase]" if cp.cptype == ControlPointType.AIRCRAFT_CARRIER_GROUP: wpt.pretty_name = cp.name + " (Aircraft Carrier Group)" elif cp.cptype == ControlPointType.LHA_GROUP: wpt.pretty_name = cp.name + " (LHA Group)" else: wpt.pretty_name = cp.name + " (Airbase)" i = add_model_item(i, model, wpt.pretty_name, wpt) self.setModel(model)
def find_possible_waypoints(self): self.wpts = [] model = QStandardItemModel() i = 0 def add_model_item(i, model, name, wpt): print(name) item = QStandardItem(name) model.setItem(i, 0, item) self.wpts.append(wpt) return i + 1 if self.include_frontlines: for cp in self.game.theater.controlpoints: if cp.captured: enemy_cp = [ecp for ecp in cp.connected_points if ecp.captured != cp.captured] for ecp in enemy_cp: pos = Conflict.frontline_position(self.game.theater, cp, ecp)[0] wpt = FlightWaypoint( FlightWaypointType.CUSTOM, pos.x, pos.y, 800) wpt.name = "Frontline " + cp.name + "/" + ecp.name + " [CAS]" wpt.alt_type = "RADIO" wpt.pretty_name = wpt.name wpt.description = "Frontline" wpt.data = [cp, ecp] wpt.category = PredefinedWaypointCategory.FRONTLINE i = add_model_item(i, model, wpt.pretty_name, wpt) if self.include_targets: for cp in self.game.theater.controlpoints: if (self.include_enemy and not cp.captured) or (self.include_friendly and cp.captured): for ground_object in cp.ground_objects: if not ground_object.is_dead and not ground_object.dcs_identifier == "AA": wpt = FlightWaypoint( FlightWaypointType.CUSTOM, ground_object.position.x, ground_object.position.y, 0 ) wpt.alt_type = "RADIO" wpt.name = wpt.name = "[" + str(ground_object.obj_name) + "] : " + ground_object.category + " #" + str(ground_object.object_id) wpt.pretty_name = wpt.name wpt.obj_name = ground_object.obj_name wpt.targets.append(ground_object) wpt.data = ground_object if cp.captured: wpt.description = "Friendly Building" wpt.category = PredefinedWaypointCategory.ALLY_BUILDING else: wpt.description = "Enemy Building" wpt.category = PredefinedWaypointCategory.ENEMY_BUILDING i = add_model_item(i, model, wpt.pretty_name, wpt) if self.include_units: for cp in self.game.theater.controlpoints: if (self.include_enemy and not cp.captured) or (self.include_friendly and cp.captured): for ground_object in cp.ground_objects: if not ground_object.is_dead and ground_object.dcs_identifier == "AA": for g in ground_object.groups: for j, u in enumerate(g.units): wpt = FlightWaypoint( FlightWaypointType.CUSTOM, u.position.x, u.position.y, 0 ) wpt.alt_type = "RADIO" wpt.name = wpt.name = "[" + str(ground_object.obj_name) + "] : " + u.type + " #" + str(j) wpt.pretty_name = wpt.name wpt.targets.append(u) wpt.data = u wpt.obj_name = ground_object.obj_name wpt.waypoint_type = FlightWaypointType.CUSTOM if cp.captured: wpt.description = "Friendly unit : " + u.type wpt.category = PredefinedWaypointCategory.ALLY_UNIT else: wpt.description = "Enemy unit : " + u.type wpt.category = PredefinedWaypointCategory.ENEMY_UNIT i = add_model_item(i, model, wpt.pretty_name, wpt) if self.include_airbases: for cp in self.game.theater.controlpoints: if (self.include_enemy and not cp.captured) or (self.include_friendly and cp.captured): wpt = FlightWaypoint( FlightWaypointType.CUSTOM, cp.position.x, cp.position.y, 0 ) wpt.alt_type = "RADIO" wpt.name = cp.name wpt.data = cp if cp.captured: wpt.description = "Position of " + cp.name + " [Friendly Airbase]" wpt.category = PredefinedWaypointCategory.ALLY_CP else: wpt.description = "Position of " + cp.name + " [Enemy Airbase]" wpt.category = PredefinedWaypointCategory.ENEMY_CP if cp.cptype == ControlPointType.AIRCRAFT_CARRIER_GROUP: wpt.pretty_name = cp.name + " (Aircraft Carrier Group)" elif cp.cptype == ControlPointType.LHA_GROUP: wpt.pretty_name = cp.name + " (LHA Group)" else: wpt.pretty_name = cp.name + " (Airbase)" i = add_model_item(i, model, wpt.pretty_name, wpt) self.setModel(model)