Skip to content

Commit

Permalink
Unity4 - Fixed bug with custom directory selection
Browse files Browse the repository at this point in the history
Former-commit-id: 696d4e6
  • Loading branch information
tRidha committed Aug 31, 2016
1 parent 1dd4ddc commit f3d26f8
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 45 deletions.
4 changes: 0 additions & 4 deletions engine/unity4/Assets/resources/Images/blueBackground.xcf.meta

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions engine/unity4/Assets/resources/Images/greyBackground.xcf.meta

This file was deleted.

4 changes: 0 additions & 4 deletions engine/unity4/Assets/resources/Images/greyButton.xcf.meta

This file was deleted.

This file was deleted.

This file was deleted.

71 changes: 51 additions & 20 deletions engine/unity4/Assets/scripts/GUI/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,27 @@ void OnGUI ()
switch (currentTab)
{
case Tab.FieldDir:
if (!customfieldon || !fieldBrowser.Active) SwitchTabSim();
if (customfieldon && !fieldBrowser.Active)
{
currentTab = Tab.Sim;

homeTab.SetActive(false);
optionsTab.SetActive(false);
simTab.SetActive(true);
customfieldon = false;
}
break;

case Tab.RobotDir:
if (!customroboton || !robotBrowser.Active) SwitchTabSim();
if (customroboton && !robotBrowser.Active)
{
currentTab = Tab.Sim;

homeTab.SetActive(false);
optionsTab.SetActive(false);
simTab.SetActive(true);
customroboton = false;
}
break;
}
InitFieldBrowser();
Expand All @@ -109,6 +125,7 @@ public void SwitchTabHome()
optionsTab.SetActive(false);
homeTab.SetActive(true);
}
else UserMessageManager.Dispatch("You must select a directory or exit first!",3);
}

public void SwitchTabSim()
Expand All @@ -121,6 +138,7 @@ public void SwitchTabSim()
optionsTab.SetActive(false);
simTab.SetActive(true);
}
else UserMessageManager.Dispatch("You must select a directory or exit first!", 3);
}

public void SwitchTabOptions()
Expand All @@ -133,6 +151,7 @@ public void SwitchTabOptions()
simTab.SetActive(false);
optionsTab.SetActive(true);
}
else UserMessageManager.Dispatch("You must select a directory or exit first!", 3);
}

public void SwitchSimSelection()
Expand Down Expand Up @@ -272,25 +291,28 @@ public void SwitchDPMConfiguration()
driverPracticeMode.SetActive(false);
dpmConfiguration.SetActive(true);

string line = "";
int counter = 0;
StreamReader reader = new StreamReader(PlayerPrefs.GetString("dpmSelectedRobot") + "\\dpmConfiguration.txt");

string fieldName = "";
while ((line = reader.ReadLine()) != null)
if (File.Exists(dpmSelectedRobot + "\\dpmConfiguration.txt"))
{
if (line.Equals("#Field")) counter++;
else if (counter == 1)
string line = "";
int counter = 0;
StreamReader reader = new StreamReader(dpmSelectedRobot + "\\dpmConfiguration.txt");

string fieldName = "";
while ((line = reader.ReadLine()) != null)
{
fieldName = line;
break;
if (line.Equals("#Field")) counter++;
else if (counter == 1)
{
fieldName = line;
break;
}
}
reader.Close();
configurationText.GetComponent<Text>().text = "Robot Status: <color=#008000ff>Configured For " + fieldName + "</color>";
}

if (File.Exists(dpmSelectedRobot + "\\dpmConfiguration.txt")) configurationText.GetComponent<Text>().text = "Robot Status: <color=#008000ff>Configured For " + fieldName + "</color>";
else configurationText.GetComponent<Text>().text = "Robot Status: <color=#a52a2aff>NOT CONFIGURED</color>";

reader.Close();

}
else UserMessageManager.Dispatch("No Robot/Field Selected!", 5);
}
Expand Down Expand Up @@ -456,8 +478,12 @@ public void InitFieldBrowser()

public void LoadFieldDirectory()
{
if (!fieldBrowser.Active) fieldBrowser.Active = true;
if (!fieldBrowser.Active)
{
fieldBrowser.Active = true;
}
customfieldon = true;
currentTab = Tab.FieldDir;
}

public void InitRobotBrowser()
Expand Down Expand Up @@ -492,8 +518,12 @@ public void InitRobotBrowser()

public void LoadRobotDirectory()
{
if (!robotBrowser.Active) robotBrowser.Active = true;
if (!robotBrowser.Active)
{
robotBrowser.Active = true;
}
customroboton = true;
currentTab = Tab.RobotDir;
}

#endregion
Expand Down Expand Up @@ -612,7 +642,9 @@ public void SelectDPMRobot()
}
#endregion
void Start () {

FindAllGameObjects();
splashScreen.SetActive(true);
InitGraphicsSettings();
fields = new ArrayList();
robots = new ArrayList();
Expand All @@ -637,7 +669,7 @@ void Start () {

customfieldon = false;
customroboton = false;

ApplyGraphics();
if (currentSim != Sim.Selection)
{
if (currentSim == Sim.DPMConfiguration)
Expand All @@ -660,6 +692,7 @@ void Start () {
SwitchSimSelection();
}


}
void FindAllGameObjects()
{
Expand Down Expand Up @@ -729,7 +762,5 @@ void InitGraphicsSettings()
else if (width == xresolution[8] && height == yresolution[8]) resolutionsetting = 8;
else if (width == xresolution[9] && height == yresolution[9]) resolutionsetting = 9;
else resolutionsetting = 2;

ApplyGraphics();
}
}
2 changes: 1 addition & 1 deletion engine/unity4/Assets/scripts/GUI/UserMessageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void Render()
GUI.color = fg;
GUI.backgroundColor = bg;
GUIContent content = new GUIContent(msg.message);
Vector2 size = GUI.skin.GetStyle("Button").CalcSize(content)*scale;
Vector2 size = GUI.skin.GetStyle("Button").CalcSize(content);
if (GUI.Button(new Rect((WIDTH - size.x) / 2f, HEIGHT - y - size.y, size.x, size.y), content))
{
msg.ttl = -1;
Expand Down
Binary file not shown.

0 comments on commit f3d26f8

Please sign in to comment.