本文整理汇总了C#中FlatRedBall.Glue.SaveClasses.NamedObjectSave.GetContainer方法的典型用法代码示例。如果您正苦于以下问题:C# NamedObjectSave.GetContainer方法的具体用法?C# NamedObjectSave.GetContainer怎么用?C# NamedObjectSave.GetContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlatRedBall.Glue.SaveClasses.NamedObjectSave
的用法示例。
在下文中一共展示了NamedObjectSave.GetContainer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTextureCoordinates
public void GetTextureCoordinates(NamedObjectSave nos, out float leftTextureCoordinate, out float rightTextureCoordinate, out float topTextureCoordinate, out float bottomTextureCoordinate, out string fullFileName)
{
var textureVar = nos.InstructionSaves.FirstOrDefault(item => item.Member == "Texture");
var leftTextureCoordinateVar = nos.InstructionSaves.FirstOrDefault(item => item.Member == "LeftTexturePixel");
var rightTextureCoordinateVar = nos.InstructionSaves.FirstOrDefault(item => item.Member == "RightTexturePixel");
var topTextureCoordinateVar = nos.InstructionSaves.FirstOrDefault(item => item.Member == "TopTexturePixel");
var bottomTextureCoordinateVar = nos.InstructionSaves.FirstOrDefault(item => item.Member == "BottomTexturePixel");
leftTextureCoordinate = 0;
rightTextureCoordinate = 1;
topTextureCoordinate = 0;
bottomTextureCoordinate = 1;
fullFileName = null;
if (textureVar != null && textureVar.Value != null)
{
var fileVariableName = textureVar.Value as string;
var container = nos.GetContainer();
var rfs = container.ReferencedFiles.FirstOrDefault((item) =>
{
return FileManager.RemovePath(FileManager.RemoveExtension(item.Name)) == fileVariableName;
});
if (rfs != null)
{
fullFileName = FlatRedBall.Glue.ProjectManager.MakeAbsolute(rfs.Name, true);
}
}
if (leftTextureCoordinateVar != null && leftTextureCoordinateVar.Value != null)
{
leftTextureCoordinate = (float)leftTextureCoordinateVar.Value;
}
if (rightTextureCoordinateVar != null && rightTextureCoordinateVar.Value != null)
{
rightTextureCoordinate = (float)rightTextureCoordinateVar.Value;
}
if (topTextureCoordinateVar != null && topTextureCoordinateVar.Value != null)
{
topTextureCoordinate = (float)topTextureCoordinateVar.Value;
}
if (bottomTextureCoordinateVar != null && bottomTextureCoordinateVar.Value != null)
{
bottomTextureCoordinate = (float)bottomTextureCoordinateVar.Value;
}
}
示例2: ReactToTextureAddressMode
private void ReactToTextureAddressMode(NamedObjectSave namedObjectSave, object oldValue)
{
bool isSprite = namedObjectSave.SourceType == SourceType.FlatRedBallType && namedObjectSave.SourceClassType == "Sprite";
if(isSprite)
{
var addressModeVariable = namedObjectSave.GetCustomVariable("TextureAddressMode");
if (addressModeVariable != null && addressModeVariable.Value != null &&
((TextureAddressMode)(addressModeVariable.Value) == TextureAddressMode.Wrap || (TextureAddressMode)(addressModeVariable.Value) == TextureAddressMode.Mirror))
{
// How big is the texture?
var textureVariable = namedObjectSave.GetCustomVariable("Texture");
if (textureVariable != null && textureVariable.Value != null)
{
string value = textureVariable.Value as string;
var rfs = namedObjectSave.GetContainer().GetReferencedFileSaveByInstanceName(value);
if (rfs != null)
{
var width = ImageHeader.GetDimensions(
ProjectManager.MakeAbsolute(rfs.Name)).Width;
var height = ImageHeader.GetDimensions(
ProjectManager.MakeAbsolute(rfs.Name)).Height;
string whatIsWrong = null;
if (FlatRedBall.Math.MathFunctions.IsPowerOfTwo(width) == false)
{
whatIsWrong = "This Sprite's texture (" + textureVariable.Value + ") has a width of " +
width + " but it should be a power of two to use " + addressModeVariable.Value + " TextureAddressMode";
}
if (FlatRedBall.Math.MathFunctions.IsPowerOfTwo(height) == false)
{
whatIsWrong = "This Sprite's texture (" + textureVariable.Value + ") has a height of " +
height + " but it should be a power of two to use " + addressModeVariable.Value + " TextureAddressMode";
}
if(!string.IsNullOrEmpty(whatIsWrong))
{
whatIsWrong += "\nWhat would you like to do?";
MultiButtonMessageBox mbmb = new MultiButtonMessageBox();
mbmb.MessageText = whatIsWrong;
mbmb.AddButton("Undo the change", DialogResult.Cancel);
mbmb.AddButton("Keep the change (May cause runtime crashes)", DialogResult.Yes);
var result = mbmb.ShowDialog();
if(result == DialogResult.Cancel)
{
addressModeVariable.Value = oldValue;
}
}
}
}
}
}
}
示例3: NamedObjectTreeNode
public TreeNode NamedObjectTreeNode(NamedObjectSave namedObjectSave)
{
IElement container = namedObjectSave.GetContainer();
if (container is ScreenSave)
{
ScreenTreeNode screenTreeNode = GlueState.Self.Find.ScreenTreeNode((ScreenSave)container);
return screenTreeNode.GetTreeNodeFor(namedObjectSave);
}
else if (container is EntitySave)
{
EntityTreeNode entityTreeNode = GlueState.Self.Find.EntityTreeNode((EntitySave)container);
return entityTreeNode.GetTreeNodeFor(namedObjectSave);
}
else
{
return null;
}
}
示例4: MoveObjectOnObjectsRoot
private static bool MoveObjectOnObjectsRoot(TreeNode treeNodeMoving, TreeNode targetNode, NamedObjectSave movingNos, bool succeeded)
{
// Dropped it on the "Objects" tree node
// Let's see if it's the Objects that contains node or another one
IElement parentOfMovingNos = movingNos.GetContainer();
IElement elementMovingInto = ((BaseElementTreeNode)targetNode.Parent).SaveObjectAsElement;
if (parentOfMovingNos == elementMovingInto)
{
if (treeNodeMoving.Parent.IsNamedObjectNode())
{
succeeded = true;
// removing from a list
NamedObjectSave container = treeNodeMoving.Parent.Tag as NamedObjectSave;
IElement elementToAddTo = movingNos.GetContainer();
container.ContainedObjects.Remove(movingNos);
NamedObjectSaveExtensionMethodsGlue.AddNewNamedObjectToElementTreeNode(EditorLogic.CurrentElementTreeNode, movingNos, false);
EditorLogic.CurrentElementTreeNode.UpdateReferencedTreeNodes();
IElement elementToRegenerate = targetNode.Parent.Tag as IElement;
}
}
else
{
succeeded = DragDropNosIntoElement(movingNos, elementMovingInto);
}
return succeeded;
}
示例5: GetActivityForNamedObject
public static void GetActivityForNamedObject(NamedObjectSave namedObjectSave, ICodeBlock codeBlock)
{
///////////////////////////EARLY OUT/////////////////////////////////////////////////
if (
(namedObjectSave.SetByContainer && namedObjectSave.GetContainer() is EntitySave)
||
namedObjectSave.IsDisabled || namedObjectSave.CallActivity == false ||
namedObjectSave.InstantiatedByBase || !namedObjectSave.IsFullyDefined)
{
return;
}
/////////////////////////END EARLY OUT///////////////////////////////////////////////
bool setByDerived = namedObjectSave.SetByDerived;
AddIfConditionalSymbolIfNecesssary(codeBlock, namedObjectSave);
if (!setByDerived)
{
if (namedObjectSave.Instantiate == false)
{
// This may be null or it may be instantiated later by the user, so we should
// handle both cases:
codeBlock = codeBlock.If(namedObjectSave.InstanceName + " != null");
}
if (namedObjectSave.SourceType == SourceType.Entity)
{
// Entities need activity!
codeBlock.Line(namedObjectSave.InstanceName + ".Activity();");
}
else if (namedObjectSave.SourceType == SourceType.FlatRedBallType &&
namedObjectSave.ClassType != null &&
namedObjectSave.ClassType.Contains("PositionedObjectList<"))
{
// Now let's see if the object in the list is an entity
string genericType = namedObjectSave.SourceClassGenericType;
if (genericType.Contains("Entities\\"))
{
codeBlock.For("int i = " + namedObjectSave.InstanceName + ".Count - 1; i > -1; i--")
.If("i < " + namedObjectSave.InstanceName + ".Count")
.Line("// We do the extra if-check because activity could destroy any number of entities")
.Line(namedObjectSave.InstanceName + "[i].Activity();");
}
}
}
// If it's an emitter, call TimedEmit:
ParticleCodeGenerator.GenerateTimedEmit(codeBlock, namedObjectSave);
if (!setByDerived)
{
if (namedObjectSave.Instantiate == false)
{
// end the if-statement we started above.
codeBlock = codeBlock.End();
}
}
AddEndIfIfNecessary(codeBlock, namedObjectSave);
}
示例6: NamedObjectSaveToString
public static string NamedObjectSaveToString(NamedObjectSave nos)
{
IElement container = nos.GetContainer();
string containerName = " (Uncontained)";
if (container != null)
{
containerName = " in " + container.ToString();
}
return nos.ClassType + " " + nos.FieldName + containerName;
}
示例7: RemoveNamedObject
public static void RemoveNamedObject(NamedObjectSave namedObjectToRemove, bool performSave, bool updateUi, List<string> additionalFilesToRemove)
{
StringBuilder removalInformation = new StringBuilder();
// The additionalFilesToRemove is included for consistency with other methods. It may be used later
// There are the following things that need to happen:
// 1. Remove the NamedObject from the Glue project (GLUX)
// 2. Remove any variables that use this NamedObject as their source
// 3. Remove the named object from the GUI
// 4. Update the variables for any NamedObjects that use this element containing this NamedObject
// 5. Find any Elements that contain NamedObjects that are DefinedByBase - if so, see if we should remove those or make them not DefinedByBase
// 6. Remove any events that tunnel into this.
IElement element = namedObjectToRemove.GetContainer();
if (element != null)
{
if (!namedObjectToRemove.RemoveSelfFromNamedObjectList(element.NamedObjects))
{
throw new ArgumentException();
}
#region Remove all CustomVariables that reference the removed NamedObject
for (int i = element.CustomVariables.Count - 1; i > -1; i--)
{
CustomVariable variable = element.CustomVariables[i];
if (variable.SourceObject == namedObjectToRemove.InstanceName)
{
removalInformation.AppendLine("Removed variable " + variable.ToString());
element.CustomVariables.RemoveAt(i);
}
}
#endregion
// Remove any events that use this
for (int i = element.Events.Count - 1; i > -1; i--)
{
EventResponseSave ers = element.Events[i];
if (ers.SourceObject == namedObjectToRemove.InstanceName)
{
removalInformation.AppendLine("Removed event " + ers.ToString());
element.Events.RemoveAt(i);
}
}
// Remove any objects that use this as a layer
for (int i = 0; i < element.NamedObjects.Count; i++)
{
if (element.NamedObjects[i].LayerOn == namedObjectToRemove.InstanceName)
{
removalInformation.AppendLine("Removed the following object from the deleted Layer: " + element.NamedObjects[i].ToString());
element.NamedObjects[i].LayerOn = null;
}
}
element.RefreshStatesToCustomVariables();
#region Ask the user what to do with all NamedObjects that are DefinedByBase
List<IElement> derivedElements = new List<IElement>();
if (element is EntitySave)
{
derivedElements.AddRange(ObjectFinder.Self.GetAllEntitiesThatInheritFrom(element as EntitySave));
}
else
{
derivedElements.AddRange(ObjectFinder.Self.GetAllScreensThatInheritFrom(element as ScreenSave));
}
foreach (IElement derivedElement in derivedElements)
{
// At this point, namedObjectToRemove is already removed from the current Element, so this will only
// return NamedObjects that exist in the derived.
NamedObjectSave derivedNamedObject = derivedElement.GetNamedObjectRecursively(namedObjectToRemove.InstanceName);
if (derivedNamedObject != null && derivedNamedObject != namedObjectToRemove && derivedNamedObject.DefinedByBase)
{
MultiButtonMessageBox mbmb = new MultiButtonMessageBox();
mbmb.MessageText = "What would you like to do with the object " + derivedNamedObject.ToString();
mbmb.AddButton("Keep it", DialogResult.OK);
mbmb.AddButton("Delete it", DialogResult.Cancel);
DialogResult result = mbmb.ShowDialog(MainGlueWindow.Self);
if (result == DialogResult.OK)
{
// Keep it
derivedNamedObject.DefinedByBase = false;
BaseElementTreeNode treeNode = GlueState.Self.Find.ElementTreeNode(derivedElement);
if (updateUi)
{
treeNode.UpdateReferencedTreeNodes();
//.........这里部分代码省略.........