Ejemplo n.º 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);
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
 public static HUDToggleButton CreateToggleButton(float fButtonRadius, float fHUDRadius,
                                                  float fAngleHorz, float fAngleVert,
                                                  string enabledIcon, string disabledIcon,
                                                  IGameObjectGenerator addGeometry = null)
 {
     return(CreateToggleButton(
                new HUDShape(HUDShapeType.Disc, fButtonRadius),
                fHUDRadius, fAngleHorz, fAngleVert, enabledIcon, disabledIcon, addGeometry));
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public static HUDButton CreateMeshClickButton(
            Mesh mesh, Color color, float fMeshScale, Quaternion meshRotation,
            HUDSurface hudSurf, float dx, float dy,
            IGameObjectGenerator addGeometry = null)
        {
            Material mat = (color.a < 1.0f) ?
                           MaterialUtil.CreateTransparentMaterial(color, color.a) :
                           MaterialUtil.CreateStandardMaterial(color);

            HUDButton button = new HUDButton();

            button.Create(mesh, mat, fMeshScale, meshRotation);

            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            hudSurf.Place(button, dx, dy);
            return(button);
        }
Ejemplo n.º 7
0
        public static HUDButton CreateMeshClickButton(
            Mesh mesh, Color color, float fMeshScale, Quaternion meshRotation,
            float fHUDRadius, float fAngleHorz, float fAngleVert,
            IGameObjectGenerator addGeometry = null)
        {
            Material mat = (color.a < 1.0f) ?
                           MaterialUtil.CreateTransparentMaterial(color, color.a) :
                           MaterialUtil.CreateStandardMaterial(color);

            HUDButton button = new HUDButton();

            button.Create(mesh, mat, fMeshScale, meshRotation);

            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            return(button);
        }
Ejemplo n.º 8
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);
        }
    DropPrimitiveButton add_primitive_button(Cockpit cockpit, string sName, float fHUDRadius, float dx, float dy,
                                             PrimitiveType primType, SOType soType, float fPrimRadiusScale,
                                             Material bgMaterial, Material primMaterial,
                                             Func <SceneObject> CreatePrimitiveF,
                                             IGameObjectGenerator customGenerator = null
                                             )
    {
        float fButtonRadius = 0.08f;

        DropPrimitiveButton button = new DropPrimitiveButton()
        {
            TargetScene     = cockpit.Scene,
            CreatePrimitive = CreatePrimitiveF
        };

        button.Create(fButtonRadius, bgMaterial);
        var gen = (customGenerator != null) ? customGenerator :
                  new primitiveIconGenerator()
        {
            PrimType = primType, PrimMaterial = primMaterial, PrimSize = fButtonRadius * fPrimRadiusScale
        };

        button.AddVisualElements(gen.Generate(), true);
        HUDUtil.PlaceInSphere(button, fHUDRadius, dx, dy);
        button.Name       = sName;
        button.OnClicked += (s, e) => {
            cockpit.Scene.DefaultPrimitiveType = soType;
        };
        button.OnDoubleClicked += (s, e) => {
            // [TODO] could have a lighter record here because we can easily recreate primitive...
            cockpit.Scene.History.PushChange(
                new AddSOChange()
            {
                scene = cockpit.Scene, so = CreatePrimitiveF()
            });
            cockpit.Scene.History.PushInteractionCheckpoint();
        };
        return(button);
    }