public void LoadFromLibraryWizard(string xName)
        {
            GSDRootUtil.Dir_GetLibrary_CheckSpecialDirs();
            string xPath = GSDRootUtil.Dir_GetLibrary();
            string tPath = xPath + "W/" + xName + ".gsd";
            EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker)GSDRootUtil.LoadXML <EdgeObjectLibraryMaker>(ref tPath);

            ELM.LoadTo(this);
            bNeedsUpdate = true;
        }
        public void LoadFromLibrary(string xName, bool bIsQuickAdd = false)
        {
            GSDRootUtil.Dir_GetLibrary_CheckSpecialDirs();
            string xPath = GSDRootUtil.Dir_GetLibrary();
            string tPath = xPath + "EOM" + xName + ".gsd";

            if (bIsQuickAdd)
            {
                tPath = xPath + "Q/EOM" + xName + ".gsd";
            }
            EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker)GSDRootUtil.LoadXML <EdgeObjectLibraryMaker>(ref tPath);

            ELM.LoadTo(this);
            bNeedsUpdate = true;
        }
        public static void GetLibraryFiles(out string[] tNames, out string[] tPaths, bool bIsDefault = false)
        {
                        #if UNITY_WEBPLAYER
            tNames = null;
            tPaths = null;
            return;
                        #else
            tNames = null;
            tPaths = null;
            DirectoryInfo info;
            string        xPath = GSDRootUtil.Dir_GetLibrary();
            if (bIsDefault)
            {
                info = new DirectoryInfo(xPath + "Q/");
            }
            else
            {
                info = new DirectoryInfo(xPath);
            }

            FileInfo[] fileInfo = info.GetFiles();
            int        tCount   = 0;


            foreach (FileInfo tInfo in fileInfo)
            {
                if (tInfo.Name.Contains("EOM") && tInfo.Extension.ToLower().Contains("gsd"))
                {
                    tCount += 1;
                }
            }

            tNames = new string[tCount];
            tPaths = new string[tCount];
            tCount = 0;
            foreach (FileInfo tInfo in fileInfo)
            {
                if (tInfo.Name.Contains("EOM") && tInfo.Extension.ToLower().Contains("gsd"))
                {
                    tNames[tCount] = tInfo.Name.Replace(".gsd", "").Replace("EOM", "");
                    tPaths[tCount] = tInfo.FullName;
                    tCount        += 1;
                }
            }
                        #endif
        }
        public void SaveToLibrary(string fName = "", bool bIsDefault = false)
        {
            EdgeObjectLibraryMaker ELM = new EdgeObjectLibraryMaker();

            ELM.Setup(this);
            GSDRootUtil.Dir_GetLibrary_CheckSpecialDirs();
            string xPath = GSDRootUtil.Dir_GetLibrary();
            string tPath = xPath + "EOM" + tName + ".gsd";

            if (fName.Length > 0)
            {
                if (bIsDefault)
                {
                    tPath = xPath + "Q/EOM" + fName + ".gsd";
                }
                else
                {
                    tPath = xPath + "EOM" + fName + ".gsd";
                }
            }
            GSDRootUtil.CreateXML <EdgeObjectLibraryMaker>(ref tPath, ELM);
        }
Exemple #5
0
    private void OnGUI()
    {
        GUILayout.Space(4f);
        EditorGUILayout.LabelField(titleText, EditorStyles.boldLabel);

        temp2D_2 = (Texture2D)EditorGUILayout.ObjectField("Square thumb (optional):", temp2D, typeof(Texture2D), false);
        if (temp2D_2 != temp2D)
        {
            temp2D      = temp2D_2;
            ThumbString = AssetDatabase.GetAssetPath(temp2D);
        }

        if (xPath.Length < 5)
        {
            xPath = GSDRootUtil.Dir_GetLibrary();
        }

        EditorGUILayout.LabelField("Short description (optional):");
        Desc         = EditorGUILayout.TextArea(Desc, GUILayout.Height(40f));
        displayName2 = EditorGUILayout.TextField("Display name:", displayName);
        if (string.Compare(displayName2, displayName) != 0)
        {
            displayName = displayName2;
            SanitizeFilename();

            if (tWindowType == WindowTypeEnum.Edge)
            {
                if (System.IO.File.Exists(xPath + "EOM" + fileName + ".gsd"))
                {
                    fileExists = true;
                }
                else
                {
                    fileExists = false;
                }
            }
            else if (tWindowType == WindowTypeEnum.Extrusion)
            {
                if (System.IO.File.Exists(xPath + "ESO" + fileName + ".gsd"))
                {
                    fileExists = true;
                }
                else
                {
                    fileExists = false;
                }
            }
            else
            {
                if (System.IO.File.Exists(xPath + "B/" + fileName + ".gsd"))
                {
                    fileExists = true;
                }
                else
                {
                    fileExists = false;
                }
            }
        }


        if (fileExists)
        {
            EditorGUILayout.LabelField("File exists already!", EditorStyles.miniLabel);
            if (tWindowType == WindowTypeEnum.Edge)
            {
                EditorGUILayout.LabelField(xPath + "EOM" + fileName + ".gsd", EditorStyles.miniLabel);
            }
            else if (tWindowType == WindowTypeEnum.Extrusion)
            {
                EditorGUILayout.LabelField(xPath + "ESO" + fileName + ".gsd", EditorStyles.miniLabel);
            }
            else
            {
                EditorGUILayout.LabelField(xPath + "B/" + fileName + ".gsd", EditorStyles.miniLabel);
            }
        }
        else
        {
            if (tWindowType == WindowTypeEnum.Edge)
            {
                EditorGUILayout.LabelField(xPath + "EOM" + fileName + ".gsd", EditorStyles.miniLabel);
            }
            else if (tWindowType == WindowTypeEnum.Extrusion)
            {
                EditorGUILayout.LabelField(xPath + "ESO" + fileName + ".gsd", EditorStyles.miniLabel);
            }
            else
            {
                EditorGUILayout.LabelField(xPath + "B/" + fileName + ".gsd", EditorStyles.miniLabel);
            }
        }

        GUILayout.Space(4f);

        isBridge = EditorGUILayout.Toggle("Is bridge related:", isBridge);
        //		GUILayout.Space(4f);
        //		bIsDefault = EditorGUILayout.Toggle("Is GSD:",bIsDefault);
        GUILayout.Space(8f);
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Cancel"))
        {
            Close();
        }
        if (tWindowType == WindowTypeEnum.Extrusion)
        {
            DoExtrusion();
        }
        else if (tWindowType == WindowTypeEnum.Edge)
        {
            DoEdgeObject();
        }
        else if (tWindowType == WindowTypeEnum.BridgeWizard)
        {
            DoBridge();
        }

        EditorGUILayout.EndHorizontal();
    }
Exemple #6
0
    public void Initialize(ref Rect _rect, WindowTypeEnum _windowType, GSDSplineN _node, GSD.Roads.Splination.SplinatedMeshMaker _SMM = null, GSD.Roads.EdgeObjects.EdgeObjectMaker _EOM = null)
    {
        int   Rheight = 300;
        int   Rwidth  = 360;
        float Rx      = ((float)_rect.width / 2f) - ((float)Rwidth / 2f) + _rect.x;
        float Ry      = ((float)_rect.height / 2f) - ((float)Rheight / 2f) + _rect.y;

        if (Rx < 0)
        {
            Rx = _rect.x;
        }
        if (Ry < 0)
        {
            Ry = _rect.y;
        }
        if (Rx > (_rect.width + _rect.x))
        {
            Rx = _rect.x;
        }
        if (Ry > (_rect.height + _rect.y))
        {
            Ry = _rect.y;
        }

        Rect fRect = new Rect(Rx, Ry, Rwidth, Rheight);

        if (fRect.width < 300)
        {
            fRect.width = 300;
            fRect.x     = _rect.x;
        }
        if (fRect.height < 300)
        {
            fRect.height = 300;
            fRect.y      = _rect.y;
        }

        position    = fRect;
        tWindowType = _windowType;
        Show();
        titleContent.text = "Save";
        if (tWindowType == WindowTypeEnum.Extrusion)
        {
            titleText = "Save extrusion";
            tSMMs     = new GSD.Roads.Splination.SplinatedMeshMaker[1];
            tSMMs[0]  = _SMM;
            if (_SMM != null)
            {
                fileName    = _SMM.tName;
                displayName = fileName;
            }
        }
        else if (tWindowType == WindowTypeEnum.Edge)
        {
            titleText = "Save edge object";
            tEOMs     = new GSD.Roads.EdgeObjects.EdgeObjectMaker[1];
            tEOMs[0]  = _EOM;
            if (_EOM != null)
            {
                fileName    = _EOM.tName;
                displayName = fileName;
            }
        }
        else if (tWindowType == WindowTypeEnum.BridgeWizard)
        {
            isBridge    = true;
            tSMMs       = _node.SplinatedObjects.ToArray();
            tEOMs       = _node.EdgeObjects.ToArray();
            titleText   = "Save group";
            fileName    = "Group" + Random.Range(0, 10000).ToString();
            displayName = fileName;
        }

        if (xPath.Length < 5)
        {
            xPath = GSDRootUtil.Dir_GetLibrary();
        }

        if (tWindowType == WindowTypeEnum.Edge)
        {
            if (System.IO.File.Exists(xPath + "EOM" + fileName + ".gsd"))
            {
                fileExists = true;
            }
            else
            {
                fileExists = false;
            }
        }
        else if (tWindowType == WindowTypeEnum.Extrusion)
        {
            if (System.IO.File.Exists(xPath + "ESO" + fileName + ".gsd"))
            {
                fileExists = true;
            }
            else
            {
                fileExists = false;
            }
        }
        else
        {
            if (System.IO.File.Exists(xPath + "B/" + fileName + ".gsd"))
            {
                fileExists = true;
            }
            else
            {
                fileExists = false;
            }
        }
    }
Exemple #7
0
    public static void GetGroupListing(out string[] tNames, out string[] tPaths, int Lanes, bool bIsDefault = false)
    {
        if (xPath.Length < 5)
        {
            xPath = GSDRootUtil.Dir_GetLibrary();
        }

        string LaneText = "-2L";

        if (Lanes == 4)
        {
            LaneText = "-4L";
        }
        else if (Lanes == 6)
        {
            LaneText = "-6L";
        }

        tNames = null;
        tPaths = null;
        DirectoryInfo info;

        if (bIsDefault)
        {
            info = new DirectoryInfo(xPath + "B/W/");
        }
        else
        {
            info = new DirectoryInfo(xPath + "B/");
        }

        FileInfo[] fileInfo = info.GetFiles();
        int        tCount   = 0;

        foreach (FileInfo tInfo in fileInfo)
        {
            if (tInfo.Extension.ToLower().Contains("gsd"))
            {
                if (!bIsDefault)
                {
                    tCount += 1;
                }
                else
                {
                    if (tInfo.Name.Contains(LaneText))
                    {
                        tCount += 1;
                    }
                }
            }
        }

        tNames = new string[tCount];
        tPaths = new string[tCount];
        tCount = 0;
        foreach (FileInfo tInfo in fileInfo)
        {
            if (tInfo.Extension.ToLower().Contains("gsd"))
            {
                if (!bIsDefault)
                {
                    tNames[tCount] = tInfo.Name.Replace(".gsd", "");
                    tPaths[tCount] = tInfo.FullName;
                    tCount        += 1;
                }
                else
                {
                    if (tInfo.Name.Contains(LaneText))
                    {
                        tNames[tCount] = tInfo.Name.Replace(".gsd", "");
                        tPaths[tCount] = tInfo.FullName;
                        tCount        += 1;
                    }
                }
            }
        }
    }