Beispiel #1
0
 public override CompatibilitySetting GetCompatibilitySetting(PsaiMusicEntity targetEntity)
 {
     if (targetEntity is Segment)
     {
         if (ManuallyBlockedSnippets.Contains((Segment)targetEntity))
         {
             return(CompatibilitySetting.blocked);
         }
         else if (ManuallyLinkedSnippets.Contains((Segment)targetEntity))
         {
             return(CompatibilitySetting.allowed);
         }
     }
     return(CompatibilitySetting.neutral);
 }
Beispiel #2
0
        // this method returns the compatibility type of this Snippet to a following Snippet, based
        // on the compatibility flowchart in the "doc_internal" folder of this project.
        public override CompatibilityType GetCompatibilityType(PsaiMusicEntity targetEntity, out CompatibilityReason reason)
        {
            reason = CompatibilityReason.not_set;

            if (targetEntity is Segment)
            {
                Segment targetSegment = (Segment)targetEntity;
                Group   sourceGroup   = this.Group;
                Group   targetGroup   = targetSegment.Group;


                if (sourceGroup.GetCompatibilityType(targetGroup, out reason) == CompatibilityType.logically_impossible)
                {
                    return(CompatibilityType.logically_impossible);
                }
                else
                {
                    // step 1
                    // a pure END-Segment can never follow another pure END-Segment
                    if (this.HasOnlyEndSuitability())
                    {
                        if (targetSegment.HasOnlyEndSuitability())
                        {
                            reason = CompatibilityReason.target_segment_and_source_segment_are_both_only_usable_at_end;
                            return(CompatibilityType.logically_impossible);
                        }
                    }


                    // step 2
                    // transitioning to a pure END-Segment (which is no BridgeSnippet) of some other Group will never happen
                    if (sourceGroup != targetGroup &&
                        targetSegment.HasOnlyEndSuitability() &&
                        !targetSegment.IsAutomaticBridgeSegment &&
                        !targetSegment.IsManualBridgeSegmentForSourceGroup(sourceGroup)
                        )
                    {
                        reason = CompatibilityReason.target_segment_is_of_a_different_group_and_is_only_usable_at_end;
                        return(CompatibilityType.logically_impossible);
                    }


                    // step 3
                    // transitioning to a pure Bridge-Snippet within the same Group is not allowed
                    if (sourceGroup == targetGroup)
                    {
                        if (!targetSegment.IsUsableInMiddle && !targetSegment.IsUsableAtEnd &&
                            (targetSegment.IsAutomaticBridgeSegment || targetSegment.IsManualBridgeSegmentForSourceGroup(sourceGroup)))
                        {
                            reason = CompatibilityReason.target_segment_is_a_pure_bridge_segment_within_the_same_group;
                            return(CompatibilityType.blocked_implicitly);
                        }
                    }


                    // step 4
                    if (ManuallyLinkedSnippets.Contains(targetSegment))
                    {
                        reason = CompatibilityReason.manual_setting_within_same_hierarchy;
                        return(CompatibilityType.allowed_manually);
                    }

                    // step 5
                    if (ManuallyBlockedSnippets.Contains(targetSegment))
                    {
                        reason = CompatibilityReason.manual_setting_within_same_hierarchy;
                        return(CompatibilityType.blocked_manually);
                    }


                    // step 6
                    // In case of group-transitions: Is there a BridgeSnippet in the targetGroup for the SourceGroup? Then block the TargetSnippet implicitly, if it is no BridgSnippet from the SourceGroup to TargetGroup.
                    // Otherwise allow.
                    if (sourceGroup != null && sourceGroup != targetGroup)
                    {
                        //if (EditorModel.Instance.Project.CheckIfThereIsAtLeastOneBridgeSnippetFromSourceGroupToTargetGroup(sourceGroup, targetGroup))
                        if (targetGroup.ContainsAtLeastOneAutomaticBridgeSegment() || targetGroup.ContainsAtLeastOneManualBridgeSegmentForSourceGroup(sourceGroup))
                        {
                            if (targetSegment.IsManualBridgeSegmentForSourceGroup(sourceGroup))
                            {
                                reason = CompatibilityReason.target_segment_is_a_manual_bridge_segment_for_the_source_group;
                                return(CompatibilityType.allowed_manually);
                            }

                            if (targetSegment.IsAutomaticBridgeSegment)
                            {
                                reason = CompatibilityReason.target_segment_is_an_automatic_bridge_segment;
                                return(CompatibilityType.allowed_implicitly);
                            }

                            // block all non-bridge-snippets:
                            reason = CompatibilityReason.target_group_contains_at_least_one_bridge_segment;
                            return(CompatibilityType.blocked_implicitly);
                        }
                    }


                    // step
                    // Anything is implicitly allowed after a pure END-Segment
                    if (this.HasOnlyEndSuitability())
                    {
                        reason = CompatibilityReason.anything_may_be_played_after_a_pure_end_segment;
                        return(CompatibilityType.allowed_implicitly);
                    }


                    // step
                    // if the default compatibility of the targetSegment is allowed_implicitly, continue evaluation by regarding the parent group
                    if (targetSegment.DefaultCompatibiltyAsFollower == CompatibilityType.allowed_implicitly)
                    {
                        CompatibilityType groupCompatibility = this.Group.GetCompatibilityType(targetSegment.Group, out reason);
                        {
                            switch (groupCompatibility)
                            {
                            case CompatibilityType.blocked_manually:
                                reason = CompatibilityReason.manual_setting_of_parent_entity;
                                return(CompatibilityType.blocked_implicitly);

                            case CompatibilityType.blocked_implicitly:
                                return(CompatibilityType.blocked_implicitly);

                            case CompatibilityType.allowed_manually:
                                reason = CompatibilityReason.manual_setting_of_parent_entity;
                                return(CompatibilityType.allowed_implicitly);

                            default:
                                reason = CompatibilityReason.inherited_from_parent_hierarchy;
                                return(CompatibilityType.allowed_implicitly);
                            }
                        }
                    }
                    else
                    {
                        reason = CompatibilityReason.default_compatibility_of_the_target_segment_as_a_follower;
                        return(targetSegment.DefaultCompatibiltyAsFollower);
                    }
                }
            }

            return(CompatibilityType.undefined);
        }