Example #1
0
        public DetailsView(BohemianArtifact bbshelf, Vector3 position, Vector3 size)
        {
            bookshelf = bbshelf;
            bookshelf.Library.SelectedArtifactChanged += new ArtifactLibrary.SelectedArtifactHandler(library_SelectedArtifactChanged);
            bookshelf.Library.LanguageChanged += new ArtifactLibrary.ChangeLanguageHandler(Library_LanguageChanged);
            this.position = position;
            this.size = size;
            font = bookshelf.Content.Load<SpriteFont>("Arial");

            titleText = new SelectableText(font, "Details", new Vector3(0.4f, 0, 0), bookshelf.GlobalTextColor, Color.White);
            titleText.InverseScale(0.8f, size.X, size.Y);

            boundingBox = new BoundingBox(new Vector3(0, 0, 0), new Vector3(1, 1, 0), Color.Black, 0.005f);
            roundedBox = new RoundedBoundingBox(new Vector3(0, 0, 0), new Vector3(1, 1, 0), new Color(200, 200, 200), 0.008f, this);
            float maxWidth = 0.5f; // as a percentage of the width of the details box

            maxImageBox = new SelectableQuad(new Vector2(0, 0), new Vector2(maxWidth, maxWidth * size.X / size.Y), Color.White);
            rotationRange = new FloatRange(0, 10, 1, (float)(-Math.PI / 24), (float)(Math.PI / 24));

            batch = new SpriteBatch(XNA.GraphicsDevice);
            headerScale = 0.9f;
            subheaderScale = 0.7f;
            bodyScale = 0.55f;

            heightOfBodyLine = font.MeasureString("Eg").Y * bodyScale; // Eg = a high capital letter + low-hanging lowercase to fill the space
            heightofSpaceBetweenLines = font.MeasureString("Eg\nEg").Y * bodyScale - 2 * heightOfBodyLine;

            //setLengths(bbshelf.Library.Artifacts); // for debugging

            maxImageBox.TouchReleased += new TouchReleaseEventHandler(maxImageBox_TouchReleased);
            //bbshelf.SelectableObjects.AddObject(maxImageBox); // for debugging
        }
Example #2
0
            // pass in: the location of its anchor, the direction pointing away from the anchor you want the text to be drawn
            // the height of the sin wave, and the text/optional circle you want to display
            public WavyText(Vector2 start, Vector2 direction, float height, string text, SelectableEllipse circle)
            {
                lineStart = start;
                lineDirection = direction;
                lineDirection.Normalize();
                initialLineDirection = lineDirection;
                insideOutText = false;

                this.text = text;
                this.circle = circle;

                lineAngle = (float)Math.Acos(lineDirection.X) * Math.Sign(lineDirection.Y);
                flipRotate = lineAngle > Math.PI / 2 || lineAngle < -Math.PI / 2;

                waveSpeed = 1f;
                font = XNA.Font;

                assignRandomTheta();
                letters = new List<SelectableText>();
                letterPositions = new List<Vector3>();
                oldLetterPositions = new List<Vector3>();

                heightRange = new FloatRange(height, NumSecondsToScale, 1, 0.5f);
                scaleRange = new FloatRange(1, NumSecondsToScale, 1, 0.25f);
                movementRange = new FloatRange(0, NumSecondsToMove, 1, (float)(-Math.PI / 6), (float)(Math.PI / 6));
                bendyRange = new FloatRange(1, 5, 1, 0.25f);

                growOutwardRange = new FloatRange(0f, 0.5f, 1, 0, 1); // grow from 0 stretch to 1 stretch
                growOutwardRange.MovementDirection = 1; // grow in the positive direction
                growOutwardRange.AllowRandomSpeed = growOutwardRange.AllowRandomTarget = false; // make sure it grows at same rate
                growOutwardRange.ChangeDirectionEvent = new FloatRange.ChangeDirection(growOutwardFinished); // when it tries to change direction, we're done growing outward
                growOutwardRange.initialize(); // need to reinitialize because we changed some movement properties

                createLetters();
                positionLetters();
            }