Skip to content

Commit

Permalink
Display script compile status after compile
Browse files Browse the repository at this point in the history
  • Loading branch information
drojf committed Aug 20, 2022
1 parent 221109b commit c421b9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Assets.Scripts.Core.AssetManagement/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public class AssetManager {
public string debugLastVoice { get; private set; } = "No voice played yet";
public string debugLastOtherAudio { get; private set; } = "No other audio played yet";

public int numCompileOK { get; private set; }
public int numCompileFail { get; private set; }

/// <summary>
/// Get the artset at the given index
/// </summary>
Expand Down Expand Up @@ -170,10 +173,12 @@ public void CompileFolder(string srcDir, string destDir)
try
{
new BGItoMG(text2, text3);
numCompileOK++;
}
catch (Exception arg)
{
Debug.LogError($"Failed to compile script {fileNameWithoutExtension}!\r\n{arg}");
numCompileFail++;
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions Assets.Scripts.UI/MainUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,19 @@ public void InitializeModMenuAndToaster(GameSystem gameSystem)
{
this.toaster = new MODToaster();
this.modMenu = new MODMenu(gameSystem);

// On startup, display a toast indicating how many scripts were compiled (or failed to compile)
int numFail = GameSystem.Instance.AssetManager.numCompileFail;
int numOK = GameSystem.Instance.AssetManager.numCompileOK;
int total = numOK + numFail;
if (numFail > 0)
{
MODToaster.Show($"FAILED compiling {numFail}/{total} scripts");
}
else if(numOK > 0)
{
MODToaster.Show($"Compiled {numOK} scripts OK");
}
}

// TODO: An empty OnGUI costs .03ms per frame and produces a little garbage, even if empty/not doing anything
Expand Down

0 comments on commit c421b9a

Please sign in to comment.