public GCMetricsProfilerVisualiser( IAssetManager assetManager, I2DRenderUtilities renderUtilities) { _renderUtilities = renderUtilities; _defaultFont = assetManager.Get <FontAsset>("font.Default"); #if PLATFORM_WINDOWS || PLATFORM_MACOS || PLATFORM_LINUX // TryGetInstanceName can take up to 1.5 seconds to complete! Queue the work of resolving // these metrics on a background thread so we don't block game startup. ThreadPool.QueueUserWorkItem(o => { string instanceName; if (TryGetInstanceName(Process.GetCurrentProcess(), out instanceName)) { _gen0PerformanceCounter = new PerformanceCounter(".NET CLR Memory", "# Gen 0 Collections", instanceName, true); _gen1PerformanceCounter = new PerformanceCounter(".NET CLR Memory", "# Gen 1 Collections", instanceName, true); _gen2PerformanceCounter = new PerformanceCounter(".NET CLR Memory", "# Gen 2 Collections", instanceName, true); } }); #endif }
public DefaultDebugRenderPass(IAssetManager assetManager) { _basicEffect = assetManager.Get <UberEffectAsset>("effect.BuiltinSurface"); Lines = new List <VertexPositionNormalColor>(); Triangles = new List <VertexPositionNormalColor>(); EnabledLayers = new List <IDebugLayer>(); }
public void RenderText(IRenderContext context, IEffect effect, IEffectParameterSet effectParameterSet, Matrix matrix, string text, IAssetReference <FontAsset> font, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left, VerticalAlignment verticalAlignment = VerticalAlignment.Top, Color?textColor = null, bool renderShadow = true, Color?shadowColor = null) { throw new NotSupportedException(); }
public void Update(ComponentizedEntity entity, IGameContext gameContext, IUpdateContext updateContext) { if (!string.IsNullOrWhiteSpace(UserInterfaceAssetName)) { if (_userInterfaceAssetRef == null || _userInterfaceControllerAsset != UserInterfaceAssetName) { _userInterfaceAssetRef = _assetManager.Get <UserInterfaceAsset>(UserInterfaceAssetName); _userInterfaceControllerAsset = UserInterfaceAssetName; } if (_userInterfaceAssetRef.IsReady && _userInterfaceAssetRef.Asset != _userInterfaceAsset) { if (_userInterfaceController != null) { _userInterfaceController.Enabled = false; } _userInterfaceAsset = _userInterfaceAssetRef.Asset; _userInterfaceController = _userInterfaceFactory.CreateUserInterfaceController(_userInterfaceAsset); _userInterfaceController.Enabled = true; // Register behaviours. foreach (var behaviour in _behaviourRegistration) { behaviour(_userInterfaceController); } } } if (_userInterfaceController != null) { _userInterfaceController.Update(gameContext, updateContext); } }
public DefaultGraphicsBlit( IAssetManager assetManager, IBackBufferDimensions backBufferDimensions) { _blitEffect = assetManager.Get <UberEffectAsset>("effect.BuiltinSurface"); _backBufferDimensions = backBufferDimensions; }
private IDictionary LoadPersitedState(IAssetReference reference, IDictionary arguments, out bool isPersisted, out IPersistenceService persistenceService) { isPersisted = false; persistenceService = GetService <IPersistenceService>(); if (persistenceService == null) { this.TraceWarning(Properties.Resources.Recipe_NoPersistence); } // Only retrieve the persisted values if there's a persistence service, // an asset reference and we have not received a dictionary that overrides it. if (persistenceService != null && reference != null && arguments == null) { // Reload state. May return null. arguments = persistenceService.LoadState(Configuration.Name, reference); if (arguments == null) { this.TraceInformation(Properties.Resources.Recipe_NoSavedState); } else { isPersisted = true; this.TraceInformation(Properties.Resources.Recipe_ArgumentsSaved, arguments.Count); } } return(arguments); }
public void RenderTexture( IRenderContext context, Vector2 position, IAssetReference <TextureAsset> texture, Vector2?size = null, Color?color = null, float rotation = 0, Vector2?rotationAnchor = null, bool flipHorizontally = false, bool flipVertically = false, Rectangle?sourceArea = null) { if (!texture.IsReady) { return; } RenderTexture( context, position, texture.Asset.Texture, size, color, rotation, rotationAnchor, flipHorizontally, flipVertically, sourceArea); }
public IAudioHandle Play(IAssetReference <AudioAsset> asset) { var handle = GetHandle(asset); handle.Play(); return(handle); }
public override void Remove(IAssetReference reference) { if (reference == null) { throw new ArgumentNullException("reference"); } if (reference is IBoundAssetReference) { IBoundAssetReference boundref = (IBoundAssetReference)reference; if (boundref.Target is EnvDTE.ProjectItem) { EnvDTE.ProjectItem prItem = (EnvDTE.ProjectItem)boundref.Target; EnvDTE.Project containingProject = null; try { containingProject = prItem.ContainingProject; } catch { containingProject = null; } if (containingProject != null) { ArrayList reflist = (ArrayList)references[containingProject]; if (reflist != null) { reflist.Remove(reference); } } } } }
/// <summary> /// Adds a reference from the service. /// </summary> /// <param name="component">The reference to remove.</param> public override void Remove(IComponent component) { if (component == null) { throw new ArgumentNullException("component"); } if (!(component is IAssetReference)) { throw new InvalidOperationException("component"); } CheckState(); base.Remove(component); IAssetReference reference = (IAssetReference)component; // Remove state. persistence.RemoveState(Package.Configuration.Name, reference); // Remove from indexers. foreach (IAssetReferenceIndexer indexer in indexers.Values) { indexer.Remove(reference); } if (!isLoading) { Save(); OnChanged(); } }
/// <summary> /// Creates the unbound reference and registers /// the reference with the Recipe Framework /// </summary> public override void Execute() { ITypeResolutionService typeLoader = GetService <ITypeResolutionService>(true); Type assetType = typeLoader.GetType(this.referenceType, true); if (!typeof(IUnboundAssetReference).IsAssignableFrom(assetType)) { throw new ArgumentException(String.Format( System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.CreateUnboundReferenceAction_WrongType, assetType)); } ConstructorInfo ctor = assetType.GetConstructor(new Type[] { typeof(string) }); if (ctor == null) { throw new NotSupportedException(String.Format( System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.CreateUnboundReferenceAction_UnsupportedConstructor, assetType)); } reference = (IAssetReference)ctor.Invoke(new object[] { this.assetName }); if (reference is IAttributesConfigurable) { ((IAttributesConfigurable)reference).Configure(this.attributes); } IAssetReferenceService service = GetService <IAssetReferenceService>(true); service.Add(reference); }
/// <summary> /// Adds the execute recipe node. /// </summary> private ExtendedTreeNode AddExecuteRecipeNode(IAssetReference assetReference, ExtendedTreeNode recipeTreeNode) { ExtendedTreeNode executeTreeNode = new ExtendedTreeNode(); if (assetReference is UnboundTemplateReference || assetReference is BoundTemplateReference) { executeTreeNode.Text = Properties.Resources.Navigator_UnfoldThisTemplate; } else { executeTreeNode.Text = Properties.Resources.Navigator_RunThisRecipe; } executeTreeNode.ToolTipText = String.Format(Properties.Resources.Reference_AppliesToTooltip, assetReference.AppliesTo); executeTreeNode.NodeFont = (executeTreeNode.NodeFont != null) ? new Font(executeTreeNode.NodeFont, FontStyle.Bold) : new Font(SystemFonts.DefaultFont, FontStyle.Bold); executeTreeNode.Tag = assetReference; executeTreeNode.ShowAsLink = true; executeTreeNode.ImageIndex = ImageExecuteIndex; executeTreeNode.SelectedImageIndex = ImageExecuteIndex; executeTreeNode.StateImageIndex = ImageExecuteIndex; recipeTreeNode.Nodes.Add(executeTreeNode); return(executeTreeNode); }
/// <summary> /// Handles the NodeMouseClick event of the availableRecipesTreeView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.Windows.Forms.TreeNodeMouseClickEventArgs"/> instance containing the event data.</param> private void availableRecipesTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag == null) { return; } IAssetReference executeReference = e.Node.Tag as IAssetReference; if (e.Node.Tag is Link) { Link documentationLink = e.Node.Tag as Link; if (documentationLink.KindSpecified && documentationLink.Kind == DocumentationKind.Documentation) { ShowHelp(documentationLink.Url); } } else if (executeReference != null) { ExecuteReference(executeReference); } else if (e.Node.Tag is Recipe) { // nothing todo... } }
public void RenderText( IRenderContext context, IEffect effect, IEffectParameterSet effectParameterSet, Matrix matrix, string text, IAssetReference <FontAsset> font, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, Color?textColor, bool renderShadow, Color?shadowColor) { if (!context.IsCurrentRenderPass <I3DRenderPass>()) { throw new InvalidOperationException("Can't use 3D rendering utilities in 2D context."); } var targets = context.GraphicsDevice.GetRenderTargets(); var size = MeasureText(context, text, font); var temporary = new RenderTarget2D( context.GraphicsDevice, (int)size.X, (int)size.Y, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.DiscardContents); context.GraphicsDevice.SetRenderTarget(temporary); context.GraphicsDevice.Clear(Color.Transparent); using (var spriteBatch = new SpriteBatch(context.GraphicsDevice)) { _twoDimensionalRenderUtilities.RenderText( context, new Vector2(0, 0), text, font, HorizontalAlignment.Left, VerticalAlignment.Top, textColor, renderShadow, shadowColor); spriteBatch.End(); } var texture = (Texture2D)temporary; context.GraphicsDevice.SetRenderTarget(null); context.GraphicsDevice.BlendState = BlendState.Opaque; context.GraphicsDevice.DepthStencilState = DepthStencilState.Default; context.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; context.GraphicsDevice.RasterizerState = RasterizerState.CullNone; RenderTexture(context, effect, effectParameterSet, matrix, texture, Color.White, flipHorizontally: false, flipVertically: false); }
/// <summary> /// See <see cref="IAssetReferenceService.Add(IAssetReference, IDictionary)"/>. /// </summary> public void Add(IAssetReference reference, IDictionary initialState, bool throwIfDuplicate) { try { BaseValidateName(reference, reference.Key); } catch (ArgumentException) // Exception thrown by the ValidateName method when duplicate components are added. { if (throwIfDuplicate) { throw; } return; } try { Add((IComponent)reference); } catch (ArgumentException) // Exception thrown by the OnSited of the reference { Remove(reference); } if (initialState != null) { persistence.SaveState(Package.Configuration.Name, reference, initialState); } }
public NuiRenderer( IAssetManager assetManager, IInterlacedBatchingDepthProvider interlacedBatchingDepthProvider) { _uiSmallFont = assetManager.Get <FontAsset>("font.UISmall"); _surfaceEffect = assetManager.Get <UberEffectAsset>("effect.BuiltinSurface"); _interlacedBatchingDepthProvider = interlacedBatchingDepthProvider; }
public NuiConsoleContainerSkinRenderer( I2DRenderUtilities renderUtilities, IAssetManager assetManager) { _renderUtilities = renderUtilities; _assetManager = assetManager; _fontAsset = assetManager.Get <FontAsset>("font.Console"); }
public DefaultStandardDirectionalLightRenderer( IAssetManager assetManager, IGraphicsBlit graphicsBlit) { _graphicsBlit = graphicsBlit; _directionalLightEffect = assetManager.Get <EffectAsset>("effect.DirectionalLight"); }
public Render3DPlaneComponent(INode node, I3DRenderUtilities renderUtilities, IAssetManager assetManager) { _node = node; _renderUtilities = renderUtilities; _defaultSurfaceEffect = assetManager.Get <UberEffectAsset>("effect.BuiltinSurface"); Enabled = true; }
public NuiLabelSkinRenderer( I2DRenderUtilities renderUtilities, IAssetManager assetManager, ILayoutPosition layoutPosition) { _renderUtilities = renderUtilities; _layoutPosition = layoutPosition; _fontAsset = assetManager.Get <FontAsset>("font.UISmall"); }
public NetworkSampler(I2DRenderUtilities renderUtilities, IAssetReference <FontAsset> defaultFont, string type) { _renderUtilities = renderUtilities; _defaultFont = defaultFont; Type = type; _bytesOverTime = new List <int>(); _countsOverTime = new List <int>(); }
public InspectorRenderPass(IAssetManager assetManager) { _basicEffect = assetManager.Get <UberEffectAsset>("effect.BuiltinSurface"); Lines = new List <VertexPositionNormalColor>(); Triangles = new List <VertexPositionNormalColor>(); _enabledLayers = new List <IDebugLayer> { new InspectorDebugLayer() }; }
public NuiListItemSkinRenderer( I2DRenderUtilities renderUtilities, NuiRenderer nuiRenderer, IAssetManager assetManager) { _renderUtilities = renderUtilities; _nuiRenderer = nuiRenderer; _fontAsset = assetManager.Get <FontAsset>("font.UISmall"); }
public ReferenceInfo(IAssetReference reference) { this.Reference = reference; ManagerExecutableAttribute attr = (ManagerExecutableAttribute)Attribute.GetCustomAttribute( reference.GetType(), typeof(ManagerExecutableAttribute), true); // By default references are executable, unless they specify otherwise. this.IsEnabled = (attr == null) || attr.AllowExecute; }
public BasicLabelSkinRenderer( I2DRenderUtilities renderUtilities, IAssetManager assetManager, ILayoutPosition layoutPosition) { _renderUtilities = renderUtilities; _layoutPosition = layoutPosition; _fontAsset = assetManager.Get <FontAsset>("font.Default"); }
/// <summary> /// Saves all the current recipe references. /// </summary> private void Save() { if (persistence != null) { IAssetReference[] refs = new IAssetReference[this.Components.Count]; this.Components.CopyTo(refs, 0); persistence.SaveReferences(Package.Configuration.Name, refs); } }
public PhysicsMetricsProfilerVisualiser( IAssetManager assetManager, I2DRenderUtilities renderUtilities, IPhysicsEngine physicsEngine) { _renderUtilities = renderUtilities; _physicsEngine = physicsEngine; _defaultFont = assetManager.Get <FontAsset>("font.Default"); }
public Render3DCubeComponent(INode node, I3DRenderUtilities renderUtilities, IAssetManager assetManager) { _node = node; _finalTransform = new DefaultFinalTransform(this, node); _renderUtilities = renderUtilities; _defaultSurfaceEffect = assetManager.Get <UberEffectAsset>("effect.BuiltinSurface"); Enabled = true; Transform = new DefaultTransform(); }
/// <summary> /// Removes the previously added reference /// </summary> public override void Undo() { IAssetReferenceService service = GetService <IAssetReferenceService>(true); if (reference != null) { service.Remove(reference); reference = null; } }
/// <summary> /// See <see cref="IAssetReferenceService.Add(IAssetReference, IDictionary)"/>. /// </summary> public void Add(IAssetReference reference, IDictionary initialState) { if (reference is RecipeReference) { IConfigurationService configuration = GetService <IConfigurationService>(true); // The configuration service will throw if the recipe doesn't exist. Configuration.Recipe recipeReferenced = configuration.CurrentPackage[reference.AssetName]; } Add(reference, initialState, false); }