diff --git a/Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/Games/DialogBox.cs b/Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/Games/DialogBox.cs
index 712a4d7bf..509ac23b1 100644
--- a/Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/Games/DialogBox.cs
+++ b/Engines/Forms/FlatRedBall.Forms/FlatRedBall.Forms.Shared/Controls/Games/DialogBox.cs
@@ -132,6 +132,11 @@ protected override void ReactToVisualChanged()
#endregion
+ ///
+ /// Shows the dialog box (adds it to managers and sets IsVisible to true) and begins showing the text.
+ ///
+ /// The text to print out, either immediately or letter-by-letter according to LettersPerSecond.
+ /// The FlatRedBall Layer to add the DialogBox to. If null, the dialog box will not be layered. This will attempt to use a Gum layer matching the FRB layer. This will automatically work if the Layer has been added through the FlatRedBall Editor.
public void Show(string text, FlatRedBall.Graphics.Layer frbLayer = null)
{
base.Show(frbLayer);
@@ -155,7 +160,12 @@ public void Show(IEnumerable pages, FlatRedBall.Graphics.Layer frbLayer
}
}
- public Task ShowAsync(string page) => ShowAsync(new string[] { page });
+ ///
+ /// Shows the dialog box (adds it to managers and sets IsVisible to true) and begins showing the text.
+ ///
+ /// The text to print out, either immediately or letter-by-letter according to LettersPerSecond.
+ /// A task which completes when the text has been displayed and the DialogBox has been dismissed.
+ public Task ShowAsync(string text) => ShowAsync(new string[] { text });
public async Task ShowAsync(IEnumerable pages, FlatRedBall.Graphics.Layer frbLayer = null)
{
diff --git a/FRBDK/Glue/GameCommunicationPlugin/JsonManager/MainGameJsonCommunicationPlugin.cs b/FRBDK/Glue/GameCommunicationPlugin/JsonManager/MainGameJsonCommunicationPlugin.cs
deleted file mode 100644
index 146865c53..000000000
--- a/FRBDK/Glue/GameCommunicationPlugin/JsonManager/MainGameJsonCommunicationPlugin.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-using FlatRedBall.Glue.Plugins;
-using FlatRedBall.Glue.Plugins.ExportedImplementations;
-using FlatRedBall.Glue.Plugins.Interfaces;
-using GameCommunicationPlugin.CodeGeneration;
-using GameCommunicationPlugin.Common;
-using GameJsonCommunicationPlugin.Common;
-using JsonDiffPatchDotNet.Formatters.JsonPatch;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.Composition;
-using System.Diagnostics;
-using System.Reflection;
-using System.Threading.Tasks;
-
-namespace GameJsonCommunicationPlugin.JsonManager
-{
- [Export(typeof(PluginBase))]
- public class MainGameJsonCommunicationPlugin : PluginBase
- {
- private const string PacketType_JsonUpdate = "JsonUpdate";
- private GlueJsonManager _glueJsonManager;
-
- public override string FriendlyName => "Game JSON Communication Plugin";
-
- public override Version Version => new Version(1, 0);
-
- public override bool ShutDown(PluginShutDownReason shutDownReason)
- {
- //Turning this plugin off
- return true;
-
- //ReactToLoadedGlux -= HandleGluxLoaded;
- //ReactToGlueJsonLoad -= HandleReactToGlueJsonLoad;
- //ReactToScreenJsonLoad -= HandleReactToScreenJsonLoad;
- //ReactToEntityJsonLoad -= HandleReactToEntityJsonLoad;
-
- //ReactToGlueJsonSave -= HandleReactToGlueJsonSave;
- //ReactToScreenJsonSave -= HandleReactToScreenJsonSave;
- //ReactToEntityJsonSave -= HandleReactToEntityJsonSave;
-
- //_glueJsonManager = null;
-
- return true;
- }
-
- public override void StartUp()
- {
- //Turning this plugin off
- return;
-
- //_glueJsonManager = new GlueJsonManager();
-
- //ReactToGlueJsonLoad += HandleReactToGlueJsonLoad;
- //ReactToScreenJsonLoad += HandleReactToScreenJsonLoad;
- //ReactToEntityJsonLoad += HandleReactToEntityJsonLoad;
-
- //ReactToGlueJsonSave += HandleReactToGlueJsonSave;
- //ReactToScreenJsonSave += HandleReactToScreenJsonSave;
- //ReactToEntityJsonSave += HandleReactToEntityJsonSave;
-
- //ReactToLoadedGlux += HandleGluxLoaded;
- }
-
- private void HandleGluxLoaded()
- {
- if (GameCommunicationHelper.IsFrbUsesJson())
- {
- EmbeddedCodeManager.Embed(new System.Collections.Generic.List
- {
- "Json.GlueJsonManager.cs",
- "Json.JsonContainer.cs",
- "Json.JsonManager.cs",
- "Json.ScreenJsonContainer.cs",
-
- "Json.Operations.JsonOperations.cs"
- });
-
- Task.Run(async () =>
- {
- var jsonVersion = await GlueCommands.Self.ProjectCommands.AddNugetIfNotAddedWithReturn("Newtonsoft.Json", "12.0.3");
- GlueCommands.Self.ProjectCommands.AddNugetIfNotAdded("JsonDiffPatch.Net", "2.3.0");
-
- var majorVersion = jsonVersion.Substring(0, jsonVersion.IndexOf('.'));
-
- //GlueCommands.Self.ProjectCommands.AddAssemblyBinding("Newtonsoft.Json", "30ad4fe6b2a6aeed", $"0.0.0.0-{majorVersion}.0.0.0", $"{majorVersion}.0.0.0");
- });
- }
- }
-
- private void HandleLoad(string type, string name, string json)
- {
- if (GameCommunicationHelper.IsFrbUsesJson())
- {
- if (_glueJsonManager.Get(type, name) == null)
- {
- _glueJsonManager.Add(type, name);
- }
-
- var jsonManager = _glueJsonManager.Get(type, name);
-
- var container = jsonManager.Reset(json);
- ReactToPluginEvent("GameCommunication_SendPacket", new GameConnectionManager.Packet
- {
- PacketType = PacketType_JsonUpdate,
- Payload = JsonConvert.SerializeObject(new JsonPayload
- {
- Type = type,
- Name = name,
- Patch = JsonConvert.SerializeObject(container)
- })
- });
- }
- }
-
- private void HandleSave(string type, string name, string json)
- {
- if (GameCommunicationHelper.IsFrbUsesJson())
- {
- if (_glueJsonManager.Get(type, name) == null)
- {
- HandleLoad(type, name, "{}");
- }
-
- {
- var jsonManager = _glueJsonManager.Get(type, name);
- var container = jsonManager.UpdateJson(json);
-
- if (container != null)
- {
- Debug.Print($"Changes for {type} {name}");
- Debug.Print(container.Data.ToString());
-
- ReactToPluginEvent("GameCommunication_SendPacket", new GameConnectionManager.Packet
- {
- PacketType = PacketType_JsonUpdate,
- Payload = JsonConvert.SerializeObject(new JsonPayload
- {
- Type = type,
- Name = name,
- Patch = JsonConvert.SerializeObject(container)
- })
- });
- }
- }
- }
- }
-
- private void HandleReactToEntityJsonLoad(string entityName, string json)
- {
- HandleLoad(GlueJsonManager.TYPE_ENTITY, entityName, json);
- }
-
- private void HandleReactToScreenJsonLoad(string screenName, string json)
- {
- HandleLoad(GlueJsonManager.TYPE_SCREEN, screenName, json);
- }
-
- private void HandleReactToGlueJsonLoad(string json)
- {
- HandleLoad(GlueJsonManager.TYPE_GLUE, "", json);
- }
-
- private void HandleReactToEntityJsonSave(string entityName, string json)
- {
- HandleSave(GlueJsonManager.TYPE_ENTITY, entityName, json);
- }
-
- private void HandleReactToScreenJsonSave(string screenName, string json)
- {
- HandleSave(GlueJsonManager.TYPE_SCREEN, screenName, json);
- }
-
- private void HandleReactToGlueJsonSave(string json)
- {
- HandleSave(GlueJsonManager.TYPE_GLUE, "", json);
- }
-
- public override void HandleEvent(string eventName, string payload)
- {
- //Turning plugin off
- return;
- //base.HandleEvent(eventName, payload);
-
- //switch(eventName)
- //{
- // case "GameCommunication_Connected":
- // foreach(var item in _glueJsonManager.GetAll())
- // {
- // var mgr = _glueJsonManager.Get(item.Type, item.Name);
-
- // HandleLoad(item.Type, item.Name, mgr.CurrentJson.ToString());
- // }
-
- // break;
- //}
- }
- }
-
- public class JsonPayload
- {
- public string Type { get; set; }
- public string Name { get; set; }
- public string Patch { get; set; }
- }
-}
diff --git a/FRBDK/Glue/Glue/Errors/CsvErrorReporter.cs b/FRBDK/Glue/Glue/Errors/CsvErrorReporter.cs
index 6d41c97a8..c16c90f4a 100644
--- a/FRBDK/Glue/Glue/Errors/CsvErrorReporter.cs
+++ b/FRBDK/Glue/Glue/Errors/CsvErrorReporter.cs
@@ -17,46 +17,49 @@ public override ErrorViewModel[] GetAllErrors()
List errors = new List();
- var csvs = glueProject.GetAllReferencedFiles()
- .Where(item => item.IsCsvOrTreatedAsCsv)
- .ToArray();
- var customClasses = glueProject.CustomClasses;
- foreach (var rfs in csvs)
+ if(glueProject != null)
{
- var classWithError = customClasses.FirstOrDefault(item =>
+ var csvs = glueProject.GetAllReferencedFiles()
+ .Where(item => item.IsCsvOrTreatedAsCsv)
+ .ToArray();
+ var customClasses = glueProject.CustomClasses;
+ foreach (var rfs in csvs)
{
- return CsvAndCustomClassSameName.IsError(rfs, item);
- });
+ var classWithError = customClasses.FirstOrDefault(item =>
+ {
+ return CsvAndCustomClassSameName.IsError(rfs, item);
+ });
- if (classWithError != null)
- {
- var error = new CsvAndCustomClassSameName(rfs, classWithError);
+ if (classWithError != null)
+ {
+ var error = new CsvAndCustomClassSameName(rfs, classWithError);
- errors.Add(error);
- }
+ errors.Add(error);
+ }
- var filePath = GlueCommands.Self.GetAbsoluteFilePath(rfs);
+ var filePath = GlueCommands.Self.GetAbsoluteFilePath(rfs);
- // See if this has a duplicate
- CsvCodeGenerator.DeserializeToRcr(
- rfs.CsvDelimiter,
- filePath,
- out RuntimeCsvRepresentation rcr, out bool succeeded);
+ // See if this has a duplicate
+ CsvCodeGenerator.DeserializeToRcr(
+ rfs.CsvDelimiter,
+ filePath,
+ out RuntimeCsvRepresentation rcr, out bool succeeded);
- if(succeeded)
- {
- var duplicateError = CsvCodeGenerator.GetDuplicateMessageIfDuplicatesFound(
- rcr,
- rfs.CreatesDictionary,
- filePath.FullPath);
-
- if(!string.IsNullOrEmpty(duplicateError))
+ if(succeeded)
{
- var vm = new CsvDuplicateItemInFileViewModel();
- vm.FilePath = filePath;
- vm.UpdateDetails();
- errors.Add(vm);
+ var duplicateError = CsvCodeGenerator.GetDuplicateMessageIfDuplicatesFound(
+ rcr,
+ rfs.CreatesDictionary,
+ filePath.FullPath);
+
+ if(!string.IsNullOrEmpty(duplicateError))
+ {
+ var vm = new CsvDuplicateItemInFileViewModel();
+ vm.FilePath = filePath;
+ vm.UpdateDetails();
+ errors.Add(vm);
+ }
}
}
}
diff --git a/FRBDK/Glue/Glue/Errors/GlueErrorManager.cs b/FRBDK/Glue/Glue/Errors/GlueErrorManager.cs
index 55ce49743..d86ca8437 100644
--- a/FRBDK/Glue/Glue/Errors/GlueErrorManager.cs
+++ b/FRBDK/Glue/Glue/Errors/GlueErrorManager.cs
@@ -29,7 +29,7 @@ public void Add(ErrorViewModel error)
// Vic says - I don't like this. I think maybe this should get moved out of a plugin?
// Need to think about it a bit...
- PluginManager.CallPluginMethod("Error Window Plugin", "RefreshErrors");
+ PluginManager.CallPluginMethod("Error Window Plugin", "RefreshAllErrors");
}
public void ClearFixedErrors()
diff --git a/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/CameraMainPlugin.cs b/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/CameraMainPlugin.cs
index 85a36a5b2..4f10758e5 100644
--- a/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/CameraMainPlugin.cs
+++ b/FRBDK/Glue/Glue/Plugins/EmbeddedPlugins/CameraPlugin/CameraMainPlugin.cs
@@ -20,7 +20,8 @@ class CameraMainPlugin : EmbeddedPlugin
CameraSettingsControl control;
DisplaySettingsViewModel viewModel = new DisplaySettingsViewModel();
PluginTab tab;
-
+ CameraToolbar cameraToolbar;
+
public static CameraMainPlugin Self { get; private set; }
private bool respondToViewModelChanges = true;
@@ -32,17 +33,27 @@ public override void StartUp()
viewModel.PropertyChanged += HandleDisplaySettingsChanged;
this.ReactToLoadedGlux += HandleLoadedGlux;
+ this.ReactToUnloadedGlux += HandleUnloadedGlux;
+
+ cameraToolbar = new CameraToolbar();
base.AddMenuItemTo(L.Texts.CameraSettings, L.MenuIds.CameraSettingsId, HandleCameraSettings, L.MenuIds.SettingsId);
+ }
- base.AddToToolBar(new CameraToolbar(), "Standard");
+ private void HandleUnloadedGlux()
+ {
+ base.RemoveFromToolbar(cameraToolbar, "Standard");
}
private void HandleLoadedGlux()
{
+
+
+ base.AddToToolBar(cameraToolbar, "Standard");
+
// When the project loads, immediately set the ATI so
// that Glue behaves properly
- if(GlueState.Self.CurrentGlueProject?.DisplaySettings != null)
+ if (GlueState.Self.CurrentGlueProject?.DisplaySettings != null)
{
respondToViewModelChanges = false;
{
diff --git a/FRBDK/Glue/GumPlugin/GumPlugin/MainGumPlugin.cs b/FRBDK/Glue/GumPlugin/GumPlugin/MainGumPlugin.cs
index a7c2e28b8..cd5290b3c 100644
--- a/FRBDK/Glue/GumPlugin/GumPlugin/MainGumPlugin.cs
+++ b/FRBDK/Glue/GumPlugin/GumPlugin/MainGumPlugin.cs
@@ -466,7 +466,6 @@ private void CreateToolbar()
gumToolbar = new GumToolbar();
gumToolbar.DataContext = toolbarViewModel;
gumToolbar.GumButtonClicked += HandleToolbarButtonClick;
- base.AddToToolBar(gumToolbar, Localization.Texts.Tools);
}
public bool HasGum() => AppState.Self.GumProjectSave != null;
@@ -623,6 +622,8 @@ private bool GetIfShouldShowTab(ITreeNode selectedTreeNode)
private void HandleUnloadedGlux()
{
+ base.RemoveFromToolbar(gumToolbar, Localization.Texts.Tools);
+
AssetTypeInfoManager.Self.UnloadProjectSpecificAtis();
AppState.Self.GumProjectSave = null;
@@ -955,6 +956,8 @@ private void HandleGluxLoadEarly()
private async void HandleGluxLoad()
{
+ base.AddToToolBar(gumToolbar, Localization.Texts.Tools);
+
var gumRfs = GumProjectManager.Self.GetRfsForGumProject();
toolbarViewModel.HasGumProject = gumRfs != null;
diff --git a/FRBDK/Glue/OfficialPlugins/ErrorPlugin/MainErrorPlugin.cs b/FRBDK/Glue/OfficialPlugins/ErrorPlugin/MainErrorPlugin.cs
index 9f40d38d0..c9bc02f54 100644
--- a/FRBDK/Glue/OfficialPlugins/ErrorPlugin/MainErrorPlugin.cs
+++ b/FRBDK/Glue/OfficialPlugins/ErrorPlugin/MainErrorPlugin.cs
@@ -66,7 +66,7 @@ public override void StartUp()
RefreshCommands.RefreshErrorsAction = () => RefreshLogic.RefreshAllErrors(errorListViewModel, errorListViewModel.IsOutputErrorCheckingDetailsChecked);
}
- public void RefreshErrors() => RefreshLogic.RefreshAllErrors(errorListViewModel, errorListViewModel.IsOutputErrorCheckingDetailsChecked);
+ public void RefreshAllErrors() => RefreshLogic.RefreshAllErrors(errorListViewModel, errorListViewModel.IsOutputErrorCheckingDetailsChecked);
private void HandleRefreshClicked(object sender, EventArgs e)
{
diff --git a/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Controllers/LevelScreenController.cs b/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Controllers/LevelScreenController.cs
deleted file mode 100644
index ccf7d032c..000000000
--- a/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Controllers/LevelScreenController.cs
+++ /dev/null
@@ -1,413 +0,0 @@
-using FlatRedBall.Glue.Controls;
-using FlatRedBall.Glue.Managers;
-using FlatRedBall.Glue.MVVM;
-using FlatRedBall.Glue.Plugins.ExportedImplementations;
-using FlatRedBall.IO;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using TiledPluginCore.ViewModels;
-using TiledPluginCore.Views;
-using FlatRedBall.Glue.SaveClasses;
-using FlatRedBall.Glue.Elements;
-using System.Collections.Specialized;
-
-namespace TiledPluginCore.Controllers
-{
- class LevelScreenController : Singleton
- {
- #region Fields/Properties
-
- LevelScreenView view;
- LevelScreenViewModel viewModel;
-
- const string IsTmxLevel = nameof(IsTmxLevel);
-
- bool isIgnoringViewModelChanges = false;
-
- #endregion
-
- #region View-related
-
- public bool GetIfShouldShow()
- {
- var screen = GlueState.Self.CurrentScreenSave;
-
- return screen?.Name == "Screens\\GameScreen";
- }
-
- internal LevelScreenView GetView()
- {
- if (view == null)
- {
- view = new LevelScreenView();
- view.RenameScreen += (not, used) => HandleRenameScreenClicked();
-
- viewModel = new ViewModels.LevelScreenViewModel();
- viewModel.PropertyChanged += HandleViewModelPropertyChanged;
- viewModel.TmxFiles.CollectionChanged += HandleTmxFileCollectionChanged;
- view.DataContext = viewModel;
- }
- return view;
- }
-
- internal void HandleTabShown()
- {
- if(viewModel.AutoCreateTmxScreens)
- {
- GenerateScreensForAllTmxFiles();
- }
- }
-
- #endregion
-
- #region View Model
-
- internal void RefreshViewModelTo(FlatRedBall.Glue.SaveClasses.ScreenSave currentScreenSave)
- {
- isIgnoringViewModelChanges = true;
-
- viewModel.GlueObject = currentScreenSave;
-
- RefreshViewModelTmxFileList();
-
- RefreshOrphanedScreens();
-
- viewModel.UpdateFromGlueObject();
-
- isIgnoringViewModelChanges = false;
- }
-
- private void RefreshOrphanedScreens()
- {
- var allScreens = GlueState.Self.CurrentGlueProject?.Screens ?? new List();
-
- List orphanedScreens = new List();
-
- var levelScreens = GetLevelScreens();
-
- foreach(var screen in levelScreens)
- {
- foreach(var tmxFile in screen.ReferencedFiles.Where(item => item.Name.ToLowerInvariant().EndsWith(".tmx")))
- {
- var filePath = GlueCommands.Self.GetAbsoluteFilePath(tmxFile);
-
- if(!filePath.Exists())
- {
- orphanedScreens.Add(screen);
- break;
- }
- }
- }
-
- viewModel.OrphanedScreens.Clear();
- foreach(var screen in orphanedScreens)
- {
- viewModel.OrphanedScreens.Add(screen.Name);
- }
- }
-
- private void RefreshViewModelTmxFileList()
- {
- viewModel.TmxFiles.Clear();
-
- var allTmxFiles = GetAllLevelTmxFiles();
-
- var contentDirectory = GlueState.Self.ContentDirectory;
- foreach (var tmxFile in allTmxFiles)
- {
- viewModel.TmxFiles.Add(FileManager.MakeRelative(tmxFile.FullPath, contentDirectory));
- }
- }
-
- private void HandleTmxFileCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- ////////////Early Out/////////////
- if (isIgnoringViewModelChanges)
- {
- return;
- }
- //////////End Early Out///////////
-
- switch(e.Action)
- {
- case NotifyCollectionChangedAction.Add:
- var newItems = e.NewItems;
-
- if(newItems.Count > 0)
- {
- GenerateScreensForAllTmxFiles();
- }
- break;
- case NotifyCollectionChangedAction.Remove:
-
- foreach(var item in e.OldItems)
- {
- var screenName = GetLevelScreenNameFor(GlueState.Self.ContentDirectory + item);
-
- if(screenName != null)
- {
- var screen = ObjectFinder.Self.GetScreenSave(screenName);
- GlueCommands.Self.GluxCommands.RemoveScreen(screen);
- }
- }
- break;
- }
-
- }
-
- private void HandleViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- ////////////Early Out/////////////
- if(isIgnoringViewModelChanges)
- {
- return;
- }
- //////////End Early Out///////////
-
- switch(e.PropertyName)
- {
- case nameof(viewModel.AutoCreateTmxScreens):
- if(viewModel.AutoCreateTmxScreens)
- {
- GenerateScreensForAllTmxFiles();
- }
- else
- {
- RemoveScreensForAllTmxFiles();
- }
- break;
- case nameof(viewModel.ShowLevelScreensInTreeView):
- var isHidden = !viewModel.ShowLevelScreensInTreeView;
- var tmxLevelScreens =
- GlueState.Self.CurrentGlueProject.Screens.Where(item => item.Properties.GetValue(IsTmxLevel)).ToArray();
- foreach (var screen in tmxLevelScreens)
- {
- screen.IsHiddenInTreeView = isHidden;
- GlueCommands.Self.RefreshCommands.RefreshTreeNodeFor(screen);
- }
- break;
- }
- }
-
- #endregion
-
- #region Utilities
-
- private static List GetAllLevelTmxFiles()
- {
- // This returns all TMX files that are in the content folder
- // and not referenced by a non-level element.
- // They are considered level files if they are files unreferenced by
- // Glue, or if they are referenced only by a level screen.
-
- var contentDirectory = GlueState.Self.ContentDirectory;
- var files = FileManager.GetAllFilesInDirectory(contentDirectory, "tmx").Select(item => new FilePath(item)).ToList();
-
- void RemoveRfsFromTmx(FlatRedBall.Glue.SaveClasses.ReferencedFileSave tmxRfs)
- {
- var filePath = GlueCommands.Self.FileCommands.GetFilePath(tmxRfs);
-
- if (files.Contains(filePath))
- {
- files.Remove(filePath);
- }
- }
-
- foreach(var screen in GlueState.Self.CurrentGlueProject.Screens)
- {
- var isLevel = screen.Properties.GetValue(IsTmxLevel);
- if(!isLevel)
- {
- foreach(var rfs in screen.ReferencedFiles)
- {
- RemoveRfsFromTmx(rfs);
- }
- }
- }
- foreach(var entity in GlueState.Self.CurrentGlueProject.Entities)
- {
- foreach (var rfs in entity.ReferencedFiles)
- {
- RemoveRfsFromTmx(rfs);
- }
- }
-
- foreach (var rfs in GlueState.Self.CurrentGlueProject.GlobalFiles)
- {
- RemoveRfsFromTmx(rfs);
- }
-
- return files;
-
- }
-
- private string GetLevelScreenNameFor(FilePath tmxFile)
- {
- var stripped = tmxFile.NoPathNoExtension
- .Replace(" ", "_")
- .Replace("-", "_")
- .Replace("(", " ")
- .Replace(")", " ");
-
- stripped = char.ToUpper(stripped[0]) + stripped.Substring(1) + "Level";
-
-
-
- return "Screens\\" + stripped;
- }
-
- private List GetLevelScreens()
- {
- List screens = new List();
-
- if(GlueState.Self.CurrentGlueProject != null)
- {
- screens = GlueState.Self.CurrentGlueProject.Screens
- .Where(item => item.Properties.GetValue(IsTmxLevel))
- .ToList();
- }
-
- return screens;
- }
-
-
- #endregion
-
- #region Glue Project
-
- private async void GenerateScreensForAllTmxFiles()
- {
- var tmxFiles = GetAllLevelTmxFiles();
-
- var shouldSave = false;
-
- foreach(var tmxFile in tmxFiles)
- {
- var expectedScreenName = GetLevelScreenNameFor(tmxFile);
-
- var existingScreen = ObjectFinder.Self.GetScreenSave(expectedScreenName);
-
- if(existingScreen == null)
- {
- var newScreen = new ScreenSave();
- newScreen.Name = expectedScreenName;
- newScreen.Properties.SetValue(IsTmxLevel, true);
- newScreen.IsHiddenInTreeView = viewModel.ShowLevelScreensInTreeView == false;
- newScreen.BaseScreen = "Screens\\GameScreen";
-
- await GlueCommands.Self.GluxCommands.ScreenCommands.AddScreen(newScreen, suppressAlreadyExistingFileMessage: true);
- GlueCommands.Self.GluxCommands.ElementCommands.UpdateFromBaseType(newScreen);
-
-
- // add the TMX file:
- var rfs = GlueCommands.Self.GluxCommands.AddSingleFileTo(tmxFile.FullPath, tmxFile.NoPathNoExtension, null, null, false, null, newScreen, null, false);
- var mapRfs = newScreen.GetNamedObject("Map");
- mapRfs.SourceType = SourceType.File;
- mapRfs.SourceFile = rfs.Name;
- mapRfs.SourceName = "Entire File (LayeredTileMap)";
-
- shouldSave = true;
- //GlueCommands.Self.GluxCommands.ScreenCommands.
-
- GlueCommands.Self.GenerateCodeCommands.GenerateElementCode(newScreen);
-
- GlueCommands.Self.RefreshCommands.RefreshTreeNodeFor(newScreen);
-
- }
- }
-
- if(shouldSave)
- {
- GlueCommands.Self.GluxCommands.SaveProjectAndElements();
- GlueCommands.Self.ProjectCommands.SaveProjects();
- }
- }
-
- private void RemoveScreensForAllTmxFiles()
- {
- foreach(var screen in GetLevelScreens())
- {
- TaskManager.Self.AddOrRunIfTasked(() =>
- {
- // don't delete the files, in case the user wants to reference
- // them or re-add.
- GlueCommands.Self.GluxCommands.RemoveScreen(screen);
- }, $"Removing {screen}");
- }
- }
-
- internal async void HandleRenameScreenClicked()
- {
- TextInputWindow tiw = new TextInputWindow();
- tiw.Message = "Enter new TMX name";
-
- tiw.Result = viewModel.SelectedTmxFile;
-
- var result = tiw.ShowDialog();
-
- if (result == System.Windows.Forms.DialogResult.OK)
- {
- // first we rename the screen...
- var currentFilePath = viewModel.SelectedTmxFilePath;
- var currentScreenName = GetLevelScreenNameFor(currentFilePath);
- var currentScreen = ObjectFinder.Self.GetScreenSave(currentScreenName);
-
- var desiredFilePath = new FilePath(GlueState.Self.ContentDirectory + tiw.Result);
- var desiredScreenName = GetLevelScreenNameFor(desiredFilePath);
-
- var desiredScreenNameWithoutScreenPrefix = desiredScreenName.Substring("Screens\\".Length);
-
- var isScreenNameValid = NameVerifier.IsScreenNameValid(desiredScreenNameWithoutScreenPrefix,
- currentScreen, out string whyScreenNameIsntValid);
-
- var rfs = currentScreen.GetReferencedFileSave(viewModel.SelectedTmxFile);
- var isRfsNameValid = NameVerifier.IsReferencedFileNameValid(tiw.Result, rfs.GetAssetTypeInfo(),
- rfs, currentScreen, out string whyRfsIsntValid);
-
- if (currentFilePath.GetDirectoryContainingThis() != desiredFilePath.GetDirectoryContainingThis())
- {
- GlueCommands.Self.DialogCommands.ShowMessageBox("The old file was located in \n" +
- currentFilePath.GetDirectoryContainingThis() + "\n" +
- "The new file is located in \n" +
- desiredFilePath.GetDirectoryContainingThis() + "\n" +
- "Currently Glue does not support changing directories.");
- }
- else if(!isRfsNameValid)
- {
- GlueCommands.Self.DialogCommands.ShowMessageBox(
- "Could not rename the TMX file because it would produce an invalid Glue file name:\n" +
- whyRfsIsntValid);
- }
- else if (!isScreenNameValid)
- {
- GlueCommands.Self.DialogCommands.ShowMessageBox(
- "Could not rename the TMX file because it would produce an invalid screen name:\n" +
- whyScreenNameIsntValid);
- }
- else
-
- {
- await GlueCommands.Self.GluxCommands.ElementCommands.RenameElement(currentScreen, desiredScreenNameWithoutScreenPrefix);
-
-
- GlueCommands.Self.FileCommands.RenameReferencedFileSave(rfs, tiw.Result);
-
- isIgnoringViewModelChanges = true;
-
- RefreshViewModelTmxFileList();
-
- isIgnoringViewModelChanges = false;
-
- GlueCommands.Self.RefreshCommands.RefreshTreeNodeFor(currentScreen);
- }
- // then we rename the file
- }
-
- }
-
- #endregion
- }
-}
diff --git a/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Managers/FileReferenceManager.cs b/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Managers/FileReferenceManager.cs
index 45b731648..f78afcb87 100644
--- a/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Managers/FileReferenceManager.cs
+++ b/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/Managers/FileReferenceManager.cs
@@ -142,9 +142,8 @@ private GeneralResponse GetTmxFileReferences(FilePath fileName, List l
listToFill.AddRange(referencedFiles.Select(item =>new FilePath(item)));
}
- catch(Exception e)
+ catch(Exception)
{
- int m = 3;
}
}
diff --git a/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/TileGraphicsPluginClass.cs b/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/TileGraphicsPluginClass.cs
index 54b01ada0..5ebb62abf 100644
--- a/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/TileGraphicsPluginClass.cs
+++ b/FRBDK/Glue/TileGraphicsPlugin/TileGraphicsPlugin/TileGraphicsPluginClass.cs
@@ -273,10 +273,12 @@ private void AddEvents()
this.ReactToLoadedGluxEarly += HandleGluxLoadEarly;
- this.ReactToLoadedGlux += () =>
+ this.ReactToUnloadedGlux += HandleGluxUnload;
+
+ this.ReactToLoadedGlux += async () =>
{
HandleGluxLoad();
- tiledObjectTypeCreator.RefreshFile();
+ await tiledObjectTypeCreator.RefreshFile();
};
// Adds all objects contained within a file (like TMX)
@@ -295,13 +297,13 @@ private void AddEvents()
//TilesetController.Self.GetTsxDirectoryRelativeToTmx = () => "../Tilesets/";
- this.ReactToChangedPropertyHandler += (changedMember, oldalue, glueElement) =>
+ this.ReactToChangedPropertyHandler += async (changedMember, oldalue, glueElement) =>
{
if(GlueState.Self.CurrentCustomVariable != null)
{
if (changedMember == nameof(CustomVariable.Name))
{
- tiledObjectTypeCreator.RefreshFile();
+ await tiledObjectTypeCreator.RefreshFile();
}
}
@@ -309,40 +311,40 @@ private void AddEvents()
{
if (changedMember == nameof(EntitySave.CreatedByOtherEntities) || changedMember == nameof(EntitySave.Name))
{
- tiledObjectTypeCreator.RefreshFile();
+ await tiledObjectTypeCreator.RefreshFile();
}
}
};
- this.ReactToElementVariableChange += (element, variable) =>
+ this.ReactToElementVariableChange += async (element, variable) =>
{
if ((element as EntitySave)?.CreatedByOtherEntities == true)
{
- tiledObjectTypeCreator.RefreshFile();
+ await tiledObjectTypeCreator.RefreshFile();
}
};
- this.ReactToVariableAdded += (newVariable) =>
+ this.ReactToVariableAdded += async (newVariable) =>
{
var element = EditorObjects.IoC.Container.Get().CurrentElement;
if ((element as EntitySave)?.CreatedByOtherEntities == true)
{
- tiledObjectTypeCreator.RefreshFile();
+ await tiledObjectTypeCreator.RefreshFile();
}
};
- this.ReactToVariableRemoved += (removedVariable) =>
+ this.ReactToVariableRemoved += async (removedVariable) =>
{
var element = EditorObjects.IoC.Container.Get().CurrentElement;
if ((element as EntitySave)?.CreatedByOtherEntities == true)
{
- tiledObjectTypeCreator.RefreshFile();
+ await tiledObjectTypeCreator.RefreshFile();
}
};
- this.NewEntityCreated += (newEntityCreated) =>
+ this.NewEntityCreated += async (newEntityCreated) =>
{
- tiledObjectTypeCreator.RefreshFile();
+ await tiledObjectTypeCreator.RefreshFile();
};
//this.ModifyAddEntityWindow += ModifyAddEntityWindowLogic.HandleModifyAddEntityWindow;
@@ -358,13 +360,15 @@ private void AddEvents()
//this.CreateNewFileHandler += TmxCreationManager.Self.HandleNewTmxCreation;
}
+ private void HandleGluxUnload()
+ {
+ base.RemoveFromToolbar(tiledToolbar, "Tools");
+ }
private void CreateToolbar()
{
tiledToolbar = new TiledToolbar();
tiledToolbar.Opened += HandleToolbarOpened;
- //gumToolbar.GumButtonClicked += HandleToolbarButtonClick;
- base.AddToToolBar(tiledToolbar, "Tools");
}
private void HandleToolbarOpened(object sender, EventArgs e)
@@ -767,6 +771,8 @@ void HandleAdjustDisplayedReferencedFile(ReferencedFileSave rfs, ReferencedFileS
void HandleGluxLoad()
{
+ base.AddToToolBar(tiledToolbar, "Tools");
+
CodeItemAdderManager.Self.RefreshAppendGenerated();
// Add the .cs files which include the map drawable batch classes