Пример #1
0
        public static void ShowCenteredPopupMessage(string sTitleText, string sText, Cockpit cockpit)
        {
            HUDPopupMessage message = new HUDPopupMessage()
            {
                Width           = 500 * cockpit.GetPixelScale(), Height = 250 * cockpit.GetPixelScale(),
                TitleTextHeight = 30 * cockpit.GetPixelScale(),
                TextHeight      = 20 * cockpit.GetPixelScale(),
                BackgroundColor = Colorf.Silver,
                TextColor       = Colorf.VideoBlack,
                TitleText       = sTitleText,
                Text            = sText
            };

            message.Create();
            if (FPlatform.IsUsingVR())
            {
                HUDUtil.PlaceInSphere(message, 0.5f, 0, 0);
            }
            else
            {
                HUDUtil.PlaceInSphere(message, 1.5f, 0, 0);
            }
            message.Name = "popup";
            cockpit.AddUIElement(message, true);
            message.OnDismissed += (s, e) => {
                AnimatedDimiss_Cockpit(message, cockpit, true);
            };
            AnimatedShow(message);
        }
Пример #2
0
        CreateDropPrimitiveButton add_curve_button(Cockpit cockpit, string sName, float fHUDRadius, float dx, float dy,
                                                   Material bgMaterial, Material primMaterial,
                                                   Func <TransformableSO> CreateCurveF
                                                   )
        {
            float fButtonRadius = 0.08f;

            CreateDropPrimitiveButton button = new CreateDropPrimitiveButton()
            {
                TargetScene     = cockpit.Scene,
                CreatePrimitive = CreateCurveF
            };

            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.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 = CreateCurveF()
                });
                cockpit.Scene.History.PushInteractionCheckpoint();
            };
            return(button);
        }
Пример #3
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);
        }
Пример #4
0
        public static void ShowToastStaticPopupMessage(string sImagePath, Cockpit cockpit)
        {
            Material mat     = MaterialUtil.CreateTransparentImageMaterial(sImagePath);
            float    fAspect = (float)mat.mainTexture.width / (float)mat.mainTexture.height;
            float    fScale  = 2.0f;    // should this be a parameter??

            HUDPopupMessage message = new HUDPopupMessage()
            {
                Shape = new HUDShape()
                {
                    Type           = HUDShapeType.Rectangle, Width = fScale * 1.0f, Height = fScale * 1.0f / fAspect,
                    UseUVSubRegion = false
                }
            };

            message.Create(mat);
            HUDUtil.PlaceInSphere(message, 3.0f, 30, -10);
            UnityUtil.TranslateInFrame(message.RootGameObject, 0.75f, -0.5f, 0.0f, CoordSpace.WorldCoords);
            message.Name = "popup";
            cockpit.AddUIElement(message, true);
            message.OnDismissed += (s, e) => {
                AnimatedDimiss_Cockpit(message, cockpit);
            };
            AnimatedShow(message, 0.5f);
        }
Пример #5
0
        ActivateToolButton add_tool_button(Cockpit cockpit, string sName,
                                           float fHUDRadius, float dx, float dy,
                                           float fButtonRadius, toolInfo info)
        {
            ActivateToolButton button = new ActivateToolButton()
            {
                TargetScene = cockpit.Scene,
                ToolType    = info.identifier
            };

            button.CreateMeshIconButton(fButtonRadius, info.sMeshPath, defaultMaterial, info.fMeshScaleFudge);
            HUDUtil.PlaceInSphere(button, fHUDRadius, dx, dy);
            button.Name = sName;

            if (info.identifier == "cancel")
            {
                button.OnClicked += (s, e) => {
                    bool bIsSpatial = InputState.IsDevice(e.device, InputDevice.AnySpatialDevice);
                    int  nSide      = bIsSpatial ? (int)e.side : 1;
                    cockpit.Context.ToolManager.DeactivateTool((ToolSide)nSide);

                    // remove icon from hand
                    if (bIsSpatial)
                    {
                        cockpit.Context.SpatialController.ClearHandIcon(nSide);
                    }

                    // hide indicator
                    remove_indicator(nSide);
                };
            }
            else
            {
                button.OnClicked += (s, e) => {
                    bool bIsSpatial = InputState.IsDevice(e.device, InputDevice.AnySpatialDevice);
                    int  nSide      = bIsSpatial ? (int)e.side : 1;
                    remove_indicator(nSide);

                    cockpit.Context.ToolManager.SetActiveToolType(info.identifier, (ToolSide)nSide);
                    if (cockpit.Context.ToolManager.ActivateTool((ToolSide)nSide))
                    {
                        if (bIsSpatial)
                        {
                            Mesh iconmesh = Resources.Load <Mesh>(info.sMeshPath);
                            if (iconmesh != null)
                            {
                                cockpit.Context.SpatialController.SetHandIcon(iconmesh, nSide);
                            }
                        }

                        add_indicator(button, nSide);
                    }
                };
            }
            return(button);
        }
Пример #6
0
        public void add_text_entry_field(Cockpit cockpit)
        {
            float fUseRadius = HUDRadius * 0.85f;
            float fAngle     = -35.0f;

            entryField            = new HUDTextEntry();
            entryField.Text       = GetDefaultFileName();
            entryField.Width      = 1.0f;
            entryField.Height     = 0.08f;
            entryField.TextHeight = 0.06f;
            entryField.Create();
            entryField.Name = "selectFileName";
            HUDUtil.PlaceInSphere(entryField, fUseRadius, 0.0f, fAngle);
            cockpit.AddUIElement(entryField, true);

            tooltipText                 = new HUDLabel();
            tooltipText.Shape           = new HUDShape(HUDShapeType.Rectangle, 1.0f, 0.04f);
            tooltipText.Text            = Tooltip;
            tooltipText.TextHeight      = 0.03f;
            tooltipText.BackgroundColor = Colorf.TransparentBlack;
            tooltipText.TextColor       = Colorf.Silver;
            tooltipText.Create();
            tooltipText.Name = "tooltip";
            HUDUtil.PlaceInSphere(tooltipText, fUseRadius, 0.0f, fAngle);
            UnityUtil.TranslateInFrame(tooltipText.RootGameObject, 0.0f, -entryField.Height, 0, CoordSpace.WorldCoords);
            cockpit.AddUIElement(tooltipText, true);


            HUDButton saveButton = HUDBuilder.CreateRectIconClickButton(
                0.2f, 0.1f, fUseRadius, 0.0f, fAngle,
                "icons/save_v1");

            UnityUtil.TranslateInFrame(saveButton.RootGameObject, 0.2f, -0.1f, 0, CoordSpace.WorldCoords);
            saveButton.Name = "save";
            cockpit.AddUIElement(saveButton, true);
            saveButton.OnClicked += (s, e) => { SaveFromEntryText(); };

            HUDButton cancelButton = HUDBuilder.CreateRectIconClickButton(
                0.2f, 0.1f, fUseRadius, 0.0f, fAngle,
                "icons/cancel_v1");

            UnityUtil.TranslateInFrame(cancelButton.RootGameObject, 0.4f, -0.1f, 0, CoordSpace.WorldCoords);
            cancelButton.Name = "cancel";
            cockpit.AddUIElement(cancelButton, true);
            cancelButton.OnClicked += (s, e) => {
                cockpit.Context.PopCockpit(true);
            };
        }
Пример #7
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);
        }
Пример #8
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);
        }
Пример #9
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);
        }
Пример #10
0
        public static void ShowToastPopupMessage(string sText, Cockpit cockpit, float heightScale = 1.0f, float textScale = 1.0f)
        {
            // [TODO] should size based on VR or not-VR...for VR use visual radius?

            HUDPopupMessage message = new HUDPopupMessage()
            {
                Width           = 500 * cockpit.GetPixelScale(), Height = heightScale * 150 * cockpit.GetPixelScale(),
                TextHeight      = textScale * 50 * cockpit.GetPixelScale(),
                BackgroundColor = Colorf.DarkYellow,
                TextColor       = Colorf.VideoBlack,
                Text            = sText
            };

            message.Create();
            HUDUtil.PlaceInSphere(message, 1.0f, 30, -30);
            message.Name = "popup";
            cockpit.AddUIElement(message, true);
            message.OnDismissed += (s, e) => {
                AnimatedDimiss_Cockpit(message, cockpit, true);
            };
            AnimatedShow(message, 0.5f);
        }
Пример #11
0
        DropMaterialButton add_material_button(Cockpit cockpit, string sName,
                                               float fHUDRadius, float dx, float dy,
                                               float fButtonRadius,
                                               Material bgMaterial, SOMaterial material)
        {
            DropMaterialButton button = new DropMaterialButton()
            {
                TargetScene = cockpit.Scene,
                Material    = material
            };

            button.Create(fButtonRadius, bgMaterial);
            HUDUtil.PlaceInSphere(button, fHUDRadius, dx, dy);
            button.Name = sName;

            button.OnClicked += (s, e) => {
                cockpit.Scene.DefaultSOMaterial = material;
                if (indicatorButton != null)
                {
                    indicatorButton.RemoveGO(indicatorGO);
                }
                indicatorButton = button;

                indicatorGO.SetPosition(Vector3f.Zero);
                indicatorGO.SetRotation(Quaternionf.Identity);
                indicatorGO.SetLocalScale(fIndicatorSize * Vector3f.One);
                indicatorGO.SetLocalPosition(
                    indicatorGO.GetLocalPosition() + fIndicatorShift * (Vector3f.AxisY - 4 * Vector3f.AxisZ + Vector3f.AxisX));
                indicatorButton.AppendNewGO(indicatorGO, indicatorButton.RootGameObject, false);
            };

            button.OnDoubleClicked += (s, e) => {
                if (cockpit.Scene.Selected.Count > 0)
                {
                    button.DoSetMaterial(cockpit.Scene.Selected, button.Material);
                }
            };
            return(button);
        }