public Body(string method, string url = null) { this.method = method; this.name = method; this.pf = AssetBundleConfig.Inst.AppChannel.ToString(); this.lang = LanguageTool.GetLangType().ToString(); this.appVersion = DeviceHelper.GetAppVersion(); if (StorageManager.Inst.Inited && StorageManager.Inst.GetStorage <StorageAccountInfo>() != null && !string.IsNullOrEmpty(this.gameUid = StorageManager.Inst.GetStorage <StorageAccountInfo>().Uid)) { this.gameUid = StorageManager.Inst.GetStorage <StorageAccountInfo>().Uid.ToString(); } if (string.IsNullOrEmpty(url)) { switch (GameConfig.Inst.serverType) { case GameConfig.ServerType.Fotoable: this.url = GameConfig.Inst.Fotoable_Gateway + method; break; case GameConfig.ServerType.Local: this.url = GameConfig.Inst.Local_Gateway + method; break; } } else { this.url = url; } }
static void open() { LanguageTool editor = GetWindowWithRect <LanguageTool>(new Rect(640, 420, 400, 400), true, WINDOW_NAME); editor.Init(); editor.Show(); }
public void BindFBActual(string _fbtoken, string _fbid, Action bindSucessCallback = null) { BindBody body = new BindBody(URLConfig.BindUser); body.type = "facebook"; body.id = _fbid; body.thirdtoken = _fbtoken; body.gameUid = StorageManager.Inst.GetStorage <StorageAccountInfo>().Uid; HttpRequestTool.SendMessage( body, (x) => { JSONNode respons = JSONNode.Parse(x); int code = respons["code"]; if (code == 0) { fbid = _fbid; Debug.Log("Bind Success 1:" + x); if (bindSucessCallback != null) { bindSucessCallback(); } EventUtil.EventDispatcher.TriggerEvent(EventKey.FB_Bind_Sucess); UIManager.Inst.ShowMessage(LanguageTool.Get("bind_fb_success")); //弹出绑定成功面板 //UIManager.Inst.ShowUI(UIModuleEnum.UIFacebookTips, FacebookTipType.Login_Suc); } else if (code == -10008) { Debug.Log("Bind Success 2 :" + "该fb之前已经绑定过当前游戏账号了,无需再次操作"); UIManager.Inst.ShowMessage(LanguageTool.Get("bind_fb_success")); fbid = _fbid; //弹出绑定失败面板 //UIManager.Inst.ShowUI(UIModuleEnum.UIFacebookTips, FacebookTipType.Login_Fail); } else if (code == -10010) { Debug.Log("Bind Success 3 :" + "找到fb之前绑定过的游戏进度,即将切换到该游戏进度"); UIManager.Inst.ShowMessage(LanguageTool.Get("fb_bind_account_reloading")); // 清除fb数据 fbid = _fbid; // 清除本地缓存数据 PlayerPrefs.DeleteAll(); //重启游戏 // GameController.Inst.Restart(); SceneLoadManager.Inst.LoadScene(SceneName.StartScene); } }, (x) => { Debug.LogError("Bind Fail :" + x); }, null, true ); }
public void LogoutFB() { UIManager.Inst.ShowMessage(LanguageTool.Get("fb_logout_success")); // fb退出登录 //FBTool.logout(); // 清除fb数据 fbid = null; // 清除玩家数据 PlayerPrefs.DeleteAll(); // 重启游戏 SceneLoadManager.Inst.LoadScene(SceneName.StartScene); }
void Refresh() { if (text == null) { text = GetComponent <Text>(); } if (text != null && !string.IsNullOrEmpty(text.text) && text.text.StartsWith("@")) { langKey = text.text.Substring(1); } if (!string.IsNullOrEmpty(langKey)) { text.text = LanguageTool.Get(langKey); } }
/// <summary> /// 下载最新的AssetBundle /// </summary> /// <param name="assetUrl"></param> /// <param name="loadBaseBundle"></param> /// <returns></returns> public static IEnumerator LoadAssetBundle(string assetUrl, List <string> needLoadBundleNames, ProgressInfo progressInfo, bool quietDownLoad = false) { //下载 progressInfo.totalCount = needLoadBundleNames.Count; progressInfo.start = true; int i = 0; while (i < needLoadBundleNames.Count) { float fileSize = Instance._versionInfo.GuessBundleByAssetName(needLoadBundleNames[i]).Size / 1024; int freeSpace = SimpleDiskUtils.DiskUtils.CheckAvailableSpace(); if (fileSize > freeSpace) { UIManager.Instance.ShowUI(UIModuleEnum.UICommonTipWithTitle, "", "Available space is not enough,please retry after release", "ok"); while (fileSize > freeSpace) { yield return(new WaitForSeconds(2f)); } freeSpace = SimpleDiskUtils.DiskUtils.CheckAvailableSpace(); } progressInfo.curIndex = i; string filePath = string.Format("{0}/{1}", assetUrl, needLoadBundleNames[i]); yield return(DownloadManager.DownLoadFile(needLoadBundleNames[i], filePath, FilePathTools.persistentDataPath_Platform, progressInfo, null)); if (progressInfo.curIndexDone) { i++; } else if (!quietDownLoad) { bool closeTip = false; Action tipCallback = () => { closeTip = true; }; DebugUtil.LogError("AssetBundleManager.LoadAssetBundle fail,filePath:" + filePath); UIManager.Instance.ShowUI(UIModuleEnum.UICommonTipWithTitle, "", LanguageTool.Get("Net_Problem_Tips") + "..", LanguageTool.Get("Button_ok"), tipCallback); while (!closeTip) { yield return(null); } } } progressInfo.sucess = true; }
private void SpellCheck() { if (!IsLoaded()) { return; } if (!SpellCheckEnable) { return; } if (Text == string.Empty) { WordCache = new Dictionary <string, bool>(); LastSpellCheck = null; } if (LastSpellCheck == Text) { return; } else { LastSpellCheck = Text; } //Backup and Reset values ErrorCount = 0; SuggestionLoaded = false; TextSuggestions = new Suggestion[0]; string[] Words = Text.Split(WordSeparators); this.ClearAllFormatting(Font); //SpellCheck for (int i = 0, WIndex = 0; i < Words.Length; WIndex += Words[i].Length, i++) { if (!WordCache.ContainsKey(Words[i].ToLower())) { WordCache.Add(Words[i].ToLower(), SpellChecker.Spell(Words[i])); } if (WordTL.ContainsKey(Words[i])) { if (WordTL[Words[i]].Length > 0 && WordTL[Words[i]][0] == IGNORE) { continue; } ErrorCount++; WaveWord(WIndex + i, Words[i].Length); } else if (!WordCache[Words[i].ToLower()]) { ErrorCount++; WaveWord(WIndex + i, Words[i].Length); } } foreach (string Phrase in PhraseCache.Keys) { if (Text.ToLower().Contains(Phrase)) { string lt = Text.ToLower(); for (int i = 0; i < Text.Length; i++) { if (i + Phrase.Length > Text.Length) { break; } string sub = lt.Substring(i, Phrase.Length); if (sub == Phrase) { ErrorCount++; WaveWord(i, Phrase.Length); if (PaintTerms) { Select(i, Phrase.Length); SelectionColor = Color.Green; } } } } } if (!Program.OfflineMode) { new System.Threading.Thread((Str) => { try { string Text = (string)Str; VNXTLP.Result Result; if (QueryCache.ContainsKey(Text)) { Result = QueryCache[Text]; } else { Result = LanguageTool.Check(Text, TargetLang, ProxyHelper.Proxy); QueryCache[Text] = Result; } HintCount = Result.matches.Length; List <Suggestion> Suggetions = new List <Suggestion>(); foreach (Match match in Result.matches) { int Pos = match.offset; while (Text[Pos] == ' ') { Pos++; } int Len = match.length - (Pos - match.offset); if (Len != match.length) { continue; } string Word = Text.Substring(Pos, Len); if (WordCache.ContainsKey(Word) && WordCache[Word]) { continue; } WaveWord(Pos, Len); Suggetions.Add(new Suggestion() { Word = Word, Suggestions = (from x in match.replacements select x.value).ToList(), Info = match.message, Pos = Pos, Len = Len }); } TextSuggestions = Suggetions.ToArray(); } catch { } }).Start(Text); } }
private IEnumerator LoadAssetBundleGroupIEnumerator(string assetUrl, List <string> needLoadBundleNames, bool quietDownLoad = false) { //下载 loadingStatus = LoadingStatus.Loading; progressInfo.start = true; int i = 0; while (i < needLoadBundleNames.Count) { float fileSize = this.assetBundleGroupInfo.Get("needLoadBundleNames").Size / 1024; int freeSpace = SimpleDiskUtils.DiskUtils.CheckAvailableSpace(); if (fileSize > freeSpace) { UIManager.Instance.ShowUI(UIModuleEnum.UICommonTipWithTitle, "", "Available space is not enough,please retry after release", "ok"); while (fileSize > freeSpace) { if (loadingStatus == LoadingStatus.Pause) { yield break; } yield return(new WaitForSeconds(3f)); freeSpace = SimpleDiskUtils.DiskUtils.CheckAvailableSpace(); } } progressInfo.curIndex = progressInfo.startIndex + i; //yield return DownloadManager.DownLoadFile(needLoadBundleNames[i], string.Format("{0}/{1}", assetUrl, needLoadBundleNames[i]), FilePathTools.persistentDataPath_Platform, progressInfo, null); string fileName = needLoadBundleNames[i]; string filePath = string.Format("{0}/{1}", assetUrl, needLoadBundleNames[i]); string desFolderName = FilePathTools.persistentDataPath_Platform; using (UnityWebRequest www = new UnityWebRequest(filePath)) { DownloadHandlerBuffer downHandler = new DownloadHandlerBuffer(); www.downloadHandler = downHandler; www.SendWebRequest(); while (!www.isDone) { if (loadingStatus == LoadingStatus.Pause) { //设置为Pause状态时,退出下载 www.Abort(); www.Dispose(); yield break; } if (progressInfo != null) { progressInfo.curProgress = www.downloadProgress; } yield return(null); } if (string.IsNullOrEmpty(www.error)) { byte[] b = www.downloadHandler.data; string destFile = string.Format("{0}/{1}", desFolderName, fileName); string destDir = Path.GetDirectoryName(destFile); if (!Directory.Exists(destDir)) { Directory.CreateDirectory(destDir); } if (Directory.Exists(destDir)) { Log("AssetBundleGroupLoadHelperItem : create fold {0} sucess", destDir); } else { Log("AssetBundleGroupLoadHelperItem : create fold {0} Fail", destDir); } if (File.Exists(destFile)) { File.Delete(destFile); } try { using (FileStream fs = new FileStream(destFile, FileMode.Create)) { fs.Seek(0, SeekOrigin.Begin); fs.Write(b, 0, b.Length); fs.Close(); Log("AssetBundleGroupLoadHelperItem :write sucess: {0},length:{1}", fileName, b.Length); } } catch (Exception e) { Log("AssetBundleGroupLoadHelperItem: save to local exception:{0}", e.ToString()); } if (File.Exists(destFile)) { if (progressInfo != null) { progressInfo.curIndexDone = true; } } else { if (progressInfo != null) { progressInfo.curIndexDone = false; } } } else { Log("AssetBundleGroupLoadHelperItem,file path:{0} , error:{1}", filePath, www.error); if (progressInfo != null) { progressInfo.curIndexDone = false; } yield return(new WaitForSeconds(3f)); } } if (progressInfo.curIndexDone) { i++; } else if (!quietDownLoad) { if (!UIManager.Instance.IsUIVisible(UIModuleEnum.UICommonTipWithTitle)) { UIManager.Instance.ShowUI(UIModuleEnum.UICommonTipWithTitle, "", LanguageTool.Get("Net_Problem_Tips"), LanguageTool.Get("Button_ok")); } } } progressInfo.sucess = true; EventDispatcher.TriggerEvent <string>(EventKey.AssetBundleGroupLoadSucess, groupName); }