Exemple #1
0
        /// <summary>
        /// Processes all of the <see cref="Objects.Action.ActionObject" />s on the page and builds a display list for the player.
        /// </summary>
        private void ProcessPage()
        {
            DisplayList.Clear();
            var oldPage = CurrentPage;
            var idx     = 0;

            while (true)
            {
                if (oldPage.Objects.Count <= idx)
                {
                    break;
                }
                var thisObject = oldPage.Objects[idx++];

                // Evaluate the expressions (hide takes precidence).
                if (!string.IsNullOrWhiteSpace(thisObject.ShowIf) && !ExpressionHandler.EvaluateBoolean(thisObject.ShowIf, Story.Data))
                {
                    continue;
                }
                if (!string.IsNullOrWhiteSpace(thisObject.HideIf) && ExpressionHandler.EvaluateBoolean(thisObject.HideIf, Story.Data))
                {
                    continue;
                }

                if (thisObject.GetType().BaseType == typeof(PageObject))
                {
                    DisplayList.Add(
                        new Tuple <IObject, Style>(
                            thisObject,
                            Style.CalculateStyle(Story, CurrentPage, (PageObject)thisObject)
                            )
                        );
                    continue;
                }

                ((ActionObject)thisObject).Activate();
                if (CurrentPage == oldPage)
                {
                    continue;
                }

                // Page changed; process controls from the top.
                idx     = 0;
                oldPage = CurrentPage;
            }
        }