123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using FantomLib;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.Localization.Settings;
- using UnityEngine.Localization.Tables;
- using static DeMaTJConfig;
- public class TianJiWindowManager : MonoBehaviour
- {
- public DeviceTypeDetail dtdlist;
- public static TianJiWindowManager Instance ;
- public GameObject LoginGo;
- public GameObject MainGo;
- public GameObject PopGo;
- public string style = "android:Theme.Holo";
- void Awake()
- {
- Instance=this;
- Application.targetFrameRate=120;
- QualitySettings.vSyncCount = 0;
-
- SetLanguage("zh");
- Invoke("Loadinginit",1f);
- }
- void OnEnable()
- {
- }
- public Action<string> OnResult;
- public void chooseDate(Action<string> callback)
- {
- OnResult=callback;
- AndroidPlugin.ShowDatePickerDialog(
- DateTime.Now.ToString() ,
- "yyyy'-'M'-'d",
- this.gameObject.name,
- "ReceiveResult",
- style);
- }
-
- private void ReceiveResult(string result)
- {
- if (OnResult != null)
- OnResult.Invoke(result);
- }
- void Loadinginit()
- {
- gotoLogin();
- }
- public void gotoMain()
- {
- MainGo.SetActive(true);
- LoginGo.SetActive(false);
- }
- public void gotoLogin()
- {
- MainGo.SetActive(false);
- LoginGo.SetActive(true);
- }
- public void showPop(int i =0,string str ="")
- {
- PopWindowManager.info = str;
- PopWindowManager.indexwd =i;
- PopGo.SetActive(true);
- }
- public void showPop(int i =0)
- {
- PopWindowManager.indexwd =i;
- PopGo.SetActive(true);
- }
- public void showMain()
- {
- this.gameObject.SetActive(true);
- }
- public void showRTC()
- {
- this.gameObject.SetActive(false);
- }
- public void SelectEnglish(bool isY)
- {
- if(isY)
- {
- SetLanguage("en");
- }
- }
- public void SelectChinese(bool isY)
- {
- if(isY)
- {
- SetLanguage("zh");
- }
- }
- public void SetLanguage(string languageCode)
- {
-
- foreach (var locale in LocalizationSettings.AvailableLocales.Locales)
- {
- if (locale.Identifier.Code == languageCode)
- {
- LocalizationSettings.SelectedLocale = locale;
- Debug.Log("Language set to: " + languageCode);
- return;
- }
- }
- Debug.LogError("Language not found: " + languageCode);
- }
- StringTable stringTable ;
-
- public string GetTextByKey(string key)
- {
- if(stringTable==null)
- stringTable= LocalizationSettings.StringDatabase.GetTable("tinaji");
-
- var tableEntry = stringTable.GetEntry(key);
- if (tableEntry != null)
- {
-
- return tableEntry.GetLocalizedString();
- }
- else
- {
- return key;
- }
- }
- public static List<string> getConfigstr(int a,int b,int d)
- {
- List<string> strings =new List<string>();
- strings.Add("") ;
- strings.Add("") ;
- strings.Add("") ;
- for (int i = 0;i<WindowMainManager.instance.TJConfig.config.Count;i++)
- {
- if(WindowMainManager.instance.TJConfig.config[i].value == a)
- {
- strings[0]=WindowMainManager.instance.TJConfig.config[i].zh;
- Config c = WindowMainManager.instance.TJConfig.config[i];
- if(c.children!=null)
- {
- for (int j = 0;j<c.children.Count;j++)
- {
- if(c.children[j].value == b)
- {
- strings[1]=c.children[j].zh;
- if(c.children[j].children!=null)
- {
- for (int k = 0;k<c.children[j].children.Count;k++)
- {
- if(c.children[j].children[k].value == d)
- {
- strings[2]=c.children[j].children[k].zh;
- }
- }
- }
- }
- }
- }
- }
- }
- return strings;
- }
- public static List<string> getConfigServerTypestr(int a,int b)
- {
- List<string> strings =new List<string>();
- for (int i = 0;i<WindowMainManager.instance.TJConfig.config.Count;i++)
- {
- if(WindowMainManager.instance.TJConfig.config[i].value == a)
- {
- strings.Add(WindowMainManager.instance.TJConfig.config[i].zh);
- if(WindowMainManager.instance.TJConfig.config[i].serviceType!=null)
- {
- for (int j = 0;j<WindowMainManager.instance.TJConfig.config[i].serviceType.Count;j++)
- {
- if(b==WindowMainManager.instance.TJConfig.config[i].serviceType[j].value)
- {
- strings.Add(WindowMainManager.instance.TJConfig.config[i].serviceType[j].zh);
- }
- }
- }
- }
- }
- if(strings.Count<2)
- {
- strings.Add("");
- }
- return strings;
- }
- }
|