public static void PlayStory(Story story, int startSegment) { loadingStory = false; if (activeStory == null) { playbackThread = new Thread(new ParameterizedThreadStart(PlayStoryCallback)); playbackThread.Start(new object[] { story, startSegment }); } }
public static void LoadStoriesFromPacket(string[] parse) { try { int n = 1; for (int i = 0; i <= MaxInfo.MaxStories; i++) { dataLoadPercent = System.Math.Min(99, Logic.MathFunctions.CalculatePercent(i, MaxInfo.MaxStories)); mStories[i] = new Story(); mStories[i].Name = parse[n]; n += 1; ((Windows.winLoading)Windows.WindowSwitcher.FindWindow("winLoading")).UpdateLoadText("Recieving Data... " + DataManager.AverageLoadPercent().ToString() + "%"); } dataLoadPercent = 100; } catch (Exception ex) { Exceptions.ExceptionHandler.OnException(ex); } }
public static void PlayStoryCallback(Object param) { Object[] paramObj = param as Object[]; Story story = paramObj[0] as Story; int startSegment = (int)paramObj[1]; if (activeStory == null) { activeStory = story; resetEvent = new ManualResetEvent(false); story.State = new StoryState(resetEvent); story.State.StoryPaused = false; story.State.CurrentSegment = startSegment; if (!string.IsNullOrEmpty(story.Name) || story.LocalStory) { try { do { if (!story.LocalStory) { Messenger.SendUpdateSegment(story.State.CurrentSegment); } ISegment segment = story.Segments[story.State.CurrentSegment]; ISegment nextSegment = GetNextSegment(story, story.State.CurrentSegment); story.State.NextSegment = nextSegment; if (segment != null) { segment.Process(story.State); } story.State.CurrentSegment++; } while (story.State.CurrentSegment < story.Segments.Count); } catch (Exception ex) { SdlDotNet.Widgets.MessageBox.Show(ex.ToString(), "Error!"); } } if (!story.LocalStory) { Messenger.SendChapterComplete(); } Menus.MenuSwitcher.CloseAllMenus(); activeStory = null; } }
static ISegment GetNextSegment(Story story, int currentSegment) { if (currentSegment < story.Segments.Count - 1) { return story.Segments[currentSegment + 1]; } else { return null; } }