Ejemplo n.º 1
0
    public void PopulateStoryStates()
    {
        StoryBackgroundStates = new Dictionary <string, Texture>();
        InkList storyStateList = InkStoryManager.GetVariable("STORY_STATES") as InkList;
        int     i = 0;

        foreach (var state in storyStateList.all.Keys)
        {
            StoryBackgroundStates[state.itemName] = StoryBackgrounds[i];
            i++;
        }
    }
Ejemplo n.º 2
0
    public void SetCharactersInTeam(string main, string second)
    {
        var list = new InkList("CharactersInTeam", inkStory);

        list.AddItem(main);

        if (!String.IsNullOrEmpty(second))
        {
            list.AddItem(second);
        }

        inkStory.variablesState["CharactersInTeam"] = list;
    }
Ejemplo n.º 3
0
 private void SetupInventoryItems(InkList all)
 {
     if (inventoryItemsSetup)
     {
         return;
     }
     foreach (var item in items)
     {
         item.value.Clear();
         var found = all.Where(i => i.Key.fullName == item.fullName);
         if (found.Count() != 1)
         {
             throw new Exception($"Cannot resolve {item.fullName} to a single item within {all}");
         }
         var listItem = found.Single();
         item.value.Add(listItem.Key, listItem.Value);
     }
     inventoryItemsSetup = true;
 }
        private void SyncListToFungus(string inkListName, object inkListNewValue)
        {
            InkList inkList = story.variablesState[inkListName] as InkList;

            if (inkList == null)
            {
                Debug.LogError("Sync list mismatch: " + inkListName + " is not a list in Ink");
            }
            else
            {
                foreach (string syncVariableName in syncVariables.Keys)
                {
                    if (syncVariableName.StartsWith(inkListName + ListItemSeparator))
                    {
                        string inkItemName = SplitFungusVariableName(syncVariableName)[1];
                        int    itemInList  = inkList.ContainsItemNamed(inkItemName) ? 1 : 0;
                        SyncToFungus(syncVariableName, itemInList);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void TestPolygonAndPolylineAnnotation()
        {
            Document document = new Document();

            document.Pages.Add(new Page(PaperFormat.A4));
            Random  rnd  = new Random();
            InkList list = new InkList();

            PointF[] f = new PointF[10];
            for (int j = 0; j < 10; ++j)
            {
                int min = rnd.Next(100);
                int max = rnd.Next(100, 600);
                for (int i = 0; i < f.Length; ++i)
                {
                    f[i].X = rnd.Next(min, max);
                    f[i].Y = rnd.Next(min, max);
                }
                list.AddArray(new PointsArray(f));
            }
            PolygonAnnotation  annotation  = new PolygonAnnotation(list[0]);
            PolylineAnnotation annotation1 = new PolylineAnnotation(list[1]);

            annotation1.StartLineStyle  = LineEndingStyle.Circle;
            annotation1.EndLineStyle    = LineEndingStyle.RClosedArrow;
            annotation1.BackgroundColor = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
            annotation1.Contents        = "PDF polygon annotation";
            annotation.BackgroundColor  = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
            annotation.Color            = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
            annotation1.Color           = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
            annotation1.Contents        = "PDF polyline annotation";
            document.Pages[0].Annotations.Add(annotation);
            document.Pages[0].Annotations.Add(annotation1);
            document.Save(OutputFolder + @"\TestPolygonAndPolylineAnnotation.pdf");
            document.Dispose();

            //Process.Start("TestPolygonAndPolylineAnnotation.pdf");
        }
        public void OnVariablesChanged(Flowchart origin)
        {
            Debug.Log("OnVariablesChange origin=" + origin.name);
            if (beforeFirstSync)
            {
                Debug.Log("Still initializing, Fungus->Ink sync request ignored");
                return;
            }
            List <Variable> affectedFungusVariables;

            if (origin != null)
            {
                affectedFungusVariables = origin.Variables;
            }
            else
            {
                affectedFungusVariables = new List <Variable>();
                foreach (KeyValuePair <string, List <Flowchart> > syncVariable in syncVariables)
                {
                    // Picks the first flowchart: any flowchart is OK, it's a global variable
                    affectedFungusVariables.Add(syncVariable.Value[0].GetVariable(syncVariable.Key));
                }
            }
            bool useless = true;

            foreach (Variable fungusVariable in affectedFungusVariables)
            {
                if (fungusVariable.Scope == VariableScope.Global && syncVariables.ContainsKey(fungusVariable.Key))
                {
                    useless = false;
                    Type fungusVariableType = fungusVariable.GetValue().GetType();
                    if (fungusVariableType == typeof(int))
                    {
                        int intValue = (fungusVariable as IntegerVariable).Value;
                        Debug.Log(fungusVariable.Key + "=" + intValue + " (Fungus->Ink)");
                        story.variablesState[fungusVariable.Key] = intValue;
                    }
                    else if (fungusVariableType == typeof(string))
                    {
                        string stringValue = (fungusVariable as StringVariable).Value;
                        Debug.Log(fungusVariable.Key + "=" + stringValue + " (Fungus->Ink)");
                        story.variablesState[fungusVariable.Key] = stringValue;
                    }
                    else if (fungusVariableType == typeof(float))
                    {
                        float floatValue = (fungusVariable as FloatVariable).Value;
                        Debug.Log(fungusVariable.Key + "=" + floatValue + " (Fungus->Ink)");
                        story.variablesState[fungusVariable.Key] = floatValue;
                    }
                    else if (fungusVariableType == typeof(bool))
                    {
                        bool boolValue = (fungusVariable as BooleanVariable).Value;
                        Debug.Log(fungusVariable.Key + "=" + boolValue + " (Fungus->Ink)");
                        string[] listVariableParts = SplitFungusVariableName(fungusVariable.Key);
                        if (listVariableParts.Length <= 1)
                        {
                            story.variablesState[fungusVariable.Key] = (boolValue ? 1 : 0);
                        }
                        else
                        {
                            string  listName     = listVariableParts[0];
                            string  listItemName = listVariableParts[1];
                            InkList inkList      = story.variablesState[listName] as InkList;
                            if (inkList == null)
                            {
                                Debug.LogError("Sync list mismatch: " + listName + " is not a list in Ink");
                            }
                            else
                            {
                                if (boolValue)
                                {
                                    if (!inkList.ContainsItemNamed(listItemName))
                                    {
                                        inkList.AddItem(listItemName);
                                        Debug.Log(listItemName + " added in Ink list " + listName);
                                    }
                                }
                                else
                                {
                                    List <InkListItem> toRemove = new List <InkListItem>();
                                    foreach (InkListItem inkListItem in inkList.Keys)
                                    {
                                        if (inkListItem.itemName == listItemName)
                                        {
                                            toRemove.Add(inkListItem);
                                        }
                                    }
                                    foreach (InkListItem inkListItem in toRemove)
                                    {
                                        inkList.Remove(inkListItem);
                                        Debug.Log(inkListItem.fullName + " removed from Ink list " + listName);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Sync variable skipped: " + fungusVariable.Key + " is " + fungusVariableType
                                         + " in Fungus, which does not translate well to Ink");
                    }
                }
            }
            if (useless)
            {
                Debug.LogWarning("No global Fungus variables to sync, consider removing this OnVariablesChange call from the flowchart");
            }
        }
Ejemplo n.º 7
0
        internal override Annotation Clone(IDocumentEssential owner, Page page)
        {
            if (Page == null)
            {
                InkList lst = InkList;

                ApplyOwner(owner);
                SetPage(page, true);

                for (int i = 0; i < lst.Count; ++i)
                {
                    PointF[] points = lst[i].ToArray();
                    lst[i].Clear();
                    lst[i].Page = page;
                    lst[i].AddRange(points);
                }
                lst.Page = page;

                return(this);
            }

            PDFDictionary res = AnnotationBase.Copy(Dictionary);

            MarkupAnnotationBase.CopyTo(Dictionary, res);

            PDFDictionary bs = Dictionary["BS"] as PDFDictionary;

            if (bs != null)
            {
                res.AddItem("BS", AnnotationBorderStyle.Copy(bs));
            }

            PDFArray inkList = Dictionary["InkList"] as PDFArray;

            if (inkList != null)
            {
                PDFArray newInkList = new PDFArray();
                for (int i = 0; i < inkList.Count; ++i)
                {
                    PDFArray points = inkList[i] as PDFArray;
                    if (points != null)
                    {
                        RectangleF oldRect;
                        if (Page == null)
                        {
                            oldRect = new RectangleF();
                        }
                        else
                        {
                            oldRect = Page.PageRect;
                        }

                        newInkList.AddItem(CloneUtility.CopyArrayCoordinates(points, oldRect, page.PageRect, Page == null));
                    }
                }
                res.AddItem("InkList", newInkList);
            }

            InkAnnotation annot = new InkAnnotation(res, owner);

            annot.SetPage(Page, false);
            annot.SetPage(page, true);
            return(annot);
        }