Пример #1
0
        public static HUDToggleButton CreateToggleButton(HUDShape shape, float fHUDRadius,
                                                         float fAngleHorz, float fAngleVert,
                                                         string enabledIcon, string disabledIcon,
                                                         IGameObjectGenerator addGeometry = null)
        {
            fMaterial enabledMat  = MaterialUtil.CreateTransparentImageMaterialF(enabledIcon);
            fMaterial disabledMat = MaterialUtil.CreateTransparentImageMaterialF(disabledIcon);

            HUDToggleButton button = new HUDToggleButton()
            {
                Shape = shape
            };

            button.Create(enabledMat);
            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }

            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            button.OnToggled += (s, bEnabled) => {
                button.SetAllGOMaterials(bEnabled ? enabledMat : disabledMat);
            };
            return(button);
        }
Пример #2
0
 public HUDButton()
 {
     Shape = new HUDShape()
     {
         Type = HUDShapeType.Disc, Radius = 0.1f
     };
 }
Пример #3
0
 // creates a button with a floating primitive in front of the button shape
 public void Create(float fRadius, Material bgMaterial)
 {
     Shape        = new HUDShape(HUDShapeType.Disc, fRadius);
     tempMaterial = MaterialUtil.ToUnityMaterial(Material);
     base.Create(PrimitiveType.Sphere, tempMaterial, 1.2f);
     ((GameObject)button).transform.localRotation = Quaternion.identity;
 }
Пример #4
0
 public HUDPopupMessage()
 {
     Shape = new HUDShape()
     {
         Type = HUDShapeType.Disc, Radius = 0.1f
     };
 }
Пример #5
0
        public static HUDButton CreateDiscIconClickButton(float fButtonRadius,
                                                          float fHUDRadius, float fAngleHorz, float fAngleVert,
                                                          string icon,
                                                          IGameObjectGenerator addGeometry = null)
        {
            HUDShape shape = new HUDShape(HUDShapeType.Disc, fButtonRadius);

            return(CreateIconClickButton(shape, fHUDRadius, fAngleHorz, fAngleVert, icon, addGeometry));
        }
Пример #6
0
        public HUDToggleButton()
        {
            Shape    = new HUDShape(HUDShapeType.Disc, 0.1f);
            bChecked = true;

            TextHeight = 0.8f;
            TextColor  = Colorf.Black;
            text       = "";
        }
Пример #7
0
        public static HUDButton CreateRectIconClickButton(float fButtonWidth, float fButtonHeight,
                                                          float fHUDRadius, float fAngleHorz, float fAngleVert,
                                                          string icon,
                                                          IGameObjectGenerator addGeometry = null)
        {
            HUDShape shape = new HUDShape(HUDShapeType.Rectangle, fButtonWidth, fButtonHeight);

            return(CreateIconClickButton(shape, fHUDRadius, fAngleHorz, fAngleVert, icon, addGeometry));
        }
Пример #8
0
        public HUDLabel()
        {
            Shape      = new HUDShape(HUDShapeType.Rectangle, 10, 1);
            TextHeight = 0.8f;

            BackgroundColor   = Colorf.VideoWhite;
            TextColor         = Colorf.VideoBlack;
            DisabledTextColor = Colorf.DimGrey;
            AlignmentHorz     = HorizontalAlignment.Left;
            text = "(default)";
        }
Пример #9
0
        public HUDLabel(float width, float height, ITextElementStyle textStyle)
        {
            Shape           = new HUDShape(HUDShapeType.Rectangle, width, height);
            BackgroundColor = Colorf.TransparentBlack;
            BorderWidth     = 0;
            BorderColor     = Colorf.TransparentBlack;
            EnableBorder    = false;

            TextHeight    = textStyle.TextHeight;
            TextColor     = textStyle.TextColor;
            AlignmentHorz = textStyle.AlignmentHorz;
            text          = "(default)";
        }
Пример #10
0
        // creates a button in the desired geometry shape
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel"));

            bgMesh = AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape),
                                  MaterialUtil.CreateFlatMaterialF(BackgroundColor),
                                  entry);
            bgMesh.RotateD(Vector3f.AxisX, -90.0f);


            if (EnableBorder)
            {
                HUDShape borderShape = Shape;
                borderShape.Radius += BorderWidth;
                borderShape.Height += 2 * BorderWidth;
                borderShape.Width  += 2 * BorderWidth;
                border              = AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape),
                                                   MaterialUtil.CreateFlatMaterialF(BorderColor), entry);
                border.RotateD(Vector3f.AxisX, -90.0f);
                border.Translate(-0.001f * Vector3f.AxisY, true);
            }

            BoxPosition horzAlign = BoxPosition.CenterLeft;

            if (AlignmentHorz == HorizontalAlignment.Center)
            {
                horzAlign = BoxPosition.Center;
            }
            else if (AlignmentHorz == HorizontalAlignment.Right)
            {
                horzAlign = BoxPosition.CenterRight;
            }

            textMesh =
                GameObjectFactory.CreateTextMeshGO(
                    "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset);

            textMesh.TextObject.SetFixedWidth(Shape.Width);
            textMesh.TextObject.SetOverflowMode(TextOverflowMode.Ellipses);

            Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign);

            BoxModel.Translate(textMesh, Vector2f.Zero, toPos);

            AppendNewGO(textMesh, entry, false);

            MaterialUtil.DisableShadows(RootGameObject);
        }
Пример #11
0
 void update_shape(HUDShape newShape)
 {
     shape = newShape;
     if (bgMesh == null)
     {
         return;
     }
     bgMesh.SetSharedMesh(
         HUDUtil.MakeBackgroundMesh(shape));
     if (EnableBorder)
     {
         HUDShape borderShape = shape;
         borderShape.Radius += BorderWidth;
         borderShape.Height += 2 * BorderWidth;
         borderShape.Width  += 2 * BorderWidth;
         border.SetSharedMesh(HUDUtil.MakeBackgroundMesh(borderShape));
     }
 }
Пример #12
0
        public static HUDButton CreateIconClickButton(HUDShape shape,
                                                      float fHUDRadius, float fAngleHorz, float fAngleVert,
                                                      string icon,
                                                      IGameObjectGenerator addGeometry = null)
        {
            Material  mat    = MaterialUtil.CreateTransparentImageMaterial(icon);
            HUDButton button = new HUDButton()
            {
                Shape = shape
            };

            button.Create(mat);
            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            return(button);
        }
Пример #13
0
        public static HUDButton CreateGeometryIconClickButton(HUDShape shape,
                                                              float fHUDRadius, float fAngleHorz, float fAngleVert,
                                                              Color bgColor,
                                                              IGameObjectGenerator addGeometry = null)
        {
            Material mat = (bgColor.a == 1.0f) ?
                           MaterialUtil.CreateStandardMaterial(bgColor) : MaterialUtil.CreateTransparentMaterial(bgColor);
            HUDButton button = new HUDButton()
            {
                Shape = shape
            };

            button.Create(mat);
            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            return(button);
        }
Пример #14
0
        // creates a button in the desired geometry shape
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDShapeElement"));

            bgMesh = new fGameObject(AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape),
                                                  MaterialUtil.CreateFlatMaterialF(Color),
                                                  entry));
            bgMesh.RotateD(Vector3f.AxisX, -90.0f);

            if (EnableBorder)
            {
                HUDShape borderShape = Shape;
                borderShape.Radius += BorderWidth;
                borderShape.Height += 2 * BorderWidth;
                borderShape.Width  += 2 * BorderWidth;
                border              = new fGameObject(AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape),
                                                                   MaterialUtil.CreateFlatMaterialF(BorderColor), entry));
                border.RotateD(Vector3f.AxisX, -90.0f);
                border.Translate(-0.001f * Vector3f.AxisY, true);
            }
        }
Пример #15
0
        // creates a button with a floating primitive in front of the button shape
        public void CreateMeshIconButton(float fRadius, string sMeshPath, Material bgMaterial,
                                         float fMeshScaleFudge)
        {
            Shape = new HUDShape(HUDShapeType.Disc, fRadius);

            fMesh    iconmesh     = null;
            Material meshMaterial = null;

            try {
                iconmesh     = FResources.LoadMesh(sMeshPath);
                meshMaterial = MaterialUtil.CreateStandardVertexColorMaterial(Color.white);
            } catch { }
            if (iconmesh == null)
            {
                iconmesh     = UnityUtil.GetPrimitiveMesh(PrimitiveType.Sphere);
                meshMaterial = MaterialUtil.CreateStandardMaterial(Color.red);
            }

            float fMeshRadius = fRadius * fMeshScaleFudge;

            base.Create(bgMaterial, iconmesh, meshMaterial, fMeshRadius,
                        Frame3f.Identity.Translated(-fMeshRadius * 0.25f, 2).Rotated(-15.0f, 1));
        }
Пример #16
0
 /// <summary>
 /// Create a fMesh of the shape/dimensions specified by Shape
 /// </summary>
 public static fMesh MakeBackgroundMesh(HUDShape Shape)
 {
     if (Shape.Type == HUDShapeType.Disc)
     {
         return(MeshGenerators.CreateTrivialDisc(Shape.Radius, Shape.Slices));
     }
     else if (Shape.Type == HUDShapeType.Rectangle)
     {
         return(MeshGenerators.CreateTrivialRect(Shape.Width, Shape.Height,
                                                 Shape.UseUVSubRegion == true ?
                                                 MeshGenerators.UVRegionType.CenteredUVRectangle : MeshGenerators.UVRegionType.FullUVSquare));
     }
     else if (Shape.Type == HUDShapeType.RoundRect)
     {
         return(MeshGenerators.CreateRoundRect(Shape.Width, Shape.Height, Shape.Radius, Shape.Slices,
                                               Shape.UseUVSubRegion == true ?
                                               MeshGenerators.UVRegionType.CenteredUVRectangle : MeshGenerators.UVRegionType.FullUVSquare,
                                               Shape.RoundRectSharpCorners));
     }
     else
     {
         throw new Exception("HUDUtil.MakeBackgroundMesh: unknown shape type!");
     }
 }
Пример #17
0
 public HUDShapeElement()
 {
     Shape = new HUDShape(HUDShapeType.Rectangle, 10, 1);
     Color = Colorf.VideoWhite;
 }
Пример #18
0
 public HUDButton()
 {
     Shape = new HUDShape(HUDShapeType.Disc, 0.1f);
 }
Пример #19
0
 public HUDSpacer()
 {
     Shape = new HUDShape(HUDShapeType.Rectangle, 10, 1);
 }
Пример #20
0
 // creates a button with a floating primitive in front of the button shape
 public void Create(float fRadius, Material bgMaterial)
 {
     Shape = new HUDShape(HUDShapeType.Disc, fRadius);
     base.Create(bgMaterial);
 }