Beispiel #1
0
        public override void GenerateIntoContainer(Runtime.Container container)
        {
            var runtimeRawList = new Runtime.InkList();

            if (itemNameList != null)
            {
                foreach (var itemName in itemNameList)
                {
                    var nameParts = itemName.Split('.');

                    string listName     = null;
                    string listItemName = null;
                    if (nameParts.Length > 1)
                    {
                        listName     = nameParts [0];
                        listItemName = nameParts [1];
                    }
                    else
                    {
                        listItemName = nameParts [0];
                    }

                    var listItem = ParsedFiction.ResolveListItem(listName, listItemName, this);
                    if (listItem == null)
                    {
                        if (listName == null)
                        {
                            Error("Could not find list definition that contains item '" + itemName + "'");
                        }
                        else
                        {
                            Error("Could not find list item " + itemName);
                        }
                    }
                    else
                    {
                        if (listName == null)
                        {
                            listName = ((ListDefinition)listItem.parent).name;
                        }
                        var item = new Runtime.InkListItem(listName, listItem.name);

                        if (runtimeRawList.ContainsKey(item))
                        {
                            Warning("Duplicate of item '" + itemName + "' in list.");
                        }
                        else
                        {
                            runtimeRawList [item] = listItem.seriesValue;
                        }
                    }
                }
            }

            container.AddContent(new Runtime.ListValue(runtimeRawList));
        }
        public override void GenerateIntoContainer(Runtime.Container container)
        {
            Expression constantValue = null;

            // If it's a constant reference, just generate the literal expression value
            // It's okay to access the constants at code generation time, since the
            // first thing the ExportRuntime function does it search for all the constants
            // in the story hierarchy, so they're all available.
            if (ParsedFiction.constants.TryGetValue(name, out constantValue))
            {
                constantValue.GenerateConstantIntoContainer(container);
                isConstantReference = true;
                return;
            }

            _runtimeVarRef = new Runtime.VariableReference(name);

            // List item reference?
            // Path might be to a list (listName.listItemName or just listItemName)
            if (path.Count == 1 || path.Count == 2)
            {
                string listItemName = null;
                string listName     = null;

                if (path.Count == 1)
                {
                    listItemName = path [0];
                }
                else
                {
                    listName     = path [0];
                    listItemName = path [1];
                }

                var listItem = ParsedFiction.ResolveListItem(listName, listItemName, this);
                if (listItem)
                {
                    isListItemReference = true;
                }
            }

            container.AddContent(_runtimeVarRef);
        }