public void UpdateIElementVariables(ElementRuntime elementRuntime, List <string> variables) { foreach (string variable in variables) { UpdateIElementVariable(elementRuntime, variable); } }
public object InstanceForElementRuntime(ElementRuntime elementRuntime) { if (elementRuntime == null) { return(null); } if (elementRuntime.AssociatedNamedObjectSave == null) { throw new Exception("The ElementRuntime does not have an associated NamedObject and it should"); } string nameToFind = elementRuntime.AssociatedNamedObjectSave.InstanceName; IElement containerIElement = ObjectFinder.Self.GetElementContaining(elementRuntime.AssociatedNamedObjectSave); string containerNameStripped = null; if (containerIElement is EntitySave) { containerNameStripped = containerIElement.Name.Substring("Entities/".Length); } else //Implied: if (containerIElement is ScreenSave) { containerNameStripped = containerIElement.Name.Substring("Screens/".Length); } ArrowElementSave container = ArrowState.Self.CurrentArrowProject.Elements.FirstOrDefault( item => item.Name == containerNameStripped); return(container.AllInstances.FirstOrDefault(item => LateBinder.GetInstance(item.GetType()).GetValue(item, "Name") as string == nameToFind)); }
public void TestSceneTypes() { EntitySave entitySave = new EntitySave(); entitySave.Name = "NosSceneTest"; NamedObjectSave nos = new NamedObjectSave(); nos.SourceType = SourceType.FlatRedBallType; nos.InstanceName = "NamedScene"; nos.SourceClassType = "Scene"; entitySave.NamedObjects.Add(nos); ElementRuntime elementRuntime = new ElementRuntime(); elementRuntime.Initialize(entitySave, null, null, null, null); if (elementRuntime.ContainedElements.Count == 0) { throw new Exception("ElementRuntimes with Scene NOS's should create ElementRuntimes for the Scene NOS"); } if (elementRuntime.ContainedElements[0].DirectObjectReference is Scene == false) { throw new Exception("Scene NOS's should create Scenes"); } if (((Scene)elementRuntime.ContainedElements[0].DirectObjectReference).Name != nos.InstanceName) { throw new Exception("Name on Scenes are not being set from NOS's"); } }
private bool GetFloatValue(ElementRuntime elementRuntime, FunctionArgs args, string variableName) { float valueToSet = float.NaN; bool wasSet = false; switch (variableName) { case "PositiveInfinity": valueToSet = float.PositiveInfinity; wasSet = true; break; case "NegativeInfinity": valueToSet = float.NegativeInfinity; wasSet = true; break; case "MaxValue": valueToSet = float.MaxValue; wasSet = true; break; case "MinValue": valueToSet = float.MinValue; wasSet = true; break; } if (wasSet) { args.Result = valueToSet; } return(wasSet); }
protected virtual void CreatePolygonForScalableEntity(ElementRuntime element) { NamedObjectSave namedObjectSave = element.AssociatedNamedObjectSave; object scaleXAsObject = namedObjectSave.GetEffectiveValue("ScaleX"); object scaleYAsObject = namedObjectSave.GetEffectiveValue("ScaleY"); if (scaleXAsObject != null && scaleYAsObject != null) { float scaleX = (float)scaleXAsObject; float scaleY = (float)scaleYAsObject; Polygon newPoly = Polygon.CreateRectangle(scaleX, scaleY); InitializeNewPoly(newPoly); newPoly.Position = element.Position; mHighlightShapes.Add(newPoly); newPoly.AttachTo(element, true); newPoly.RelativeRotationZ = 0; } }
private ElementRuntime GetElementRuntimeOver(FlatRedBall.Gui.Cursor cursor) { ElementRuntime toReturn = null; var currentElementRuntime = ArrowState.Self.CurrentContainedElementRuntime; if (currentElementRuntime != null && currentElementRuntime.HasCursorOver(cursor)) { toReturn = currentElementRuntime; } if (toReturn == null && ArrowState.Self.CurrentElementRuntime != null) { foreach (var containedElementRuntime in ArrowState.Self.CurrentElementRuntime.ContainedElements) { if (containedElementRuntime != currentElementRuntime && containedElementRuntime.HasCursorOver(cursor)) { toReturn = containedElementRuntime; break; } } } if (toReturn == null) { } return(toReturn); }
private void RefreshAvailableElements() { mAvailableElementsForHighlight.Clear(); ElementRuntime currentElement = GluxManager.CurrentElement; if (currentElement != null) { foreach (ElementRuntime elementRuntimeForNos in currentElement.ContainedElements) { if (elementRuntimeForNos.Visible && elementRuntimeForNos.AssociatedNamedObjectSave.IsLayer == false)// && elementRuntimeForNos.IsMouseOver(GuiManager.Cursor, elementRuntimeForNos.Layer)) { mAvailableElementsForHighlight.Add(elementRuntimeForNos); //return elementRuntimeForNos; } } foreach (ElementRuntime element in currentElement.ElementsInList) { if (element.Visible)// && element.IsMouseOver(GuiManager.Cursor, element.Layer)) { mAvailableElementsForHighlight.Add(element); //return element; } } } }
private static Layer GetLayerToAddTo(NamedObjectSave objectToLoad, Layer layerToPutOn, ElementRuntime elementRuntime) { Layer layerToAddTo = layerToPutOn; if (!string.IsNullOrEmpty(objectToLoad.LayerOn)) { if (objectToLoad.LayerOn == "Under Everything (Engine Layer)") { layerToAddTo = SpriteManager.UnderAllDrawnLayer; } else if (objectToLoad.LayerOn == "Top Layer (Engine Layer)") { layerToAddTo = SpriteManager.TopLayer; } else { ElementRuntime layerContainer = elementRuntime.GetContainedElementRuntime(objectToLoad.LayerOn); if (layerContainer == null) { System.Windows.Forms.MessageBox.Show( "Could not find a Layer by the name \"" + objectToLoad.LayerOn + "\" in the object " + objectToLoad, "Layer not found"); } else { layerToAddTo = ((Layer)layerContainer.DirectObjectReference); } } } return(layerToAddTo); }
int Compare(ElementRuntime first, ElementRuntime second) { ElementRuntime currentElement = GluxManager.CurrentElement; NamedObjectSave mFirstNos = first.AssociatedNamedObjectSave; NamedObjectSave mSecondNos = second.AssociatedNamedObjectSave; string firstLayer = mFirstNos.LayerOn; string secondLayer = mSecondNos.LayerOn; if (string.IsNullOrEmpty(firstLayer) && !string.IsNullOrEmpty(secondLayer)) { // second is not on a layer, so that should come first return(1); } else if (!string.IsNullOrEmpty(firstLayer) && string.IsNullOrEmpty(secondLayer)) { return(-1); } else if (string.IsNullOrEmpty(firstLayer)) { // they both are, so compare their Z return(-first.Z.CompareTo(second.Z)); } else { // they're on separate layers, so compare the layer indexes IElement element = currentElement.AssociatedIElement; NamedObjectSave firstLayerNos = element.GetNamedObjectRecursively(firstLayer); NamedObjectSave secondLayerNos = element.GetNamedObjectRecursively(secondLayer); return(-Compare(firstLayerNos, secondLayerNos)); } }
void CreateContainerElementRuntime() { EntitySave containerEntitySave = new EntitySave { Name = "ContainerVariableSetting" }; ObjectFinder.Self.GlueProject.Entities.Add(containerEntitySave); NamedObjectSave nos = new NamedObjectSave(); nos.SourceType = SourceType.Entity; nos.InstanceName = mEntitySave.Name + "Instance"; nos.SourceClassType = mEntitySave.Name; containerEntitySave.NamedObjects.Add(nos); nos.UpdateCustomProperties(); nos.SetPropertyValue("CurrentStateSaveCategoryState", "SecondState"); mContainedElementRuntime = new ElementRuntime(containerEntitySave, null, null, null, null); // This thing is attached - we need to check its relativeX //if (mContainedElementRuntime.ContainedElements[0].X != -10.0f) if (mContainedElementRuntime.ContainedElements[0].RelativeX != -10.0f) { throw new Exception("Categorized states on contained NamedObjectSave Elements aren't setting values properly"); } }
private void SelectElement(ElementRuntime elementRuntimeOver) { mCurrentSelectedElementRuntime = elementRuntimeOver; if (mCurrentSelectedElementRuntime != null && mCurrentSelectedElementRuntime.AssociatedNamedObjectSave != null) { entityControlControls.SetCurrentNamedObject( mCurrentSelectedElementRuntime, mCurrentSelectedElementRuntime.AssociatedNamedObjectSave); } if (mScalingHandles.IsElementRuntimeScalable(mCurrentSelectedElementRuntime)) { mScalingHandles.CurrentElement = mCurrentSelectedElementRuntime; } else { mScalingHandles.CurrentElement = null; } mRotationHandles.CurrentElement = mCurrentSelectedElementRuntime; if (mCurrentSelectedElementRuntime == null) { mCurrentAction = ActionType.None; } else { mCurrentAction = ActionType.Move; } }
private static object GetObjectIfFileIsContained(string sourceFile, ElementRuntime elementRuntime) { if (elementRuntime.EntireScenes.ContainsKey(sourceFile)) { return(elementRuntime.EntireScenes[sourceFile]); } if (elementRuntime.EntireShapeCollections.ContainsKey(sourceFile)) { return(elementRuntime.EntireShapeCollections[sourceFile]); } if (elementRuntime.EntireEmitterLists.ContainsKey(sourceFile)) { return(elementRuntime.EntireEmitterLists[sourceFile]); } if (elementRuntime.EntireNodeNetworks.ContainsKey(sourceFile)) { return(elementRuntime.EntireNodeNetworks[sourceFile]); } if (elementRuntime.EntireSplineLists.ContainsKey(sourceFile)) { return(elementRuntime.EntireSplineLists[sourceFile]); } return(null); }
void HandleAfterVariableSet(object sender, VariableSetArgs e) { try { if (mControl != null && mControl.Enabled) { ElementRuntime elementRuntime = sender as ElementRuntime; // If the user has just selected the element runtime,then it hasn't been set // as the current element yet, so we can't use the GlueViewState facade // IElement element = GlueViewState.Self.CurrentElement; IElement element = elementRuntime.AssociatedIElement; if (element != null) { string variableName = e.VariableName; EventResponseSave ers = element.GetEvent("After" + variableName + "Set"); if (ers != null) { mParserLog.AppendLine("Reacting to after " + e.VariableName + " Set in the file :\n\t\t" + EventResponseSave.GetSharedCodeFullFileName(element, FileManager.GetDirectory(GlueViewState.Self.CurrentGlueProjectFile))); ApplyEventResponseSave(elementRuntime, ers); } } } } catch (Exception exception) { int m = 3; } }
public void TestSetByDerived() { NamedObjectSave nos = mDerivedEntity.NamedObjects.FirstOrDefault(item => item.FieldName == "SpriteInstance"); bool shouldCreate = ElementRuntime.ShouldElementRuntimeBeCreatedForNos(nos, mDerivedEntity); if (!shouldCreate) { throw new Exception("NOS's which are defined by base, but their base has SetByDerived should be created."); } if (mDerivedElementRuntime.ContainedElements.FirstOrDefault(item => item.Name == "SpriteInstance") == null) { throw new Exception("Objects defined in base and SetByDerived should be created, but are not."); } // Verify that only 1 AARect has been made int count = 0; foreach (var item in mDerivedElementRuntime.ContainedElements.Where(item => item.Name == "RectInstance")) { count++; } if (count != 1) { throw new Exception("Only one rectangle should be created, but it looks like more are made"); } }
public void Initialize() { OverallInitializer.Initialize(); mBaseEntity = new EntitySave(); mBaseEntity.Name = "BaseEntityInheritanceTests"; ObjectFinder.Self.GlueProject.Entities.Add(mBaseEntity); NamedObjectSave nos = new NamedObjectSave(); nos.InstanceName = "SpriteInstance"; nos.SourceType = SourceType.FlatRedBallType; nos.SourceClassType = "Sprite"; nos.SetByDerived = true; mBaseEntity.NamedObjects.Add(nos); nos = new NamedObjectSave(); nos.InstanceName = "RectInstance"; nos.SourceType = SourceType.FlatRedBallType; nos.SourceClassType = "AxisAlignedRectangle"; nos.ExposedInDerived = true; mBaseEntity.NamedObjects.Add(nos); mDerivedEntity = new EntitySave(); mDerivedEntity.Name = "DerivedentityInheritanceTests"; mDerivedEntity.BaseEntity = mBaseEntity.Name; mDerivedEntity.UpdateFromBaseType(); ObjectFinder.Self.GlueProject.Entities.Add(mDerivedEntity); mDerivedElementRuntime = new ElementRuntime(mDerivedEntity, null, null, null, null); }
public void TestRegularVisibility() { CustomVariable visibleVariable = mEntitySave.GetCustomVariable("Visible"); mElementRuntime.SetCustomVariable(visibleVariable, mElementRuntime.AssociatedIElement, false, false); ElementRuntime containedElementRuntime = mElementRuntime.ContainedElements[0] as ElementRuntime; Sprite sprite = containedElementRuntime.DirectObjectReference as Sprite; if (sprite.AbsoluteVisible) { throw new Exception("Sprite is visible, but it is part of an element runtime that isn't, so it shouldn't be"); } sprite.Visible = false; mElementRuntime.SetCustomVariable(visibleVariable, mElementRuntime.AssociatedIElement, true, false); if (sprite.Visible) { throw new Exception("The Sprite should still have a relative Visibility of true, even though the parent is false"); } sprite.Visible = true; if (!sprite.AbsoluteVisible) { throw new Exception("The Sprite should be visible now!"); } }
public object UpdateInstanceValuesFromRuntime(ElementRuntime runtime) { object instance = RelationshipManager.Self.InstanceForElementRuntime(runtime); object whatToPullValuesFrom = runtime; if (runtime.DirectObjectReference != null) { whatToPullValuesFrom = runtime.DirectObjectReference; } PositionedObject whatToPullFromAsPo = whatToPullValuesFrom as PositionedObject; if (instance is CircleSave) { CircleSave save = (instance as CircleSave); save.SetFrom(whatToPullValuesFrom as Circle); SetSavePositionsFromRelativeValues(whatToPullFromAsPo, save); } else if (instance is SpriteSave) { SpriteSave save = (instance as SpriteSave); save.SetFrom(whatToPullValuesFrom as Sprite); SetSavePositionsFromRelativeValues(whatToPullFromAsPo, save); } else if (instance is AxisAlignedRectangleSave) { AxisAlignedRectangleSave save = (instance as AxisAlignedRectangleSave); save.SetFrom(whatToPullValuesFrom as AxisAlignedRectangle); SetSavePositionsFromRelativeValues(whatToPullFromAsPo, save); } else if (instance is ArrowElementInstance) { ArrowElementInstance save = (instance as ArrowElementInstance); if (whatToPullFromAsPo != null) { if (whatToPullFromAsPo.Parent == null) { save.SetVariable("X", whatToPullFromAsPo.X); save.SetVariable("Y", whatToPullFromAsPo.Y); } else { save.SetVariable("X", whatToPullFromAsPo.RelativeX); save.SetVariable("Y", whatToPullFromAsPo.RelativeY); } } // We can't do this because this object technically doesn't have X and Y properties //SetSavePositionsFromRelativeValues(whatToPullFromAsPo, save); } else { throw new Exception("Saving of type " + instance.GetType() + " is not supported"); } return(instance); }
private void CreateElementRuntime() { mElementRuntime = new ElementRuntime(); mElementRuntime.Initialize(mEntitySave, null, null, null, null); mContainerElementRuntime = new ElementRuntime(); mContainerElementRuntime.Initialize(mContainer, null, null, null, null); }
public void TestLayerOrthoValues() { EntitySave entitySave = new EntitySave(); entitySave.Name = "LayerTestTestLayerOrthoValuesEntity"; NamedObjectSave nos = new NamedObjectSave(); nos.SourceType = SourceType.FlatRedBallType; nos.SourceClassType = "Layer"; nos.InstanceName = "Layer1"; nos.IndependentOfCamera = true; nos.Is2D = true; nos.LayerCoordinateUnit = LayerCoordinateUnit.Pixel; nos.LayerCoordinateType = LayerCoordinateType.MatchCamera; entitySave.NamedObjects.Add(nos); nos = new NamedObjectSave(); nos.SourceType = SourceType.FlatRedBallType; nos.SourceClassType = "Layer"; nos.InstanceName = "Layer2"; nos.IndependentOfCamera = true; nos.Is2D = true; nos.LayerCoordinateUnit = LayerCoordinateUnit.Pixel; nos.LayerCoordinateType = LayerCoordinateType.MatchCamera; nos.DestinationRectangle = new FloatRectangle(0, 0, 80, 64); entitySave.NamedObjects.Add(nos); SpriteManager.Camera.Orthogonal = true; SpriteManager.Camera.OrthogonalWidth = 800; SpriteManager.Camera.OrthogonalHeight = 640; ElementRuntime elementRuntime = new ElementRuntime(); elementRuntime.Initialize(entitySave, null, null, null, null); Layer layer = (elementRuntime.ContainedElements[0].DirectObjectReference as Layer); if (layer.LayerCameraSettings.OrthogonalWidth != 800 || layer.LayerCameraSettings.OrthogonalHeight != 640) { throw new Exception("A Layer using MatchCamera coordinate types is not matching the Camera's ortho values"); } layer = (elementRuntime.ContainedElements[1].DirectObjectReference as Layer); if (layer.LayerCameraSettings.OrthogonalWidth != 80 || layer.LayerCameraSettings.OrthogonalHeight != 64) { throw new Exception("A Layer using MatchCamera with a destination rectangle does not have proper coordinates"); } }
public void TestRelativeAbsoluteConversion() { NamedObjectSave nos = new NamedObjectSave(); nos.SourceType = SourceType.FlatRedBallType; nos.SourceClassType = "Sprite"; nos.UpdateCustomProperties(); nos.InstanceName = "SpriteObject"; nos.SetPropertyValue("ScaleX", 2.0f); nos.SetPropertyValue("X", 4.0f); nos.SetPropertyValue("RotationZ", 4.0f); nos.SetPropertyValue("RotationZVelocity", 4.0f); mEntitySave.NamedObjects.Add(nos); CustomVariable customVariable = new CustomVariable(); customVariable.SourceObject = nos.InstanceName; customVariable.SourceObjectProperty = "ScaleY"; customVariable.DefaultValue = 8.0f; mEntitySave.CustomVariables.Add(customVariable); ElementRuntime elementRuntime = new ElementRuntime(); elementRuntime.Initialize(mEntitySave, null, null, null, null); Sprite sprite = elementRuntime.ContainedElements[0].DirectObjectReference as Sprite; sprite.ForceUpdateDependencies(); if (elementRuntime.X != 0) { throw new Exception("NOS variables are being applied to the container instead of just to the NOS"); } if (sprite.X != 4.0f) { throw new Exception("Absolute values should get set when setting X on objects even though they're attached"); } if (sprite.RotationZ != 4.0f) { throw new Exception("Absolute values should get set when setting RotationZ on objects even though they're attached"); } if (sprite.RelativeRotationZVelocity != 4.0f) { throw new Exception("Setting RotationZVelocity should set RelativeRotationZVelocity"); } if (sprite.ScaleX != 2.0f) { throw new Exception("Scale values aren't properly showing up on Sprites"); } if (sprite.ScaleY != 8.0f) { throw new Exception("Scale values aren't properly showing up on Sprites"); } }
private void EvaluateFunctionGetStaticMember(ElementRuntime elementRuntime, FunctionArgs args, CodeContext codeContext) { string argument = (string)args.Parameters[0].ParsedExpression.ToString(); string value = (string)mExpressionParser.EvaluateExpression(argument, codeContext); ReferencedFileSave rfs = elementRuntime.AssociatedIElement.GetReferencedFileSaveByInstanceNameRecursively(value); args.Result = elementRuntime.LoadReferencedFileSave(rfs, true, elementRuntime.AssociatedIElement); }
protected override void CreatePolygonForScalableEntity(ElementRuntime element) { base.CreatePolygonForScalableEntity(element); float scaleX = (float)element.AssociatedNamedObjectSave.GetEffectiveValue("ScaleX"); float scaleY = (float)element.AssociatedNamedObjectSave.GetEffectiveValue("ScaleY"); CreateHandles(element, scaleX, scaleY); }
private void UpdateHighlightedElement() { // if (mContextMenuStrip.Visible == false) { ElementRuntime elementRuntime = GetElementRuntimeOver(); mHighlight.CurrentElement = elementRuntime; mHighlightedElementRuntime = elementRuntime; } }
public ElementRuntime ElementRuntimeForArrowInstance(object instance, ElementRuntime container) { // todo: Add verification because we assume the current IElement contains a NOS for the instance string name = (string)LateBinder.GetInstance(instance.GetType()).GetValue(instance, "Name"); ElementRuntime contained = container.GetContainedElementRuntime(name); return(contained); }
public static void InterpolateBetween(ElementRuntime elementRuntime, object firstStateSaveAsObject, object secondStateSaveAsObject, object interpolationValueAsObject, StringBuilder logStringBuilder = null) { StateSave firstStateSave = firstStateSaveAsObject as StateSave; StateSave secondStateSave = secondStateSaveAsObject as StateSave; float interpolationValue = 0; if (interpolationValueAsObject is float) { interpolationValue = (float)interpolationValueAsObject; } if (interpolationValueAsObject is double) { interpolationValue = (float)((double)interpolationValueAsObject); } else if (interpolationValueAsObject is int) { interpolationValue = (int)interpolationValueAsObject; } if (float.IsNaN(interpolationValue)) { throw new Exception("InterpolationValue is NaN"); } StateSave resultingStateSave = StateSaveExtensionMethodsGlueView.CreateCombinedState(firstStateSave, secondStateSave, interpolationValue); string nameOfObject = "unnamed object"; if (elementRuntime.AssociatedNamedObjectSave != null) { nameOfObject = elementRuntime.AssociatedNamedObjectSave.ToString(); } else if (elementRuntime.AssociatedIElement != null) { nameOfObject = elementRuntime.AssociatedIElement.ToString(); } if (logStringBuilder != null) { logStringBuilder.AppendLine("Interpolating " + nameOfObject + " between " + firstStateSave + " and " + secondStateSave + " with value " + interpolationValue); foreach (InstructionSave instruction in resultingStateSave.InstructionSaves) { logStringBuilder.AppendLine("\t" + instruction); } } try { elementRuntime.SetState(resultingStateSave, elementRuntime.AssociatedIElement); } catch (Exception e) { throw new StateSettingException("Error in script trying to interpolate " + nameOfObject + " between " + firstStateSave + " and " + secondStateSave + " with value " + interpolationValue); } }
void OnMouseMove(object sender, EventArgs e) { if (mContextMenuStrip.Visible == false) { ElementRuntime elementRuntime = GlueViewState.Self.CursorState.GetElementRuntimeOver(); mHighlight.CurrentElement = elementRuntime; mHighlightedElementRuntime = elementRuntime; } // do something: }
public void TestScreenSave() { ElementRuntime er = new ElementRuntime(mScreenSave, null, null, null, null); float objectX = er.ContainedElements[0].X; if (objectX != 150) { throw new Exception("variables on named objects in Screens aren't being applied"); } }
public void Show(ElementRuntime elementRuntime, NamedObjectSave nosToShow) { mCurrentElementRuntime = elementRuntime; if (nosToShow != null) { nosToShow.UpdateCustomProperties(); } mCurrentNos = nosToShow; mNosDisplayer.CurrentElement = GlueViewState.Self.CurrentElement; mNosDisplayer.Instance = mCurrentNos; mNosDisplayer.PropertyGrid = mPropertyGrid; }
private void ApplyEventResponseSave(ElementRuntime elementRuntime, EventResponseSave ers) { IElement element = elementRuntime.AssociatedIElement; string projectDirectory = FileManager.GetDirectory(GlueViewState.Self.CurrentGlueProjectFile); string[] lines = GetMethodLines(element, ers, projectDirectory); string fileName = EventResponseSave.GetSharedCodeFullFileName(element, projectDirectory); CodeContext codeContext = new CodeContext(elementRuntime); ApplyLinesInternal(lines, 0, lines.Length, element, codeContext, fileName); }
private void CreateDerivedElementRuntime() { mDerivedEntitySave = new EntitySave(); mDerivedEntitySave.Name = "DerivedVariableSettingEntity"; mDerivedEntitySave.BaseEntity = mEntitySave.Name; ObjectFinder.Self.GlueProject.Entities.Add(mDerivedEntitySave); mDerivedEntitySave.UpdateFromBaseType(); mDerivedEntitySave.GetCustomVariable("CurrentState").DefaultValue = "Uncategorized"; mDerivedElementRuntime = new ElementRuntime(mDerivedEntitySave, null, null, null, null); }
protected virtual void CreatePolygonsForElement(ElementRuntime element) { bool createRectanglesForContainedElements = true; // We want to use coordinates // that match the coordinates of // whatever it is that we're viewing. // Graphical objects like Sprites use the // coordinates of the Layers that they're on, // or of their camera. However Layers themselves // have a destination rectangle which is in pixel coordiantes // so the rectangles that we render need to be in the resolution // of the window. Therefore for Layers we will want to MatchScreenResolution. LayerCoordinateType coordinateType = LayerCoordinateType.MatchCamera; if (element.DirectObjectReference != null) { object directObjectReference = element.DirectObjectReference; coordinateType = CreatePolygonsForObject(directObjectReference, coordinateType); } else if (element.AssociatedNamedObjectSave != null && element.AssociatedNamedObjectSave.GetIsScalableEntity()) { // We used to not want to show contained object scales, but I think we want to now because we're not supporting scaling (yet) in GView. //createRectanglesForContainedElements = false; CreatePolygonForScalableEntity(element); } if (createRectanglesForContainedElements) { for (int i = 0; i < element.ContainedElements.Count; i++) { ElementRuntime e = element.ContainedElements[i]; CreatePolygonsForElement(e); } for (int i = 0; i < element.ElementsInList.Count; i++) { ElementRuntime e = element.ElementsInList[i]; CreatePolygonsForElement(e); } } SpriteManager.MoveToFront(Layer); if (element != null && element.Layer != null && element.Layer.LayerCameraSettings != null && element.Layer.LayerCameraSettings.Orthogonal) { // shared layer camera settings? That seems BAD! //Layer.LayerCameraSettings = element.Layer.LayerCameraSettings; // I think we want to update to prevent modifications on the GlueView // Layer (which can occur to render highlights) from screwing other layers. Layer.LayerCameraSettings = element.Layer.LayerCameraSettings.Clone(); } else { if (coordinateType == LayerCoordinateType.MatchScreenResolution) { Layer.UsePixelCoordinates(); Layer.LayerCameraSettings.LeftDestination = Camera.Main.LeftDestination; Layer.LayerCameraSettings.RightDestination = Camera.Main.RightDestination; Layer.LayerCameraSettings.TopDestination = Camera.Main.TopDestination; Layer.LayerCameraSettings.BottomDestination = Camera.Main.BottomDestination; } else { Layer.LayerCameraSettings = null; } } }