protected override void Initialise() { var tutorials = new Dictionary<string, Type>(); Program.FindTutorials(tutorials); Camera3D camera = new Camera3D(); drawToScreen = new DrawTargetScreen(camera); backgroundParticles = new ParticleSystem(this.UpdateManager); backgroundParticles.GlobalValues[0] = ArrowXOffset; backgroundParticles.GlobalValues[2] = (float)this.WindowWidth; backgroundParticles.GlobalValues[3] = (float)this.WindowHeight; particlesTarget = new DrawTargetTexture2D(camera, this.WindowWidth, this.WindowHeight, SurfaceFormat.Color, DepthFormat.None); particlesBlurred = new DrawTargetTexture2D(camera, this.WindowWidth / 2, this.WindowHeight / 2, SurfaceFormat.Color, DepthFormat.None); DrawTargetTexture2D inter0 = null, inter1 = null; quaterDownsample = new TextureDownsample(particlesTarget, particlesBlurred, ref inter0, ref inter1, particlesBlurred.Width, particlesBlurred.Height); inter0 = new DrawTargetTexture2D(camera, particlesBlurred.Width, particlesBlurred.Height, SurfaceFormat.Color, DepthFormat.None); blurFilter = new BlurFilter(BlurFilterFormat.SevenSampleBlur, 1, particlesBlurred, inter0); backroundDrawer = new VelocityBillboardParticles2DElement(backgroundParticles, false); particlesTarget.Add(backroundDrawer); //draw the resolved particles to the screen drawToScreen.Add(new TexturedElement(particlesTarget, new Vector2(1, 1), true)); //background block other elements are inserted into. invisible var selectionBlock = new Xen.Ex.Graphics2D.SolidColourElement(new Color(0, 0, 0, 0), new Vector2(ElementWidth, tutorials.Count * ElementSeparation)); selectionBlock.AlphaBlendState = AlphaBlendState.Alpha; selectionBlock.VerticalAlignment = VerticalAlignment.Top; this.menuBlock = selectionBlock; int y_pos = 0; foreach (var tutorial in tutorials) { var tut_item = new TutorialSelection(tutorial.Key, y_pos, this.Content, selectionBlock, this.UpdateManager, tutorial.Value); y_pos -= ElementSeparation; buttons.Add(tut_item); } drawToScreen.Add(selectionBlock); var bloom = new TexturedElement(particlesBlurred, new Vector2(1, 1), true); bloom.AlphaBlendState = AlphaBlendState.AdditiveSaturate; drawToScreen.Add(bloom); this.logo = new TexturedElement(new Vector2(282,100)); this.logo.VerticalAlignment = VerticalAlignment.Top; this.logo.HorizontalAlignment = HorizontalAlignment.Centre; this.logo.Position = new Vector2(0, -50); this.helperText = new TextElementRect(new Vector2(800,100),"Use the DPAD to select an item, press 'A' to run the example\nWhen running an example, press 'back' to return to this menu"); this.helperText.VerticalAlignment = VerticalAlignment.Bottom; this.helperText.HorizontalAlignment = HorizontalAlignment.Centre; this.helperText.TextHorizontalAlignment = TextHorizontalAlignment.Centre; this.helperText.TextVerticalAlignment = VerticalAlignment.Centre; this.helperText.Colour = Color.Gray; drawToScreen.Add(logo); drawToScreen.Add(helperText); }
public TutorialSelection(string text, int y_pos, IContentRegister content, ElementRect parent, UpdateManager update, Type value) { this.Value = value; this.YPos = XenMenuApp.ElementHeight * 0.5f - y_pos; background = new SolidColourElement[3]; for (int i = 0; i < background.Length; i++) { background[i] = new SolidColourElement(Color.Black, new Vector2(parent.Size.X, XenMenuApp.ElementHeight)); background[i].VerticalAlignment = VerticalAlignment.Top; background[i].HorizontalAlignment = HorizontalAlignment.Left; background[i].Position = new Vector2(0, (float)y_pos); parent.Add(background[i]); } //offset the elements a bit, to give a 3D effect. background[1].AlphaBlendState = AlphaBlendState.ModulateX2; background[2].AlphaBlendState = AlphaBlendState.ModulateX2; background[1].Size -= new Vector2(1, 1); background[1].Position += new Vector2(1, 0); background[2].Size -= new Vector2(1, 1); background[2].Position -= new Vector2(0, 1); this.text = new TextElementRect(new Vector2(parent.Size.X - XenMenuApp.ElementTextOffset, XenMenuApp.ElementHeight), text); this.text.VerticalAlignment = VerticalAlignment.Top; this.text.HorizontalAlignment = HorizontalAlignment.Left; this.text.Position = new Vector2(XenMenuApp.ElementTextOffset, (float)y_pos); parent.Add(this.text); content.Add(this); update.Add(this); }
public void Initalise(IGameStateManager stateManager) { this.stateManager = stateManager; //Put up a beautiful and intricate loading bar (a green box on top of a black box) this.loadingBar = new SolidColourElement(Color.Lime, new Vector2(0, 0.15f), true); this.loadingBackground = new SolidColourElement(Color.Black, new Vector2(0.52f, 0.17f), true); this.loadingBar.Position = new Vector2(0.25f, 0.35f); this.loadingBackground.Position = new Vector2(0.24f, 0.34f); //tell the next state (in this case, it'll be the game) to begin loading this.stateToLoad.BeginLoad(); }
protected override void Initialise() { //draw targets usually need a camera. Camera3D camera = new Camera3D(); //look at the sphere, which will be at 0,0,0 camera.LookAt(Vector3.Zero, new Vector3(0, 0, 4), Vector3.UnitY); //create the draw target. drawToScreen = new DrawTargetScreen(camera); drawToScreen.ClearBuffer.ClearColour = Color.CornflowerBlue; //create the sphere SphereDrawer sphere = new SphereDrawer(Vector3.Zero); //before adding the sphere, add a rect over half the background to show blending is active //element covers half the screen SolidColourElement element = new SolidColourElement(Color.DarkGray, new Vector2(0.5f, 1), true); //element is added before the sphere (so it draws first) drawToScreen.Add(element); //add it to be drawn to the screen drawToScreen.Add(sphere); }
public RenderConfigEditor(ContentRegister content) { //setup the text elements this.stateText = new List<TextElement>(); this.visibleElementGap = new List<bool>(); #if XBOX360 this.helpText = new TextElement("Use 'A' and the DPad to interact with the menu"); #else this.helpText = new TextElement("Use the Arrow Keys and 'Enter' to interact with the menu"); #endif this.helpText.HorizontalAlignment = HorizontalAlignment.Left; this.helpText.VerticalAlignment = VerticalAlignment.Bottom; this.helpText.Colour = Color.Black; this.backgroundContainer = new SolidColourElement(new Color(0, 0, 0, 200), new Vector2(0, 0)); this.backgroundContainer.AlphaBlendState = AlphaBlendState.Alpha; foreach (string name in ConfigProperties.Keys) { //create the text TextElement text = new TextElement(); //if it's a ediable value, then put a '[X]' infront if (ConfigProperties[name].CanRead) text.Text.SetText("[ ] " + name); else text.Text.SetText(name); text.VerticalAlignment = VerticalAlignment.Bottom; this.stateText.Add(text); bool gap = false; if (ConfigProperties[name].GetCustomAttributes(typeof(RenderConfiguration.GapAttribute), false).Length > 0) gap = true; this.visibleElementGap.Add(gap); } //select top instance this.editSelection = this.stateText.Count - 1; //sizes of the elements are setup in LoadContent() content.Add(this); }
protected override void Initialise() { //Xen.Ex provides a very useful Camera3D called 'FirstPersonControlledCamera3D'. //This camera uses player input to act as a simple first-person style flythrough camera Xen.Camera.FirstPersonControlledCamera3D camera = null; //it uses player input, so the UpdateManager must be passed in camera = new Xen.Camera.FirstPersonControlledCamera3D(this.UpdateManager); //in this case, we want the z-axis to be the up/down axis (otherwise it's the Y-axis) camera.ZAxisUp = true; //also it's default is a bit too fast moving camera.MovementSensitivity *= 0.1f; camera.LookAt(new Vector3(1, 0, 0), new Vector3(), new Vector3(0, 0, 1)); this.camera = camera; //create the draw target. drawToScreen = new DrawTargetScreen(camera); //create a large number of actor instance from tutorial 10.. for (int n = 0; n <= 16; n++) { //create in a half circle float angle = (n / 16.0f) * MathHelper.Pi; var position = new Vector3((float)Math.Sin(angle), (float)Math.Cos(angle), 0); //not too close together position *= 10; drawToScreen.Add(new Tutorial_10.Actor(this.Content, position)); } //this element will display the camera position positionDisplay = new TextElement(); //TextElement (unlike other Elements) defaults to Top Left alignment //So, in order to bring it closer to the centre of the screen (due to potential overscan) //it's position needs to be set 'right' and 'down' from 'top left' //(this is just an example, see XNA docs for correct overscan compensation behaviour) positionDisplay.Position = new Vector2(40, -40); //offset from top left corner alignment //add it to the screen drawToScreen.Add(positionDisplay); var sizeInPixels = new Vector2(400, 200); //create the main block of yellow text this.yellowElement = new TextElementRect(sizeInPixels); this.yellowElement.Colour = Color.Yellow; //first line of text... this will have a flashing 2D element embedded string embeddedText = @"This is a text box with a large amount of custom text! It also includes an embedded 2D element: , which is a 16x16 SolidColourElement"; uint insertAtIndex = 96; // Hard coded to insert a 2D element at character index 96 which is about here: ^ //add a bunch of text... this.yellowElement.Text.AppendLine(embeddedText); this.yellowElement.Text.AppendLine(); this.yellowElement.Text.AppendLine(@"This class is:"); this.yellowElement.Text.AppendLine(this.GetType().FullName); this.yellowElement.Text.AppendLine(@"It is located in assembly:"); this.yellowElement.Text.AppendLine(this.GetType().Assembly.FullName); this.yellowElement.Text.AppendLine(); //add an embedded 2D element within the text //create it.. this.embeddedElement = new SolidColourElement(Color.Red, new Vector2(16, 16)); // quite small this.embeddedElement.AlphaBlendState = AlphaBlendState.Alpha; //add it. this.yellowElement.AddInline(this.embeddedElement, insertAtIndex); #if XBOX360 this.yellowElement.Text.AppendLine(@"Press and hold both thumbsticks to show the debug overlay"); #else this.yellowElement.Text.AppendLine(@"Press F12 to show the debug overlay"); #endif //align the element rectangle to the bottom centre of the screen this.yellowElement.VerticalAlignment = VerticalAlignment.Bottom; this.yellowElement.HorizontalAlignment = HorizontalAlignment.Centre; //centre align the text this.yellowElement.TextHorizontalAlignment = TextHorizontalAlignment.Centre; //centre the text in the middle of the 400x200 area of the element rectangle this.yellowElement.TextVerticalAlignment = VerticalAlignment.Centre; //add it to the screen drawToScreen.Add(yellowElement); //create the statistics display //this class will query the DrawState for the previous frames DrawStatistics structure. //this structure provides a large number of statistics for the drawn frame. //The DrawStatisticsDisplay displays some of the more important statistics. It will also //display thread activity on the xbox. //DrawStatistics are only available in DEBUG xen builds //They can be accessed at runtime with DrawState GetPreviousFrameStatistics() //at runtime, pressing 'F12' will toggle the overlay (or holding both thumbsticks on x360) this.statisticsOverlay = new Xen.Ex.Graphics2D.Statistics.DrawStatisticsDisplay(this.UpdateManager); //then add it to the screen drawToScreen.Add(statisticsOverlay); }