public Initialize ( Microsoft.Xna.Framework.Graphics.GraphicsDevice graphicsDevice ) : void | ||
graphicsDevice | Microsoft.Xna.Framework.Graphics.GraphicsDevice | |
return | void |
public void CustomInitialize() { mTimeManager = new TimeManager(); mManagers = new SystemManagers(); mManagers.Initialize(GraphicsDevice); mManagers.Name = "Image Region Selection"; Assembly assembly = Assembly.GetAssembly(typeof(GraphicsDeviceControl));// Assembly.GetCallingAssembly(); string targetFntFileName = FileManager.UserApplicationDataForThisApplication + "Font18Arial.fnt"; string targetPngFileName = FileManager.UserApplicationDataForThisApplication + "Font18Arial_0.png"; FileManager.SaveEmbeddedResource( assembly, "XnaAndWinforms.Content.Font18Arial.fnt", targetFntFileName); FileManager.SaveEmbeddedResource( assembly, "XnaAndWinforms.Content.Font18Arial_0.png", targetPngFileName); var contentLoader = new ContentLoader(); contentLoader.SystemManagers = mManagers; LoaderManager.Self.ContentLoader = contentLoader; LoaderManager.Self.Initialize("Content/InvalidTexture.png", targetFntFileName, Services, mManagers); CreateNewSelector(); mCursor = new InputLibrary.Cursor(); mCursor.Initialize(this); mKeyboard = new InputLibrary.Keyboard(); mKeyboard.Initialize(this); mCameraPanningLogic = new CameraPanningLogic(this, mManagers, mCursor, mKeyboard); mCameraPanningLogic.Panning += HandlePanning; MouseWheel += new MouseEventHandler(MouseWheelRegion); ZoomNumbers = new Zooming.ZoomNumbers(); }
public static void StaticInitialize(string projectFileName) { if (mManagers == null) { mManagers = new SystemManagers(); mManagers.Initialize(FlatRedBallServices.GraphicsDevice); mManagers.Renderer.Camera.AbsoluteLeft = 0; mManagers.Renderer.Camera.AbsoluteTop = 0; var viewport = mManagers.Renderer.GraphicsDevice.Viewport; viewport.Width = FlatRedBall.Math.MathFunctions.RoundToInt(FlatRedBall.Camera.Main.DestinationRectangle.Width); viewport.Height = FlatRedBall.Math.MathFunctions.RoundToInt(FlatRedBall.Camera.Main.DestinationRectangle.Height); mManagers.Renderer.GraphicsDevice.Viewport = viewport; if (FlatRedBall.Camera.Main.Orthogonal) { GraphicalUiElement.CanvasHeight = FlatRedBall.Camera.Main.OrthogonalHeight; GraphicalUiElement.CanvasWidth = FlatRedBall.Camera.Main.OrthogonalWidth; } else { GraphicalUiElement.CanvasHeight = FlatRedBall.Camera.Main.DestinationRectangle.Height; GraphicalUiElement.CanvasWidth = FlatRedBall.Camera.Main.DestinationRectangle.Width; } // Need to do the zoom here in response to the FRB camera vs. the Gum camera mManagers.Renderer.Camera.Zoom = viewport.Height / (float)GraphicalUiElement.CanvasHeight; mManagers.Renderer.Camera.CameraCenterOnScreen = CameraCenterOnScreen.TopLeft; mManagers.Renderer.Camera.X = 0; mManagers.Renderer.Camera.Y = 0; SystemManagers.Default = mManagers; FlatRedBallServices.AddManager(RenderingLibrary.SystemManagers.Default); RenderingLibrary.Graphics.Text.RenderBoundaryDefault = false; // FlatRedBall uses premult alpha. RenderingLibrary.Graphics.Renderer.NormalBlendState = Microsoft.Xna.Framework.Graphics.BlendState.AlphaBlend; var idb = new GumIdb(); // We don't want the UI to be at Z=0 because it will render // at the same Z along with FRB entities and environments so UI might // be hidden. The proper way to solve this is to use Layers, but // this shouldn't be creating new Layers, that's up to the user. // Let's make it have a positive Z so it draws in more things at once idb.Z = 10; // This could be called on a secondary thread, like if called by GlobalContent, so we // want this to happen on the primary thread: Action primaryThreadAction = () => { FlatRedBall.SpriteManager.AddDrawableBatch(idb); FlatRedBall.Screens.ScreenManager.PersistentDrawableBatches.Add(idb); }; var instruction = new FlatRedBall.Instructions.DelegateInstruction(primaryThreadAction); FlatRedBall.Instructions.InstructionManager.Add(instruction); } if (projectFileName == null) { throw new Exception("The GumIDB must be initialized with a valid (non-null) project file."); } string errors; mProjectFileName = projectFileName; if (FlatRedBall.IO.FileManager.IsRelative(mProjectFileName)) { mProjectFileName = FlatRedBall.IO.FileManager.RelativeDirectory + mProjectFileName; } // First let's set the relative directory to the file manager's relative directory so we can load // the file normally... ToolsUtilities.FileManager.RelativeDirectory = FlatRedBall.IO.FileManager.RelativeDirectory; GumLoadResult result; ObjectFinder.Self.GumProjectSave = GumProjectSave.Load(mProjectFileName, out result); #if DEBUG if(ObjectFinder.Self.GumProjectSave == null) { throw new Exception("Could not find Gum project at " + mProjectFileName); } if(!string.IsNullOrEmpty(result.ErrorMessage)) { throw new Exception(result.ErrorMessage); } if(result.MissingFiles.Count != 0) { throw new Exception("Missing files starting with " + result.MissingFiles[0]); } #endif // Now we can set the directory to Gum's root: ToolsUtilities.FileManager.RelativeDirectory = ToolsUtilities.FileManager.GetDirectory(mProjectFileName); // The Gum tool does a lot more init than this, but we're going to only do a subset //of initialization for performance // reasons: foreach (var item in ObjectFinder.Self.GumProjectSave.Screens) { // Only initialize using the default state if (item.DefaultState != null) { item.Initialize(item.DefaultState); } } foreach (var item in ObjectFinder.Self.GumProjectSave.Components) { // Only initialize using the default state if (item.DefaultState != null) { item.Initialize(item.DefaultState); } } foreach (var item in ObjectFinder.Self.GumProjectSave.StandardElements) { // Only initialize using the default state if (item.DefaultState != null) { item.Initialize(item.DefaultState); } //for atlased colored rectangles if (item.Name == "ColoredRectangle") RenderingLibrary.Graphics.SolidRectangle.AtlasedTextureName = "..\\Graphics\\Misc\\ColoredRectangle.png"; } StandardElementsManager.Self.Initialize(); }
private void CreateManagers() { // For now we'll just use one SystemManagers but we may need to expand this if we have two windows mManagers = new SystemManagers(); mManagers.Initialize(XnaControl.GraphicsDevice); }
public static void StaticInitialize(string projectFileName) { if (mManagers == null) { mManagers = new SystemManagers(); mManagers.Initialize(FlatRedBallServices.GraphicsDevice); mManagers.Renderer.Camera.AbsoluteLeft = 0; mManagers.Renderer.Camera.AbsoluteTop = 0; } if (projectFileName == null) { throw new Exception("The GumIDB must be initialized with a valid (non-null) project file."); } string errors; mProjectFileName = projectFileName; ObjectFinder.Self.GumProjectSave = GumProjectSave.Load(projectFileName, out errors); StandardElementsManager.Self.Initialize(); }
void HandleXnaInitialize() { mManagers = new SystemManagers(); mManagers.Initialize(mControl.GraphicsDevice); mManagers.Renderer.SamplerState = SamplerState.PointClamp; mManagers.Name = "Preview Window Managers"; ShapeManager shapeManager = mManagers.ShapeManager; mSprite = new RenderingLibrary.Graphics.Sprite(null); mRectangle = new LineRectangle(mManagers); mManagers.ShapeManager.Add(mRectangle); // Move it in front of the Sprite mRectangle.Z = 1; mManagers.SpriteManager.Add(mSprite); mControl.Resize += new EventHandler(HandleResize); mControl.XnaUpdate += new Action(HandleXnaUpdate); MoveCameraToProperLocation(); // We'll use Cursor.Self which is initialized and updated elsewhere // Actually looks like that's not the case. We'll make a new one. mCursor = new Cursor(); mCursor.Initialize(mControl); mKeyboard = new Keyboard(); mKeyboard.Initialize(mControl); mLeftRuler = new Ruler(mControl, mManagers, mCursor); mLeftRuler.RulerSide = RulerSide.Left; mTopRuler = new Ruler(mControl, mManagers, mCursor); mTopRuler.RulerSide = RulerSide.Top; mManagers.Renderer.Camera.CameraCenterOnScreen = CameraCenterOnScreen.TopLeft; mManagers.Renderer.Camera.X = -50; mManagers.Renderer.Camera.Y = -50; cameraController = new CameraController(Camera, mManagers, mCursor, mControl, mTopRuler, mLeftRuler); }
void HandleXnaInitialize() { try { // For now we'll just use one SystemManagers but we may need to expand this if we have two windows mManagers = new SystemManagers(); mManagers.Initialize(XnaControl.GraphicsDevice); Assembly assembly = Assembly.GetAssembly(typeof(XnaAndWinforms.GraphicsDeviceControl)); string targetFntFileName = WahooToolsUtilities.FileManager.UserApplicationDataForThisApplication + "Font18Arial.fnt"; string targetPngFileName = WahooToolsUtilities.FileManager.UserApplicationDataForThisApplication + "Font18Arial_0.png"; WahooToolsUtilities.FileManager.SaveEmbeddedResource( assembly, "XnaAndWinforms.Content.Font18Arial.fnt", targetFntFileName); WahooToolsUtilities.FileManager.SaveEmbeddedResource( assembly, "XnaAndWinforms.Content.Font18Arial_0.png", targetPngFileName); LoaderManager.Self.Initialize(null, targetFntFileName, XnaControl.Services, mManagers); ToolComponentManager.Self.ReactToXnaInitialize(mManagers); } catch (Exception e) { throw new Exception("Error initializing XNA"); } }