Skip to content

Commit

Permalink
Merge branch 'NetStandard' of https://github.com/vchelaru/FlatRedBall
Browse files Browse the repository at this point in the history
…into NetStandard
  • Loading branch information
vchelaru committed Apr 2, 2024
2 parents 89af208 + 95173e7 commit c8448af
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public bool Visible
if (mVisible != value)
{
mVisible = value;

UpdateShapes();
}

Expand Down Expand Up @@ -936,7 +937,9 @@ public virtual void UpdateShapes()
#region Create nodes to match how many nodes are in the network
while (mNodes.Count > mNodeVisibleRepresentation.Count)
{
Polygon newPolygon = Polygon.CreateEquilateral(4, 1, MathHelper.PiOver4);
Polygon newPolygon = Polygon.CreateEquilateral(4,
4, // radius
MathHelper.PiOver4);
newPolygon.Name = "NodeNetwork Polygon";

const bool makeAutomaticallyUpdated = false;
Expand Down Expand Up @@ -971,7 +974,8 @@ public virtual void UpdateShapes()
mNodeVisibleRepresentation[i].ScaleBy(
GetVisibleNodeRadius(SpriteManager.Camera, i) /
mNodeVisibleRepresentation[i].BoundingRadius);
mNodeVisibleRepresentation[i].UpdateDependencies(-1, true);

mNodeVisibleRepresentation[i].ForceUpdateDependencies();

foreach (Link link in mNodes[i].mLinks)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public void Inflate(float horizontalAmount, float verticalAmount)
Bottom -= verticalAmount;
}

public bool IsPointInside(float x, float y)
{
return x >= Left && x <= Right && y <= Top && y >= Bottom;
}

public override string ToString()
{
return "Top:" + Top + " Left:" + Left + " Bottom:" + Bottom + " Right:" + Right;
Expand Down
8 changes: 5 additions & 3 deletions FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ public static void GenerateFieldsAndProperties(EntitySave entity, ICodeBlock cod
public static void GenerateActivity(IElement saveObject, ICodeBlock codeBlock)
{
codeBlock.Line("#if DEBUG");

// in codeblock, write code to check if the mLastTimeCalledActivity is equal to the current time. If so, throw an exception
// 9/2/2023 - activity gets called 2x at the beginning. I'm not sure if this is desirable, but until I figure this out, I'm going
// to tolerate double calls on frame 0
codeBlock.Line("if(mLastTimeCalledActivity > 0 && mLastTimeCalledActivity == FlatRedBall.TimeManager.CurrentScreenTime)")
// to tolerate double calls on frame 0.
// Miguel 02/04/2024 - Setting TimeFactor = 0 causes time to not advance causing this exception, but I think it should be a valid
// setting the user can choose.
codeBlock.Line("if(TimeManager.TimeFactor > 0 && mLastTimeCalledActivity > 0 && mLastTimeCalledActivity == FlatRedBall.TimeManager.CurrentScreenTime)")
.Line("{")
.Line(" throw new System.Exception(\"Activity was called twice in the same frame. This can cause objects to move 2x as fast.\");")
.Line("}")
Expand Down
16 changes: 12 additions & 4 deletions FRBDK/Glue/Glue/FormHelpers/RightClickHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ private static void PopulateRightClickMenuItemsShared(ITreeNode targetNode, Menu
Add(L.Texts.FolderAdd, () => RightClickHelper.AddFolderClick(targetNode), image: FolderImage);
AddSeparator();
Add(L.Texts.ViewInExplorer, () => RightClickHelper.ViewInExplorerClick(targetNode));
AddEvent(L.Texts.CopyPathClipboard, (_, _) => HandleCopyToClipboardClick(targetNode));
Add(L.Texts.CopyPathClipboard, () => HandleCopyToClipboardClick(targetNode));

AddSeparator();
if (targetNode.IsFolderInFilesContainerNode())
{
Expand Down Expand Up @@ -833,11 +834,18 @@ private static void PopulateRightClickMenuItemsShared(ITreeNode targetNode, Menu
Add(L.Texts.ViewInExplorer, () => RightClickHelper.ViewInExplorerClick(targetNode));
Add(L.Texts.Open, () => HandleOpen(targetNode));
AddItem(mFindAllReferences);
AddEvent(L.Texts.CopyPathClipboard, (_,_) => HandleCopyToClipboardClick(targetNode));
Add(L.Texts.CopyPathClipboard, () => HandleCopyToClipboardClick(targetNode));
var rfs = targetNode.Tag as ReferencedFileSave;
var name = rfs.GetInstanceName();
Add($"Copy Code Instance Name ({name})", () =>
{
Clipboard.SetText(name);


});
AddSeparator();

AddItem(mCreateZipPackage);
var rfs = (ReferencedFileSave)targetNode.Tag;

AddSeparator();

Expand Down Expand Up @@ -917,7 +925,7 @@ private static void PopulateRightClickMenuItemsShared(ITreeNode targetNode, Menu
{
Add("View code folder", () => ViewCodeFolderInExplorerClick(targetNode));
}
AddEvent(L.Texts.CopyPathClipboard, (_, _) => HandleCopyToClipboardClick(targetNode));
Add(L.Texts.CopyPathClipboard, () => HandleCopyToClipboardClick(targetNode));

AddSeparator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,24 @@ private AssetTypeInfo CreateAtiForTileNodeNetwork()
//toReturn.FindByNameSyntax = $"Collisions.First(item => item.Name == \"OBJECTNAME\");";

toReturn.GetObjectFromFileFunc = GetTileNodeNetworkObjectFromFileFunc;
toReturn.VariableDefinitions.Add(new VariableDefinition() { Name = "Visible", DefaultValue = "false", Type = "bool" });

var visibleVariableDefinition = new VariableDefinition() { Name = "Visible", DefaultValue = "false", Type = "bool" };
visibleVariableDefinition.UsesCustomCodeGeneration = true;
visibleVariableDefinition.CustomGenerationFunc = (element, nos, rfs, layer) =>
{
var isVisible = (nos.GetCustomVariable("Visible")?.Value as bool?) == true;
var visibleText = isVisible ? "true" : "false";
return @$"
{{
var wasSuppressedForNodeNetwork = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue;
FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = false;
{nos.InstanceName}.Visible = {visibleText};
FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = wasSuppressedForNodeNetwork;
}}
";
};

toReturn.VariableDefinitions.Add(visibleVariableDefinition);
toReturn.ConstructorFunc = GenerateTileNodeNetworkConstructionFunc;
return toReturn;
}
Expand Down

0 comments on commit c8448af

Please sign in to comment.