diff --git a/.github/workflows/Engine.yml b/.github/workflows/Engine.yml
index a41eaea76..708a2a1cb 100644
--- a/.github/workflows/Engine.yml
+++ b/.github/workflows/Engine.yml
@@ -1,10 +1,7 @@
name: Build Engine DLLs
on:
- push:
- branches: [ "NetStandard" ]
- pull_request:
- branches: [ "NetStandard" ]
+ workflow_dispatch:
jobs:
build:
diff --git a/.github/workflows/glue.yml b/.github/workflows/glue.yml
index 7492e241e..07936aac3 100644
--- a/.github/workflows/glue.yml
+++ b/.github/workflows/glue.yml
@@ -1,10 +1,7 @@
name: FlatRedBall Editor
on:
- push:
- branches: [ "NetStandard" ]
- pull_request:
- branches: [ "NetStandard" ]
+ workflow_dispatch:
jobs:
build:
@@ -49,7 +46,7 @@ jobs:
- name: Build
run: dotnet build -c ${{ matrix.configuration }} 'FlatRedBall\FRBDK\Glue\Glue with All.sln'
- - name: Zip and upload templates
+ - name: Zip and upload FRBDK
env: # Or as an environment variable
username: ${{ secrets.FTPUSERNAME }}
password: ${{ secrets.FTPPASSWORD }}
diff --git a/Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/FloatRectangle.cs b/Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/FloatRectangle.cs
index 754f10628..26a1b2c18 100644
--- a/Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/FloatRectangle.cs
+++ b/Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/FloatRectangle.cs
@@ -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;
diff --git a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/BuildServerUploaderConsole.csproj b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/BuildServerUploaderConsole.csproj
index 0a291f607..11e9acfdf 100644
--- a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/BuildServerUploaderConsole.csproj
+++ b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/BuildServerUploaderConsole.csproj
@@ -142,6 +142,13 @@
3.5
+
+
+ ..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll
+ True
+ True
+
+
3.5
diff --git a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/CopyFrbdkAndPluginsToReleaseFolder.cs b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/CopyFrbdkAndPluginsToReleaseFolder.cs
index d30135dd4..d642bb2ad 100644
--- a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/CopyFrbdkAndPluginsToReleaseFolder.cs
+++ b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/CopyFrbdkAndPluginsToReleaseFolder.cs
@@ -1,6 +1,10 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.IO;
+using System.Net.Http;
+using System.Threading.Tasks;
using FlatRedBall.IO;
+using Ionic.Zip;
namespace BuildServerUploaderConsole.Processes
{
@@ -54,7 +58,7 @@ public CopyFrbdkAndPluginsToReleaseFolder(IResults results)
_excludeFiles.Add(@"Thumbs.db");
}
- public override void ExecuteStep()
+ public override async Task ExecuteStepAsync()
{
//Create Directory
var frbdkForZipDirectory = DirectoryHelper.FrbdkForZipReleaseDirectory;
@@ -71,11 +75,14 @@ public override void ExecuteStep()
CopyDirectory(DirectoryHelper.FrbdkDirectory + extraTool, "Copied" + extraTool, subdirectoryName:extraTool);
}
- if(Directory.Exists(DirectoryHelper.GumBuildDirectory))
- {
- // todo - this doesn't exist on github actions
- CopyDirectory(DirectoryHelper.GumBuildDirectory, "Copied Gum", "Gum");
- }
+ // Gum can't be built on github actions because it fails with dotnetbuild - something to do with
+ // it being net 4.7.1 or maybe XNA? So instead...
+ //if(Directory.Exists(DirectoryHelper.GumBuildDirectory))
+ //{
+ // CopyDirectory(DirectoryHelper.GumBuildDirectory, "Copied Gum", "Gum");
+ //}
+ // ... we'll download the file:
+ await DownloadGum();
@@ -103,6 +110,49 @@ public override void ExecuteStep()
CopyDirectory(DirectoryHelper.GluePublishDestinationFolder, "Copied " + DirectoryHelper.GluePublishDestinationFolder);
CopyDirectory(DirectoryHelper.FrbdkDirectory + GlueRegularBuildDestinationFolder + @"Plugins\", "Copied plugins to Glue", @"\Plugins\");
+ // save the run FlatRedBall batch file:
+ System.IO.File.WriteAllText(path:frbdkForZipDirectory + "Run FlatRedBall.bat", contents: @"START """" ""%~dp0Xna 4 Tools\GlueFormsCore.exe""");
+
+ }
+
+ async Task DownloadGum()
+ {
+ string url = "http://files.flatredball.com/content/Tools/Gum/Gum.zip"; // Replace with your actual URL
+ string targetDirectory = Path.Combine(_destDirectory, "Gum");
+ string zipFilePath = Path.Combine(targetDirectory, "Gum.zip");
+ string unzipDirectory = targetDirectory;
+
+ Results.WriteMessage($"Downloading Gum from {url}");
+
+ if(!System.IO.Directory.Exists(targetDirectory))
+ {
+ Directory.CreateDirectory(targetDirectory);
+ }
+
+ using (var client = new HttpClient())
+ {
+ // Download the file
+ using (var response = await client.GetAsync(url))
+ {
+ using (Stream stream = await response.Content.ReadAsStreamAsync())
+ {
+ using (FileStream fileStream = new FileStream(zipFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
+ {
+ await stream.CopyToAsync(fileStream);
+ }
+ }
+ }
+
+ Results.WriteMessage($"Unzipping Gum from {zipFilePath}");
+
+ // Unzip the file
+ System.IO.Compression.ZipFile.ExtractToDirectory(zipFilePath, unzipDirectory);
+
+ // delete the zip - we don't need it anymore and it bloats the ultimate file:
+ System.IO.File.Delete(zipFilePath);
+
+ Results.WriteMessage($"Gum unzipped to {unzipDirectory}");
+ }
}
private void CopyDirectory(string sourceDirectory, string successfulMessage, string subdirectoryName = null)
diff --git a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/DirectoryHelper.cs b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/DirectoryHelper.cs
index 99a403b17..f04789c61 100644
--- a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/DirectoryHelper.cs
+++ b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/DirectoryHelper.cs
@@ -76,11 +76,23 @@ public static string CheckoutDirectory
public static string FrbdkDirectory => FlatRedBallDirectory + "FRBDK/";
+ static string GithubFilePath =>
+ System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "GitHub");
+
public static string GumRootDirectory
{
get
{
- return FileManager.MakeAbsolute("../../../../../../../Gum/");
+ string defaultGumFilePath = System.IO.Path.Combine(GithubFilePath, "Gum\\");
+ if(System.IO.Directory.Exists(defaultGumFilePath))
+ {
+ // This makes the BuildServerUploader portable
+ return defaultGumFilePath;
+ }
+ else
+ {
+ return FileManager.MakeAbsolute("../../../../../../../Gum/");
+ }
}
}
diff --git a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/ProcessStep.cs b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/ProcessStep.cs
index 50463de85..b5c185539 100644
--- a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/ProcessStep.cs
+++ b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/ProcessStep.cs
@@ -1,4 +1,6 @@
-namespace BuildServerUploaderConsole.Processes
+using System.Threading.Tasks;
+
+namespace BuildServerUploaderConsole.Processes
{
public class ProcessStep
{
@@ -32,6 +34,7 @@ public ProcessStep(string message, IResults results)
}
public virtual void ExecuteStep() { }
+ public virtual Task ExecuteStepAsync() { return Task.CompletedTask; }
#endregion
}
}
diff --git a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/UploadFilesToFrbServer.cs b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/UploadFilesToFrbServer.cs
index 6402b3816..46b2385c2 100644
--- a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/UploadFilesToFrbServer.cs
+++ b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/UploadFilesToFrbServer.cs
@@ -15,7 +15,8 @@ public enum UploadType
{
Entire,
EngineAndTemplatesOnly,
- FrbdkOnly
+ FrbdkOnly,
+ GumOnly,
}
#endregion
@@ -144,19 +145,37 @@ public override void ExecuteStep()
UploadFrbdkFiles();
}
+ else if(uploadType == UploadType.GumOnly)
+ {
+ UploadGumFiles();
+ }
}
private void UploadGumFiles()
{
string localFile = FileManager.GetDirectory(DirectoryHelper.GumBuildDirectory) + "Gum.zip";
-
+ if(!System.IO.File.Exists(localFile))
+ {
+ throw new Exception($"{localFile} file doesn't exist for upload");
+ }
string targetFile = gumFolder + FileManager.RemovePath(localFile);
+ Results.WriteMessage("Uploading " + localFile + " to " + targetFile);
SftpManager.UploadFile(
- localFile, host, targetFile, Username, Password);
+ localFile, host, targetFile, Username, Password, PrintOutput);
Results.WriteMessage(localFile + " uploaded to " + targetFile);
}
+ DateTime lastWrite = DateTime.Now;
+ void PrintOutput(ulong amount)
+ {
+ if(DateTime.Now - lastWrite > TimeSpan.FromSeconds(1))
+ {
+ Results.WriteMessage("Uploaded " + (amount / 1024).ToString("N0") + " kbytes");
+ lastWrite = DateTime.Now;
+ }
+ }
+
private void UploadFrbdkFiles()
{
string localFile = ZipFrbdk.DestinationFile;
@@ -164,7 +183,7 @@ private void UploadFrbdkFiles()
string targetFile = _ftpFolder + FileManager.RemovePath(localFile);
SftpManager.UploadFile(
- localFile, host, targetFile, Username, Password);
+ localFile, host, targetFile, Username, Password, PrintOutput);
Results.WriteMessage(localFile + " uploaded to " + targetFile);
@@ -196,7 +215,7 @@ private void UploadEngineFiles()
string destination = _ftpFolder + "SingleDlls/" + fileName;
SftpManager.UploadFileWithOpenConnection(
- localFile, destination, client);
+ localFile, destination, client, PrintOutput);
Results.WriteMessage(engineFiles[i].DestinationFile + " uploaded to " + destination);
@@ -205,7 +224,7 @@ private void UploadEngineFiles()
}
}
- private static void UploadTemplateFiles(string _ftpFolder, IResults Results)
+ private void UploadTemplateFiles(string _ftpFolder, IResults Results)
{
string templateDirectory = DirectoryHelper.ReleaseDirectory + @"ZippedTemplates/";
@@ -226,7 +245,7 @@ private static void UploadTemplateFiles(string _ftpFolder, IResults Results)
string localFile = templateDirectory + fileName;
string destination = _ftpFolder + "ZippedTemplates/" + fileName;
SftpManager.UploadFileWithOpenConnection(
- localFile, destination, client);
+ localFile, destination, client, PrintOutput);
Results.WriteMessage(file + " uploaded to " + destination);
diff --git a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/ZipHelper.cs b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/ZipHelper.cs
index 133fdb8ae..f1bbdea96 100644
--- a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/ZipHelper.cs
+++ b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Processes/ZipHelper.cs
@@ -46,7 +46,7 @@ public static void CreateZip(IResults results, string destinationDirectory, stri
}
}
- results.WriteMessage($" Finished adding {containedObjects} files to zip");
+ results.WriteMessage($" Finished adding {containedObjects.Count} files to zip");
zip.Save(fullZipFileName);
diff --git a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Program.cs b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Program.cs
index c9e9d081e..88585fbf7 100644
--- a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Program.cs
+++ b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Program.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Threading.Tasks;
using BuildServerUploaderConsole.Processes;
using FlatRedBall.IO;
@@ -15,6 +16,7 @@ public static class CommandLineCommands
public const string ZipAndUploadFrbdk = "zipanduploadfrbdk";
public const string ChangeEngineVersion = "changeengineversion";
public const string ChangeFrbdkVersion = "changefrbdkversion";
+ public const string ZipAndUploadGum = "zipanduploadgum";
}
@@ -24,7 +26,7 @@ public class Program
private static readonly List ProcessSteps = new List();
private static readonly IResults Results = new TraceResults();
- static void Main(string[] args)
+ static async Task Main(string[] args)
{
FileManager.PreserveCase = true;
@@ -61,6 +63,10 @@ static void Main(string[] args)
case CommandLineCommands.ChangeFrbdkVersion:
CreateChangeFrbdkVersion();
break;
+ case CommandLineCommands.ZipAndUploadGum:
+ ProcessSteps.Add(new ZipGum(Results));
+ ProcessSteps.Add(new UploadFilesToFrbServer(Results, UploadType.GumOnly, null, null));
+ break;
case "":
break;
default:
@@ -83,7 +89,7 @@ static void Main(string[] args)
//CreateCopyToInstallerSteps(true);
}
- ExecuteSteps();
+ await ExecuteSteps();
}
@@ -121,10 +127,12 @@ private static void CreateZipAndUploadFrbdk(string[] args)
if (args.Length < 3)
{
- throw new Exception("Expected 3 arguments: {operation} {username} {password}, but only got " + args.Length + "arguments");
+ ProcessSteps.Add(new UploadFilesToFrbServer(Results, UploadType.FrbdkOnly, null, null));
+ }
+ else
+ {
+ ProcessSteps.Add(new UploadFilesToFrbServer(Results, UploadType.FrbdkOnly, args[1], args[2]));
}
-
- ProcessSteps.Add(new UploadFilesToFrbServer(Results, UploadType.FrbdkOnly, args[1], args[2]));
}
private static void CreateCopyToTemplatesSteps()
@@ -160,13 +168,14 @@ private static void CreateUploadProcessSteps()
ProcessSteps.Add(new UploadFilesToFrbServer(Results, UploadType.Entire, null, null));
}
- private static void ExecuteSteps()
+ private static async Task ExecuteSteps()
{
for (int i = 0; i < ProcessSteps.Count; i++)
{
int step1Based = i + 1;
Results.WriteMessage($"Processing {step1Based}/{ProcessSteps.Count} : {ProcessSteps[i].Message}");
ProcessSteps[i].ExecuteStep();
+ await ProcessSteps[i].ExecuteStepAsync();
}
}
diff --git a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Sftp/SftpManager.cs b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Sftp/SftpManager.cs
index 8c6bfb56e..cebc22c72 100644
--- a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Sftp/SftpManager.cs
+++ b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/Sftp/SftpManager.cs
@@ -37,19 +37,19 @@ public static SftpClient GetClient(string host, string userName, string password
return new SftpClient(host, userName, password);
}
- public static void UploadFile(string localFileToUpload, string host, string targetFile, string userName, string password)
+ public static void UploadFile(string localFileToUpload, string host, string targetFile, string userName, string password, Action uploadCallback)
{
using (var sftp = new SftpClient(host, userName, password))
{
sftp.OperationTimeout = new TimeSpan(0, 0, seconds: 40);
sftp.Connect();
- UploadFileWithOpenConnection(localFileToUpload, targetFile, sftp);
+ UploadFileWithOpenConnection(localFileToUpload, targetFile, sftp, uploadCallback);
sftp.Disconnect();
}
}
- public static void UploadFileWithOpenConnection(string localFileToUpload, string targetFile, SftpClient sftp)
+ public static void UploadFileWithOpenConnection(string localFileToUpload, string targetFile, SftpClient sftp, Action uploadCallback)
{
var directory = FlatRedBall.IO.FileManager.GetDirectory(targetFile, FlatRedBall.IO.RelativeType.Relative);
@@ -57,7 +57,7 @@ public static void UploadFileWithOpenConnection(string localFileToUpload, string
using (var file = File.OpenRead(localFileToUpload))
{
- sftp.UploadFile(file, targetFile, canOverride: true);
+ sftp.UploadFile(file, targetFile, canOverride: true, uploadCallback);
}
}
diff --git a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/packages.config b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/packages.config
index d7b227b2a..5fca1836f 100644
--- a/FRBDK/BuildServerUploader/BuildServerUploaderConsole/packages.config
+++ b/FRBDK/BuildServerUploader/BuildServerUploaderConsole/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file