コード例 #1
0
        AlgorithmBlob(TabCanvas tabCanvas)
        {
            UIGraph          = tabCanvas.GraphCanvas.Graph;
            AlgorithmGraph   = new Choosability.Graph(UIGraph.GetEdgeWeights());
            BitGraph         = new BitLevelGeneration.BitGraph_long(UIGraph.GetEdgeWeights());
            SelectedVertices = UIGraph.Vertices.Select((v, i) => v.IsSelected ? i : -1).Where(x => x >= 0).ToList();
            SelectedEdges    = UIGraph.Edges.Where(e => e.IsSelected).Select(e => new Tuple <int, int>(UIGraph.Vertices.IndexOf(e.V1), UIGraph.Vertices.IndexOf(e.V2))).ToList();

            EdgeIndexLookup = new Dictionary <Tuple <int, int>, int>();
            int k = 0;

            for (int i = 0; i < AlgorithmGraph.N; i++)
            {
                for (int j = i + 1; j < AlgorithmGraph.N; j++)
                {
                    if (AlgorithmGraph[i, j])
                    {
                        EdgeIndexLookup[new Tuple <int, int>(i, j)] = k;
                        EdgeIndexLookup[new Tuple <int, int>(j, i)] = k;
                        k++;
                    }
                }
            }

            SelectedEdgeIndices = SelectedEdges.Select(tuple => EdgeIndexLookup[tuple]).ToList();
        }
コード例 #2
0
        public static void CreateScripts(UIGraph graph)
        {
            var firstNode = graph.nodes.OfType <ViewNode>().FirstOrDefault();

            if (firstNode == null)
            {
                return;
            }

            CreateNeededFolders(firstNode.rt.gameObject.scene);
            LoadTemplates();

            foreach (var node in graph.nodes.OfType <ViewNode>())
            {
                try
                {
                    CreateScript(node, false);
                }catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }

            //create localization file
            Localization.CreateLocalizationFile();

            Debug.Log("CometUI: Build completed.");

            AssetDatabase.Refresh();
        }
コード例 #3
0
        void DrawToolBar()
        {
            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f);

            if (GUILayout.Button("File", EditorStyles.toolbarDropDown, GUILayout.Width(50)))
            {
                var menu = new GenericMenu();

                menu.AddItem(new GUIContent("Clear"), false, () => {
                    var option = EditorUtility.DisplayDialog(
                        "What do you want to clear all data ?",
                        "Please choose one of the following options.",
                        "Yes",
                        "No");

                    if (option)
                    {
                        _uiGraph = ScriptableObject.CreateInstance <UIGraph>();
                        SaveSerializeJson();
                    }
                });

                //Import JSON
                menu.AddItem(new GUIContent("Import JSON"), false, () =>
                {
                    if (currentGraph.allNodes.Count > 0 && !EditorUtility.DisplayDialog("Import Graph", "All current graph information will be lost. Are you sure?", "YES", "NO"))
                    {
                        return;
                    }

                    var path = EditorUtility.OpenFilePanel(string.Format("Import '{0}' Graph", this.GetType().Name), "Assets", "json");
                    if (!string.IsNullOrEmpty(path))
                    {
                        if (!currentGraph.Deserialize(System.IO.File.ReadAllText(path), true))
                        {
                            EditorUtility.DisplayDialog("Import Failure", "Please read the logs for more information", "OK", "");
                        }
                    }
                });

                //Expot JSON
                menu.AddItem(new GUIContent("Export JSON"), false, () =>
                {
                    var path = EditorUtility.SaveFilePanelInProject(string.Format("Export '{0}' Graph", this.GetType().Name), "", "json", "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        //System.IO.File.WriteAllText(path, this.Serialize(true, null)); //true: pretyJson, null: this._objectReferences
                        System.IO.File.WriteAllText(path, currentGraph.Serialize(true));
                        AssetDatabase.Refresh();
                    }
                });

                menu.ShowAsContext();
            }

            GUILayout.EndHorizontal();
            GUI.backgroundColor = Color.white;
        }
コード例 #4
0
 public RedoCreateNode(string stackId, string js, Point p, List <Tuple <string, List <Nodes.NodeOutputConnection> > > pars, UIGraph g)
 {
     json    = js;
     graph   = g;
     point   = p;
     parents = pars;
     StackId = stackId;
 }
コード例 #5
0
ファイル: BreadCrumb.xaml.cs プロジェクト: ykafia/Materia
 public BreadCrumb(BreadCrumbs view, string name, UIGraph g, string node)
 {
     InitializeComponent();
     CrumbName.Text = name;
     CrumbsView     = view;
     graph          = g;
     Id             = node;
     view.Add(this);
 }
コード例 #6
0
 private void CreateGraph()
 {
     m_graph                  = AddUIComponent <UIGraph>();
     m_graph.enabled          = true;
     m_graph.isVisible        = true;
     m_graph.name             = "EmploymentGraph";
     m_graph.size             = new Vector2(250, 120);
     m_graph.relativePosition = new Vector2(chartPadding, 200);
     m_graph.color            = new Color32(200, 200, 200, 255);
     m_graph.AddCurve("TestData", "EN-US", _chartLine, 2, new Color32(132, 55, 55, 255));
 }
コード例 #7
0
 public CreateNode(string stackId, string i, UIGraph g, string[] gstack = null)
 {
     id      = i;
     graph   = g;
     StackId = stackId;
     if (gstack == null)
     {
         stack = graph.GetGraphStack();
     }
     else
     {
         stack = gstack;
     }
 }
コード例 #8
0
        void OnEnable()
        {
            InitToolRes();

            if (currentGraph == null)
            {
                currentGraph = ScriptableObject.CreateInstance <UIGraph>();
                Vector2 pos = new Vector2(position.width / 2, position.height / 2);
                currentGraph.AddNode <RootNode>(pos);
            }

            _willRepaint  = true;
            _zoomPivotPos = new Vector2(position.width / 2, position.height / 2);

            EditorApplication.playmodeStateChanged += PlayModeChange;
        }
コード例 #9
0
        private void StoreInfoOfUIGraph(UIGraph graph)
        {
            graph.bridges.Clear();
            graph.b_nodes.Clear();
            graph.p_nodes.Clear();

            InsertBridges(graph.bridges, GetBridges());
            if (graph.loadType == LoadType.Prefab)
            {
                InsertPrefabinfo(graph.p_nodes, GetPrefabUIInfos(GetNodeInfos()));
            }
            else if (graph.loadType == LoadType.Bundle)
            {
                InsertBundleinfo(graph.b_nodes, GetBundleUIInfos(GetNodeInfos()));
            }
            EditorUtility.SetDirty(graph);
        }
コード例 #10
0
        public DeleteNode(string stackId, string js, string id, Point p, List <NodeConnection> pars, UIGraph g, string[] gstack = null)
        {
            json    = js;
            nid     = id;
            graph   = g;
            point   = p;
            parents = pars;
            StackId = stackId;

            if (gstack == null)
            {
                stack = graph.GetGraphStack();
            }
            else
            {
                stack = gstack;
            }
        }
コード例 #11
0
ファイル: UIPinNode.xaml.cs プロジェクト: xuyanning/Materia
        public UIPinNode(Node n, UIGraph graph, double ox, double oy, double xs, double xy, double sc = 1)
        {
            InitializeComponent();
            Graph   = graph;
            Node    = n;
            xShift  = xs;
            yShift  = xy;
            originX = ox;
            originY = oy;
            scale   = sc;

            Id = n.Id;

            Margin = new Thickness(0);

            pinNode = n as PinNode;

            Color = pinNode.GetColor();
            PinColorBrush.Color = Color;
        }
コード例 #12
0
        public UICommentNode(Node n, UIGraph graph, double ox, double oy, double xs, double xy, double sc = 1)
        {
            InitializeComponent();
            Graph   = graph;
            Node    = n;
            xShift  = xs;
            yShift  = xy;
            originX = ox;
            originY = oy;
            scale   = sc;

            Id = n.Id;

            Margin = new Thickness(0);

            contained   = new List <IUIGraphNode>();
            OutputNodes = new List <UINodePoint>();
            InputNodes  = new List <UINodePoint>();

            commentNode = n as CommentNode;
        }
コード例 #13
0
        private UIGraph _createGraph(string text, int y)
        {
            m_FMUgraph                  = AddUIComponent <UIGraph>();
            m_FMUgraph.name             = "fmuGraph";
            m_FMUgraph.relativePosition = new Vector3(15f, y);
            m_FMUgraph.width            = 100;
            m_FMUgraph.height           = 100;
            m_FMUgraph.Clear();
            m_FMUgraph.StartTime = DateTime.Now;
            m_FMUgraph.EndTime   = DateTime.Now.AddMinutes(10);
            float[] array9 = new float[] { 1, 2, 3, 6, 5, 4, 1, 2, 3 };

            m_FMUgraph.AddCurve("stringUserData", "localID", array9, 1f, color, float.NegativeInfinity);
            m_FMUgraph.Start();
            m_FMUgraph.isVisible = true;
            m_FMUgraph.color     = new Color32(150, 150, 150, 150);
            m_FMUgraph.enabled   = true;
            m_FMUgraph.Show();
            m_FMUgraph.spriteName = "toto";
            m_FMUgraph.Update();
            return(m_FMUgraph);
        }
コード例 #14
0
    public void Show()
    {
        if (this.Deleted)
        {
            return;
        }
        this.FieldName = EditorGUILayout.TextField("组件名称", this.FieldName);
        this.FieldPath = EditorGUILayout.TextField("组件所在UI路径", this.FieldPath);
        EUIManagerType type = EUIManagerType.e_NGUI;

        if (this.OwnerNode.graph is UIGraph)
        {
            UIGraph graph = this.OwnerNode.graph as UIGraph;
            type = graph.uiPluginType;
        }
        switch (type)
        {
        case EUIManagerType.e_FairyGUI:
            UIFairyPramaType fairygui = (UIFairyPramaType)EditorGUILayout.EnumPopup("组件类型", (UIFairyPramaType)this.FieldType);
            this.FieldType = (int)fairygui;
            break;

        case EUIManagerType.e_UGUI:

            break;

        case EUIManagerType.e_NGUI:

            break;
        }

        GUI.color = Color.red;
        if (GUILayout.Button("删除", EditorStyles.miniButton))
        {
            this.Deleted = true;
        }
        GUI.color = Color.white;
    }
コード例 #15
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (!skin)
        {
            skin = Resources.Load("skin") as GUISkin;
        }
        if (!uiManager)
        {
            uiManager = (UIGraph)EditorTool.GetAssetOfType(typeof(UIGraph), ".asset");
            if (!uiManager)
            {
                if (EditorUtility.DisplayDialog("配置游戏UI界面管理器", "第一次需要配置游戏UI界面管理器!", "确定", "不要取消"))
                {
                    uiManager = (UIGraph)this.NewAsAsset();
                }
                else
                {
                    uiManager = (UIGraph)this.NewAsAsset();
                }
            }
        }
        GUI.skin = skin;
        GUILayout.BeginVertical("游戏UI界面管理器", "window");
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.BeginVertical();

        GUILayout.Space(10);
        EditorGUILayout.HelpBox("游戏UI界面管理器是管理不同场景游戏界面,比如登录界面,创建角色界面等", MessageType.Info);
        GUILayout.Space(10);
        if (GraphWindow.IsClosed() == true)
        {
            if (GUILayout.Button("打开游戏UI界面管理器"))
            {
                bIsOpen = true;
                GraphWindow.OpenWindow(uiManager);
            }
        }
        else
        {
            if (GUILayout.Button("关闭游戏UI界面管理器"))
            {
                bIsOpen = false;
                GraphWindow.CloseWindow();
            }
        }
        if (bIsOpen)
        {
            GUILayout.Space(10);
            var uiType = property.FindPropertyRelative("m_eUIType");
            EditorGUILayout.PropertyField(uiType, new GUIContent("UI界面插件类型"));
            uiManager.uiPluginType = (EUIManagerType)uiType.enumValueIndex;
            GUILayout.Space(10);
        }
        (property.serializedObject.targetObject as UnityMonoDriver).uiManager.m_dicUIs = new Dictionary <string, UIBase>(UIGraph.uiDics);
        //Debug.Log("fwefewf:"+ (property.serializedObject.targetObject as UnityMonoDriver).uiManager.m_dicUIs.Count);
        EditorUtility.SetDirty(property.serializedObject.targetObject);
        GUI.enabled = true;
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndVertical();
        property.serializedObject.ApplyModifiedProperties();
    }
コード例 #16
0
ファイル: UIGraphPatch.cs プロジェクト: lanicon/RealTime
            private static void Postfix(
                UIGraph __instance,
                List <CurveSettings> ___m_Curves,
                Rect ___m_GraphRect,
                PoolList <UIRenderData> ___m_RenderData,
                PoolList <Vector3> vertices,
                PoolList <int> indices,
                PoolList <Vector2> uvs,
                PoolList <Color32> colors)
            {
                // Note: this method is extracted from the original game and is slightly modified
                if (___m_Curves.Count == 0)
                {
                    return;
                }

                float   units       = pixelsToUnits(__instance);
                var     maxSize     = new Vector2(__instance.size.x, __instance.size.y);
                var     center      = __instance.pivot.TransformToCenter(__instance.size, __instance.arbitraryPivotOffset) * units;
                Vector3 size        = units * __instance.size;
                float   aspectRatio = __instance.size.x / __instance.size.y;

                using (var uiFontRenderer = __instance.font.ObtainRenderer())
                {
                    float xmin        = units * __instance.width * (-0.5f + ___m_GraphRect.xMin);
                    float xmax        = units * __instance.width * (-0.5f + ___m_GraphRect.xMax);
                    float minInterval = GridIntervalX * units;

                    float startTicks     = __instance.StartTime.Ticks;
                    var   visibleEndTime = GetVisibleEndTime(___m_Curves, __instance.StartTime, __instance.EndTime);
                    float endTicks       = visibleEndTime.Ticks;

                    float minRangeTicks = __instance.StartTime.AddDays(MinRangeInDays).Ticks - __instance.StartTime.Ticks;
                    float rangeTicks    = __instance.EndTime.Ticks - __instance.StartTime.Ticks;
                    float timeScale     = minRangeTicks / rangeTicks;

                    float scaledX = Mathf.Lerp(xmin, xmax, timeScale) - xmin;
                    var   step    = scaledX <= 0.0001f ? TimeSpan.FromDays(10000) : TimeSpan.FromDays(minInterval / scaledX);

                    var textRenderData = ___m_RenderData.Count > 1 ? ___m_RenderData[1] : null;

                    for (var current = __instance.StartTime.AddDays(1); current <= visibleEndTime; current += step)
                    {
                        float  currentTicks = current.Ticks;
                        float  x            = Mathf.Lerp(xmin, xmax, (currentTicks - startTicks) / (endTicks - startTicks));
                        string text         = current.ToString("M", currentCulture);
                        uiFontRenderer.textScale    = 1f;
                        uiFontRenderer.vectorOffset = new Vector3(x, __instance.height * units * -0.95f, 0f);
                        uiFontRenderer.pixelRatio   = units;
                        uiFontRenderer.maxSize      = maxSize;
                        uiFontRenderer.textAlign    = UIHorizontalAlignment.Center;
                        uiFontRenderer.defaultColor = __instance.TextColor;
                        uiFontRenderer.Render(text, textRenderData);
                        float val     = Mathf.Lerp(-0.5f + ___m_GraphRect.xMin, -0.5f + ___m_GraphRect.xMax, (currentTicks - startTicks) / (endTicks - startTicks));
                        var   corner1 = new Vector2(val - units * __instance.HelpAxesWidth * aspectRatio, -0.5f + ___m_GraphRect.yMin);
                        var   corner2 = new Vector2(val + units * __instance.HelpAxesWidth * aspectRatio, corner1.y + ___m_GraphRect.height);
                        addSolidQuad(
                            __instance,
                            Vector3.Scale(corner1, size) + center,
                            Vector3.Scale(corner2, size) + center,
                            __instance.HelpAxesColor,
                            vertices,
                            indices,
                            uvs,
                            colors);
                    }
                }
            }
コード例 #17
0
 public RedoDeleteNode(string stackId, string i, UIGraph g)
 {
     id      = i;
     graph   = g;
     StackId = stackId;
 }
コード例 #18
0
 public UndoCreateNode(string stackId, string i, UIGraph g)
 {
     id      = i;
     graph   = g;
     StackId = stackId;
 }
コード例 #19
0
 public GraphCanvas()
     : base()
 {
     Graph = new UIGraph();
 }
コード例 #20
0
ファイル: UIExportOutputs.xaml.cs プロジェクト: hglei/Materia
 public UIExportOutputs(UIGraph g)
 {
     InitializeComponent();
     graph = g;
 }