예제 #1
0
        /*
         * Read connections from JSON entry.
         */
        private static void ReadConnections(Project project, JSONClass root)
        {
            List <Connection> tmp = new List <Connection>();

            IEnumerator children = root.GetEnumerator();

            while (children.MoveNext())
            {
                // Get current
                KeyValuePair <string, JSONNode> current = (children.Current != null) ?
                                                          (KeyValuePair <string, JSONNode>)children.Current : default(KeyValuePair <string, JSONNode>);
                JSONNode child = current.Value;

                // Create element
                Connection c = new Connection();
                c.id              = current.Key;
                c.label           = child["label"];
                c.sourceElementId = child["sourceid"];
                c.targetElementId = child["targetid"];

                // Add
                tmp.Add(c);
            }

            project.connections = tmp.ToArray();
        }
예제 #2
0
        public IParseble Parse(JSONNode projectNode)
        {
            id     = projectNode ["id"].AsInt;
            name   = projectNode ["name"];
            nameEn = projectNode ["nameEn"];
            virtualCurrencyName    = projectNode ["virtualCurrencyName"];
            virtualCurrencyIconUrl = projectNode ["virtualCurrencyImage"];
            merchantId             = projectNode ["merchantId"].AsInt;
            isDiscrete             = projectNode ["isDiscrete"].AsBool;
            projectUrl             = projectNode ["projectUrl"];
            returnUrl             = projectNode ["returnUrl"];
            isKeepUsers           = projectNode ["isKeepUsers"].AsBool;
            recurringPackageCount = projectNode ["recurringPackageCount"].AsInt;
            eula             = projectNode ["eula"];
            canRepeatPayment = projectNode ["canRepeatPayment"].AsBool;

            JSONClass   jsonObj  = projectNode["components"].AsObject;
            IEnumerator elements = jsonObj.GetEnumerator();

            while (elements.MoveNext())
            {
                KeyValuePair <string, JSONNode> elem = (KeyValuePair <string, JSONNode>)elements.Current;
                string localName = elem.Value["name"].Value;
                bool   isEnabled = elem.Value["enabled"].AsBool;
                Debug.Log("elem.Key " + elem.Key + " name " + localName + " isEnabled " + isEnabled);
                XComponent newComponent = new XComponent(localName, isEnabled);
                components.Add(elem.Key, newComponent);
            }
            return(this);
        }
예제 #3
0
        /*
         * Read jumpers from JSON entry.
         */
        private static void ReadJumpers(Project project, JSONClass root)
        {
            List <Jumper> tmp = new List <Jumper>();

            IEnumerator children = root.GetEnumerator();

            while (children.MoveNext())
            {
                // Get current
                KeyValuePair <string, JSONNode> current = (children.Current != null) ?
                                                          (KeyValuePair <string, JSONNode>)children.Current : default(KeyValuePair <string, JSONNode>);
                JSONNode child = current.Value;

                // Create element
                Jumper jumper = new Jumper();
                jumper.id        = current.Key;
                jumper.boardID   = null;
                jumper.elementID = child["elementId"];

                // Add
                tmp.Add(jumper);
            }

            project.jumpers = tmp.ToArray();
        }
        private void fillMap(JSONNode translationsNode)
        {
            JSONClass   jsonObj  = translationsNode.AsObject;
            IEnumerator elements = jsonObj.GetEnumerator();

            while (elements.MoveNext())
            {
                KeyValuePair <string, JSONNode> elem = (KeyValuePair <string, JSONNode>)elements.Current;
                translations.Add(elem.Key, elem.Value);
            }
        }
예제 #5
0
        /*
         * Read boards from JSON entry.
         */
        public static void ReadBoards(Project project, JSONClass boardRoot)
        {
            string boardsPath = "Assets" + ProjectUtils.projectResourceFolder + "Boards/";

            List <Board>       tmp        = new List <Board>();
            List <BoardFolder> tmpFolders = new List <BoardFolder>();

            IEnumerator children = boardRoot.GetEnumerator();

            while (children.MoveNext())
            {
                // Get current
                KeyValuePair <string, JSONNode> current = (children.Current != null) ?
                                                          (KeyValuePair <string, JSONNode>)children.Current : default(KeyValuePair <string, JSONNode>);
                JSONNode child = current.Value;

                // Get its ID
                string id = current.Key;

                bool isFolder = child["children"] != null;

                if (isFolder)
                {
                    BoardFolder folder = ScriptableObject.CreateInstance <BoardFolder>();
                    folder.id = id;
                    ReadBoardFolder(folder, project, child);
                    tmpFolders.Add(folder);
                    AssetDatabase.CreateAsset(folder, boardsPath + folder.name + ".asset");
                }
                else
                {
                    Board board = ScriptableObject.CreateInstance <Board>();
                    board.id = id;
                    ReadBoard(board, project, child);
                    tmp.Add(board);
                    AssetDatabase.CreateAsset(board, boardsPath + board.name + ".asset");
                }
            }

            project.boards       = tmp.ToArray();
            project.boardFolders = tmpFolders.ToArray();
        }
예제 #6
0
        /*
         * Read components from given JSON Class.
         */
        private static void ReadComponents(Project project, JSONClass componentRoot, string projectPath)
        {
            string componentPath = "Assets" + projectResourceFolder + "Components/";

            List <IComponentEntry> entries = new List <IComponentEntry>();

            IEnumerator children = componentRoot.GetEnumerator();

            while (children.MoveNext())
            {
                // Get current
                KeyValuePair <string, JSONNode> current = (children.Current != null) ?
                                                          (KeyValuePair <string, JSONNode>)children.Current : default(KeyValuePair <string, JSONNode>);
                JSONNode child = current.Value;

                // Get its ID
                string id       = current.Key;
                bool   isFolder = child["children"] != null;

                if (isFolder)
                {
                    ComponentFolder folder = ScriptableObject.CreateInstance <ComponentFolder>();
                    folder.id = id;
                    ReadComponentFolder(folder, child);
                    entries.Add(folder);
                    AssetDatabase.CreateAsset(folder, componentPath + folder.id + ".asset");
                }
                else
                {
                    // Async operation because it might load images
                    Component component = ScriptableObject.CreateInstance <Component>();
                    component.id = id;
                    ReadComponent(project, component, child, projectPath);
                    entries.Add(component);
                    AssetDatabase.CreateAsset(component, componentPath + component.id + ".asset");
                }
            }

            project.components = entries.ToArray();
        }
예제 #7
0
        /*
         * Read assets from given JSON Class.
         */
        private static void ReadAssets(Project project, JSONClass assetsRoot, string projectPath)
        {
            List <AssetEntry>  entries = new List <AssetEntry>();
            List <AssetFolder> folders = new List <AssetFolder>();

            IEnumerator children = assetsRoot.GetEnumerator();

            while (children.MoveNext())
            {
                // Get current
                KeyValuePair <string, JSONNode> current = (children.Current != null) ?
                                                          (KeyValuePair <string, JSONNode>)children.Current : default(KeyValuePair <string, JSONNode>);
                JSONNode child = current.Value;

                // Get its ID
                string id       = current.Key;
                bool   isFolder = child["children"] != null;

                if (isFolder)
                {
                    AssetFolder folder = new AssetFolder();
                    folder.id   = id;
                    folder.name = child["root"] != null ? "Root" : child["name"].ToString();
                    ReadAssetFolder(folder, child);
                    folders.Add(folder);
                }
                else
                {
                    AssetEntry asset = new AssetEntry();
                    asset.id   = id;
                    asset.name = child["name"];
                    asset.ParseType(child["type"]);
                    asset.LinkAsset(projectPath);
                    entries.Add(asset);
                }
            }

            project.assetEntries = entries.ToArray();
            project.assetFolders = folders.ToArray();
        }
예제 #8
0
        /*
         * Read notes from JSON entry.
         */
        private static void ReadNotes(Project project, JSONClass noteRoot)
        {
            List <Note> tmp = new List <Note>();

            IEnumerator children = noteRoot.GetEnumerator();

            while (children.MoveNext())
            {
                // Get current
                KeyValuePair <string, JSONNode> current = (children.Current != null) ?
                                                          (KeyValuePair <string, JSONNode>)children.Current : default(KeyValuePair <string, JSONNode>);
                JSONNode child = current.Value;

                // Create element
                Note note = new Note(current.Key, current.Value);

                // Add
                tmp.Add(note);
            }

            project.notes = tmp.ToArray();
        }
예제 #9
0
        /*
         * Read attributes from given JSON Class.
         */
        private static void ReadAttributes(Project project, JSONClass attributesRoot)
        {
            List <Attribute> tmp = new List <Attribute>();

            IEnumerator children = attributesRoot.GetEnumerator();

            while (children.MoveNext())
            {
                // Get current
                KeyValuePair <string, JSONNode> current = (children.Current != null) ?
                                                          (KeyValuePair <string, JSONNode>)children.Current : default(KeyValuePair <string, JSONNode>);
                JSONNode child = current.Value;

                string    unusedBoardId = null; // ToDo: The HTML parser is shit because I have to pass this useless parameter most of the time
                Attribute a             = new Attribute();
                a.id = current.Key;
                Utils.ParseHTML(child["label"], ref a.label, ref a.labelNoStyle, ref unusedBoardId);
                Utils.ParseHTML(child["content"], ref a.content, ref a.contentNoStyle, ref unusedBoardId);
                tmp.Add(a);
            }

            project.attributes = tmp.ToArray();
        }
예제 #10
0
        /*
         * Read elements from JSON entry.
         */
        private static void ReadElements(Project project, JSONClass elementRoot)
        {
            List <Element> tmp = new List <Element>();

            IEnumerator children = elementRoot.GetEnumerator();

            while (children.MoveNext())
            {
                // Get current
                KeyValuePair <string, JSONNode> current = (children.Current != null) ?
                                                          (KeyValuePair <string, JSONNode>)children.Current : default(KeyValuePair <string, JSONNode>);
                JSONNode child = current.Value;

                // Create element
                Element element = new Element();
                element.id = current.Key;
                ReadElement(element, project, current.Value);

                // Add
                tmp.Add(element);
            }

            project.elements = tmp.ToArray();
        }
예제 #11
0
        public void MetadataObjectUI(JSONClass j)
        {
            IEnumerator iter = j.GetEnumerator();

            while (iter.MoveNext())
            {
                KeyValuePair <string, JSONNode> N = (KeyValuePair <string, JSONNode>)iter.Current;
                if (N.Value.AsArray != null && N.Value.AsArray.Count != 0)
                {
                    if (N.Value.AsArray.Count == 3 && N.Value.AsArray [0].Value != "XYZ")
                    {
                        MetadataVector3UI(N.Value.AsArray, N.Key);
                        continue;
                    }
                    if (!ShowPosition.ContainsKey(N.Key))
                    {
                        ShowPosition.Add(N.Key, true);
                    }
                    ShowPosition [N.Key] = EditorGUILayout.Foldout(ShowPosition [N.Key], N.Key);
                    if (ShowPosition [N.Key] == true)
                    {
                        EditorGUI.indentLevel++;
                        MetadataArrayUI(N.Value.AsArray, name);
                        EditorGUI.indentLevel--;
                    }
                    continue;
                }
                if (N.Value.AsObject != null && N.Value.AsObject.Count != 0)
                {
                    if (N.Value.AsObject.Count == 3)
                    {
                        IEnumerator iter2 = N.Value.AsObject.GetEnumerator();
                        int         nb    = 0;
                        while (iter2.MoveNext())
                        {
                            KeyValuePair <string, JSONNode> K = (KeyValuePair <string, JSONNode>)iter2.Current;
                            if (K.Key == "x" || K.Key == "y" || K.Key == "z")
                            {
                                nb++;
                            }
                        }
                        if (nb == 3)
                        {
                            MetadataVector3UI(N.Value.AsObject, N.Key);
                            continue;
                        }
                    }
                    if (!ShowPosition.ContainsKey(N.Key))
                    {
                        ShowPosition.Add(N.Key, true);
                    }
                    ShowPosition [N.Key] = EditorGUILayout.Foldout(ShowPosition [N.Key], N.Key);
                    if (ShowPosition [N.Key] == true)
                    {
                        EditorGUI.indentLevel++;
                        MetadataObjectUI(N.Value.AsObject);
                        EditorGUI.indentLevel--;
                    }
                    continue;
                }
                EditorGUILayout.LabelField(N.Key, N.Value.ToString());
            }
        }