Exemplo n.º 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);
        }
Exemplo n.º 2
0
        void BuildParameterPanel(Cockpit cockpit)
        {
            float panel_width             = 500 * cockpit.GetPixelScale();
            HUDParametersPanel paramPanel = new HUDParametersPanel(cockpit)
            {
                Width              = panel_width,
                Height             = panel_width,
                ParameterRowHeight = panel_width / 10.0f,
                ParametersPadding  = panel_width * 0.025f,
            };

            paramPanel.Create();
            paramPanel.Name = "ParametersPanel";
            cockpit.AddUIElement(paramPanel, true);
            paramPanel.IsVisible = true;

            cockpit.DefaultLayout.Add(paramPanel, new LayoutOptions()
            {
                Flags            = LayoutFlags.None,
                PinSourcePoint2D = LayoutUtil.BoxPointF(paramPanel, BoxPosition.TopLeft),
                PinTargetPoint2D = LayoutUtil.BoxPointF(cockpit.DefaultLayout.BoxElement, BoxPosition.TopRight)
                                   //PinTargetPoint2D = LayoutUtil.BoxPointInterpF(cockpit.DefaultLayout.BoxElement, BoxPosition.TopRight, BoxPosition.BottomRight, 0.5f)
            });

            //UnityUtil.TranslateInFrame(shapesButton.RootGameObject, fButtonW * 0.5f, 0, 0, CoordSpace.WorldCoords);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is very hacky.
        /// </summary>
        public static void AddDropShadow(HUDStandardItem item, Cockpit cockpit, Colorf color,
                                         float falloffWidthPx, Vector2f offset, float fZShift, bool bTrackCockpitScaling = true)
        {
            if (item is IBoxModelElement == false)
            {
                throw new Exception("HUDUtil.AddDropShadow: can only add drop shadow to IBoxModelElement");
            }

            float falloffWidth = falloffWidthPx * cockpit.GetPixelScale();

            // [TODO] need interface that provides a HUDShape?
            var   shape = item as IBoxModelElement;
            float w     = shape.Size2D.x + falloffWidth;
            float h     = shape.Size2D.y + falloffWidth;

            fRectangleGameObject meshGO = GameObjectFactory.CreateRectangleGO("shadow", w, h, color, false);

            meshGO.RotateD(Vector3f.AxisX, -90.0f);
            fMaterial dropMat = MaterialUtil.CreateDropShadowMaterial(color, w, h, falloffWidth);

            meshGO.SetMaterial(dropMat);

            item.AppendNewGO(meshGO, item.RootGameObject, false);
            BoxModel.Translate(meshGO, offset, fZShift);

            if (bTrackCockpitScaling)
            {
                PreRenderBehavior pb = meshGO.AddComponent <PreRenderBehavior>();
                pb.ParentFGO = meshGO;
                pb.AddAction(() => {
                    Vector3f posW = item.RootGameObject.PointToWorld(meshGO.GetLocalPosition());
                    ((Material)dropMat).SetVector("_Center", new Vector4(posW.x, posW.y, posW.z, 0));
                    float curWidth    = falloffWidthPx * cockpit.GetPixelScale();
                    Vector2f origSize = shape.Size2D + falloffWidth * Vector2f.One;
                    Vector2f size     = cockpit.GetScaledDimensions(origSize);
                    float ww          = size.x;
                    float hh          = size.y;
                    ((Material)dropMat).SetVector("_Extents", new Vector4(ww / 2, hh / 2, 0, 0));
                    float newWidth = falloffWidthPx * cockpit.GetPixelScale();
                    ((Material)dropMat).SetFloat("_FalloffWidth", newWidth);
                });
            }
        }
Exemplo n.º 4
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);
        }