Esempio n. 1
0
        public static PopupMenu.Item ValueItems(FieldInfo valField, IOutlet <object> layer, Generator gen, Graph graph, int priority = 2)
        {
            PopupMenu.Item valItems = new PopupMenu.Item("Value");
            valItems.onDraw   = RightClick.DrawItem;
            valItems.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Value");
            valItems.color    = Color.gray;
            valItems.subItems = new List <PopupMenu.Item>();
            valItems.priority = priority;

            valItems.disabled = valField == null || gen == null;

            PopupMenu.Item exposeItem = new PopupMenu.Item("Expose", onDraw: RightClick.DrawItem, priority: 6);
            exposeItem.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Expose");
            if (valField != null)
            {
                exposeItem.onClick =                               // () => { if (gen.exposed==null) gen.exposed=new Exposed(); gen.exposed.ExposeField(valField); };
                                     () => ExposeWindow.ShowWindow(graph, gen, layer, valField, Event.current.mousePosition + EditorWindow.focusedWindow.position.position);
            }
            // graph.exposed.Expose(gen, valField);
            valItems.subItems.Add(exposeItem);

            PopupMenu.Item unExposeItem = new PopupMenu.Item("UnExpose", onDraw: RightClick.DrawItem, priority: 6);
            unExposeItem.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/UnExpose");
            if (valField != null)
            {
                unExposeItem.onClick =                               //() => { if (gen.exposed==null) gen.exposed=new Exposed(); gen.exposed.ExposeField(valField); };
                                       () => graph.exposed.Unexpose(gen, valField);
            }
            valItems.subItems.Add(unExposeItem);

            return(valItems);
        }
Esempio n. 2
0
		public static Item ValueItems (RightClickExpose expose, Generator gen, Graph graph, int priority=2)
		/// chNum is a channel for vector fields
		{
			Item valItems = new Item("Value");
			valItems.onDraw = RightClick.DrawItem;
			valItems.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Value");
			valItems.color =  RightClick.defaultColor;
			valItems.subItems = new List<Item>();
			valItems.priority = priority;

			valItems.disabled = expose==null || gen==null;

			Item exposeItem = new Item("Expose", onDraw:RightClick.DrawItem, priority:6); 
			exposeItem.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Expose");
			if (expose != null) exposeItem.onClick =
				() => { ExposeWindow.ShowWindow(graph, expose.id, expose.fieldName, expose.fieldType, expose.channel, expose.arrIndex); UI.current.editorWindow.Close(); };
			valItems.subItems.Add(exposeItem);

			Item unExposeItem = new Item("UnExpose", onDraw:RightClick.DrawItem, priority:6); 
			unExposeItem.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/UnExpose");
			if (expose != null) unExposeItem.onClick = //() => { if (gen.exposed==null) gen.exposed=new Exposed(); gen.exposed.ExposeField(valField); };
				() => 
				{
					//graph.exposed.Unexpose(gen, valField);
					graph.exposed.Remove(gen.id, expose.fieldName, expose.channel);
					GraphWindow.current.Focus();
					GraphWindow.current.Repaint();
				};
			valItems.subItems.Add(unExposeItem);

			return valItems;
		}
Esempio n. 3
0
		public static void ShowWindow (Graph graph, IExposedGuid gen, IOutlet<object> layer, FieldInfo field, Vector2 pos)
		{
			ExposeWindow window = ScriptableObject.CreateInstance(typeof(ExposeWindow)) as ExposeWindow;

			if (layer != null  &&  layer is IExposedGuid expLayer) window.obj = expLayer;
			else window.obj = gen;

			window.graph = graph;
			window.field = field;
			window.customName = field.Name.Nicify();
			window.ShowUtility();

			Vector2 windowSize = new Vector2(300, 100);
			window.position = new Rect(
				pos - windowSize/2,
				windowSize);
		}
Esempio n. 4
0
        /// Drawing field of a value that is currently exposed
        private static void ExposedField(ulong genId, string fieldName, Type fieldType, int chNum, int arrIndex)
        {
            if (UI.current.layout)             //will need field widt, and what's the point to do it in layout?
            {
                return;
            }

            Graph graph = GraphWindow.current.graph;

            float fieldWidth = Cell.current.finalSize.x;             //we are not in layout

            string label      = graph.exposed.GetExpression(genId, fieldName, channel: chNum, arrIndex: arrIndex);
            float  labelWidth = UI.current.styles.label.CalcSize(new GUIContent(label)).x;

            if (labelWidth > fieldWidth - 20)
            {
                label = "...";
            }

            Draw.Label(label, UI.current.styles.field);

            Vector2 center  = Cell.current.InternalCenter;
            Vector2 iconPos = new Vector2(center.x + fieldWidth / 2 - 10, center.y);

            Draw.Icon(UI.current.textures.GetTexture("DPUI/Icons/Expose"), iconPos, scale: 0.5f);

            //if (Draw.Button(visible:false))  //cell inactive
            if (UI.current.mouseButton == 0 && Cell.current.Contains(UI.current.mousePos))
            {
                ExposeWindow.ShowWindow(graph, genId, fieldName, fieldType, chNum, arrIndex);
            }

                        #if UNITY_EDITOR
//			Rect rect = Cell.current.GetRect(UI.current.scrollZoom);
//			UnityEditor.EditorGUIUtility.AddCursorRect(rect, UnityEditor.MouseCursor.Zoom);
                        #endif
        }