Beispiel #1
0
        public void ConstructStoryLines(StoryViewModel storyModel, StoryLineViewModel parent, IScene startScene, int depth, IStorylinePositioner storylineAdder)
        {            
            IScene currentScene = startScene;

            StoryLineViewModel lineScenes = new StoryLineViewModel(storyModel, parent);
            lineScenes.Depth = depth;            

            storylineAdder.Position(lineScenes);

            int padding = depth;
            while (currentScene != null)
            {
                padding++;
                lineScenes.Add(new SceneViewModel(currentScene));
                InteractiveScene interactiveScene = currentScene as InteractiveScene;
                if (null != interactiveScene && interactiveScene.Type == SceneType.Interactive)
                {
                    foreach (IScene possibleStartScene in interactiveScene.PossibleScenes)
                    {
                        ConstructStoryLines(storyModel, lineScenes, possibleStartScene, padding, storylineAdder);
                    }

                    break;
                }
                else
                {
                    currentScene = currentScene.FollowingScene;
                }
            }

            lineScenes.CollectionChanged += lineScenes_CollectionChanged;
        }
 private StoryLineViewModel AddStoryline(int index, StoryLineViewModel childStorylineModel)
 {            
     if (index < storyLines.Count - 1)
     {
         storyLines.Insert(index + 1, childStorylineModel);
     }
     else
     {
         storyLines.Add(childStorylineModel);
     }
     return childStorylineModel;
 }
 internal ObservableCollection<DataModel.Model.IScene> GetScenes(StoryLineViewModel storylineModel)
 {
     ObservableCollection<IScene> scenes = new ObservableCollection<IScene>();
     if (storylineModel != null)
     {
         foreach (SceneViewModel sceneModel in storylineModel)
         {
             scenes.Add(sceneModel.CurrentScene);
         }
     }
     return scenes;
 }
 public void Position(StoryLineViewModel lineScenes)
 {
     AddStoryline(index, lineScenes);
 }
Beispiel #5
0
 public void Position(StoryLineViewModel lineScenes)
 {
     storylines.Add(lineScenes);
 }
Beispiel #6
0
 internal StoryLineViewModel CreateStoryLine(StoryViewModel storyViewModel)
 {
     StoryLineViewModel storylineModel = new StoryLineViewModel(storyViewModel, null);
     storylineModel.CollectionChanged += lineScenes_CollectionChanged;
     return storylineModel;
 }
Beispiel #7
0
        private static InteractiveScene GetPredecessor(int index, StoryLineViewModel storylineModel)
        {
            if ((index == 0 && storylineModel.Parent == null) || index > storylineModel.Count)
            {
                return null;
            }
            
            InteractiveScene oldPredecessor = null;

            if (index == 0 && storylineModel.Parent != null)
            {
                StoryLineViewModel parentStoryline = storylineModel.Parent;
                SceneViewModel parentSceneModel = parentStoryline.Last();
                if (parentSceneModel.CurrentScene is InteractiveScene)
                {
                    oldPredecessor = parentSceneModel.CurrentScene as InteractiveScene;
                }
            }
            else{
                SceneViewModel lastExistingSceneModel = storylineModel[index - 1];
                oldPredecessor = lastExistingSceneModel.CurrentScene as InteractiveScene;
            }

            return oldPredecessor;
        }
Beispiel #8
0
        private InteractiveScene GetSuccessor(int addedSceneIndex, StoryLineViewModel storylineModel)
        {
            int successorIndex = addedSceneIndex + 1;
            if (successorIndex < storylineModel.Count)
            {
                SceneViewModel successorSceneModel = storylineModel[successorIndex];
                return successorSceneModel.CurrentScene as InteractiveScene;
            }

            return null;
        }
Beispiel #9
0
        public void RefreshScenes(StoryLineViewModel storyline, bool refreshSelected = true)
        {
            ScenesViewModel = new ObservableCollection<SceneViewModel>(BuildPath(storyline));
            SceneViewModel lastSceneViewModel = null;
            lastSceneViewModel = storyline.LastOrDefault();

            if (null != lastSceneViewModel)
            {
                Scenes = new ObservableCollection<IScene>(BuildPath(Story.StartScene, lastSceneViewModel.CurrentScene));
            }

            if (Scenes.Count > 0)
            {
                CurrentScene = Scenes[0];
                if (refreshSelected)
                {
                    SelectedSceneViewModel = storyline.FirstOrDefault();
                    SelectedSceneViewModel = null;
                }
            }
        }
Beispiel #10
0
 private int FindStoryLineIndex(StoryLineViewModel storyline)
 {
     for (int i = 0; i < StoryLines.Count; i++)
     {
         if (StoryLines[i] == storyline)
         {
             return i;
         }
     }
     return -1;
 }
Beispiel #11
0
        internal void AddStoryline(StoryLineViewModel storyline)
        {
            if (storyline.Count > 0)
            {
                SceneViewModel lastScene = storyline.Last();

                InteractiveScene interactiveScene;
                if (lastScene.CurrentScene is InteractiveScene)
                {
                    interactiveScene = lastScene.CurrentScene as InteractiveScene;
                    if (null != interactiveScene)
                    {
                        interactiveScene.Type = SceneType.Interactive;
                    }
                }
                else
                {
                    interactiveScene = new InteractiveScene(lastScene.CurrentScene.LibraryItem);
                    storyline.Remove(lastScene);
                    storyline.Add(CreateSceneViewModel(interactiveScene));
                }

                int index = FindStoryLineIndex(storyline);
                if (index > -1)
                {
                    IStorylinePositioner positioner = new StorylineInserter(StoryLines, index);
                    _builder.ConstructStoryLines(this, storyline, null, storyline.Depth + storyline.Count, positioner);
                    SelectStoryline(StoryLines[index + 1]);
                }
            }
        }
Beispiel #12
0
 private static bool isFavorited(StoryLineViewModel targetStoryLine, SceneViewModel scene)
 {
     ObservableCollection<SceneTag> favoriteTags = targetStoryLine.StoryModel.FavoriteTags;
     if (favoriteTags.Count == 0)
     {
         return false;
     }
     foreach (SceneTag sceneTag in scene.Tags)
     {
         foreach (SceneTag favoriteTag in favoriteTags)
         {
             if (favoriteTag.Content.Equals(sceneTag.Content))
             {
                 return true;
             }
         }
     }
     return false;
 }
Beispiel #13
0
 private static IEnumerable<SceneViewModel> ReverseAndFilter(StoryLineViewModel targetStoryLine)
 {
     return (from scene in targetStoryLine
             where (!scene.IsBonus || (scene.IsBonus && isFavorited(targetStoryLine, scene)))
             select scene).Reverse();
 }
Beispiel #14
0
        private IEnumerable<SceneViewModel> BuildPath(StoryLineViewModel targetStoryLine)
        {
            List<SceneViewModel> result = new List<SceneViewModel>();
            result.AddRange(ReverseAndFilter(targetStoryLine));
            StoryLineViewModel parent = targetStoryLine;
            while (null != (parent = parent.Parent))
            {
                result.AddRange(ReverseAndFilter(parent));
            }

            result.Reverse();
            return result;
        }
Beispiel #15
0
 internal void SelectStoryline(StoryLineViewModel storyline)
 {
     CurrentStoryline = storyline;
     RefreshScenes(storyline);
 }
Beispiel #16
0
 private void HandleReorder(StoryViewModel storyModel, StoryLineViewModel storyline)
 {
     //storyModel.Story = storyModel.Story;
     storyModel.RefreshScenes(storyline);
 }
Beispiel #17
0
 private void UpdateIsCurrent(StoryLineViewModel storyline)
 {
     if (storyline != null)
     {
         //This value is dummy, just to trigger property notification
         storyline.IsCurrent = true;
     }
 }