Browse Source

Added UnversionedLibDir to config

Brian Fiete 6 years ago
parent
commit
f258b4a25b

+ 1 - 0
BeefLibs/Beefy2D/src/utils/StructuredData.bf

@@ -410,6 +410,7 @@ namespace Beefy.utils
 				result = Enum.Parse<T>((StringView)obj);
 			else
 				return;
+
 			if (result case .Ok(var parsedVal))
 				val = parsedVal;
 		}

+ 3 - 16
IDE/dist/BeefConfig.toml

@@ -1,19 +1,6 @@
+Version = 1
+UnversionedLibDirs = ["../../BeefLibs"]
+
 [Registry.minlib]
 Version = "1.0.0"
 Location = { Path = "../mintest/minlib" }
-
-[Registry.corlib]
-Version = "1.0.0"
-Location = { Path = "../../BeefLibs/corlib" }
-
-[Registry.Beefy2D]
-Version = "1.0.0"
-Location = { Path = "../../BeefLibs/Beefy2D" }
-
-[Registry.SDL2]
-Version = "1.0.0"
-Location = { Path = "../../BeefLibs/SDL2" }
-
-[Registry.MiniZ]
-Version = "1.0.0"
-Location = { Path = "../../BeefLibs/MiniZ" }

+ 3 - 5
IDE/dist/BeefConfig_host.toml

@@ -1,8 +1,6 @@
+Version = 1
+UnversionedLibDirs = ["../../../BeefLibs"]
+
 [Registry.minlib]
 Version = "1.0.0"
 Location = { Path = "../../mintest/minlib" }
-
-[Registry.corlib]
-Version = "1.0.0"
-Location = { Path = "../../../BeefLibs/corlib" }
-

+ 2 - 15
IDE/dist/BeefConfig_install.toml

@@ -1,15 +1,2 @@
-[Registry.corlib]
-Version = "1.0.0"
-Location = { Path = "../BeefLibs/corlib" }
-
-[Registry.SDL2]
-Version = "1.0.0"
-Location = { Path = "../BeefLibs/SDL2" }
-
-[Registry.MiniZ]
-Version = "1.0.0"
-Location = { Path = "../BeefLibs/MiniZ" }
-
-[Registry.Beefy2D]
-Version = "1.0.0"
-Location = { Path = "../BeefLibs/Beefy2D" }
+Version = 1
+UnversionedLibDirs = ["../BeefLibs"]

+ 43 - 2
IDE/src/BeefConfig.bf

@@ -63,7 +63,7 @@ namespace IDE
 					regEntry.mLocation.Parse(data).IgnoreError();
 			}
 
-			for (data.Enumerate("LibDirs"))
+			for (data.Enumerate("UnversionedLibDirs"))
 			{
 				String dirStr = scope .();
 				data.GetCurString(dirStr);
@@ -74,6 +74,39 @@ namespace IDE
 					libDir.mPath = new String(dirStr);
 					libDir.mConfigFile = configFile;
 					mLibDirectories.Add(libDir);
+
+					String absPath = scope .();
+					Path.GetAbsolutePath(libDir.mPath, configFile.mConfigDir, absPath);
+
+					for (var entry in Directory.EnumerateDirectories(absPath))
+					{
+						String projName = scope .();
+						entry.GetFileName(projName);
+						
+						String filePath = scope .();
+						entry.GetFilePath(filePath);
+
+						String projFilePath = scope .();
+						projFilePath.Concat(filePath, "/BeefProj.toml");
+
+						if (File.Exists(projFilePath))
+						{
+							RegistryEntry regEntry = new RegistryEntry();
+							regEntry.mProjName = new String(projName);
+							mRegistry.Add(regEntry);
+
+							regEntry.mConfigFile = configFile;
+
+							var verString = scope String();
+							data.GetString("Version", verString);
+							regEntry.mVersion = new SemVer();
+							regEntry.mVersion.Parse("0.0.0");
+
+							regEntry.mLocation = new VerSpecRecord();
+							using (data.Open("Location"))
+								regEntry.mLocation.SetPath(filePath);
+						}
+					}
 				}
 			}
 
@@ -82,6 +115,11 @@ namespace IDE
 			return .Ok;
 		}
 
+		public void Refresh()
+		{
+			Load().IgnoreError();
+		}
+
 		public void QueuePaths(StringView topLevelDir)
 		{
 			let dir = scope String(topLevelDir);
@@ -96,7 +134,7 @@ namespace IDE
 				if (File.Exists(path))
 				{
 					if (mConfigPathQueue.Contains(path))
-						break; // We have this and everthing under it already
+						break; // We have this and everything under it already
 					mConfigPathQueue.Add(new String(path));
 				}
 
@@ -116,6 +154,9 @@ namespace IDE
 
 		public Result<void> Load()
 		{
+			ClearAndDeleteItems(mRegistry);
+			ClearAndDeleteItems(mConfigFiles);
+
 			for (int i = mConfigPathQueue.Count - 1; i >= 0; i--)
 			{
 				let path = mConfigPathQueue[i];

+ 2 - 0
IDE/src/IDEApp.bf

@@ -2225,6 +2225,8 @@ namespace IDE
             
             if (StructuredLoad(data, workspaceFileName) case .Err(let err))
             {
+				mBeefConfig.Refresh();
+
 				switch (err)
 				{
 				case .FormatError(int lineNum):

+ 24 - 0
IDE/src/ScriptManager.bf

@@ -1762,6 +1762,30 @@ namespace IDE
 			}
 		}
 
+		[IDECommand]
+		public void AssertIsAtColumn(String fileName, int column)
+		{
+			String filePath = scope String();
+			FixSrcPath(fileName, filePath);
+
+			var sourceViewPanel = GetActiveSourceViewPanel();
+			if (sourceViewPanel == null)
+				return;
+
+			if (!Path.Equals(filePath, sourceViewPanel.mFilePath))
+			{
+				ScriptManager.sActiveManager.Fail("Expected source file '{0}', got '{1}'", filePath, sourceViewPanel.mFilePath);
+				return;
+			}
+
+			let atColumn = sourceViewPanel.mEditWidget.mEditWidgetContent.CursorLineAndColumn.mColumn + 1;
+			if (atColumn != column)
+			{
+				ScriptManager.sActiveManager.Fail("Expected column '{0}', got '{1}'", column, atColumn);
+				return;
+			}
+		}
+
 		[IDECommand]
 		public void GotoTextSkip(String findText, int skipIdx)
 		{

+ 3 - 1
IDE/src/ui/ProjectPanel.bf

@@ -1291,7 +1291,7 @@ namespace IDE.ui
 		                    projectsReferenced.Add(selectedProjectItem.mProject);
 		                    folderCount++;
 		                }
-		                else if (selectedProjectItem is ProjectItem)
+		                else
 		                {
 		                    projectsReferenced.Add(selectedProjectItem.mProject);
 		                    fileCount++;
@@ -1749,6 +1749,8 @@ namespace IDE.ui
         void ImportProject()
         {
 #if !CLI
+			gApp.mBeefConfig.Refresh();
+
             var fileDialog = scope OpenFileDialog();
 			fileDialog.ShowReadOnly = false;
             fileDialog.Title = "Import Project";