コード例 #1
0
            // builds either the sing disk or, if given the complete hierarchy
            public void BakePie(bool isVisible)
            {
                Visible = isVisible;
                if (rootRecipe.subList != null && (rootRecipe.subList.Count > 0))
                {
                    // build full pie!
                    for (int i = 0; i < rootRecipe.subList.Count; i++)
                    {
                        PieRecipeItem pieRecipeSlice = rootRecipe.subList[i];

                        PieMenuSlice slice = new PieMenuSlice(pieRecipeSlice);
                        AddSlice(slice);
                        if (pieRecipeSlice.subList != null && pieRecipeSlice.subList.Count > 0)
                        { // this is a "group node" with another pie structure below
                            PieDisk fullPie = new PieDisk(this, pieRecipeSlice);
                            slice.subDisk = fullPie;

                            subList.Add(fullPie);
                            fullPie.BakePie(false);
                            //subList[subList.Count - 1].BakePie(false);
                        }
                    }
                }
                else if (slices.Count == 0)
                {
                    // something whent wrong.. we have nothing to build!
                    return;
                }

                if (Visible)
                {
                    BuildSlices();
                }
            }
コード例 #2
0
            public void SetFocus(int indexNew)
            {
                float twitchTime = 0.1f;

                // Undo previous slice selection state.
                if ((this.indexLastHoverItem > -1) &&
                    (this.indexLastHoverItem != indexNew))
                {
                    PieMenuSlice menuSlice = this.slices[indexLastHoverItem];
                    menuSlice.DiffuseColor = PieSelector.RenderObjSlice.ColorNormal;

                    if (slices.Count > 2) // dont move them if only two
                    {
                        ITransform transformSlice       = menuSlice.mySlice as ITransform;
                        TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                        {
                            transformSlice.Local.OriginTranslation = value;
                            transformSlice.Compose();
                        };
                        TwitchManager.CreateTwitch <Vector3>(
                            transformSlice.Local.OriginTranslation,
                            SliceOffsetDefault,
                            set,
                            twitchTime,
                            TwitchCurve.Shape.EaseInOut);
                    }
                }

                // apply new slice selection state
                // if (indexNew != indexCenteredItem)
                if ((indexNew > -1) &&
                    (indexNew != indexCurrentHoverItem))
                {
                    PieMenuSlice menuSlice = this.slices[indexNew];
                    menuSlice.DiffuseColor = PieSelector.RenderObjSlice.ColorSelectedBright;

                    Foley.PlayClick();
                    if (slices.Count > 2) // don't move them if only two
                    {
                        ITransform transformSlice = menuSlice.mySlice as ITransform;
                        {
                            TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                            {
                                transformSlice.Local.OriginTranslation = value;
                                transformSlice.Compose();
                            };
                            TwitchManager.CreateTwitch <Vector3>(
                                transformSlice.Local.OriginTranslation,
                                new Vector3(0.20f, 0.0f, 0.0f),
                                set,
                                twitchTime,
                                TwitchCurve.Shape.EaseInOut);
                        }
                    }
                    indexCurrentHoverItem = indexNew;
                }
            }
コード例 #3
0
 public void OnCancel()
 {
     for (int i = 0; i < slices.Count; i++)
     {
         PieMenuSlice pms = slices[slices.Count - 1];
         pms.OnDestroy();
     }
     // slices.Clear();
 }
コード例 #4
0
            protected void CalcLayoutInfoFromItems(out float circumference, out float maxRadius)
            {
                circumference = 0.0f;
                //  UiSelector.ItemData itemData;
                maxRadius = float.NegativeInfinity;
                for (int indexItem = 0; indexItem < slices.Count; indexItem++)
                {
                    PieMenuSlice tmpItemData = slices[indexItem];

                    float diagonal = (float)Math.Sqrt(Math.Pow(tmpItemData.IconTexture.Height, 2) +
                                                      Math.Pow(tmpItemData.IconTexture.Width, 2));
                    diagonal *= iconScaling;
                    if (tmpItemData != null)
                    {
                        circumference += diagonal;                                //  boundingItem.BoundingSphere.Radius * 2.0f;
                        maxRadius      = MathHelper.Max(maxRadius, diagonal / 2); //boundingItem.BoundingSphere.Radius);
                    }
                }
            }
コード例 #5
0
        private void RenderDisk(PieDisk disk, int depth)
        {
            Matrix  invWorld = Matrix.Invert(disk.worldMatrix);
            Vector2 orthoPos = TouchInput.GetHitOrtho(disk.ScreenPosition, camera, ref invWorld, useRtCoords: false);

            for (int i = 0; i < disk.slices.Count; i++)
            {
                PieMenuSlice pieSlice = disk.slices[i];
                RenderBastardPieSlice(pieSlice, orthoPos, disk.ScreenOffset, depth);
            }
            for (int i = 0; i < disk.slices.Count; i++)
            {
                PieMenuSlice pieSlice = disk.slices[i];
                if (pieSlice.sliceType == PieSelector.SliceType.group)
                {
                    PieDisk subDisk = pieSlice.subDisk;
                    if (subDisk.Visible)
                    {
                        RenderDisk(subDisk, depth + 1);
                    }
                }
            }
        }
コード例 #6
0
        private void RenderBastardPieSlice(PieMenuSlice pieSlice, Vector2 orthPos, Vector2 screenOffset, int depth)
        {
            if (pieSlice.mySlice == null)
            {
                return;
            }
            float alphaLevel = 1.0f;
            bool  fadeAlpha  = false;

            if (depth != CurrentDiskNo)
            {
                fadeAlpha = true;
            }

            if (fadeAlpha)
            {
                alphaLevel = 0.82f;
                if (CurrentDiskNo < 7)
                {
                    alphaLevel -= (CurrentDiskNo - depth) / 10.0f;
                }
            }

            GraphicsDevice device      = BokuGame.bokuGame.GraphicsDevice;
            Matrix         viewMatrix  = camera.ViewMatrix;
            Matrix         projMatrix  = camera.ProjectionMatrix;
            Matrix         worldMatrix = pieSlice.mySlice.localTransform.Matrix;

            worldMatrix.Translation += new Vector3(orthPos.X, orthPos.Y, 0.0f);

            Matrix worldViewProjMatrix = worldMatrix * viewMatrix * projMatrix;

            effect.Parameters["WorldViewProjMatrix"].SetValue(worldViewProjMatrix);
            effect.Parameters["WorldMatrix"].SetValue(worldMatrix);


            Vector4 baseColor = PieSelector.RenderObjSlice.ColorNormal;

            // used for debugging

            /*
             * if (pieSlice.Focused)
             * {
             *  baseColor = PieSelector.RenderObjSlice.ColorSelectedBright;
             * }
             */
            baseColor = pieSlice.DiffuseColor;
            if (fadeAlpha)
            {
                baseColor.W = alphaLevel;
            }


            effect.Parameters["DiffuseColor"].SetValue(baseColor);
            effect.Parameters["SpecularColor"].SetValue(new Vector4(0.12f, 0.12f, 0.12f, alphaLevel));
            effect.Parameters["EmissiveColor"].SetValue(new Vector4(0.01f, 0.01f, 0.01f, alphaLevel));
            effect.Parameters["SpecularPower"].SetValue(4.0f);
            effect.Parameters["Shininess"].SetValue(0.0f);

            if (InGame.inGame.renderEffects != InGame.RenderEffect.Normal)
            {
                effect.CurrentTechnique = effect.Techniques[InGame.inGame.renderEffects.ToString()];
            }
            else
            {
                effect.CurrentTechnique = effect.Techniques["NoTextureColorPass"];
            }

            pieSlice.mySlice.Render(device, effect);


            // render icon if there is one
            if (pieSlice.IconTexture != null)
            {
                ScreenSpaceQuad ssquad      = ScreenSpaceQuad.GetInstance();
                Vector4         myBaseColor = new Vector4(1.0f, 1.0f, 1.0f, alphaLevel);

                ssquad.Render(pieSlice.IconTexture,
                              myBaseColor,
                              pieSlice.Position + screenOffset,
                              pieSlice.WhenBlockSize,
                              "TexturedRegularAlpha");
            }
            if (pieSlice.SliceFont != null)
            {
                // Render text!

                float textWidth      = pieSlice.font().MeasureString(pieSlice.label).X;
                Color greyTextColor  = new Color(1.0f, 1.0f, 1.0f, alphaLevel);
                Color blackTextColor = new Color(1.0f, 1.0f, 1.0f, alphaLevel);
                Color renderColor    = blackTextColor;
                if (fadeAlpha)
                {
                    renderColor = greyTextColor;
                }
                // Correct for icon and pie position offset.
                Vector2 textPosition = pieSlice.Position + screenOffset + (pieSlice.WhenBlockSize) / 2;
                if (pieSlice.IconTexture != null) // move text below icon
                {
                    textPosition   += new Vector2(0.0f, pieSlice.IconSize);
                    textPosition.Y -= (float)(pieSlice.WhenBlockSize.Y / 2.0f);
                }
                textPosition.X -= (textWidth / 2);

                TextHelper.DrawStringNoBatch(pieSlice.font, pieSlice.label, textPosition, renderColor);
            }
        }
コード例 #7
0
        // Add a simple slice to the main pie
        public void AddSlice(Object menuItem, Texture2D iconTexture, UI2D.Shared.GetFont font, string displaytext)
        {
            PieMenuSlice slice = new PieMenuSlice(menuItem, iconTexture, font, displaytext);

            this.rootDisk.AddSlice(slice);
        }
コード例 #8
0
 public void AddSlice(PieMenuSlice slice)
 {
     slices.Add(slice);
 }