コード例 #1
0
        public static void OnSurfaceFlagButtons(SurfaceFlagState state, SelectedBrushSurface[] selectedBrushSurfaces, bool isSceneGUI = false)
        {
            var leftStyle = isSceneGUI ? EditorStyles.miniButtonLeft  : GUI.skin.button;
            //var middleStyle	= isSceneGUI ? EditorStyles.miniButtonMid   : GUI.skin.button;
            var rightStyle = isSceneGUI ? EditorStyles.miniButtonRight : GUI.skin.button;

            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
            {
                if (!isSceneGUI)
                {
                    GUILayout.Label(ContentShadows, EditModeSurfaceGUI.largeLabelWidth);
                }
                else
                {
                    GUILayout.Label(ContentShadows, EditorStyles.miniLabel, EditModeSurfaceGUI.smallLabelWidth);
                }

                EditorGUI.BeginChangeCheck();
                {
                    // TODO: implement support
                    EditorGUI.showMixedValue = !state.noReceiveShadows.HasValue;
                    state.noReceiveShadows   = !GUILayout.Toggle(!(state.noReceiveShadows ?? (state.noRender ?? true)), ContentReceiveShadowsSurfaces, leftStyle);
                    TooltipUtility.SetToolTip(ToolTipReceiveShadowsSurfaces);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoReceiveShadows, state.noReceiveShadows.Value);
                }
                EditorGUI.BeginChangeCheck();
                {
                    // TODO: implement support
                    EditorGUI.showMixedValue = !state.noCastShadows.HasValue;
                    state.noCastShadows      = !GUILayout.Toggle(!(state.noCastShadows ?? true), ContentCastShadowsSurfaces, rightStyle);
                    TooltipUtility.SetToolTip(ToolTipCastShadowsSurfaces);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCastShadows, state.noCastShadows.Value);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
            {
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUI.showMixedValue = !state.noRender.HasValue;
                    state.noRender           = !GUILayout.Toggle(!(state.noRender ?? true), ContentVisibleSurfaces, leftStyle);
                    TooltipUtility.SetToolTip(ToolTipVisibleSurfaces);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoRender, state.noRender.Value);
                }
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUI.showMixedValue = !state.noCollision.HasValue;
                    state.noCollision        = !GUILayout.Toggle(!(state.noCollision ?? true), ContentCollisionSurfaces, rightStyle);
                    TooltipUtility.SetToolTip(ToolTipCollisionSurfaces);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCollision, state.noCollision.Value);
                }
            }
            GUILayout.EndHorizontal();
            EditorGUI.showMixedValue = false;
        }
コード例 #2
0
        public static void OnSurfaceFlagButtons(Rect rect, SurfaceFlagState state, SelectedBrushSurface[] selectedBrushSurfaces)
        {
            var leftStyle  = EditorStyles.miniButtonLeft;
            var rightStyle = EditorStyles.miniButtonRight;

            var tempRect = rect;

            {
                tempRect.Set(rect.x + 4, rect.y + 1, 45, 16);
                GUI.Label(tempRect, ContentShadows, EditorStyles.miniLabel);

                EditorGUI.BeginChangeCheck();
                {
                    var mixed   = !state.noReceiveShadows.HasValue;
                    var enabled = !(state.noReceiveShadows ?? (state.noRender ?? true));
                    EditorGUI.showMixedValue = mixed;
                    tempRect.Set(rect.x + 53, rect.y + 1, 90 - 4, 15);
                    state.noReceiveShadows = !GUI.Toggle(tempRect, enabled, ContentReceiveShadowsSurfaces, leftStyle);
                    TooltipUtility.SetToolTip(ToolTipReceiveShadowsSurfaces, tempRect);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoReceiveShadows, state.noReceiveShadows.Value);
                }
                EditorGUI.BeginChangeCheck();
                {
                    var mixed   = !state.noCastShadows.HasValue;
                    var enabled = !(state.noCastShadows ?? true);
                    EditorGUI.showMixedValue = mixed;
                    tempRect.Set(rect.x + 143 - 4, rect.y + 1, 74 - 4, 15);
                    state.noCastShadows = !GUI.Toggle(tempRect, enabled, ContentCastShadowsSurfaces, rightStyle);
                    TooltipUtility.SetToolTip(ToolTipCastShadowsSurfaces, tempRect);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCastShadows, state.noCastShadows.Value);
                }
            }
            {
                EditorGUI.BeginChangeCheck();
                {
                    var mixed   = !state.noRender.HasValue;
                    var enabled = !(state.noRender ?? true);
                    EditorGUI.showMixedValue = mixed;
                    tempRect.Set(rect.x + 4, rect.y + 18, 94, 15);
                    state.noRender = !GUI.Toggle(tempRect, enabled, ContentVisibleSurfaces, leftStyle);
                    TooltipUtility.SetToolTip(ToolTipVisibleSurfaces, tempRect);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoRender, state.noRender.Value);
                }
                EditorGUI.BeginChangeCheck();
                {
                    var mixed   = !state.noCollision.HasValue;
                    var enabled = !(state.noCollision ?? true);
                    EditorGUI.showMixedValue = mixed;
                    tempRect.Set(rect.x + 98, rect.y + 18, 112, 15);
                    state.noCollision = !GUI.Toggle(tempRect, enabled, ContentCollisionSurfaces, rightStyle);
                    TooltipUtility.SetToolTip(ToolTipCollisionSurfaces, tempRect);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCollision, state.noCollision.Value);
                }
            }
            EditorGUI.showMixedValue = false;
        }
コード例 #3
0
        public static void OnSurfaceFlagButtons(SelectedBrushSurface[] selectedBrushSurfaces, bool isSceneGUI = false)
        {
            var leftStyle = isSceneGUI ? EditorStyles.miniButtonLeft  : GUI.skin.button;
            //var middleStyle	= isSceneGUI ? EditorStyles.miniButtonMid   : GUI.skin.button;
            var rightStyle = isSceneGUI ? EditorStyles.miniButtonRight : GUI.skin.button;

            bool?noRender         = false;
            bool?noCollision      = false;
            bool?noCastShadows    = false;
            bool?noReceiveShadows = false;

            if (selectedBrushSurfaces.Length > 0)
            {
                for (var i = 0; i < selectedBrushSurfaces.Length; i++)
                {
                    var brush        = selectedBrushSurfaces[i].brush;
                    var surfaceIndex = selectedBrushSurfaces[i].surfaceIndex;
                    if (surfaceIndex >= brush.Shape.Surfaces.Length)
                    {
                        Debug.LogWarning("surface_index >= brush.Shape.Surfaces.Length");
                        continue;
                    }
                    var texGenIndex = brush.Shape.Surfaces[surfaceIndex].TexGenIndex;
                    if (texGenIndex >= brush.Shape.TexGens.Length)
                    {
                        Debug.LogWarning("texGen_index >= brush.Shape.TexGens.Length");
                        continue;
                    }

                    var texGenFlags             = brush.Shape.TexGenFlags[texGenIndex];
                    var surfaceNoRender         = ((texGenFlags & TexGenFlags.NoRender) == TexGenFlags.NoRender);
                    var surfaceNoCollision      = ((texGenFlags & TexGenFlags.NoCollision) == TexGenFlags.NoCollision);
                    var surfaceNoCastShadows    = ((texGenFlags & TexGenFlags.NoCastShadows) == TexGenFlags.NoCastShadows);
                    var surfaceNoReceiveShadows = ((texGenFlags & TexGenFlags.NoReceiveShadows) == TexGenFlags.NoReceiveShadows);

                    if (i == 0)
                    {
                        noRender         = surfaceNoRender;
                        noCollision      = surfaceNoCollision;
                        noCastShadows    = surfaceNoCastShadows;
                        noReceiveShadows = surfaceNoReceiveShadows;
                    }
                    else
                    {
                        if (noRender.HasValue && noRender.Value != surfaceNoRender)
                        {
                            noRender = surfaceNoRender;
                        }
                        if (noCollision.HasValue && noCollision.Value != surfaceNoCollision)
                        {
                            noCollision = surfaceNoCollision;
                        }
                        if (noCastShadows.HasValue && noCastShadows.Value != surfaceNoCastShadows)
                        {
                            noCastShadows = surfaceNoCastShadows;
                        }
                        if (noReceiveShadows.HasValue && noReceiveShadows.Value != surfaceNoReceiveShadows)
                        {
                            noReceiveShadows = surfaceNoReceiveShadows;
                        }
                    }
                }
            }

            GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
            {
                if (!isSceneGUI)
                {
                    GUILayout.Label(ContentShadows, SurfaceToolGUI.largeLabelWidth);
                }
                else
                {
                    GUILayout.Label(ContentShadows, EditorStyles.miniLabel, SurfaceToolGUI.smallLabelWidth);
                }

                EditorGUI.BeginChangeCheck();
                {
                    // TODO: implement support
                    EditorGUI.showMixedValue = !noReceiveShadows.HasValue;
                    noReceiveShadows         = !GUILayout.Toggle(!(noReceiveShadows ?? (noRender ?? true)), ContentReceiveShadowsSurfaces, leftStyle);
                    TooltipUtility.SetToolTip(ToolTipReceiveShadowsSurfaces);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoReceiveShadows, noReceiveShadows.Value);
                }
                EditorGUI.EndDisabledGroup();
                EditorGUI.BeginChangeCheck();
                {
                    // TODO: implement support
                    EditorGUI.showMixedValue = !noCastShadows.HasValue;
                    noCastShadows            = !GUILayout.Toggle(!(noCastShadows ?? true), ContentCastShadowsSurfaces, rightStyle);
                    TooltipUtility.SetToolTip(ToolTipCastShadowsSurfaces);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCastShadows, noCastShadows.Value);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
            {
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUI.showMixedValue = !noRender.HasValue;
                    noRender = !GUILayout.Toggle(!(noRender ?? true), ContentVisibleSurfaces, leftStyle);
                    TooltipUtility.SetToolTip(ToolTipVisibleSurfaces);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoRender, noRender.Value);
                }
                EditorGUI.BeginChangeCheck();
                {
                    EditorGUI.showMixedValue = !noCollision.HasValue;
                    noCollision = !GUILayout.Toggle(!(noCollision ?? true), ContentCollisionSurfaces, rightStyle);
                    TooltipUtility.SetToolTip(ToolTipCollisionSurfaces);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    SurfaceUtility.SetSurfaceTexGenFlags(selectedBrushSurfaces, TexGenFlags.NoCollision, noCollision.Value);
                }
            }
            GUILayout.EndHorizontal();
            EditorGUI.showMixedValue = false;
        }