Ver Fonte

Project Manager Launch on Startup

Added a checkbox for non-synced modules that states if the module should launch at startup. Behind the scenes this is done by setting the module's group to launch. The AppCore then loads the group at startup. Actually changing the group can only be done after the module is unregistered - so basically when the engine is shutting down.
Peter Robinson há 3 anos atrás
pai
commit
a554456be8

+ 2 - 2
editor/EditorCore/Themes/BaseTheme/BaseTheme.cs

@@ -120,11 +120,11 @@ function BaseTheme::makeTipProfile(%this)
 
 
 	%this.tipProfile = new GuiControlProfile()
 	%this.tipProfile = new GuiControlProfile()
 	{
 	{
-		fillColor = %this.setAlpha(%this.color3, 220);
+		fillColor = %this.setAlpha(%this.color3, 240);
 
 
 		fontType = %this.font[1];
 		fontType = %this.font[1];
 		fontDirectory = %this.fontDirectory;
 		fontDirectory = %this.fontDirectory;
-		fontSize = %this.fontSize - 2;
+		fontSize = %this.fontSize - 4;
 		fontColor = %this.color1;
 		fontColor = %this.color1;
 
 
 		borderDefault = %tipBorder;
 		borderDefault = %tipBorder;

+ 1 - 1
editor/ProjectManager/ProjectManager.cs

@@ -92,7 +92,7 @@ function ProjectManager::create(%this)
 
 
 function ProjectManager::destroy(%this)
 function ProjectManager::destroy(%this)
 {
 {
-
+	%this.postEvent("ShutDown");
 }
 }
 
 
 function ProjectManager::open(%this)
 function ProjectManager::open(%this)

+ 131 - 13
editor/ProjectManager/scripts/ProjectModuleCard.cs

@@ -1,6 +1,7 @@
 
 
  function ProjectModuleCard::onAdd(%this)
  function ProjectModuleCard::onAdd(%this)
  {
  {
+	 %this.toggleLaunchGroupCount = 0;
 	 %this.chain = new GuiChainCtrl()
 	 %this.chain = new GuiChainCtrl()
 	 {
 	 {
 		 HorizSizing="width";
 		 HorizSizing="width";
@@ -52,7 +53,7 @@
 	ThemeManager.setProfile(%this.versionText, "codeProfile");
 	ThemeManager.setProfile(%this.versionText, "codeProfile");
 	%this.chain.add(%this.versionText);
 	%this.chain.add(%this.versionText);
 
 
-	%this.addSpacer();
+	%this.addSpacer(%this.chain);
 
 
 	%this.descriptionText = new GuiControl()
 	%this.descriptionText = new GuiControl()
 	{
 	{
@@ -67,6 +68,28 @@
 	ThemeManager.setProfile(%this.descriptionText, "normalTextProfile");
 	ThemeManager.setProfile(%this.descriptionText, "normalTextProfile");
 	%this.chain.add(%this.descriptionText);
 	%this.chain.add(%this.descriptionText);
 
 
+	%this.optionGroup = %this.addSubSection("Module Options");
+
+	%this.launchGroupCheckBox = new GuiCheckBoxCtrl()
+	{
+		Class="ProjectManagerLaunchGroupCheckBox";
+		HorizSizing="width";
+		Position = "0 0";
+		Extent = "286 26";
+		Text = "Start on Project Launch";
+		BoxOffset = "0 2";
+		TextOffset = "22 0";
+		TextExtent = "264 26";
+		vAlign = "Middle";
+		Tooltip = "This change will be applied after restarting.";
+	};
+	ThemeManager.setProfile(%this.launchGroupCheckBox, "checkboxProfile");
+	ThemeManager.setProfile(%this.launchGroupCheckBox, "tipProfile", "TooltipProfile");
+	%this.optionGroup.add(%this.launchGroupCheckBox);
+	%this.launchGroupCheckBox.addListener(%this);
+
+	%this.addEmptySpace(30, %this.optionGroup);
+
 	%this.addSubSection("Dependencies");
 	%this.addSubSection("Dependencies");
 
 
 	%this.dependList = new GuiChainCtrl()
 	%this.dependList = new GuiChainCtrl()
@@ -99,20 +122,20 @@
 	%this.startListening(ThemeManager);
 	%this.startListening(ThemeManager);
  }
  }
 
 
-function ProjectModuleCard::addSpacer(%this)
+function ProjectModuleCard::addSubSection(%this, %name)
 {
 {
-	%spacer = new GuiControl()
+	%chain = new GuiChainCtrl()
 	{
 	{
 		HorizSizing="width";
 		HorizSizing="width";
+		VertSizing="height";
 		Position = "0 0";
 		Position = "0 0";
-		Extent = "286 6";
+		Extent = "286 0";
+		IsVertical = "1";
+		ChildSpacing = -4;
 	};
 	};
-	ThemeManager.setProfile(%spacer, "spacerProfile");
-	%this.chain.add(%spacer);
-}
+	ThemeManager.setProfile(%chain, "emptyProfile");
+	%this.chain.add(%chain);
 
 
-function ProjectModuleCard::addSubSection(%this, %name)
-{
 	%subSection = new GuiControl()
 	%subSection = new GuiControl()
 	{
 	{
 		HorizSizing="width";
 		HorizSizing="width";
@@ -121,18 +144,40 @@ function ProjectModuleCard::addSubSection(%this, %name)
 		FontSizeAdjust = "0.8";
 		FontSizeAdjust = "0.8";
 	};
 	};
 	ThemeManager.setProfile(%subSection, "titleProfile");
 	ThemeManager.setProfile(%subSection, "titleProfile");
-	%this.chain.add(%subSection);
+	%chain.add(%subSection);
+
+	%this.addSpacer(%chain);
+	%this.addEmptySpace(8, %chain);
 
 
-	%this.addSpacer();
+	return %chain;
+}
+
+function ProjectModuleCard::addSpacer(%this, %chain)
+{
+   %spacer = new GuiControl()
+   {
+	   HorizSizing="width";
+	   Position = "0 0";
+	   Extent = "286 6";
+   };
+   ThemeManager.setProfile(%spacer, "spacerProfile");
+   %chain.add(%spacer);
 
 
+   return %spacer;
+}
+
+function ProjectModuleCard::addEmptySpace(%this, %size, %chain)
+{
 	%empty = new GuiControl()
 	%empty = new GuiControl()
 	{
 	{
 		HorizSizing="width";
 		HorizSizing="width";
 		Position = "0 0";
 		Position = "0 0";
-		Extent = "286 8";
+		Extent = "286" SPC %size;
 	};
 	};
 	ThemeManager.setProfile(%empty, "emptyProfile");
 	ThemeManager.setProfile(%empty, "emptyProfile");
-	%this.chain.add(%empty);
+	%chain.add(%empty);
+
+	return %empty;
 }
 }
 
 
 function ProjectModuleCard::onThemeChange(%this, %theme)
 function ProjectModuleCard::onThemeChange(%this, %theme)
@@ -145,6 +190,7 @@ function ProjectModuleCard::show(%this, %module)
 {
 {
 	if(isObject(%module))
 	if(isObject(%module))
 	{
 	{
+		%this.activeModule = %module;
 		%this.moduleID = %module.moduleID;
 		%this.moduleID = %module.moduleID;
 		%this.versionID = %module.versionID;
 		%this.versionID = %module.versionID;
 
 
@@ -173,6 +219,21 @@ function ProjectModuleCard::show(%this, %module)
 
 
 		}
 		}
 
 
+		%this.optionGroup.visible = false;
+		if(!%module.Synchronized)
+		{
+			%this.optionGroup.visible = true;
+			%this.launchGroupCheckBox.setStateOn(%module.Group $= "launch");
+			for(%i = 0; %i < %this.toggleLaunchGroupCount; %i++)
+			{
+				if(%this.toggleLaunchGroup[%i] $= %this.activeModule.getModulePath())
+				{
+					%this.launchGroupCheckBox.setStateOn(!%this.launchGroupCheckBox.getStateOn());
+					break;
+				}
+			}
+		}
+
 		%this.visible = true;
 		%this.visible = true;
 		%this.dependList.show(%module);
 		%this.dependList.show(%module);
 	}
 	}
@@ -180,6 +241,7 @@ function ProjectModuleCard::show(%this, %module)
 
 
 function ProjectModuleCard::hide(%this)
 function ProjectModuleCard::hide(%this)
 {
 {
+	%this.activeModule = 0;
 	%this.moduleID = "";
 	%this.moduleID = "";
 	%this.versionID = 0;
 	%this.versionID = 0;
 	%this.visible = false;
 	%this.visible = false;
@@ -243,3 +305,59 @@ function ProjectModuleCard::onButtonClick(%this)
 {
 {
 	%this.postEvent(%this.button.getText() @ "Click");
 	%this.postEvent(%this.button.getText() @ "Click");
 }
 }
+
+function ProjectManagerLaunchGroupCheckBox::onClick(%this)
+{
+	%state = %this.getStateOn();
+	%this.postEvent("LauchGroupClick", %state);
+}
+
+function ProjectModuleCard::onLauchGroupClick(%this, %state)
+{
+	%this.startListening(ProjectManager);
+	if(isObject(%this.activeModule))
+	{
+		if((%state && %this.activeModule.group $= "launch") || (!%state && %this.activeModule.group !$= "launch"))
+		{
+			%path = %this.activeModule.getModulePath();
+			for(%i = 0; %i < %this.toggleLaunchGroupCount; %i++)
+			{
+				if(%this.toggleLaunchGroup[%i] $= %path)
+				{
+					%this.toggleLaunchGroup[%i] = "";
+				}
+			}
+		}
+		else
+		{
+			%this.toggleLaunchGroup[%this.toggleLaunchGroupCount] = %this.activeModule.getModulePath();
+			%this.toggleLaunchGroupCount++;
+		}
+	}
+}
+
+function ProjectModuleCard::onShutDown(%this)
+{
+	for(%i = 0; %i < %this.toggleLaunchGroupCount; %i++)
+	{
+		%path = pathConcat(%this.toggleLaunchGroup[%i], "module.taml");
+		if(%path !$= "" && isFile(%path))
+		{
+			%this.toggleLaunchGroupForPath(%path);
+		}
+	}
+}
+
+function ProjectModuleCard::toggleLaunchGroupForPath(%this, %path)
+{
+	%module = TamlRead(%path);
+	if(%module.group $= "launch")
+	{
+		%module.group = "";
+	}
+	else
+	{
+		%module.group = "launch";
+	}
+	TamlWrite(%module, %path);
+}

+ 1 - 1
engine/source/module/moduleDefinition_ScriptBinding.h

@@ -115,7 +115,7 @@ ConsoleMethodWithDocs(ModuleDefinition, removeDependency, ConsoleBool, 3, 3, (mo
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 
 
 /*! Returns the path to the module directory.
 /*! Returns the path to the module directory.
-    @return (bool success) Whether the module dependency was removed or not.
+    @return A path to the module definition.
 */
 */
 ConsoleMethodWithDocs(ModuleDefinition, getModulePath, ConsoleString, 2, 2, ())
 ConsoleMethodWithDocs(ModuleDefinition, getModulePath, ConsoleString, 2, 2, ())
 {
 {