Commit 79057b74 authored by ATREVI Dieudonne's avatar ATREVI Dieudonne
Browse files

- Merge with the command line code

parent fcb9d06b
......@@ -65,6 +65,7 @@ public class LoadEnv : MonoBehaviour
cam_Movement.enabled = false;
menuM = gameObject.GetComponent<MenuManager>();
menuM.CheckCommandLine(); // The Command Line Checker works when it's called here not in MenuManager Start()
}
/// <summary>
......
......@@ -44,9 +44,9 @@ public class MenuManager : MonoBehaviour
Dropdown configFilesMenu; // GUI object to select the scenario
GameObject menu; // the menu gameObject
GameObject panel; // the panel gameObject
GameObject configPanel; // the panel to set the config parameters
GameObject configPanel, wall; // the panel to set the config parameters
LoadEnv env;
/// <summary>
/// initialize the menu
/// </summary>
......@@ -58,6 +58,7 @@ public class MenuManager : MonoBehaviour
menu = GameObject.FindGameObjectWithTag("Menu");
panel = GameObject.FindGameObjectWithTag("Panel");
configPanel = GameObject.FindGameObjectWithTag("configPanel");
wall = GameObject.FindGameObjectWithTag("Obst");
obstReader = new ObstaclesReader();
......@@ -66,6 +67,7 @@ public class MenuManager : MonoBehaviour
configFilesMenu.options.Clear();
Time.timeScale = 0;
//CheckCommandLine(); // Fab: Doesn't work when i tested. I call it in the LoadEnv start and it works
}
/// <summary>
......@@ -97,9 +99,9 @@ public class MenuManager : MonoBehaviour
/// <summary>
/// Check if argument are given and start scenario if needed
/// command line: ChAOS.exe ScenarioPath width(optional) height(optional)
/// command line: ChAOS.exe -s ScenarioPath -r width(optional) height(optional)
/// </summary>
private void CheckCommandLine()
public void CheckCommandLine()
{
string [] arguments = System.Environment.GetCommandLineArgs();
if (arguments.Length >1 && !Application.isEditor)
......@@ -107,14 +109,21 @@ public class MenuManager : MonoBehaviour
// Parse Command Line
CommandLineParser CommandLine = new CommandLineParser(arguments);
configPath = CommandLine.GetScenarioFile();
// StartScenario
ConfigReader.LoadConfig(configPath);
obstReader.clear();
obstReader.createObstacles(ConfigReader.obstaclesFile, ConfigReader.stageInfos);
LoadEnv env = gameObject.GetComponent<LoadEnv>();
env = gameObject.GetComponent<LoadEnv>();
env.loadScenario(ConfigReader.trajectoriesDir);
ConfigReader.camResolution = CommandLine.GetCamResolution();
menu.SetActive(false);
panel.SetActive(false);
configPanel.SetActive(false);
Time.timeScale = 1;
}
}
......@@ -170,76 +179,21 @@ public class MenuManager : MonoBehaviour
configPanel.SetActive(false);
}
/*/// <summary>
/// Build the default scenarios folder path from the application path
/// </summary>
/// <returns>default scenarios folder path</returns>
public string defaultScenarioPath()
{
string pathPlayer = Application.dataPath;
int lastIndex = pathPlayer.LastIndexOf('/');
string dataPath = pathPlayer.Remove(lastIndex, pathPlayer.Length - lastIndex);
string scenarioPath = dataPath + "/Scenarios";
if (Directory.Exists(scenarioPath))
return scenarioPath;
return dataPath;
}
/// <summary>
/// update the dropdown menu listing the scenarios
/// show/hide menu
/// </summary>
/// <param name="NewPath">path to the current scenario folder</param>
public void updateConfigList(string NewPath)
public void toogleMenu()
{
if (configFilesMenu == null)
return;
panel.SetActive(!panel.activeSelf);
DirectoryInfo dir;
if (Directory.Exists(inputConfigPath.text))
dir = new DirectoryInfo(inputConfigPath.text);
else
// Pause the scenario when showing the menu
if(Time.timeScale == 1)
{
string dataPath = defaultScenarioPath();
dir = new DirectoryInfo(dataPath);
Time.timeScale = 0;
}
FileInfo[] infos = dir.GetFiles("*.xml");
configFilesMenu.options.Clear();
configFilesMenu.options.Add(new Dropdown.OptionData("NONE"));
foreach (FileInfo i in infos)
{
configFilesMenu.options.Add(new Dropdown.OptionData(i.Name.Remove(i.Name.Length - 4)));
else{
Time.timeScale = 1;
}
configFilesMenu.value = 0;
configFilesMenu.RefreshShownValue();
}
/// <summary>
/// Update the current scenario file
/// </summary>
/// <param name="i">the id of the selection from the dropdown menu</param>
public void updateConfigFile(int i)
{
if (configFilesMenu == null || configFilesMenu.value == 0)
return;
configPath = inputConfigPath.text + '/' + configFilesMenu.options[configFilesMenu.value].text + ".xml";
//cam.transform.position = ConfigReader.camPosition;
//cam.transform.rotation = Quaternion.Euler(ConfigReader.camRotation);
}*/
/// <summary>
/// show/hide menu
/// </summary>
public void toogleMenu()
{
panel.SetActive(!panel.activeSelf);
// Stop the record
// Hide the background
}
/// <summary>
......@@ -247,7 +201,7 @@ public class MenuManager : MonoBehaviour
/// </summary>
public void configParams()
{
//SceneManager.LoadScene("paramConfig");
Time.timeScale = 0; // Pause the scenario when modifying the parameters
configPanel.SetActive(!configPanel.activeSelf);
ConfigManager.showConfig();
}
......@@ -262,6 +216,7 @@ public class MenuManager : MonoBehaviour
ConfigReader.LoadConfig(configPath);
env.updateScenario(ConfigReader.trajectoriesDir);
Time.timeScale = 1; // start after the parameters modification
}
/// <summary>
......
......@@ -8,14 +8,15 @@
<rotation x="0" y="0" z="0" />
</env_stageInfos>
<cam>
<position x="-18.72852" y="0" z="5" />
<rotation x="30.00001" y="0" z="90" />
<position x="-21" y="0" z="5" />
<rotation x="20.09134" y="9.090955E-07" z="259.4649" />
<lookAtAgent agentID="-1" />
<followAgent agentID="0" followOnX="true" followOnY="false" />
<CamResolution x="-1" y="-1" />
</cam>
<recording start="0" end="0" framerate="15">
<saveDir>/home/fabrice/Documents/OCSR/chaos/output2/</saveDir>
<savedData ImgOriginal="true" ImgSegmentation="false" ImgCategories="false" ImgDepth="false" ImgNormals="false" ImgOpticalFlow="true" BodyBoundingBoxes="false" HeadBoundingBoxes="false" />
<savedData ImgOriginal="true" ImgSegmentation="false" ImgCategories="false" ImgDepth="false" ImgNormals="false" ImgOpticalFlow="false" BodyBoundingBoxes="false" HeadBoundingBoxes="false" />
</recording>
<AgentColorList />
</ConfigData>
\ No newline at end of file
</ConfigData>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment