Ejemplo n.º 1
0
 void ReadUI()
 {
     DefaultUI();
     //Debug.Log(Screen.currentResolution.ToString());
     try
     {
         StreamReader srd;
         if (File.Exists(GeoTools.UIPath + "CHN.txt"))
         {
             srd = File.OpenText(GeoTools.UIPath + "CHN.txt");
         }
         else
         {
             srd = File.OpenText(GeoTools.UIPath + "EN.txt");
         }
         //Debug.Log(Ci + "  " + Screen.width.ToString() + "*" + Screen.height.ToString());
         while (srd.Peek() != -1)
         {
             string   str   = srd.ReadLine();
             string[] chara = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
             if (chara.Length > 2)
             {
                 if (chara[0] == "_Timer")
                 {
                     if (chara[1] == "unit")
                     {
                         if (chara[2] == "kmh")
                         {
                             this.Unit = ModUnit.kmh;
                         }
                         if (chara[2] == "ms")
                         {
                             this.Unit = ModUnit.ms;
                         }
                         if (chara[2] == "mach")
                         {
                             this.Unit = ModUnit.mach;
                         }
                     }
                     else if (chara[1] == "overload")
                     {
                         if (chara[2] == "OFF")
                         {
                             _overloadUI = string.Empty;
                         }
                         else
                         {
                             _overloadUI = chara[2];
                         }
                     }
                     else if (chara[1] == "time")
                     {
                         if (chara[2] == "OFF")
                         {
                             _timeUI = string.Empty;
                         }
                         else
                         {
                             _timeUI = chara[2];
                         }
                     }
                     else if (chara[1] == "coordinates")
                     {
                         if (chara[2] == "OFF")
                         {
                             _coordinatesUI = string.Empty;
                         }
                         else
                         {
                             _coordinatesUI = chara[2];
                         }
                     }
                     else if (chara[1] == "velocity")
                     {
                         if (chara[2] == "OFF")
                         {
                             _velocityUI = string.Empty;
                         }
                         else
                         {
                             _velocityUI = chara[2];
                         }
                     }
                     else if (chara[1] == "timer")
                     {
                         if (chara[2] == "OFF")
                         {
                             _timerUI = string.Empty;
                         }
                         else
                         {
                             _timerUI = chara[2];
                         }
                     }
                     else if (chara[1] == "distance")
                     {
                         if (chara[2] == "OFF")
                         {
                             _distanceUI = string.Empty;
                         }
                         else
                         {
                             _distanceUI = chara[2];
                         }
                     }
                     else if (chara[1] == "trigger")
                     {
                         if (chara[2] == "OFF")
                         {
                             _triggerUI = string.Empty;
                         }
                         else
                         {
                             _triggerUI = chara[2];
                         }
                     }
                     else if (chara[1] == "display_UI")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _DisplayUI = outputkey;
                         }
                     }
                     else if (chara[1] == "reload_UI")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _ReloadUI = outputkey;
                         }
                     }
                     else if (chara[1] == "Get_Center")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _GetCenter = outputkey;
                         }
                     }
                     else if (chara[1] == "Get_LevelInfo")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _GetLevelInfo = outputkey;
                         }
                     }
                     else if (chara[1] == "Get_Shader")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _GetShader = outputkey;
                         }
                     }
                     else if (chara[1] == "show_on_start")
                     {
                         if (chara[2] == "0" || chara[2] == "OFF")
                         {
                             ShowGUI = false;
                         }
                         else
                         {
                             ShowGUI = true;
                         }
                     }
                 }
                 else if (chara[0] == Screen.width.ToString() + "*" + Screen.height.ToString() + "_Timer")
                 {
                     if (chara[1] == "window_poistion")
                     {
                         windowRect.x = Convert.ToSingle(chara[2]);
                         windowRect.y = Convert.ToSingle(chara[3]);
                     }
                 }
             }
         }
         srd.Close();
         if (Unit == ModUnit.kmh)
         {
             _velocityUI += "(km/h)";
         }
         else if (Unit == ModUnit.ms)
         {
             _velocityUI += "(m/s)";
         }
         else if (Unit == ModUnit.mach)
         {
             _velocityUI += "(mach)";
         }
         filtUI();
         Debug.Log("TimerUISetting Completed!");
     }
     catch (Exception ex)
     {
         Debug.Log("Error! TimerUISetting Failed!");
         Debug.Log(ex.ToString());
         DefaultUI();
         return;
     }
 }
Ejemplo n.º 2
0
 void ReadUI()
 {
     DefaultUI();
     try
     {
         StreamReader srd;
         if (File.Exists(GeoTools.UIPath + "CHN.txt"))
         {
             Debug.Log("zh-CN UI " + Screen.width.ToString() + "*" + Screen.height.ToString());
             srd = File.OpenText(GeoTools.UIPath + "CHN.txt");
         }
         else
         {
             Debug.Log("en-US UI " + Screen.width.ToString() + "*" + Screen.height.ToString());
             srd = File.OpenText(GeoTools.UIPath + "EN.txt");
         }
         while (srd.Peek() != -1)
         {
             string   str   = srd.ReadLine();
             string[] chara = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
             if (chara.Length > 2)
             {
                 if (chara[0] == "_Scene")
                 {
                     if (chara[1] == "buttonname")
                     {
                         _ButtonName.Add(chara[2]);
                     }
                     else if (chara[1] == "scenename")
                     {
                         _SceneName.Add(chara[2]);
                     }
                     else if (chara[1] == "display_UI")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _DisplayUI = outputkey;
                         }
                     }
                     else if (chara[1] == "reload_UI")
                     {
                         KeyCode outputkey;
                         if (GeoTools.StringToKeyCode(chara[2], out outputkey))
                         {
                             _ReloadUI = outputkey;
                         }
                     }
                     else if (chara[1] == "show_on_start")
                     {
                         if (chara[2] == "0" || chara[2] == "OFF")
                         {
                             ShowGUI = false;
                         }
                         else
                         {
                             ShowGUI = true;
                         }
                     }
                 }
                 else if (chara[0] == Screen.width.ToString() + "*" + Screen.height.ToString() + "_Scene")
                 {
                     if (chara[1] == "window_poistion")
                     {
                         windowRect.x = Convert.ToSingle(chara[2]);
                         windowRect.y = Convert.ToSingle(chara[3]);
                     }
                 }
             }
         }
         srd.Close();
         filtUI();
         if (_ButtonName.Count != _SceneName.Count || _ButtonName.Count < 0)
         {
             Debug.Log("LoadUISetting Failed!Button Error!");
             DefaultItem();
         }
         else
         {
             Debug.Log("LoadUISetting Completed!");
         }
     }
     catch (Exception ex)
     {
         Debug.Log("Error! LoadUISetting Failed!");
         Debug.Log(ex.ToString());
         DefaultUI();
         return;
     }
 }