コード例 #1
0
        public LanguageView(BohemianArtifact bbshelf, Vector3 position, Vector3 size)
        {
            bookshelf = bbshelf;
            this.position = position;
            this.size = size;

            Texture2D englishTexture = XNA.LoadTexture(BohemianArtifact.TexturePath + "en_flag.jpg");
            englishCircle = new SelectableEllipse(new Vector2(0.25f, 0.25f), 0.225f, 0.01f, Color.White, Color.Gray, englishTexture);
            englishCircle.Alpha = unselectedAlpha;
            englishCircle.TouchActivated += new TouchActivatedEventHandler(Circle_TouchActivated);
            englishCircle.TouchReleased += new TouchReleaseEventHandler(Circle_TouchReleased);
            bookshelf.SelectableObjects.AddObject(englishCircle);

            Texture2D frenchTexture = XNA.LoadTexture(BohemianArtifact.TexturePath + "fr_flag.jpg");
            frenchCircle = new SelectableEllipse(new Vector2(0.75f, 0.25f), 0.225f, 0.01f, Color.White, Color.Gray, frenchTexture);
            frenchCircle.Alpha = unselectedAlpha;
            frenchCircle.TouchActivated += new TouchActivatedEventHandler(Circle_TouchActivated);
            frenchCircle.TouchReleased += new TouchReleaseEventHandler(Circle_TouchReleased);
            bookshelf.SelectableObjects.AddObject(frenchCircle);

            if (Artifact.CurrentLanguage == Artifact.LANGUAGE_ENGLISH)
                englishCircle.Alpha = selectedAlpha;
            else
                frenchCircle.Alpha = selectedAlpha;
        }
コード例 #2
0
        public MaterialsView(BohemianArtifact bbshelf, Vector3 position, Vector3 size)
        {
            bookshelf = bbshelf;
            bookshelf.Library.SelectedArtifactChanged += new ArtifactLibrary.SelectedArtifactHandler(library_SelectedArtifactChanged);
            this.position = position;
            this.size = size;

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

            // create a list of tier boundaries
            tierBoundaries = new Tier[MAX_TIERS];
            tierBoundaries[0] = new Tier(0, 0.25f);
            tierBoundaries[1] = new Tier(0.275f, 0.02f);
            tierBoundaries[2] = new Tier(0.325f, 0.020f);
            tierBoundaries[3] = new Tier(0.375f, 0.020f);
            tierBoundaries[4] = new Tier(0.425f, 0.020f);
            // and a list of materials that were previously selected
            materialConstraints = new List<string>();
            // and the list of tiers, including the center
            materialTiers = new List<ArrayList>();

            // the border circle that encases the centre and separates the tiers
            borderCircle = new SelectableEllipse(new Vector2(center.X, center.Y), tierBoundaries[0].CircleRadius, 0.01f, Color.White, Color.Gray, null);

            animationTimer = new Timer(0.5f);
            animationTimer.FinishEvent += new TimerFinished(AnimationTimerFinished);

            materialColors = new Dictionary<string, Color>();
            materialTextures = new Dictionary<string, Texture2D>();
            LoadMaterialTextures();
            materialTexts = new Dictionary<string, SelectableText>();
            LoadMaterialTexts();

            CreateMaterialBlobs();
            PackAllTiers();
            animationTimer.Start();
        }
コード例 #3
0
 private ArtifactContainer FindArtifactContainerFromCircle(SelectableEllipse circle)
 {
     foreach (ArtifactContainer container in artifactList)
     {
         if (container.Circle == circle)
         {
             return container;
         }
     }
     return null;
 }
コード例 #4
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();
            }
コード例 #5
0
 private WavyText FindWavyTextFromCircle(SelectableEllipse circle)
 {
     foreach (WavyText t in wavyText)
         if (t.Circle == circle)
             return t;
     return null;
 }
コード例 #6
0
 private KeywordContainer FindMaterialContainerFromCircle(SelectableEllipse circle)
 {
     foreach (KeywordContainer keyContainer in artifactCircles)
     {
         if (keyContainer.Circle == circle)
         {
             return keyContainer;
         }
     }
     return null;
 }
コード例 #7
0
        public TimelineView(BohemianArtifact bbshelf, Vector3 position, Vector3 size)
        {
            bookshelf = bbshelf;
            bookshelf.Library.SelectedArtifactChanged += new ArtifactLibrary.SelectedArtifactHandler(library_SelectedArtifactChanged);
            this.position = position;
            this.size = size;

            // create left and right white fadeouts
            leftWhiteVertices = new VertexPositionColor[6];
            leftWhiteVertices[0] = new VertexPositionColor(new Vector3(-2, 0, 0), Color.White);
            leftWhiteVertices[1] = new VertexPositionColor(new Vector3(0, 0, 0), Color.White);
            leftWhiteVertices[2] = new VertexPositionColor(new Vector3(0.005f, 0, 0), Color.Transparent);
            leftWhiteVertices[3] = new VertexPositionColor(new Vector3(0.005f, 1, 0), Color.Transparent);
            leftWhiteVertices[4] = new VertexPositionColor(new Vector3(0, 1, 0), Color.White);
            leftWhiteVertices[5] = new VertexPositionColor(new Vector3(-2, 1, 0), Color.White);
            rightWhiteVertices = new VertexPositionColor[6];
            rightWhiteVertices[0] = new VertexPositionColor(new Vector3(1 - 0.005f, 0, 0), Color.Transparent);
            rightWhiteVertices[1] = new VertexPositionColor(new Vector3(1, 0, 0), Color.White);
            rightWhiteVertices[2] = new VertexPositionColor(new Vector3(3, 0, 0), Color.White);
            rightWhiteVertices[3] = new VertexPositionColor(new Vector3(3, 1, 0), Color.White);
            rightWhiteVertices[4] = new VertexPositionColor(new Vector3(1, 1, 0), Color.White);
            rightWhiteVertices[5] = new VertexPositionColor(new Vector3(1 - 0.005f, 1, 0), Color.Transparent);
            hexWhiteIndices = new int[12];
            hexWhiteIndices[0] = 0;
            hexWhiteIndices[1] = 1;
            hexWhiteIndices[2] = 4;
            hexWhiteIndices[3] = 4;
            hexWhiteIndices[4] = 5;
            hexWhiteIndices[5] = 0;
            hexWhiteIndices[6] = 1;
            hexWhiteIndices[7] = 2;
            hexWhiteIndices[8] = 3;
            hexWhiteIndices[9] = 3;
            hexWhiteIndices[10] = 4;
            hexWhiteIndices[11] = 1;
            // create left and right black quads
            leftBlackVertices = new VertexPositionColor[4];
            leftBlackVertices[0] = new VertexPositionColor(new Vector3(-2, 0, 0), Color.Black);
            leftBlackVertices[1] = new VertexPositionColor(new Vector3(0, 0, 0), Color.Black);
            leftBlackVertices[2] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Black);
            leftBlackVertices[3] = new VertexPositionColor(new Vector3(-2, 1, 0), Color.Black);
            rightBlackVertices = new VertexPositionColor[4];
            rightBlackVertices[0] = new VertexPositionColor(new Vector3(1, 0, 0), Color.Black);
            rightBlackVertices[1] = new VertexPositionColor(new Vector3(3, 0, 0), Color.Black);
            rightBlackVertices[2] = new VertexPositionColor(new Vector3(3, 1, 0), Color.Black);
            rightBlackVertices[3] = new VertexPositionColor(new Vector3(1, 1, 0), Color.Black);
            quadBlackIndices = new int[6];
            quadBlackIndices[0] = 0;
            quadBlackIndices[1] = 1;
            quadBlackIndices[2] = 2;
            quadBlackIndices[3] = 2;
            quadBlackIndices[4] = 3;
            quadBlackIndices[5] = 0;

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

            // arrays to hold tick marks for each timeline
            catalogTicks = new List<TimelineYearTick>();
            useTicks = new List<TimelineYearTick>();
            manufactureTicks = new List<TimelineYearTick>();

            // create a line for each timeline, these will not be interactive elements
            catalogLine = new SelectableLine(new Vector3(0, catalogLineHeight, 0), new Vector3(1, catalogLineHeight, 0), Color.LightGray, lineThickness);
            useLine = new SelectableLine(new Vector3(0, useLineHeight, 0), new Vector3(1, useLineHeight, 0), Color.LightGray, lineThickness);
            manufactureLine = new SelectableLine(new Vector3(0, manufactureLineHeight, 0), new Vector3(1, manufactureLineHeight, 0), Color.LightGray, lineThickness);

            // underneath each timeline, there are three widgets to control zooming and traversing
            catalogWidgets = new SelectableLine[3];
            useWidgets = new SelectableLine[3];
            manufactureWidgets = new SelectableLine[3];
            for (int i = 0; i < 3; i++)
            {
                // create interactive elements and add them to the object manager
                catalogWidgets[i] = new SelectableLine(new Vector3((float)i / 3, catalogLineHeight, 0), new Vector3((float)(i + 1) / 3, catalogLineHeight, 0), new Color(i * 255 / 2, 0, 0), lineThickness * 2);
                useWidgets[i] = new SelectableLine(new Vector3((float)i / 3, useLineHeight, 0), new Vector3((float)(i + 1) / 3, useLineHeight, 0), new Color(0, i * 255 / 2, 0), lineThickness * 2);
                manufactureWidgets[i] = new SelectableLine(new Vector3((float)i / 3, manufactureLineHeight, 0), new Vector3((float)(i + 1) / 3, manufactureLineHeight, 0), new Color(0, 0, i * 255 / 2), lineThickness * 2);
                catalogWidgets[i].TouchActivated += new TouchActivatedEventHandler(TimelineView_TouchActivated);
                useWidgets[i].TouchActivated += new TouchActivatedEventHandler(TimelineView_TouchActivated);
                manufactureWidgets[i].TouchActivated += new TouchActivatedEventHandler(TimelineView_TouchActivated);
                bookshelf.SelectableObjects.AddObject(catalogWidgets[i]);
                bookshelf.SelectableObjects.AddObject(useWidgets[i]);
                bookshelf.SelectableObjects.AddObject(manufactureWidgets[i]);
            }

            // the circles are test objects to show how the timeline range is being manipulated
            catalogCircles = new SelectableEllipse[2];
            useCircles = new SelectableEllipse[2];
            manufactureCircles = new SelectableEllipse[2];
            // these arrays store the left/right for each timeline, along with a left/right offset that is used as a temp variable
            // the order is: L_RANGE, L_OFFSET, R_RANGE, R_OFFSET
            catalogTimelineRange = new float[4] { 0, 0, 1, 1 };
            useTimelineRange = new float[4] { 0, 0, 1, 1 };
            manufactureTimelineRange = new float[4] { 0, 0, 1, 1 };
            catalogCircles[0] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Orange, Color.Black, null);
            catalogCircles[1] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Pink, Color.Black, null);
            useCircles[0] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Orange, Color.Black, null);
            useCircles[1] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Pink, Color.Black, null);
            manufactureCircles[0] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Orange, Color.Black, null);
            manufactureCircles[1] = new SelectableEllipse(Vector2.Zero, 0.01f, 0.001f, Color.Pink, Color.Black, null);

            topSorted = new List<KeyValuePair<TimelineContainer, float>>();
            bottomSorted = new List<KeyValuePair<TimelineContainer, float>>();

            timelineArtifactList = new List<TimelineContainer>();
            lineArtifactDictionary = new Dictionary<SelectableLine, TimelineContainer>();
            selectedContainer = null;
            highlightedContainer = null;
            relatedContainers = new List<TimelineContainer>();
            InitializeTimelineList();

            animationTimer = new Timer(0.5f);
            animationTimer.FinishEvent += new TimerFinished(AnimationTimerFinished);
        }