5 using System.Collections.Generic;
7 using SiliconStudio.Paradox.Games;
8 using SiliconStudio.Core;
10 namespace SiliconStudio.
Paradox.Effects
17 private List<ParameterLocation> currentParameterLocations =
new List<ParameterLocation>();
18 private List<ResizeAction> resizeActions =
new List<ResizeAction>();
19 private ResizeAction currentAction;
29 resizeActions.Add(
new ResizeAction { Action = action, ParameterLocations = currentParameterLocations });
30 currentAction = resizeActions.Last();
32 currentParameterLocations =
new List<ParameterLocation>();
48 foreach (var resizeAction
in resizeActions)
50 if (!resizeAction.ParameterLocations.All(x => (
IReferencable)x.ParameterCollection.GetObject(x.ParameterKey) == x.Value))
52 throw new InvalidOperationException(
"Attempted to resize resource that changed.");
55 foreach (var parameterLocation
in resizeAction.ParameterLocations)
57 parameterLocation.ParameterCollection.SetObject(parameterLocation.ParameterKey, null);
59 resizeAction.ParameterLocations.Clear();
70 foreach (var resizeAction
in resizeActions)
72 currentAction = resizeAction;
73 resizeAction.Action(
this);
80 parameterCollection.Set(key, resourceValue);
81 if (currentAction == null)
82 throw new InvalidOperationException(
"Tried to use SetWithResize outside of a SetupResize callback.");
87 private class ResizeAction
89 public Action<GraphicsResizeContext> Action;
90 public List<ParameterLocation> ParameterLocations;
93 private struct ParameterLocation
95 public ParameterCollection ParameterCollection;
96 public ParameterKey ParameterKey;
Keep track of actions to execute when GraphicsDevice is resized.
Key of an effect parameter.
Base interface for all referencable objects.
void StartResize()
First step of the resize process: it sets to null all the resources assigned to a group through SetWi...
Key of an gereric effect parameter.
void SetupResize(Action< GraphicsResizeContext > action)
Execute the resize action and register it for later reexecution.
void EndResize()
Recreate all the resizable resources. It reexecute all the resize handlers registered through SetupRe...
A container to handle a hierarchical collection of effect variables.