Exemplo n.º 1
0
 public static void TexturesGeneratorEditor(TexturesOutput200 gen)
 {
     using (Cell.LinePx(20)) GeneratorDraw.DrawLayersAddRemove(gen, ref gen.layers, inversed: true);
     using (Cell.LinePx(0)) GeneratorDraw.DrawLayersThemselves(gen, gen.layers, inversed: true, layerEditor: DrawTexturesLayer);
 }
Exemplo n.º 2
0
        private static void DrawTexturesLayer(Generator tgen, int num)
        {
            TexturesOutput200 texOut = (TexturesOutput200)tgen;

            TexturesOutput200.TextureLayer layer = texOut.layers[num];
            if (layer == null)
            {
                return;
            }

            Cell.EmptyLinePx(3);
            using (Cell.LinePx(28))
            {
                if (num != 0)
                {
                    using (Cell.RowPx(0)) GeneratorDraw.DrawInlet(layer, texOut);
                }
                else
                //disconnecting last layer inlet
                if (GraphWindow.current.graph.IsLinked(layer))
                {
                    GraphWindow.current.graph.UnlinkInlet(layer);
                }

                Cell.EmptyRowPx(10);

                Texture2D tex = layer.prototype != null ? layer.prototype.diffuseTexture : UI.current.textures.GetTexture("DPUI/Backgrounds/Empty");
                using (Cell.RowPx(28)) Draw.TextureIcon(tex);

                using (Cell.Row)
                {
                    Cell.current.trackChange = false;
                    Draw.EditableLabel(ref layer.name);
                }

                using (Cell.RowPx(20))
                {
                    Cell.current.trackChange = false;
                    Draw.LayerChevron(num, ref texOut.guiExpanded);
                }

                Cell.EmptyRowPx(10);
                using (Cell.RowPx(0)) GeneratorDraw.DrawOutlet(layer);
            }
            Cell.EmptyLinePx(2);

            if (texOut.guiExpanded == num)
            {
                using (Cell.Line)
                {
                    Cell.EmptyRowPx(2);

                    using (Cell.Row)
                    {
                        using (Cell.LinePx(0))
                            using (Cell.Padded(1, 0, 0, 0))
                            {
                                //using (Cell.LineStd) layer.Opacity = Draw.Field(layer.Opacity, "Opacity");
                                //using (Cell.LineStd) Draw.ObjectField(ref layer.prototype, "Layer");

                                Draw.Class(layer, "Layer", addFieldsToCellObjs: true);
                                //this will add terrainlayer to exposed

                                if (layer.name == "Layer" && layer.prototype != null)
                                {
                                    layer.name = layer.prototype.name;
                                }
                            }

                        if (layer.prototype != null)
                        {
                            Cell.EmptyLinePx(2);

                            using (Cell.LineStd)
                                using (new Draw.FoldoutGroup(ref layer.guiProperties, "Properties"))
                                    if (layer.guiProperties)
                                    {
                                        //textures
                                        using (Cell.LineStd)
                                        {
                                            Texture2D tex = layer.prototype.diffuseTexture;
                                            Draw.Field(ref tex, "Diffuse");
                                            if (Cell.current.valChanged)
                                            {
                                                if (layer.prototype.diffuseTexture.name == "WrColorPlaceholder2x2")
                                                {
                                                    GameObject.DestroyImmediate(layer.prototype.diffuseTexture);                             // removing temporary color texture if assigned
                                                }
                                                layer.prototype.diffuseTexture = tex;
                                            }
                                        }

                                        using (Cell.LineStd)
                                        {
                                            Texture2D tex = layer.prototype.normalMapTexture;
                                            Draw.Field(ref tex, "Normal");
                                            if (Cell.current.valChanged)
                                            {
                                                layer.prototype.normalMapTexture = tex;
                                            }
                                        }

                                        using (Cell.LineStd)
                                        {
                                            Texture2D tex = layer.prototype.maskMapTexture;
                                            Draw.Field(ref tex, "Mask");
                                            if (Cell.current.valChanged)
                                            {
                                                layer.prototype.maskMapTexture = tex;
                                            }
                                        }

                                        //color (after texture)
                                        if (layer.prototype.diffuseTexture == null)
                                        {
                                            layer.prototype.diffuseTexture      = TextureExtensions.ColorTexture(2, 2, layer.color);
                                            layer.prototype.diffuseTexture.name = "WrColorPlaceholder2x2";
                                        }

                                        if (layer.prototype.diffuseTexture.name == "WrColorPlaceholder2x2")
                                        {
                                            using (Cell.LineStd)
                                            {
                                                using (Cell.LineStd) Draw.Field(ref layer.color, "Color");
                                                if (Cell.current.valChanged)
                                                {
                                                    layer.prototype.diffuseTexture.Colorize(layer.color);
                                                }
                                            }
                                        }


                                        using (Cell.LineStd) layer.prototype.specular = Draw.Field(layer.prototype.specular, "Specular");
                                        using (Cell.LineStd) layer.prototype.smoothness = Draw.Field(layer.prototype.smoothness, "Smooth");
                                        using (Cell.LineStd) layer.prototype.metallic = Draw.Field(layer.prototype.metallic, "Metallic");
                                        using (Cell.LineStd) layer.prototype.normalScale = Draw.Field(layer.prototype.normalScale, "N. Scale");
                                    }

                            using (Cell.LineStd)
                                using (new Draw.FoldoutGroup(ref layer.guiTileSettings, "Tile Settings"))
                                    if (layer.guiTileSettings)
                                    {
                                        using (Cell.LineStd) layer.prototype.tileSize = Draw.Field(layer.prototype.tileSize, "Size");
                                        using (Cell.LineStd) layer.prototype.tileOffset = Draw.Field(layer.prototype.tileOffset, "Offset");
                                    }

                            if (layer.guiTileSettings)
                            {
                                Cell.EmptyLinePx(3);
                            }
                        }
                    }

                    /*using (UI.FoldoutGroup(ref layer.guiRemapping, "Remapping", inspectorOffset:0, margins:0))
                     * if (layer.guiTileSettings)
                     * {
                     *      using (Cell.LineStd)
                     *      {
                     *              Draw.Label("Red", cell:UI.Empty(Size.row));
                     *              layer.prototype.diffuseRemapMin.x = Draw.Field(layer.prototype.diffuseRemapMin.x, cell:UI.Empty(Size.row));
                     *      }
                     * }*/

                    Cell.EmptyRowPx(2);
                }
            }
        }
Exemplo n.º 3
0
 public static void NormalizeGeneratorEditor(Normalize200 gen)
 {
     using (Cell.LinePx(20)) GeneratorDraw.DrawLayersAddRemove(gen, ref gen.layers, inversed: true);
     using (Cell.LinePx(0)) GeneratorDraw.DrawLayersThemselves(gen, gen.layers, inversed: true, layerEditor: DrawNormalizeLayer);
 }
Exemplo n.º 4
0
        public static void DrawGrassOutput(MatrixGenerators.GrassOutput200 grassOut)
        {
            using (Cell.Padded(1, 1, 0, 0))
            {
                //Cell.current.margins = new Padding(4,4,4,4);

                using (Cell.LinePx(0))
                {
                    Cell.current.fieldWidth = 0.6f;

                    using (Cell.LineStd) Draw.Field(ref grassOut.renderMode, "Mode");

                    if (grassOut.renderMode == MatrixGenerators.GrassOutput200.GrassRenderMode.MeshUnlit || grassOut.renderMode == MatrixGenerators.GrassOutput200.GrassRenderMode.MeshVertexLit)
                    {
                        using (Cell.LineStd) grassOut.prototype.prototype = Draw.Field(grassOut.prototype.prototype, "Object");
                        grassOut.prototype.prototypeTexture = null;                         //otherwise this texture will be included to build even if not displayed
                        grassOut.prototype.usePrototypeMesh = true;
                    }
                    else
                    {
                        using (Cell.LineStd) grassOut.prototype.prototypeTexture = Draw.Field(grassOut.prototype.prototypeTexture, "Texture");
                        grassOut.prototype.prototype        = null;                  //otherwise this object will be included to build even if not displayed
                        grassOut.prototype.usePrototypeMesh = false;
                    }
                    switch (grassOut.renderMode)
                    {
                    case MatrixGenerators.GrassOutput200.GrassRenderMode.Grass: grassOut.prototype.renderMode = DetailRenderMode.Grass; break;

                    case MatrixGenerators.GrassOutput200.GrassRenderMode.Billboard: grassOut.prototype.renderMode = DetailRenderMode.GrassBillboard; break;

                    case MatrixGenerators.GrassOutput200.GrassRenderMode.MeshVertexLit: grassOut.prototype.renderMode = DetailRenderMode.VertexLit; break;

                    case MatrixGenerators.GrassOutput200.GrassRenderMode.MeshUnlit: grassOut.prototype.renderMode = DetailRenderMode.Grass; break;
                    }
                }

                using (Cell.LinePx(0))
                {
                    Cell.current.fieldWidth = 0.4f;

                    using (Cell.LineStd) Draw.Field(ref grassOut.density, "Density");
                    using (Cell.LineStd) grassOut.prototype.dryColor = Draw.Field(grassOut.prototype.dryColor, "Dry");
                    using (Cell.LineStd) grassOut.prototype.healthyColor = Draw.Field(grassOut.prototype.healthyColor, "Healthy");

                    Vector2 temp = new Vector2(grassOut.prototype.minWidth, grassOut.prototype.maxWidth);
                    using (Cell.LineStd) Draw.Field(ref temp, "Width", xName: "Min", yName: "Max", xyWidth: 25);
                    grassOut.prototype.minWidth = temp.x; grassOut.prototype.maxWidth = temp.y;

                    temp = new UnityEngine.Vector2(grassOut.prototype.minHeight, grassOut.prototype.maxHeight);
                    using (Cell.LineStd) Draw.Field(ref temp, "Height", xName: "Min", yName: "Max", xyWidth: 25);
                    grassOut.prototype.minHeight = temp.x; grassOut.prototype.maxHeight = temp.y;

                    using (Cell.LineStd) grassOut.prototype.noiseSpread = (float)Draw.Field(grassOut.prototype.noiseSpread, "Noise");

                    if (GraphWindow.current.mapMagic != null)
                    {
                        using (Cell.LineStd) GeneratorDraw.DrawGlobalVar(ref GraphWindow.current.mapMagic.globals.grassResPerPatch, "Res/Patch");
                    }
                }
            }
        }
        public static void DrawMicroSplatLayer(MicroSplatOutput200.MicroSplatLayer layer, object[] arguments)
        {
            int num = (int)arguments[0];
            MicroSplatOutput200 gen = (MicroSplatOutput200)arguments[1];

            if (layer == null)
            {
                return;
            }

            Material microSplatMat = null;

            if (GraphWindow.current.mapMagic != null)
            {
                microSplatMat = GraphWindow.current.mapMagic.terrainSettings.material;
            }

            Cell.EmptyLinePx(3);
            using (Cell.LinePx(28))
            {
                //Cell.current.margins = new Padding(0,0,0,1); //1-pixel more padding from the bottom since layers are 1 pixel overlayed

                if (num != 0)
                {
                    using (Cell.RowPx(0)) GeneratorDraw.DrawInlet(layer, gen);
                }
                else
                //disconnecting last layer inlet
                if (GraphWindow.current.graph.IsLinked(layer))
                {
                    GraphWindow.current.graph.UnlinkInlet(layer);
                }

                Cell.EmptyRowPx(10);

                //icon
                Texture2DArray icon = null;
                if (microSplatMat != null && microSplatMat.HasProperty("_Diffuse"))
                {
                    icon = (Texture2DArray)microSplatMat?.GetTexture("_Diffuse");
                }

                using (Cell.RowPx(28))
                {
                    if (icon != null)
                    {
                        Draw.TextureIcon(icon, layer.channelNum);
                    }
                }

                //index
                using (Cell.Row)
                {
                    Cell.EmptyLine();
                    using (Cell.LineStd)
                    {
                        int newIndex = Draw.Field(layer.channelNum, "Index");
                        if (newIndex >= 0 && (icon == null || newIndex < icon.depth))
                        {
                            layer.channelNum = newIndex;
                        }
                    }
                    Cell.EmptyLine();
                }

                Cell.EmptyRowPx(10);
                using (Cell.RowPx(0)) GeneratorDraw.DrawOutlet(layer);
            }
            Cell.EmptyLinePx(3);
        }
Exemplo n.º 6
0
        public static Item CreateItems(Vector2 mousePos, Graph graph, int priority = 5)
        {
            Item create = new Item("Add (Create)");

            create.onDraw   = RightClick.DrawItem;
            create.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Create");
            create.color    = Color.gray;
            create.subItems = new List <Item>();
            create.priority = priority;

            //automatically adding generators from this assembly
            Type[] types = typeof(Generator).Subtypes();
            for (int t = 0; t < types.Length; t++)
            {
                if (!generatorTypes.Contains(types[t]))
                {
                    generatorTypes.Add(types[t]);
                }
            }

            //adding outer-assembly types
            //via their initialize

            //creating unsorted create items
            foreach (Type type in generatorTypes)
            {
                GeneratorMenuAttribute attribute = GeneratorDraw.GetMenuAttribute(type);
                if (attribute == null)
                {
                    continue;
                }

                string texPath = attribute.iconName ?? "MapMagic/Popup/Standard";
                string texName = texPath;
                if (StylesCache.isPro)
                {
                    texName += "_icon";
                }

                Item item = new Item( )
                {
                    name     = attribute.name,
                    onDraw   = RightClick.DrawItem,
                    icon     = RightClick.texturesCache.GetTexture(texPath, texName, forceLight: true),
                    color    = GeneratorDraw.GetGeneratorColor(attribute.colorType ?? Generator.GetGenericType(type)),
                    onClick  = () => GraphEditorActions.CreateGenerator(graph, type, mousePos),
                    priority = attribute.priority
                };

                //moving into the right section using priority
                //int sectionPriority = 10000 - attribute.section*1000;
                //item.priority += sectionPriority;


                //placing items in categories
                string catName = attribute.menu;
                if (catName == null)
                {
                    continue;                                  //if no 'menu' defined this generator could not be created
                }
                string[] catNameSplit = catName.Split('/');

                Item currCat = create;
                if (catName != "")                  //if empty menu is defined using root category
                {
                    for (int i = 0; i < catNameSplit.Length; i++)
                    {
                        //trying to find category
                        bool catFound = false;
                        if (currCat.subItems != null)
                        {
                            foreach (Item sub in currCat.subItems)
                            {
                                if (sub.onClick == null && sub.name == catNameSplit[i])
                                {
                                    currCat  = sub;
                                    catFound = true;
                                    break;
                                }
                            }
                        }

                        //creating if not found
                        if (!catFound)
                        {
                            Item newCat = new Item(catNameSplit[i]);
                            if (currCat.subItems == null)
                            {
                                currCat.subItems = new List <Item>();
                            }
                            currCat.subItems.Add(newCat);
                            currCat = newCat;

                            newCat.color = item.color;
                        }
                    }
                }

                if (currCat.subItems == null)
                {
                    currCat.subItems = new List <Item>();
                }
                currCat.subItems.Add(item);
            }

            //default sorting order
            foreach (Item item in create.All(true))
            {
                if (item.name == "Map")
                {
                    item.priority = 10004; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Map"); item.color = Color.gray;
                }
                if (item.name == "Objects" && item.onClick == null)
                {
                    item.priority = 10003; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Objects"); item.color = Color.gray;
                }
                if (item.name == "Spline")
                {
                    item.priority = 10002; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Spline"); item.color = Color.gray;
                }
                if (item.name == "Biomes")
                {
                    item.priority = 9999; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Biomes");
                }

                if (item.name == "Initial")
                {
                    item.priority = 10009; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Initial");
                }
                if (item.name == "Modifiers")
                {
                    item.priority = 10008; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Modifier");
                }
                if (item.name == "Standard")
                {
                    item.priority = 10009; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Standard");
                }
                if (item.name == "Output")
                {
                    item.priority = 10007; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Output");
                }
                if (item.name == "Outputs")
                {
                    item.priority = 10006; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Output");
                }
                if (item.name == "Input")
                {
                    item.priority = 10005; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Input");
                }
                if (item.name == "Inputs")
                {
                    item.priority = 10004; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Input");
                }
                if (item.name == "Portals")
                {
                    item.priority = 10003; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Portals");
                }
                if (item.name == "Function")
                {
                    item.priority = 10002; item.icon = RightClick.texturesCache.GetTexture("MapMagic/Popup/Function");
                }

                if (item.name == "Height")
                {
                    item.priority = 10003;
                }
                if (item.name == "Textures")
                {
                    item.priority = 10002;
                }
                if (item.name == "Grass")
                {
                    item.priority = 10001;
                }

                if (item.onDraw == null)
                {
                    item.onDraw = RightClick.DrawItem;
                }
            }

            //adding separator between standard and special categories
            if (create.subItems.FindIndex(i => i.name == "Biomes") >= 0)         //add separator if biomes item present
            {
                Item separator = Item.Separator(priority: 10001);
                separator.onDraw = RightClick.DrawSeparator;
                separator.color  = Color.gray;
                create.subItems.Add(separator);
            }

            return(create);
        }
Exemplo n.º 7
0
		private void DragDrawAddRemove ()
		{
			//if dragging generator
			if (DragDrop.IsDragging()  &&  !DragDrop.IsStarted()  &&  DragDrop.obj is Cell  &&  UI.current.cellObjs.TryGetObject((Cell)DragDrop.obj, "Generator", out Generator draggedGen) )
			{
				if (Cell.current.Contains(UI.current.mousePos))
					Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeRemoveActive"));
				else
					Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeRemove"));
			}


			//if released generator on remove icon
			else if (DragDrop.IsReleased()  &&  
				DragDrop.releasedObj is Cell  &&  
				UI.current.cellObjs.TryGetObject((Cell)DragDrop.releasedObj, "Generator", out Generator releasedGen)  &&  
				Cell.current.Contains(UI.current.mousePos))
			{
				GraphEditorActions.RemoveGenerator(graph, releasedGen, selected);
				GraphWindow.RefreshMapMagic();
			}


			//if not dragging generator
			else
			{
				addDragTo = addDragDefault;

				if (focusedWindow == this) disableAddRemoveButton = false; //re-enabling when window is focused again after popup

				if (DragDrop.TryDrag(addDragId, UI.current.scrollZoom.ToScreen(UI.current.mousePos)))
				{
					addDragTo += DragDrop.totalDelta;

					Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeAdd"));

					//if dragging near link, output or node
					//Vector2 mousePos = graphUI.mousePos;
					Vector2 mousePos = graphUI.scrollZoom.ToInternal(addDragTo + new Vector2(addDragSize/2,addDragSize/2)); //add button center

					object clickedObj = RightClick.ClickedOn(graphUI, mousePos);
				
					if (clickedObj != null  &&  !(clickedObj is Group))
					{
						Color linkColor = GeneratorDraw.GetLinkColor(Generator.GetGenericType(clickedObj.GetType()));
						Texture2D frameTex = UI.current.textures.GetColorizedTexture("MapMagic/Icons/NodeAddRemoveFrame", linkColor);
						Draw.Texture(frameTex);
					}
				}
				else if (!disableAddRemoveButton) //don't show this button if right-click items are shown
					Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeAdd")); //using Texture since Icon is scaled with scrollzoom


				if (DragDrop.TryRelease(addDragId))
				{
					disableAddRemoveButton = true;

					//Vector2 mousePos = graphUI.mousePos;
					Vector2 mousePos = graphUI.scrollZoom.ToInternal(addDragTo + new Vector2(addDragSize/2,addDragSize/2)); //add button center

					RightClick.ClickedNear (graphUI, mousePos, 
						out Group clickedGroup, out Generator clickedGen, out IOutlet<object> clickedLayer, out IInlet<object> clickedLink, out IInlet<object> clickedInlet, out IOutlet<object> clickedOutlet, out FieldInfo clickedField);

					if (clickedOutlet != null)
						CreateRightClick.DrawAppendItems(mousePos, graph, clickedOutlet);

					else if (clickedLayer != null)
						CreateRightClick.DrawAppendItems(mousePos, graph, clickedLayer);

					else if (clickedLink != null)
						CreateRightClick.DrawInsertItems(mousePos, graph, clickedLink);

					else
						CreateRightClick.DrawCreateItems(mousePos, graph);
				}


				DragDrop.TryStart(addDragId, new Rect(addDragDefault, new Vector2(addDragSize-4,addDragSize-4)));
			}
		}
Exemplo n.º 8
0
		private void DragDrawAddRemove ()
		{
			int origButtonSize = 34; int origButtonOffset = 20;

			Vector2 buttonPos = new Vector2(
				UI.current.editorWindow.position.width - (origButtonSize + origButtonOffset)*UI.current.DpiScaleFactor,
				20*UI.current.DpiScaleFactor);
			Vector2 buttonSize = new Vector2(origButtonSize,origButtonSize) * UI.current.DpiScaleFactor;

			using (Cell.Custom(buttonPos,buttonSize))
			//later button pos could be overriden if dragging it
			{
				Cell.current.MakeStatic();


				//if dragging generator
				if (DragDrop.IsDragging()  &&  !DragDrop.IsStarted()  &&  DragDrop.obj is Cell  &&  UI.current.cellObjs.TryGetObject((Cell)DragDrop.obj, "Generator", out Generator draggedGen) )
				
				{
					if (Cell.current.Contains(UI.current.mousePos))
						Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeRemoveActive"));
					else
						Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeRemove"));
				}


				//if released generator on remove icon
				else if (DragDrop.IsReleased()  &&  
					DragDrop.releasedObj is Cell  &&  
					UI.current.cellObjs.TryGetObject((Cell)DragDrop.releasedObj, "Generator", out Generator releasedGen)  &&  
					Cell.current.Contains(UI.current.mousePos))
				{
					GraphEditorActions.RemoveGenerator(graph, releasedGen, selected); 
					GraphWindow.RefreshMapMagic();
				}


				//if not dragging generator
				else
				{
					if (focusedWindow==this) drawAddRemoveButton = true;   //re-enabling when window is focused again after popup
					bool drawFrame = false;
					Color frameColor = new Color();

					//dragging button
					if (DragDrop.TryDrag(addDragId, UI.current.mousePos))
					{
						Cell.current.pixelOffset += DragDrop.totalDelta; //offsetting cell position with the mouse

						Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeAdd"));

						//if dragging near link, output or node
						Vector2 mousePos = graphUI.mousePos;
						//Vector2 mousePos = graphUI.scrollZoom.ToInternal(addDragTo + new Vector2(addDragSize/2,addDragSize/2)); //add button center

						object clickedObj = RightClick.ClickedOn(graphUI, mousePos);
				
						if (clickedObj != null  &&  !(clickedObj is Group))
						{
							drawFrame = true;
							frameColor = GeneratorDraw.GetLinkColor(Generator.GetGenericType(clickedObj.GetType()));
						}
					}

					//releasing button
					if (DragDrop.TryRelease(addDragId))
					{
						drawAddRemoveButton = false;

						Vector2 mousePos = graphUI.mousePos;
						//Vector2 mousePos = graphUI.scrollZoom.ToInternal(addDragTo + new Vector2(addDragSize/2,addDragSize/2)); //add button center

						RightClick.ClickedNear (graphUI, mousePos, 
							out Group clickedGroup, out Generator clickedGen, out IInlet<object> clickedLink, out IInlet<object> clickedInlet, out IOutlet<object> clickedOutlet, out RightClickExpose clickedField);

						if (clickedOutlet != null)
							CreateRightClick.DrawAppendItems(mousePos, graph, clickedOutlet);

						else if (clickedLink != null)
							CreateRightClick.DrawInsertItems(mousePos, graph, clickedLink);

						else
							CreateRightClick.DrawCreateItems(mousePos, graph);
					}

					//starting button drag
					DragDrop.TryStart(addDragId, UI.current.mousePos, Cell.current.InternalRect);

					//drawing button
					#if !MM_DOC
					if (drawAddRemoveButton) //don't show this button if right-click items are shown
						Draw.Texture(UI.current.textures.GetTexture("MapMagic/Icons/NodeAdd")); //using Texture since Icon is scaled with scrollzoom
					#endif

					if (drawFrame)
					{
						Texture2D frameTex = UI.current.textures.GetColorizedTexture("MapMagic/Icons/NodeAddRemoveFrame", frameColor);
						Draw.Texture(frameTex);
					}
				}
			}
		}
Exemplo n.º 9
0
        public static void DrawMicroSplat(MicroSplatOutput200 gen)
        {
                        #if !__MICROSPLAT__
            using (Cell.LinePx(60))
                Draw.Helpbox("MicroSplat doesn't seem to be installed, or MicroSplat compatibility is not enabled in settings");
                        #endif
            if (GraphWindow.current.mapMagic != null)
            {
                using (Cell.LineStd)
                {
                    //Cell.current.fieldWidth = 0.5f;
                    using (Cell.LineStd) GeneratorDraw.DrawGlobalVar(ref GraphWindow.current.mapMagic.terrainSettings.material, "Material");

                    using (Cell.LinePx(0))
                        using (new Draw.FoldoutGroup(ref gen.guiAdvanced, "Advanced"))
                            if (gen.guiAdvanced)
                            {
                                using (Cell.LineStd)
                                {
                                    Cell.current.fieldWidth = 0.15f;
                                    GeneratorDraw.DrawGlobalVar(ref GraphWindow.current.mapMagic.globals.assignComponent, "Set Component");
                                }

                                                        #if __MICROSPLAT__
                                if (GraphWindow.current.mapMagic.globals.assignComponent)
                                {
                                    using (Cell.LineStd)
                                        GraphWindow.current.mapMagic.globals.microSplatPropData = GeneratorDraw.DrawGlobalVar <MicroSplatPropData>(
                                            GraphWindow.current.mapMagic.globals.microSplatPropData == null ? null : (MicroSplatPropData)GraphWindow.current.mapMagic.globals.microSplatPropData,
                                            "PropData");
                                }
                                                        #endif

                                //using (Cell.LineStd)
                                //	Draw.Label("Apply Type");

                                using (Cell.LineStd)
                                    GeneratorDraw.DrawGlobalVar(ref GraphWindow.current.mapMagic.globals.microSplatApplyType, "Apply Type");

                                using (Cell.LineStd)
                                {
                                    Cell.current.fieldWidth = 0.15f;
                                    Cell.current.disabled   = GraphWindow.current.mapMagic.globals.microSplatApplyType == Globals.MicroSplatApplyType.Splats;                         //no tex names when applying
                                    GeneratorDraw.DrawGlobalVar(ref GraphWindow.current.mapMagic.globals.useCustomControlTextures, "Custom Splatmaps");
                                }

                                using (Cell.LineStd)
                                {
                                    Cell.current.fieldWidth = 0.15f;
                                    Cell.current.disabled   = GraphWindow.current.mapMagic.globals.microSplatApplyType == Globals.MicroSplatApplyType.Splats;                         //no normals texture when applying only splats
                                    GeneratorDraw.DrawGlobalVar(ref GraphWindow.current.mapMagic.globals.microSplatNormals, "Add Normals Tex");
                                }

                                //using (Cell.LineStd)
                                //	{ Cell.current.fieldWidth = 0.15f; GeneratorDraw.DrawGlobalVar(ref GraphWindow.current.mapMagic.globals.microSplatTerrainDescriptor, "Add Descriptor"); }
                            }

                    if (Cell.current.valChanged)
                    {
                        GraphWindow.current.mapMagic.ApplyTerrainSettings();
                    }
                }
            }
            else
            {
                using (Cell.LinePx(18 + 18)) Draw.Label("Not assigned to current \nMapMagic object");
            }

            using (Cell.LinePx(0)) CheckShader(gen);
            //using (Cell.LinePx(0)) CheckCustomSplatmaps(gen);

            using (Cell.LinePx(20)) GeneratorDraw.DrawLayersAddRemove(gen, ref gen.layers, inversed: true, unlinkBackground: true);
            using (Cell.LinePx(0)) GeneratorDraw.DrawLayersThemselves(gen, gen.layers, inversed: true, layerEditor: DrawMicroSplatLayer);
        }
Exemplo n.º 10
0
		private void DrawGraph () 
			{using (Timer.Start("DrawGraph"))
		{
				//background
				#if MM_DOC
					float gridColor = 0.95f;
					float gridBackgroundColor = 0.95f;
				#else
					float gridColor = !StylesCache.isPro ? 0.45f : 0.14f; //0.135f; 
					float gridBackgroundColor = !StylesCache.isPro ? 0.5f : 0.16f; //0.16f;
				#endif

				Draw.StaticGrid(
					displayRect: new Rect(0, 0, Screen.width, Screen.height-toolbarSize),
					cellSize:32,
					color:new Color(gridColor,gridColor,gridColor), 
					background:new Color(gridBackgroundColor,gridBackgroundColor,gridBackgroundColor),
					fadeWithZoom:true);


				//drawing groups
				foreach (Group group in graph.groups)
					using (Cell.Custom(group.guiPos.x, group.guiPos.y, group.guiSize.x, group.guiSize.y))
					{
						GroupDraw.DragGroup(group, graph.generators);
						GroupDraw.DrawGroup(group);
					}


				//dragging nodes
				foreach (Generator gen in graph.generators)
					GeneratorDraw.DragGenerator(gen, selected);


				//drawing links
				using (Timer.Start("Links"))
				if (!UI.current.layout)
				{
					List<(IInlet<object> inlet, IOutlet<object> outlet)> linksToRemove = null;
					foreach (var kvp in graph.links)
					{
						IInlet<object> inlet = kvp.Key;
						IOutlet<object> outlet = kvp.Value;

						Cell outletCell = UI.current.cellObjs.GetCell(outlet, "Outlet");
						Cell inletCell = UI.current.cellObjs.GetCell(inlet, "Inlet");

						if (outletCell == null || inletCell == null)
						{
							Debug.LogError("Could not find a cell for inlet/outlet. Removing link");
							if (linksToRemove == null) linksToRemove = new List<(IInlet<object> inlet, IOutlet<object> outlet)>();
							linksToRemove.Add((inlet,outlet));
							continue;
						}

						GeneratorDraw.DrawLink(
							GeneratorDraw.StartCellLinkpos(outletCell),
							GeneratorDraw.EndCellLinkpos(inletCell), 
							GeneratorDraw.GetLinkColor(inlet) );
					}

					if (linksToRemove != null)
						foreach ((IInlet<object> inlet, IOutlet<object> outlet) in linksToRemove)
						{
							graph.UnlinkInlet(inlet);
							graph.UnlinkOutlet(outlet);
						}
				}

				//removing null generators (for test purpose)
				for (int n=graph.generators.Length-1; n>=0; n--)
				{
					if (graph.generators[n] == null)
						ArrayTools.RemoveAt(ref graph.generators, n);
				}

				//drawing generators
				using (Timer.Start("Generators"))
				foreach (Generator gen in graph.generators)
					using (Cell.Custom(gen.guiPosition.x, gen.guiPosition.y, GeneratorDraw.nodeWidth, 0))
					{
						if (gen is IPortalEnter<object> || gen is IPortalExit<object> || gen is IFunctionInput<object> || gen is IFunctionOutput<object>) 
							GeneratorDraw.DrawPortal(gen, graph, selected:selected.Contains(gen));

						else
						{
							try { GeneratorDraw.DrawGenerator(gen, graph, selected:selected.Contains(gen)); }
							catch (ExitGUIException)
								{ } //ignoring
							catch (Exception e) 
								{ Debug.LogError("Draw Graph Window failed: " + e); }
						}
					}

				//de-selecting nodes (after dragging and drawing since using drag obj)
				if (!UI.current.layout)
				{
					GeneratorDraw.SelectGenerators(selected);
					GeneratorDraw.DeselectGenerators(selected);
				}
				
				//add/remove button
				using (Timer.Start("AddRemove"))
				using (Cell.Static(addDragTo.x, addDragTo.y, addDragSize,addDragSize))
					DragDrawAddRemove();

				//right click menu (should have access to cellObjs)
				if (!UI.current.layout  &&  Event.current.type == EventType.MouseDown  &&  Event.current.button == 1)
					RightClick.DrawRightClickItems(graphUI, graphUI.mousePos, graph);

				//create menu on space
				if (!UI.current.layout  &&  Event.current.type == EventType.KeyDown  &&  Event.current.keyCode == KeyCode.Space)
					CreateRightClick.DrawCreateItems(graphUI.mousePos, graph);

				//delete selected generators
				if (selected!=null  &&  selected.Count!=0  &&  Event.current.type==EventType.KeyDown  &&  Event.current.keyCode==KeyCode.Delete)
					GraphEditorActions.RemoveGenerators(graph, selected);
		}}
Exemplo n.º 11
0
        private static void DrawMicroSplatLayer(Generator tgen, int num)
        {
            MicroSplatOutput200 gen = (MicroSplatOutput200)tgen;

            MicroSplatOutput200.MicroSplatLayer layer = gen.layers[num];
            if (layer == null)
            {
                return;
            }

            Material microSplatMat = null;

            if (GraphWindow.current.mapMagic != null)
            {
                microSplatMat = GraphWindow.current.mapMagic.terrainSettings.material;
            }

            Cell.EmptyLinePx(3);
            using (Cell.LinePx(28))
            {
                //Cell.current.margins = new Padding(0,0,0,1); //1-pixel more padding from the bottom since layers are 1 pixel overlayed

                if (num != 0)
                {
                    using (Cell.RowPx(0)) GeneratorDraw.DrawInlet(layer, gen);
                }
                else
                //disconnecting last layer inlet
                if (GraphWindow.current.graph.IsLinked(layer))
                {
                    GraphWindow.current.graph.UnlinkInlet(layer);
                }

                Cell.EmptyRowPx(10);

                //icon
                Texture2DArray iconsArr = null;
                if (microSplatMat != null && microSplatMat.HasProperty("_Diffuse"))
                {
                    iconsArr = (Texture2DArray)microSplatMat?.GetTexture("_Diffuse");
                }

                using (Cell.RowPx(28))
                {
                    if (iconsArr != null)
                    {
                        Draw.TextureIcon(iconsArr, layer.channelNum);
                    }
                }

                Cell.EmptyRowPx(10);

                //index
                using (Cell.Row)
                {
                    Cell.EmptyLine();
                    using (Cell.LineStd)
                    {
                        int newIndex = Draw.Field(layer.channelNum, "Index");
                        if (newIndex >= 0 && (iconsArr == null || newIndex < iconsArr.depth))
                        {
                            layer.channelNum = newIndex;
                            layer.prototype  = null;
                        }
                    }
                    Cell.EmptyLine();
                }

                //terrain layer (if enabled)
                if (GraphWindow.current.mapMagic != null && GraphWindow.current.mapMagic.globals.microSplatApplyType != Globals.MicroSplatApplyType.Textures)               //no need to create layers for textures-only mode
                {
                    TerrainLayer tlayer = layer.prototype;
                    if (tlayer == null)
                    {
                        tlayer = new TerrainLayer(); layer.prototype = tlayer;
                    }
                    if (tlayer.diffuseTexture == null)
                    {
                        tlayer.diffuseTexture = iconsArr.GetTexture(num);
                    }
                }

                Cell.EmptyRowPx(10);
                using (Cell.RowPx(0)) GeneratorDraw.DrawOutlet(layer);
            }
            Cell.EmptyLinePx(3);
        }
Exemplo n.º 12
0
        public static void DrawCTSLayer(MatrixGenerators.CTSOutput200.CTSLayer layer, object[] arguments)
        {
            int num = (int)arguments[0];

            MatrixGenerators.CTSOutput200 gen = (MatrixGenerators.CTSOutput200)arguments[1];
            if (layer == null)
            {
                return;
            }

                        #if CTS_PRESENT
            CTS.CTSProfile profile = (CTS.CTSProfile)GraphWindow.current.mapMagic?.globals.ctsProfile;
                        #endif

            Cell.EmptyLinePx(3);
            using (Cell.LinePx(28))
            {
                //Cell.current.margins = new Padding(0,0,0,1); //1-pixel more padding from the bottom since layers are 1 pixel overlayed

                if (num != 0)
                {
                    using (Cell.RowPx(0)) GeneratorDraw.DrawInlet(layer, gen);
                }
                else
                //disconnecting last layer inlet
                if (GraphWindow.current.graph.IsLinked(layer))
                {
                    GraphWindow.current.graph.UnlinkInlet(layer);
                }

                Cell.EmptyRowPx(10);

                                #if CTS_PRESENT
                //icon
                using (Cell.RowPx(28))
                {
                    Texture2D icon = null;
                    if (profile != null)
                    {
                        List <CTS.CTSTerrainTextureDetails> textureDetails = profile.TerrainTextures;
                        if (layer.channelNum < textureDetails.Count)
                        {
                            icon = textureDetails[layer.channelNum].Albedo;
                        }
                    }
                    Draw.TextureIcon(icon);
                }

                //channel selector
                Cell.EmptyRowPx(5);
                using (Cell.Row)
                {
                    Cell.EmptyLine();
                    using (Cell.LineStd)
                    {
                        if (textureNames != null)
                        {
                            Draw.PopupSelector(ref layer.channelNum, textureNames);
                        }
                        else
                        {
                            Draw.Field(ref layer.channelNum, "Channel");
                        }
                    }
                    Cell.EmptyLine();
                }
                                #else
                using (Cell.Row) Draw.Field(ref layer.channelNum, "Channel");
                                #endif

                Cell.EmptyRowPx(10);
                using (Cell.RowPx(0)) GeneratorDraw.DrawOutlet(layer);
            }
            Cell.EmptyLinePx(3);
        }
        public static bool ClickedNear(UI ui, Vector2 mousePos,
                                       out Group clickedGroup,
                                       out Generator clickedGen,
                                       out IOutlet <object> clickedLayer,
                                       out IInlet <object> clickedLink,
                                       out IInlet <object> clickedInlet,
                                       out IOutlet <object> clickedOutlet,
                                       out FieldInfo clickedField)
        /// Returns the top clicked object (or null) in clickedGroup-to-clickedField priority
        {
            clickedGroup  = null;
            clickedGen    = null;
            clickedLayer  = null;
            clickedLink   = null;
            clickedInlet  = null;
            clickedOutlet = null;
            clickedField  = null;

            List <Cell> cellsUnderCursor = new List <Cell>();

            ui.rootCell.FillCellsUnderCursor(cellsUnderCursor, mousePos);

            //checking cells
            for (int i = 0; i < cellsUnderCursor.Count; i++)
            {
                Cell cell = cellsUnderCursor[i];

                //GeneratorDraw.genCellLut.TryGetValue(cell, out clickedGen);  //TryGet will overwrite to null if not found

                if (ui.cellObjs.TryGetObject(cell, "Generator", out Generator gen))
                {
                    clickedGen = gen;
                }
                if (ui.cellObjs.TryGetObject(cell, "Group", out Group group))
                {
                    clickedGroup = group;
                }
                if (ui.cellObjs.TryGetObject(cell, "Layer", out IOutlet <object> layer))
                {
                    clickedLayer = layer;
                }
                if (ui.cellObjs.TryGetObject(cell, "Inlet", out IInlet <object> inlet))
                {
                    clickedInlet = inlet;
                }
                if (ui.cellObjs.TryGetObject(cell, "Outlet", out IOutlet <object> outlet))
                {
                    clickedOutlet = outlet;
                }
                if (ui.cellObjs.TryGetObject(cell, "Field", out FieldInfo field))
                {
                    clickedField = field;
                }

                if (clickedGen != null && clickedOutlet == null && clickedGen is IOutlet <object> o)
                {
                    clickedOutlet = o;
                }
                //assigning outlet if clicked on single-outlet gen
            }

            //checking links
            float minDist = 10 / ui.scrollZoom.zoom;           //10 pixels is max dist to link

            foreach (var kvp in GraphWindow.current.graph.links)
            {
                float dist = GeneratorDraw.DistToLink(mousePos, kvp.Value, kvp.Key);
                if (dist < minDist)
                {
                    minDist = dist; clickedLink = kvp.Key;
                }
            }

            return(clickedGroup != null || clickedGen != null || clickedLayer != null || clickedLink != null || clickedInlet != null || clickedOutlet != null || clickedField != null);
        }
Exemplo n.º 14
0
        private static void DrawRTPLayer(Generator tgen, int num)
        {
            RTPOutput200 gen = (RTPOutput200)tgen;

            RTPOutput200.RTPLayer layer = gen.layers[num];
            if (layer == null)
            {
                return;
            }

            using (Cell.LinePx(32))
            {
                //Cell.current.margins = new Padding(0,0,0,1); //1-pixel more padding from the bottom since layers are 1 pixel overlayed

                if (num != 0)
                {
                    using (Cell.RowPx(0)) GeneratorDraw.DrawInlet(layer, gen);
                }
                else
                //disconnecting last layer inlet
                if (GraphWindow.current.graph.IsLinked(layer))
                {
                    GraphWindow.current.graph.UnlinkInlet(layer);
                }

                Cell.EmptyRowPx(10);

                //icon
                                #if RTP
                Texture2D icon = null;
                if (gen.rtp != null)
                {
                    if (layer.channelNum < gen.rtp.globalSettingsHolder.splats.Length)
                    {
                        icon = gen.rtp.globalSettingsHolder.splats[layer.channelNum];
                    }

                    using (Cell.RowPx(28))
                    {
                        Cell.EmptyLinePx(2);
                        using (Cell.Line) Draw.TextureIcon(icon);
                        Cell.EmptyLinePx(2);
                    }

                    //channel selector
                    Cell.EmptyRowPx(3);
                    using (Cell.Row)
                    {
                        Cell.EmptyLine();
                        using (Cell.LineStd) Draw.PopupSelector(ref layer.channelNum, textureNames);
                        Cell.EmptyLine();
                    }
                }
                else
                                #endif
                using (Cell.Row)
                {
                    Cell.EmptyLine();
                    using (Cell.LineStd) Draw.Field(ref layer.channelNum, "Channel");
                    Cell.EmptyLine();
                }

                Cell.EmptyRowPx(10);
                using (Cell.RowPx(0)) GeneratorDraw.DrawOutlet(layer);
            }
        }
Exemplo n.º 15
0
        private static void DrawCTSLayer(Generator tgen, int num)
        {
            MegaSplatOutput200 gen = (MegaSplatOutput200)tgen;

            MegaSplatOutput200.MegaSplatLayer layer = gen.layers[num];
            if (layer == null)
            {
                return;
            }

                        #if __MEGASPLAT__
            MegaSplatTextureList textureList = GraphWindow.current.mapMagic?.globals.megaSplatTexList as MegaSplatTextureList;
                        #endif

            Cell.EmptyLinePx(3);
            using (Cell.LinePx(28))
            {
                //Cell.current.margins = new Padding(0,0,0,1); //1-pixel more padding from the bottom since layers are 1 pixel overlayed

                if (num != 0)
                {
                    using (Cell.RowPx(0)) GeneratorDraw.DrawInlet(layer, gen);
                }
                else
                //disconnecting last layer inlet
                if (GraphWindow.current.graph.IsLinked(layer))
                {
                    GraphWindow.current.graph.UnlinkInlet(layer);
                }

                Cell.EmptyRowPx(10);

                //icon
                Texture2DArray icon  = null;
                int            index = -2;

                Material material = null;
                if (GraphWindow.current.mapMagic != null)
                {
                    material = GraphWindow.current.mapMagic.terrainSettings.material;
                }

                if (material != null && material.HasProperty("_Diffuse"))
                {
                    icon = (Texture2DArray)material?.GetTexture("_Diffuse");
                }

                                #if __MEGASPLAT__
                if (textureList != null)
                {
                    //icon = textureList.clusters[num].previewTex; //preview textures doesnt seem to be working in recent versions
                    index = textureList.clusters[num].indexes[0];
                }
                                #endif

                using (Cell.RowPx(28))
                {
                    if (icon != null && index >= 0)
                    {
                        Draw.TextureIcon(icon, index);
                    }
                }

                //channel
                Cell.EmptyRowPx(3);
                using (Cell.Row)
                {
                    Cell.EmptyLine();
                    using (Cell.LineStd)
                    {
                        Cell.current.fieldWidth = 0.4f;
                                                #if __MEGASPLAT__
                        if (textureList != null)
                        {
                            Draw.PopupSelector(ref layer.channelNum, textureList.textureNames);
                        }
                        else
                        {
                            Draw.Field(ref layer.channelNum, "Channel");
                        }
                                                #else
                        Draw.Field(ref layer.channelNum, "Channel");
                                                #endif
                    }
                    Cell.EmptyLine();
                }

                Cell.EmptyRowPx(10);
                using (Cell.RowPx(0)) GeneratorDraw.DrawOutlet(layer);
            }
            Cell.EmptyLinePx(3);
        }
Exemplo n.º 16
0
		private void DrawGraph ()
		{
			bool isMini = IsMini;

			//background
			float gridColor = !StylesCache.isPro ? 0.45f : 0.12f;
			float gridBackgroundColor = !StylesCache.isPro ? 0.5f : 0.15f;

			#if MM_DEBUG
				if (!graph.debugGraphBackground)
				{
					gridColor = graph.debugGraphBackColor;
					gridBackgroundColor = graph.debugGraphBackColor;
				}
			#endif

			Draw.StaticGrid(
				displayRect: new Rect(0, 0, Screen.width, Screen.height-toolbarSize),
				cellSize:32,
				color:new Color(gridColor,gridColor,gridColor), 
				background:new Color(gridBackgroundColor,gridBackgroundColor,gridBackgroundColor),
				fadeWithZoom:true);

			#if MM_DEBUG
				if (graph.drawInSceneView)
				{
					using (Cell.Full)
						DrawSceneView();
				}
			#endif

			//drawing groups
			foreach (Group group in graph.groups)
				using (Cell.Custom(group.guiPos.x, group.guiPos.y, group.guiSize.x, group.guiSize.y))
				{
					GroupDraw.DragGroup(group, graph.generators);
					GroupDraw.DrawGroup(group, isMini:isMini);
				}


			//dragging nodes
			foreach (Generator gen in graph.generators)
				GeneratorDraw.DragGenerator(gen, selected);


			//drawing links
			//using (Timer.Start("Links"))
			if (!UI.current.layout)
			{
				List<(IInlet<object> inlet, IOutlet<object> outlet)> linksToRemove = null;
				foreach (var kvp in graph.links)
				{
					IInlet<object> inlet = kvp.Key;
					IOutlet<object> outlet = kvp.Value;

					Cell outletCell = UI.current.cellObjs.GetCell(outlet, "Outlet");
					Cell inletCell = UI.current.cellObjs.GetCell(inlet, "Inlet");

					if (outletCell == null || inletCell == null)
					{
						Debug.LogError("Could not find a cell for inlet/outlet. Removing link");
						if (linksToRemove == null) linksToRemove = new List<(IInlet<object> inlet, IOutlet<object> outlet)>();
						linksToRemove.Add((inlet,outlet));
						continue;
					}

					GeneratorDraw.DrawLink(
						GeneratorDraw.StartCellLinkpos(outletCell),
						GeneratorDraw.EndCellLinkpos(inletCell), 
						GeneratorDraw.GetLinkColor(inlet),
						width:!isMini ? 4f : 6f );
				}

				if (linksToRemove != null)
					foreach ((IInlet<object> inlet, IOutlet<object> outlet) in linksToRemove)
					{
						graph.UnlinkInlet(inlet);
						graph.UnlinkOutlet(outlet);
					}
			}

			//removing null generators (for test purpose)
			for (int n=graph.generators.Length-1; n>=0; n--)
			{
				if (graph.generators[n] == null)
					ArrayTools.RemoveAt(ref graph.generators, n);
			}

			//drawing generators
			//using (Timer.Start("Generators"))
			float nodeWidth = !isMini ? GeneratorDraw.nodeWidth : GeneratorDraw.miniWidth;
			foreach (Generator gen in graph.generators)
				using (Cell.Custom(gen.guiPosition.x, gen.guiPosition.y, nodeWidth, 0))
					GeneratorDraw.DrawGeneratorOrPortal(gen, graph, isMini:isMini, selected.Contains(gen));


			//de-selecting nodes (after dragging and drawing since using drag obj)
			if (!UI.current.layout)
			{
				GeneratorDraw.SelectGenerators(selected, shiftForSingleSelect:!isMini);
				GeneratorDraw.DeselectGenerators(selected); //and deselected always without shift
			}
				
			//add/remove button
			//using (Timer.Start("AddRemove"))
			using (Cell.Full)
				DragDrawAddRemove();

			//right click menu (should have access to cellObjs)
			if (!UI.current.layout  &&  Event.current.type == EventType.MouseDown  &&  Event.current.button == 1)
				RightClick.DrawRightClickItems(graphUI, graphUI.mousePos, graph);

			//create menu on space
			if (!UI.current.layout  &&  Event.current.type == EventType.KeyDown  &&  Event.current.keyCode == KeyCode.Space  && !Event.current.shift)
				CreateRightClick.DrawCreateItems(graphUI.mousePos, graph);

			//delete selected generators
			if (selected!=null  &&  selected.Count!=0  &&  Event.current.type==EventType.KeyDown  &&  Event.current.keyCode==KeyCode.Delete)
				GraphEditorActions.RemoveGenerators(graph, selected);
		}
Exemplo n.º 17
0
 public static void BlendGeneratorEditor(Blend200 gen)
 {
     using (Cell.LinePx(20)) GeneratorDraw.DrawLayersAddRemove(gen, ref gen.layers, inversed: true);
     using (Cell.LinePx(0)) GeneratorDraw.DrawLayersThemselves(gen, gen.layers, inversed: true, layerEditor: DrawBlendLayer);
 }
        public static void DrawMicroSplat(MicroSplatOutput200 gen)
        {
                        #if !__MICROSPLAT__
            using (Cell.LinePx(60))
                Draw.Helpbox("MicroSplat doesn't seem to be installed, or MicroSplat compatibility is not enabled in settings");
                        #endif
            if (GraphWindow.current.mapMagic != null)
            {
                using (Cell.LineStd)
                {
                    //Cell.current.fieldWidth = 0.5f;
                    using (Cell.LineStd) GeneratorDraw.DrawGlobalVar(ref GraphWindow.current.mapMagic.terrainSettings.material, "Material");

                    using (Cell.LineStd)
                    {
                        Cell.current.fieldWidth = 0.15f;
                        GeneratorDraw.DrawGlobalVar(ref GraphWindow.current.mapMagic.globals.assignComponent, "Set Component");
                    }

                                        #if __MICROSPLAT__
                    if (GraphWindow.current.mapMagic.globals.assignComponent)
                    {
                        using (Cell.LineStd)
                            GraphWindow.current.mapMagic.globals.microSplatPropData = GeneratorDraw.DrawGlobalVar <MicroSplatPropData>(
                                GraphWindow.current.mapMagic.globals.microSplatPropData == null ? null : (MicroSplatPropData)GraphWindow.current.mapMagic.globals.microSplatPropData,
                                "PropData");
                    }
                                        #endif

                    if (Cell.current.valChanged)
                    {
                        GraphWindow.current.mapMagic.ApplyTerrainSettings();
                    }
                }
            }

            using (Cell.LinePx(0)) CheckShader(gen);
            using (Cell.LinePx(0)) CheckCustomSplatmaps(gen);
        }
Exemplo n.º 19
0
        private static void DrawBlendLayer(Generator tgen, int num)
        {
            Blend200 gen = (Blend200)tgen;

            Blend200.Layer layer = gen.layers[num];

            Cell.EmptyLinePx(2);

            using (Cell.LineStd)
            {
                using (Cell.RowPx(0))
                    GeneratorDraw.DrawInlet(layer.inlet, gen);
                Cell.EmptyRowPx(10);

                using (Cell.RowPx(20)) Draw.Icon(UI.current.textures.GetTexture("DPUI/Icons/Layer"));

                if (num == 0)
                {
                    layer.algorithm = MatrixGenerators.Blend200.BlendAlgorithm.add;
                    using (Cell.Row) Draw.Label("Background");
                }

                else
                {
                    if (!layer.guiExpanded)
                    {
                        using (Cell.Row) {
                            layer.algorithm = Draw.Field(layer.algorithm);
                        }
                        //Draw.AddFieldToCellObj(typeof(MatrixGenerators.Blend200.Layer), "algorithm"); }
                        //could not be exposed since it's layer value, not generator one
                        using (Cell.RowPx(20)) layer.guiExpanded = Draw.LayerChevron(layer.guiExpanded);
                    }

                    else
                    {
                        using (Cell.Row)
                        {
                            using (Cell.LineStd) {
                                layer.algorithm = Draw.Field(layer.algorithm);
                            }
                            //Draw.AddFieldToCellObj(typeof(MatrixGenerators.Blend200.Layer), "algorithm"); }
                            using (Cell.LineStd) {
                                Draw.FieldDragIcon(ref layer.opacity, UI.current.textures.GetTexture("DPUI/Icons/Opacity"));
                            }
                            //Draw.AddFieldToCellObj(typeof(MatrixGenerators.Blend200.Layer), "opacity"); }
                        }

                        using (Cell.RowPx(20))
                            using (Cell.LineStd) layer.guiExpanded = Draw.LayerChevron(layer.guiExpanded);
                    }

                    /*using (Cell.RowPx(35))
                     * {
                     *      //Draw.Field(ref layer.opacity);
                     *      Draw.FieldDragIcon(ref layer.opacity, UI.current.textures.GetTexture("DPUI/Icons/Opacity"));
                     * }*/
                }

                Cell.EmptyRowPx(3);
            }


            Cell.EmptyLinePx(2);
        }
Exemplo n.º 20
0
        public static Item AppendItems(Vector2 mousePos, Graph graph, IOutlet <object> clickedOutlet, int priority = 4)
        /// Item set appeared on node or outlet click
        {
            Item addItems = null;

            if (clickedOutlet != null)
            {
                Type genericLinkType = Generator.GetGenericType(clickedOutlet);
                if (genericLinkType == null)
                {
                    throw new Exception("Could not find category " + clickedOutlet.GetType().ToString());
                }

                Item createItems = CreateItems(mousePos, graph);
                addItems = createItems.Find(GetCategoryByType(genericLinkType));
            }

            if (addItems != null && addItems.subItems != null)
            {
                Item initial = addItems.Find("Initial");
                if (initial != null)
                {
                    initial.disabled = true;
                }

                //adding link to all create actions
                foreach (Item item in addItems.All(true))
                {
                    if (item.onClick != null)
                    {
                        Action baseOnClick = item.onClick;
                        item.onClick = () =>
                        {
                            baseOnClick();

                            Generator createdGen = graph.generators[graph.generators.Length - 1];                           //the last on is the one that's just created. Hacky

                            Vector2 pos = clickedOutlet.Gen.guiPosition + new Vector2(200, 0);
                            GeneratorDraw.FindPlace(ref pos, new Vector2(100, 200), GraphWindow.current.graph);
                            createdGen.guiPosition = pos;

                            graph.AutoLink(createdGen, clickedOutlet);

                            GraphWindow.RefreshMapMagic(createdGen);
                        };
                    }
                }
            }
            else
            {
                addItems          = new Item("Add");
                addItems.onDraw   = RightClick.DrawItem;
                addItems.disabled = true;
            }

            addItems.name     = "Add (Append)";
            addItems.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Create");
            addItems.color    = Color.gray;
            addItems.priority = priority;

            return(addItems);
        }
Exemplo n.º 21
0
        public static void DrawVSProMapsOut(VSProMapsOut gen)
        {
                        #if VEGETATION_STUDIO_PRO
            Cell.current.fieldWidth = 0.49f;

            using (Cell.LinePx(0))
                using (Cell.Padded(1, 1, 0, 0))
                {
                    if (GraphWindow.current.mapMagic != null)
                    {
                        VegetationSystemPro system = GraphWindow.current.mapMagic.globals.vegetationSystem as VegetationSystemPro;
                        using (Cell.LineStd) GeneratorDraw.DrawGlobalVar(ref system, "System");
                        GraphWindow.current.mapMagic.globals.vegetationSystem = system;
                    }

                    VegetationPackagePro package = null;
                    if (GraphWindow.current.mapMagic != null)
                    {
                        package = GraphWindow.current.mapMagic.globals.vegetationPackage as VegetationPackagePro;
                        using (Cell.LineStd) GeneratorDraw.DrawGlobalVar(ref package, "Package");
                        GraphWindow.current.mapMagic.globals.vegetationPackage = package;
                    }

                    //populating masks list to choose from
                    if (package != null)
                    {
                        int masksCount = package.TextureMaskGroupList.Count;
                        if (maskNames == null || maskNames.Length != masksCount)
                        {
                            maskNames = new string[masksCount];
                        }

                        for (int i = 0; i < masksCount; i++)
                        {
                            maskNames[i] = (i + 1).ToString() + ". " +
                                           package.TextureMaskGroupList[i].TextureMaskName + " - " +
                                           package.TextureMaskGroupList[i].TextureMaskType;
                        }
                    }

                    Cell.EmptyLinePx(4);

                    using (Cell.LineStd)
                    {
                        if (package != null)
                        {
                            Draw.PopupSelector(ref gen.maskGroup, maskNames, "Group");
                        }
                        else
                        {
                            Draw.Field(ref gen.maskGroup, "Group");
                        }
                    }
                    using (Cell.LineStd)
                        Draw.PopupSelector(ref gen.textureChannel, channelNames, "Channel");
                }


            Cell.EmptyLinePx(3);
            using (Cell.LineStd)
                using (new Draw.FoldoutGroup(ref gen.guiAdvanced, "Advanced", isLeft: false, padding: 1))
                    if (gen.guiAdvanced)
                    {
                        if (GraphWindow.current.mapMagic != null)
                        {
                            using (Cell.LineStd) GeneratorDraw.DrawGlobalVar(
                                    ref GraphWindow.current.mapMagic.globals.vegetationSystemCopy,
                                    "Copy VS");
                        }

                        using (Cell.LineStd) Draw.Field(ref gen.outputLevel, "Out Level");
                    }
                        #else
            using (Cell.LinePx(76))
                Draw.Helpbox("Vegetation Studio Pro doesn't seem to be installed, or Vegetation Studio Pro compatibility is not enabled in settings");

            using (Cell.LineStd)
                Draw.Field(ref gen.maskGroup, "Group");
            using (Cell.LineStd)
                Draw.PopupSelector(ref gen.textureChannel, channelNames, "Channel");
                        #endif
        }