Example #1
0
    /// <summary>
    /// 更改面板状态
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="windowTypeEnum"></param>
    /// <param name="showModeEnum"></param>
    public static T ChangePanelState <T>(WindowTypeEnum windowTypeEnum, UIPanelStateEnum panelStateEnum) where T : BasePanel
    {
        T t = default(T);

        t = GetPanel <T>(windowTypeEnum);
        if (t)
        {
            switch (panelStateEnum)
            {
            case UIPanelStateEnum.Open:
                t.Open();
                break;

            case UIPanelStateEnum.Hide:
                t.Hide();
                break;

            default:
                break;
            }
        }
        else
        {
            Debug.Log("面板不存在" + windowTypeEnum + "窗口中");
        }
        return(t);
    }
Example #2
0
    /// <summary>
    /// 获取窗口下所有面板
    /// </summary>
    /// <param name="windowTypeEnum"></param>
    /// <returns></returns>
    public static List <T> GetPanelS <T>(WindowTypeEnum windowTypeEnum) where T : BasePanel
    {
        List <T> panel = new List <T>();

        if (PanelDic.ContainsKey(windowTypeEnum))
        {
            panel = PanelDic[windowTypeEnum] as List <T>;
        }

        return(panel);
    }
Example #3
0
    /// <summary>
    /// 获取面板
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="windowTypeEnum"></param>
    /// <returns></returns>
    public static T GetPanel <T>(WindowTypeEnum windowTypeEnum) where T : BasePanel
    {
        T panel = default(T);

        if (PanelDic.ContainsKey(windowTypeEnum))
        {
            panel = PanelDic[windowTypeEnum].FindLast((p) => p.name == typeof(T).ToString()) as T;
        }

        return(panel);
    }
Example #4
0
    public void Initialize(WindowTypeEnum _tWindowType, GSDSplineN _tNode)
    {
        if (xRect.width < 1f && xRect.height < 1f)
        {
            xRect.x      = 275f;
            xRect.y      = 200f;
            xRect.width  = 860f;
            xRect.height = 500f;
        }

        position    = xRect;
        tWindowType = _tWindowType;
        tNode       = _tNode;
        InitWindow();
        Show();
    }
Example #5
0
            string WindowTypeToString(WindowTypeEnum windowType)
            {
                switch (windowType)
                {
                case WindowTypeEnum.Windowed:
                    return("Windowed");

                case WindowTypeEnum.BorderlessWindowed:
                    return("Borderless windowed");

                case WindowTypeEnum.Fullscreen:
                    return("Fullscreen");

                default:
                    throw new ArgumentOutOfRangeException(nameof(windowType), windowType, null);
                }
            }
Example #6
0
    /// <summary>
    /// 创建面板
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="windowTypeEnum"></param>
    /// <returns></returns>
    public static T CreatePanel <T>(WindowTypeEnum windowTypeEnum, UIPanelStateEnum panelStateEnum = UIPanelStateEnum.Open) where T : BasePanel
    {
        T t = default(T);

        t = GetPanel <T>(windowTypeEnum);
        if (t == null)
        {
            T[] ts = Resources.LoadAll <T>("UIPanel");
            if (ts.Length > 0)
            {
                t = SourcesManager.LoadSources <T>(ts[0], windowsDic[windowTypeEnum].transform);
                if (!PanelDic.ContainsKey(windowTypeEnum))
                {
                    PanelDic.Add(windowTypeEnum, new List <BasePanel> {
                        t
                    });
                }
                else
                {
                    PanelDic[windowTypeEnum].RemoveNull();
                    PanelDic[windowTypeEnum].Add(t);
                }
            }
            else
            {
                Debug.Log("资源中不存在" + t.GetType().Name);
            }
        }
        switch (panelStateEnum)
        {
        case UIPanelStateEnum.Open:
            t.Open();
            break;

        case UIPanelStateEnum.Hide:
            t.Hide();
            break;

        default:
            break;
        }
        return(t);
    }
Example #7
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;
            }
        }
    }
Example #8
0
	public void Initialize(ref Rect tRect, WindowTypeEnum _tWindowType, GSDSplineN tNode, GSD.Roads.Splination.SplinatedMeshMaker SMM = null, GSD.Roads.EdgeObjects.EdgeObjectMaker EOM = null) {
		int Rheight = 300;
		int Rwidth = 360;
		float Rx = ((float)tRect.width/2f) - ((float)Rwidth/2f) + tRect.x;
		float Ry = ((float)tRect.height/2f) - ((float)Rheight/2f) + tRect.y;
		
		if(Rx < 0){ Rx = tRect.x; }
		if(Ry < 0){ Ry = tRect.y; }
		if(Rx > (tRect.width + tRect.x)){ Rx = tRect.x; }
		if(Ry > (tRect.height + tRect.y)){ Ry = tRect.y; }
		
		Rect fRect = new Rect(Rx,Ry,Rwidth,Rheight);

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

		position = fRect;
		tWindowType = _tWindowType;
        Show();
		title = "Save";
		if(tWindowType == WindowTypeEnum.Extrusion){
			TitleText =  "Save extrusion";
			tSMMs = new GSD.Roads.Splination.SplinatedMeshMaker[1];
			tSMMs[0] = SMM;
			if(SMM != null){
				tFilename = SMM.tName;
				tDisplayName = tFilename;
			}
		}else if(tWindowType == WindowTypeEnum.Edge){
			TitleText =  "Save edge object";
			tEOMs = new GSD.Roads.EdgeObjects.EdgeObjectMaker[1];
			tEOMs[0] = EOM;
			if(EOM != null){
				tFilename = EOM.tName;
				tDisplayName = tFilename;
			}
		}else if(tWindowType ==  WindowTypeEnum.BridgeWizard){
			bIsBridge = true;
			tSMMs = tNode.SplinatedObjects.ToArray();
			tEOMs = tNode.EdgeObjects.ToArray();
			TitleText = "Save group";
			tFilename = "Group" + Random.Range(0,10000).ToString();
			tDisplayName = tFilename;
		}
		
		if(xPath.Length < 5){
			xPath = GSDRootUtil.Dir_GetLibrary();
		}
		
		if(tWindowType == WindowTypeEnum.Edge){
			if(System.IO.File.Exists(xPath + "EOM"+tFilename+".gsd")){
				bFileExists = true;
			}else{
				bFileExists = false;	
			}
		}else if(tWindowType == WindowTypeEnum.Extrusion){
			if(System.IO.File.Exists(xPath + "ESO"+tFilename+".gsd")){
				bFileExists = true;
			}else{
				bFileExists = false;	
			}
		}else{
			if(System.IO.File.Exists(xPath + "B/"+tFilename+".gsd")){
				bFileExists = true;
			}else{
				bFileExists = false;	
			}
		}
    }
Example #9
0
 bool WindowTypeToBorderless(WindowTypeEnum windowType)
 {
     return(windowType == WindowTypeEnum.BorderlessWindowed);
 }
Example #10
0
 bool WindowTypeToFullscreen(WindowTypeEnum windowType)
 {
     return(windowType == WindowTypeEnum.Fullscreen);
 }
Example #11
0
    private void DoGUI()
    {
        if (bNoGUI)
        {
            return;
        }
        if (oList == null)
        {
            Close(); return;
        }

        GUILayout.Space(4f);
        EditorGUILayout.BeginHorizontal();

        if (tNode.bIsBridgeStart)
        {
            xWindowType = (WindowTypeEnum)EditorGUILayout.Popup("Category: ", (int)tWindowType, WindowTypeDescBridge, GUILayout.Width(312f));
        }
        else
        {
            if (xWindowType == WindowTypeEnum.Edge)
            {
                SxWindowType = WindowTypeEnumShort.Edge;
            }
            else if (xWindowType == WindowTypeEnum.Extrusion)
            {
                SxWindowType = WindowTypeEnumShort.Extrusion;
            }
            else
            {
                SxWindowType = WindowTypeEnumShort.Groups;
            }

            SxWindowType = (WindowTypeEnumShort)EditorGUILayout.Popup("Category: ", (int)StWindowType, WindowTypeDesc, GUILayout.Width(312f));

            if (SxWindowType == WindowTypeEnumShort.Extrusion)
            {
                xWindowType = WindowTypeEnum.Extrusion;
            }
            else if (SxWindowType == WindowTypeEnumShort.Edge)
            {
                xWindowType = WindowTypeEnum.Edge;
            }
            else
            {
                xWindowType = WindowTypeEnum.Groups;
            }
            StWindowType = SxWindowType;
        }

        if (xWindowType != tWindowType)
        {
            Initialize(xWindowType, tNode);
            EditorGUILayout.EndHorizontal();
            return;
        }



        EditorGUILayout.LabelField("");
        EditorGUILayout.LabelField("Single-click items to load", EditorStyles.boldLabel, GUILayout.Width(200f));



        EditorGUILayout.EndHorizontal();
        if (oList.Count == 0)
        {
            return;
        }
        int oCount = oList.Count;

        int WidthSpacing       = 160;
        int HeightSpacing      = 200;
        int HeightOffset       = 30;
        int ScrollHeightOffset = 25;

        int xCount = 0;
        int yCount = 0;
        int yMod   = Mathf.FloorToInt((float)position.width / 142f) - 1;

        int yMax = 0;

        if (yMod == 0)
        {
            yMax = 1;
        }
        else
        {
            yMax = Mathf.CeilToInt((float)oCount / (float)yMod);
        }

        bool bScrolling = false;

        if ((((yMax) * HeightSpacing) + 25) > position.height)
        {
            scrollPos    = GUI.BeginScrollView(new Rect(0, 25, position.width - 10, position.height - 30), scrollPos, new Rect(0, 0, (yMod * WidthSpacing) + 25, (((yMax) * HeightSpacing) + 50)));
            bScrolling   = true;
            HeightOffset = ScrollHeightOffset;
        }

        EditorGUILayout.BeginHorizontal();

        bool bClicked = false;

        for (int i = 0; i < oCount; i++)
        {
            if (i > 0)
            {
                if (yMod == 0)
                {
                    EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); yCount += 1; xCount = 0;
                }
                else
                {
                    if (i % yMod == 0)
                    {
                        EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); yCount += 1; xCount = 0;
                    }
                }
            }

            if (xCount == 0)
            {
                bClicked = DoItem((xCount * WidthSpacing) + 5, (yCount * HeightSpacing) + HeightOffset, i);
            }
            else
            {
                bClicked = DoItem(xCount * WidthSpacing, (yCount * HeightSpacing) + HeightOffset, i);
            }

            if (bClicked)
            {
                if (tWindowType == WindowTypeEnum.Extrusion)
                {
                    GSD.Roads.Splination.SplinatedMeshMaker SMM = tNode.AddSplinatedObject();
                    SMM.SetDefaultTimes(tNode.bIsEndPoint, tNode.tTime, tNode.NextTime, tNode.idOnSpline, tNode.GSDSpline.distance);
                    SMM.LoadFromLibrary(oList[i].FileName, oList[i].bIsDefault);
                    SMM.bIsGSD = oList[i].bIsDefault;
                    SMM.Setup(true);
                }
                else if (tWindowType == WindowTypeEnum.Edge)
                {
                    GSD.Roads.EdgeObjects.EdgeObjectMaker EOM = tNode.AddEdgeObject();
                    EOM.SetDefaultTimes(tNode.bIsEndPoint, tNode.tTime, tNode.NextTime, tNode.idOnSpline, tNode.GSDSpline.distance);
                    EOM.LoadFromLibrary(oList[i].FileName, oList[i].bIsDefault);
                    EOM.bIsGSD = oList[i].bIsDefault;
                    EOM.Setup();
                }
                else if (tWindowType == WindowTypeEnum.Groups)
                {
                    tNode.LoadWizardObjectsFromLibrary(oList[i].FileName, oList[i].bIsDefault, oList[i].bIsBridge);
                }
                else if (tWindowType == WindowTypeEnum.BridgeComplete)
                {
                    tNode.LoadWizardObjectsFromLibrary(oList[i].FileName, oList[i].bIsDefault, oList[i].bIsBridge);
                }
                tNode.bQuitGUI       = true;
                oList.Clear(); oList = null;
                EditorGUILayout.EndHorizontal();
                if (bScrolling)
                {
                    GUI.EndScrollView();
                }
                bNoGUI = true;
                Close();
                return;
            }
            xCount += 1;
        }
        EditorGUILayout.EndHorizontal();

        if (bScrolling)
        {
            GUI.EndScrollView();
        }
    }
Example #12
0
    private void DoGUI()
    {
        if(bNoGUI){ return; }
        if(oList == null){ Close(); return; }

        GUILayout.Space(4f);
        EditorGUILayout.BeginHorizontal();

        if(tNode.bIsBridgeStart){
            xWindowType = (WindowTypeEnum)EditorGUILayout.Popup("Category: ",(int)tWindowType,WindowTypeDescBridge,GUILayout.Width(312f));
        }else{

            if(xWindowType == WindowTypeEnum.Edge){
                SxWindowType = WindowTypeEnumShort.Edge;
            }else if(xWindowType == WindowTypeEnum.Extrusion){
                SxWindowType = WindowTypeEnumShort.Extrusion;
            }else{
                SxWindowType = WindowTypeEnumShort.Groups;
            }

            SxWindowType = (WindowTypeEnumShort)EditorGUILayout.Popup("Category: ",(int)StWindowType,WindowTypeDesc,GUILayout.Width(312f));

            if(SxWindowType == WindowTypeEnumShort.Extrusion){
                xWindowType = WindowTypeEnum.Extrusion;
            }else if(SxWindowType == WindowTypeEnumShort.Edge){
                xWindowType = WindowTypeEnum.Edge;
            }else{
                xWindowType = WindowTypeEnum.Groups;
            }
            StWindowType = SxWindowType;
        }

        if(xWindowType != tWindowType){
            Initialize(xWindowType,tNode);
            EditorGUILayout.EndHorizontal();
            return;
        }

        EditorGUILayout.LabelField("");
        EditorGUILayout.LabelField("Single-click items to load",EditorStyles.boldLabel,GUILayout.Width(200f));

        EditorGUILayout.EndHorizontal();
        if(oList.Count == 0){ return; }
        int oCount = oList.Count;

        int WidthSpacing = 160;
        int HeightSpacing = 200;
        int HeightOffset = 30;
        int ScrollHeightOffset = 25;

        int xCount = 0;
        int yCount = 0;
        int yMod = Mathf.FloorToInt((float)position.width / 142f) - 1;

        int yMax = 0;
        if(yMod == 0){
            yMax = 1;
        }else{
            yMax = Mathf.CeilToInt((float)oCount/(float)yMod);
        }

        bool bScrolling = false;
        if((((yMax) * HeightSpacing)+25) > position.height){
            scrollPos = GUI.BeginScrollView(new Rect(0, 25,position.width-10, position.height-30), scrollPos,new Rect (0, 0, (yMod*WidthSpacing)+25, (((yMax)*HeightSpacing)+50)));
            bScrolling= true;
            HeightOffset=ScrollHeightOffset;
        }

        EditorGUILayout.BeginHorizontal();

        bool bClicked = false;
        for(int i=0;i<oCount;i++){
            if(i > 0){
                if(yMod == 0){
                    EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); yCount+=1; xCount=0;
                }else{
                    if(i % yMod == 0){ EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); yCount+=1; xCount=0; }
                }
            }

            if(xCount == 0){
                bClicked = DoItem((xCount*WidthSpacing)+5,(yCount*HeightSpacing)+HeightOffset,i);
            }else{
                bClicked = DoItem(xCount*WidthSpacing,(yCount*HeightSpacing)+HeightOffset,i);
            }

            if(bClicked){
                if(tWindowType == WindowTypeEnum.Extrusion){
                    GSD.Roads.Splination.SplinatedMeshMaker SMM = tNode.AddSplinatedObject();
                    SMM.SetDefaultTimes(tNode.bIsEndPoint,tNode.tTime,tNode.NextTime,tNode.idOnSpline,tNode.GSDSpline.distance);
                    SMM.LoadFromLibrary(oList[i].FileName,oList[i].bIsDefault);
                    SMM.bIsGSD = oList[i].bIsDefault;
                    SMM.Setup(true);
                }else if(tWindowType == WindowTypeEnum.Edge){
                    GSD.Roads.EdgeObjects.EdgeObjectMaker EOM = tNode.AddEdgeObject();
                    EOM.SetDefaultTimes(tNode.bIsEndPoint,tNode.tTime,tNode.NextTime,tNode.idOnSpline,tNode.GSDSpline.distance);
                    EOM.LoadFromLibrary(oList[i].FileName,oList[i].bIsDefault);
                    EOM.bIsGSD = oList[i].bIsDefault;
                    EOM.Setup();
                }else if(tWindowType == WindowTypeEnum.Groups){
                    tNode.LoadWizardObjectsFromLibrary(oList[i].FileName,oList[i].bIsDefault,oList[i].bIsBridge);
                }else if(tWindowType == WindowTypeEnum.BridgeComplete){
                    tNode.LoadWizardObjectsFromLibrary(oList[i].FileName,oList[i].bIsDefault,oList[i].bIsBridge);
                }
                tNode.bQuitGUI = true;
                oList.Clear(); oList = null;
                EditorGUILayout.EndHorizontal();
                if(bScrolling){
                    GUI.EndScrollView();
                }
                bNoGUI = true;
                Close();
                return;
            }
            xCount+=1;

        }
        EditorGUILayout.EndHorizontal();

        if(bScrolling){
            GUI.EndScrollView();
        }
    }
Example #13
0
    public void Initialize(WindowTypeEnum _tWindowType, GSDSplineN _tNode)
    {
        if(xRect.width < 1f && xRect.height < 1f){
            xRect.x = 275f;
            xRect.y = 200f;
            xRect.width = 860f;
            xRect.height = 500f;
        }

        position = xRect;
        tWindowType = _tWindowType;
        tNode = _tNode;
        InitWindow();
        Show();
    }