浏览代码

Project Manager Display and Add Dependencies to Modules

This allows a user to quickly see a list of dependencies for a module and add dependencies to modules that aren't synced to the library. Loading library modules using dependencies on custom modules is the foundation of how the project manager works.
Peter Robinson 3 年之前
父节点
当前提交
ca486cd57f

+ 5 - 0
editor/EditorCore/EditorForm.cs

@@ -182,3 +182,8 @@ function EditorFormDropDown::onClose(%this)
 {
 	%this.form.postEvent("DropDownClosed", %this);
 }
+
+function EditorFormDropDown::onSelect(%this)
+{
+	%this.form.postEvent("DropDownSelect", %this);
+}

+ 66 - 0
editor/EditorCore/Themes/BaseTheme/BaseTheme.cs

@@ -65,6 +65,7 @@ function BaseTheme::onAdd(%this)
 	%this.makeListBoxProfile();
 	%this.makeGraphProfile();
 	%this.makeTextDisplayProfile();
+	%this.makeSubListProfile();
 }
 
 function BaseTheme::init(%this)
@@ -423,6 +424,71 @@ function BaseTheme::makeItemSelectProfile(%this)
 	};
 }
 
+function BaseTheme::makeSubListProfile(%this)
+{
+	%vBorder = new GuiBorderProfile()
+	{
+		padding = 1;
+		paddingHL = 1;
+		paddingSL = 1;
+		paddingNA = 1;
+
+		border = 1;
+		borderHL = 1;
+		borderSL = 1;
+		borderNA = 1;
+
+		borderColor = %this.setAlpha(%this.color1, 150);
+		borderColorHL = %this.setAlpha(%this.color1, 240);
+		borderColorSL = %this.setAlpha(%this.color5, 200);
+		borderColorNA = %this.setAlpha(%this.color1, 100);
+
+		underfill = false;
+	};
+
+	%hBorder = new GuiBorderProfile()
+	{
+		padding = 5;
+		paddingHL = 5;
+		paddingSL = 5;
+		paddingNA = 5;
+
+		border = 1;
+		borderHL = 1;
+		borderSL = 1;
+		borderNA = 1;
+
+		borderColor = %this.setAlpha(%this.color1, 150);
+		borderColorHL = %this.setAlpha(%this.color1, 240);
+		borderColorSL = %this.setAlpha(%this.color5, 200);
+		borderColorNA = %this.setAlpha(%this.color1, 100);
+
+		underfill = false;
+	};
+
+	%this.subListProfile = new GuiControlProfile()
+	{
+		fillColor = %this.setAlpha(%this.color1, 100);
+		fillColorHL = %this.setAlpha(%this.color1, 200);
+		fillColorSL = %this.color5;
+		fillColorNA = %this.setAlpha(%this.color1, 10);
+
+		fontType = %this.font[3];
+		fontDirectory = %this.fontDirectory;
+		fontSize = %this.fontSize - 2;
+		fontColor = %this.setAlpha(%this.color4, 150);
+		fontColorHL = %this.adjustValue(%this.color4, 10);
+		fontColorSL = %this.color1;
+		fontColorNA = %this.setAlpha(%this.color4, 50);
+		align = Center;
+		vAlgin = Middle;
+
+		borderDefault = %vBorder;
+		borderLeft = %hBorder;
+		borderRight = %hBorder;
+	};
+}
+
 function BaseTheme::makeButtonProfile(%this)
 {
 	%borderLightH = new GuiBorderProfile()

+ 2 - 0
editor/ProjectManager/ProjectManager.cs

@@ -26,6 +26,8 @@ function ProjectManager::create(%this)
 	exec("./scripts/ProjectGamePanel.cs");
 	exec("./scripts/ProjectLibraryPanel.cs");
 	exec("./scripts/ProjectModuleCard.cs");
+	exec("./scripts/ProjectModuleDependList.cs");
+	exec("./scripts/NewDependencyDialog.cs");
 
 	%this.guiPage = EditorCore.RegisterEditor("Project Manager", %this);
 

+ 157 - 0
editor/ProjectManager/scripts/NewDependencyDialog.cs

@@ -0,0 +1,157 @@
+
+function NewDependencyDialog::init(%this, %width, %height)
+{
+	//Get the dialog contents
+	%window = %this.getObject(0);
+	%content = %window.getObject(0);
+
+	//Create the file text box
+	%form = new GuiGridCtrl()
+	{
+		class = "EditorForm";
+		extent = %width SPC %height;
+		cellSizeX = %width;
+		cellSizeY = 50;
+	};
+	%form.addListener(%this);
+
+	%item = %form.addFormItem("Dependency", %width SPC 30);
+	%this.moduleDropDown = %form.createDropDownItem(%item);
+
+	%item = %form.addFormItem("Version", %width SPC 30);
+	%this.versionDropDown = %form.createDropDownItem(%item);
+
+	%this.populateModuleDropDown();
+	%this.populateVersionDropDown();
+
+	%content.add(%form);
+
+	%this.cancelButton = new GuiButtonCtrl()
+	{
+		HorizSizing = "right";
+		VertSizing = "bottom";
+		Position = "278 120";
+		Extent = "100 30";
+		Text = "Cancel";
+		Command = %this.getID() @ ".onClose();";
+	};
+	ThemeManager.setProfile(%this.cancelButton, "buttonProfile");
+
+	%this.createButton = new GuiButtonCtrl()
+	{
+		HorizSizing = "right";
+		VertSizing = "bottom";
+		Position = "388 118";
+		Extent = "100 34";
+		Text = "Add";
+		Command = %this.getID() @ ".onCreate();";
+	};
+	ThemeManager.setProfile(%this.createButton, "primaryButtonProfile");
+
+	%content.add(%this.feedback);
+	%content.add(%this.cancelButton);
+	%content.add(%this.createButton);
+
+	%this.validate();
+}
+
+function NewDependencyDialog::populateModuleDropDown(%this)
+{
+	%this.moduleDropDown.clearItems();
+
+	%allModules = ModuleDatabase.findModules(false);
+
+	for(%i = 0; %i < getWordCount(%allModules); %i++)
+	{
+		%mod = getWord(%allModules, %i);
+		if(%mod.ModuleID !$= "AppCore")
+		{
+			if(%this.versionList[%mod.ModuleID] $= "")
+			{
+				%this.moduleDropDown.addItem(%mod.ModuleID);
+				%this.versionList[%mod.ModuleID] = %mod.VersionID;
+			}
+			else
+			{
+				%this.versionList[%mod.ModuleID] = %this.versionList[%mod.ModuleID] SPC %mod.VersionID;
+			}
+		}
+	}
+	%this.moduleDropDown.sortByText();
+	%this.moduleDropDown.insertItem(0, "");
+	%this.moduleDropDown.setSelected(0);
+}
+
+function NewDependencyDialog::onDropDownClosed(%this, %dropDown)
+{
+	%this.validate();
+}
+
+function NewDependencyDialog::onDropDownSelect(%this, %dropDown)
+{
+	if(%dropDown == %this.moduleDropDown)
+	{
+		%this.populateVersionDropDown();
+	}
+}
+
+function NewDependencyDialog::populateVersionDropDown(%this)
+{
+	%this.versionDropDown.clearItems();
+
+	if(%this.moduleDropDown.getText() !$= "")
+	{
+		%versionList = %this.versionList[%this.moduleDropDown.getText()];
+		for(%i = 0; %i < getWordCount(%versionList); %i++)
+		{
+			%version = getWord(%versionList, %i);
+			%this.versionDropDown.addItem(%version);
+		}
+		%this.versionDropDown.sortByText();
+		%this.versionDropDown.insertItem(0, "Latest");
+		%this.versionDropDown.setSelected(0);
+	}
+}
+
+function NewDependencyDialog::Validate(%this)
+{
+	%this.createButton.active = false;
+
+	%module = %this.moduleDropDown.getText();
+
+	if(%module $= "")
+	{
+		return false;
+	}
+
+	%this.createButton.active = true;
+	return true;
+}
+
+function NewDependencyDialog::onClose(%this)
+{
+	Canvas.popDialog(%this);
+	%this.postEvent("DialogClosed", %this);
+}
+
+function NewDependencyDialog::onCreate(%this)
+{
+	if(%this.validate())
+	{
+		%module = %this.moduleDropDown.getText();
+		%version = %this.versionDropDown.getText();
+		if(%version $= "Latest")
+		{
+			%version = "0";
+		}
+
+		%data = new ScriptObject()
+		{
+			module = %module;
+			version = %version;
+		};
+
+		%this.postEvent("DependencyAdded", %data);
+		%this.onClose();
+	}
+}

+ 55 - 10
editor/ProjectManager/scripts/ProjectModuleCard.cs

@@ -18,7 +18,7 @@
 		HorizSizing="width";
 		Position = "0 13";
 		Extent = "286 38";
-		Text = "ModuleName";
+		Text = "";
 		FontSizeAdjust = "1.4";
 	};
 	ThemeManager.setProfile(%this.titleText, "titleProfile");
@@ -52,14 +52,7 @@
 	ThemeManager.setProfile(%this.versionText, "codeProfile");
 	%this.chain.add(%this.versionText);
 
-	%this.spacer = new GuiControl()
-	{
-		HorizSizing="width";
-		Position = "0 0";
-		Extent = "286 6";
-	};
-	ThemeManager.setProfile(%this.spacer, "spacerProfile");
-	%this.chain.add(%this.spacer);
+	%this.addSpacer();
 
 	%this.descriptionText = new GuiControl()
 	{
@@ -67,13 +60,28 @@
 		Position = "0 10";
 		Extent = "286 150";
 		MinExtent = "250 150";
-		Text = "Demonstrates the ability to create rope and chains using joints.";
+		Text = "";
 		TextWrap = 1;
 		TextExtend = 1;
 	};
 	ThemeManager.setProfile(%this.descriptionText, "normalTextProfile");
 	%this.chain.add(%this.descriptionText);
 
+	%this.addSubSection("Dependencies");
+
+	%this.dependList = new GuiChainCtrl()
+	{
+		Class = ProjectModuleDependList;
+		HorizSizing="width";
+		VertSizing="height";
+		Position = "0 0";
+		Extent = "286 100";
+		IsVertical = "1";
+		ChildSpacing = 2;
+	};
+   ThemeManager.setProfile(%this.dependList, "emptyProfile");
+   %this.chain.add(%this.dependList);
+
 	%this.button = new GuiButtonCtrl()
 	{
 		Class="ProjectModuleCardButton";
@@ -91,6 +99,42 @@
 	%this.startListening(ThemeManager);
  }
 
+function ProjectModuleCard::addSpacer(%this)
+{
+	%spacer = new GuiControl()
+	{
+		HorizSizing="width";
+		Position = "0 0";
+		Extent = "286 6";
+	};
+	ThemeManager.setProfile(%spacer, "spacerProfile");
+	%this.chain.add(%spacer);
+}
+
+function ProjectModuleCard::addSubSection(%this, %name)
+{
+	%subSection = new GuiControl()
+	{
+		HorizSizing="width";
+		Extent = "286 24";
+		Text = %name;
+		FontSizeAdjust = "0.8";
+	};
+	ThemeManager.setProfile(%subSection, "titleProfile");
+	%this.chain.add(%subSection);
+
+	%this.addSpacer();
+
+	%empty = new GuiControl()
+	{
+		HorizSizing="width";
+		Position = "0 0";
+		Extent = "286 8";
+	};
+	ThemeManager.setProfile(%empty, "emptyProfile");
+	%this.chain.add(%empty);
+}
+
 function ProjectModuleCard::onThemeChange(%this, %theme)
 {
 	%this.authorText.FontColor = %theme.color5;
@@ -130,6 +174,7 @@ function ProjectModuleCard::show(%this, %module)
 		}
 
 		%this.visible = true;
+		%this.dependList.show(%module);
 	}
 }
 

+ 135 - 0
editor/ProjectManager/scripts/ProjectModuleDependList.cs

@@ -0,0 +1,135 @@
+
+function ProjectModuleDependList::onAdd(%this)
+{
+	%this.startListening(ThemeManager);
+}
+
+function ProjectModuleDependList::onThemeChange(%this, %theme)
+{
+	if(isObject(%this.activeModule))
+	{
+		%this.show(%this.activeModule);
+	}
+}
+
+function ProjectModuleDependList::show(%this, %module)
+{
+	%this.activeModule = %module;
+	%this.clearItems();
+
+	for(%i = 0; %i < %module.getdependencyCount(); %i++)
+	{
+		%dep = %module.getDependency(%i);
+		%name = getWord(%dep, 0);
+		%version = getWord(%dep, 1);
+		if(%version $= "*" || %version $= "0")
+		{
+			%version = "Latest";
+		}
+		%this.addDependItem(%name, %version);
+	}
+
+	if(!%module.Synchronized)
+	{
+		%this.addAddButton();
+	}
+}
+
+function ProjectModuleDependList::hide(%this)
+{
+	%this.activeModule = 0;
+	%this.clearItems();
+}
+
+function ProjectModuleDependList::clearItems(%this)
+{
+	for(%i = %this.getCount() - 1; %i >= 0; %i--)
+	{
+		%item = %this.getObject(%i);
+		%item.delete();
+	}
+}
+
+function ProjectModuleDependList::addDependItem(%this, %name, %version)
+{
+	%width = getWord(%this.extent, 0) - 6;
+	%text = new GuiControl()
+	{
+		HorizSizing="width";
+		Position = "3 0";
+		Extent = %width SPC "26";
+		Text = %name @ ":" @ %version;
+		Align = "Left";
+		VAlign = "Middle";
+	};
+	ThemeManager.setProfile(%text, "subListProfile");
+	%this.add(%text);
+}
+
+function ProjectModuleDependList::addAddButton(%this)
+{
+	%width = 140;
+	%addButton = new GuiButtonCtrl()
+	{
+		Class="ProjectModuleDependButton";
+		ButtonEvent = "AddDepend";
+		ButtonData = "";
+		HorizSizing="right";
+		Position = "3 0";
+		Extent = %width SPC "26";
+		MinExtent = %width SPC "26";
+		Text = "+Add Dependency";
+		Align = "Center";
+		VAlign = "Middle";
+		TextExtend = 1;
+	};
+	ThemeManager.setProfile(%addButton, "subListProfile");
+	%this.add(%addButton);
+	%this.startListening(%addButton);
+}
+
+function ProjectModuleDependButton::onClick(%this)
+{
+	%this.postEvent(%this.buttonEvent, %this.buttonData);
+}
+
+function ProjectModuleDependList::onAddDepend(%this)
+{
+	%width = 500;
+	%height = 190;
+	%dialog = new GuiControl()
+	{
+		class = "NewDependencyDialog";
+		superclass = "EditorDialog";
+		dialogSize = (%width + 8) SPC (%height + 8);
+		dialogCanClose = true;
+		dialogText = "New Dependency";
+	};
+	%dialog.init(%width, %height);
+	%this.startListening(%dialog);
+
+	Canvas.pushDialog(%dialog);
+}
+
+function ProjectModuleDependList::onDependencyAdded(%this, %data)
+{
+	%this.activeModule.addDependency(%data.module, %data.version);
+	%this.activeModule.save();
+	%this.show(%this.activeModule);
+}
+
+function ProjectModuleDependList::onRemoveDepend(%this, %data)
+{
+
+}
+
+function ProjectModuleDependList::onDialogClosed(%this, %dialog)
+{
+	%this.dialog = %dialog;
+	%this.schedule(100, "deleteDialog");
+}
+
+function ProjectModuleDependList::deleteDialog(%this)
+{
+	%this.dialog.delete();
+}

+ 1 - 1
editor/main.cs

@@ -29,7 +29,7 @@ EditorManager.scanModules( "./" );
 
 // Load various editors
 EditorManager.LoadExplicit("EditorConsole");
-//Editormanager.LoadExplicit("ProjectManager");//Someday soon...
+Editormanager.LoadExplicit("ProjectManager");
 EditorManager.LoadExplicit("AssetAdmin");
 
 if(!isObject(AppCore))