private void AddCheckBox(OrderedDictionary <SettingCategory, OrderedDictionary <string, Setting> > settingcategories, StackPanel panel, SettingCategory category, string name, I18N.I18NString label, bool isChecked, bool isDefaultChecked) { StackPanel inputPanel = new StackPanel() { Orientation = Orientation.Horizontal, }; CheckBox cb = new CheckBox { Name = name, Content = new Run(I18N.Get(label)), Margin = new Thickness(10), IsChecked = isChecked }; cb.Checked += (object sender, RoutedEventArgs e) => { HLVRSettingsManager.TrySetSetting(settingcategories, category, name, true); }; cb.Unchecked += (object sender, RoutedEventArgs e) => { HLVRSettingsManager.TrySetSetting(settingcategories, category, name, false); }; cb.Indeterminate += (object sender, RoutedEventArgs e) => { HLVRSettingsManager.TrySetSetting(settingcategories, category, name, false); }; inputPanel.Children.Add(cb); panel.Children.Add(inputPanel); }
protected override void OnOpen() { base.OnOpen(); switch (result) { case ResultState.Win: lblResult.text = I18N.Get(1003009); lblResult.color = new Color32(255, 82, 79, 255); break; case ResultState.Lose: lblResult.text = I18N.Get(1003010); lblResult.color = new Color32(128, 128, 128, 255); break; case ResultState.MeEscape: lblResult.text = I18N.Get(1003010); lblResult.color = new Color32(128, 128, 128, 255); break; case ResultState.OppEscape: lblResult.text = I18N.Get(1003009); lblResult.color = new Color32(255, 82, 79, 255); break; default: break; } }
/// <summary> /// 每秒计算下载速度,每帧更新进度条 /// </summary> void OnUpdateProgress() { long downloadFinish = (long)(downloadTemp + downloadNow); totalProgress = KTool.GetPercent(downloadFinish, downloadTotalSize) - zipPercent; totalProgress = Mathf.Max(totalProgress, 0.0f); if (Time.time > last_time) { last_time = Time.time + 1.0f; time_per = 0; // 下载速度 = 前1秒下载量 / 1s ,总下载=下载中 + 已下载 speed = downloadFinish - downloadLastSecond; speed = (long)Mathf.Max(speed, 0); remainTime = KTool.GetPercent(downloadTotalSize - downloadFinish, speed); downloadLastSecond = downloadFinish; lastTotalProgress = totalProgress; } var panel = UIModule.Instance.GetExistUI <LoadingPanel>(); if (panel != null) { string strSize = $"{KTool.FormatFileSize(downloadFinish)}/{KTool.FormatFileSize(downloadTotalSize)}"; string strSpeed = (speed / 1024f).ToString("0.##"); time_per += Time.deltaTime; var progress = Mathf.Lerp(lastTotalProgress, totalProgress, time_per); panel.SetProgress(I18N.Get("download_speed", strSize, strSpeed, KTool.HumanizeTimeString((int)remainTime)), progress); } }
void StartSelect(int startIndex, int length) { if (length > 4) { Debug.LogError("数量过多!"); } if (startIndex + length >= dialogDatas.Count) { Debug.LogError("超出界限!"); } //List<DialogData> datas = new List<DialogData>(length); //for (int i = 0; i < length; i++) //{ // datas.Add(dialogDatas[startIndex + i]); //} for (int i = 0; i < length; i++) { DialogData data = dialogDatas[startIndex + i]; GameObject go = goSelects[i]; go.name = data.Index.ToString(); go.SetActive(true); go.transform.Find("content").GetComponent <UILabel>().text = I18N.Get(data.Content); } gridSelectItems.Reposition(); }
private void BtnLogin_Click(object sender, EventArgs e) { try { string userName = this.txtUserName.Text; if (string.IsNullOrEmpty(userName)) { throw new Exception(I18N.Get("请输入用户名")); } string userPwd = this.txtUserPwd.Text; if (string.IsNullOrEmpty(userPwd)) { throw new Exception(I18N.Get("请输入密码")); } UserInfo userInfoService = new UserInfo(); CustomMessage resouce = userInfoService.Login(JsonConvert.SerializeObject(new { userName, userPwd })) as CustomMessage; if (resouce.Status != HttpStatus.OK) { MessageBoxExt.Show(resouce.Message.ToString(), MessageboxType.Error); } } catch (Exception objException) { MessageBoxExt.Show(objException.Message, MessageboxType.Error); } }
/// <summary> /// Before Init Modules, coroutine /// </summary> /// <returns></returns> public override IEnumerator OnBeforeInit() { if (AppConfig.IsDownloadRes) { var loader = AssetBundleLoader.Load($"uiatlas/{UIModule.Instance.CommonAtlases[0]}", (isOk, ab) => { if (isOk && ab) { var atlas = ab.LoadAsset <SpriteAtlas>("atlas_common"); ABManager.SpriteAtlases["atlas_common"] = atlas; } }); while (!loader.IsCompleted) { yield return(null); } yield return(StartCoroutine(DownloadManager.Instance.CheckDownload())); if (DownloadManager.Instance.ErrorType != UpdateErrorType.None) { UIMsgBoxInfo info = new UIMsgBoxInfo().GetDefalut(I18N.Get("download_error", DownloadManager.Instance.ErrorType), null, I18N.Get("common_ignore"), I18N.Get("common_exit")); info.OkCallback = () => { DownloadManager.Instance.DownloadFinish = true; }; info.CancelCallback = KTool.ExitGame; var panel = UIModule.Instance.GetOrCreateUI <KUIMsgBox>(); panel.info = info; panel.DisPlay(true); } } else { DownloadManager.Instance.DownloadFinish = true; } }
private TextBlock CreateDefaultLabel(string defaultValue) { if (defaultValue.Contains("(")) { defaultValue = defaultValue.Substring(0, defaultValue.IndexOf("(")).Trim(); } return(CreateMiniText("(" + I18N.Get(DefaultLabel) + ": " + defaultValue + ")", 20)); }
protected void ShowContent(DialogData dialogData) { if (dialogData == null) { Debug.LogError("null"); } for (int i = 0; i < goSelects.Length; i++) { goSelects[i].SetActive(false); } if (dialogData.Sound > 0) { Game.Sound.Play(dialogData.Sound); } int action = dialogData.Action; switch (dialogData.ShowMode) { case 0: //玩家 if (oppData == null) { goOppInfo.SetActive(false); } goMyInfo.SetActive(true); lblMyContent.text = I18N.Get(dialogData.Content); StartTypewriting(lblMyContent); texMyIcon.Load(dialogData.Head); break; case 1: //怪物 if (myData == null) { goMyInfo.SetActive(false); } goOppInfo.SetActive(true); lblOppContent.text = I18N.Get(dialogData.Content); StartTypewriting(lblOppContent); texOppIcon.Load(dialogData.Head); break; case 2: //Boss if (myData == null) { goMyInfo.SetActive(false); } goOppInfo.SetActive(true); lblOppContent.text = I18N.Get(dialogData.Content); StartTypewriting(lblOppContent); texOppIcon.Load(dialogData.Head); break; default: break; } }
private void UpdateMapInfo() { if (MapMgr.Inited == false) { return; } InstanceTableSetting instanceTable = InstanceTableSettings.Get(MapMgr.Instance.InstanceId); lblMapName.text = instanceTable.Name; lblMapLayerName.text = I18N.Get(1005001, MapMgr.Instance.CurrentMapLayerData.LayerId); }
public override void OnInspectorGUI() { serializedObject.Update(); UseLangId.boolValue = EditorGUILayout.Toggle("使用语言包:", UseLangId.boolValue); if (UseLangId.boolValue) { LangId.stringValue = EditorGUILayout.TextField("语言包id:", LangId.stringValue); if (!string.IsNullOrEmpty(LangId.stringValue)) { paramArr.arraySize = EditorGUILayout.DelayedIntField("语言包参数个数:", paramArr.arraySize); args = new string[paramArr.arraySize]; ++EditorGUI.indentLevel; for (int i = 0; i < paramArr.arraySize; i++) { paramArr.GetArrayElementAtIndex(i).stringValue = EditorGUILayout.TextField(paramArr.GetArrayElementAtIndex(i).stringValue); args[i] = paramArr.GetArrayElementAtIndex(i).stringValue; } --EditorGUI.indentLevel; var str = I18N.Get(LangId.stringValue, args); if (str != null && str.IndexOf("lang_id:") < 0) { m_Text.stringValue = str; } else { m_Text.stringValue = ""; EditorGUILayout.HelpBox($"语言包id:{LangId.stringValue}不存在!", MessageType.Error); } } else { m_Text.stringValue = ""; EditorGUILayout.HelpBox("请输入语言包id", MessageType.Error); } if (GUILayout.Button("刷新语言包")) { I18N.ReLoad(); } } else { EditorGUILayout.HelpBox("请从语言包读取文本", MessageType.Warning); } serializedObject.ApplyModifiedProperties(); base.OnInspectorGUI(); }
private void AddTitle(StackPanel panel, I18N.I18NString title) { TextBlock textBlock = new TextBlock() { TextWrapping = TextWrapping.WrapWithOverflow, Padding = new Thickness(5), Margin = new Thickness(5), Focusable = true }; textBlock.Inlines.Add(new Bold(new Run(I18N.Get(title)))); panel.Children.Add(textBlock); }
public UIMsgBoxInfo GetDefalut(string msg, string strTitle = null, string strOk = null, string strCancel = null) { var info = new UIMsgBoxInfo(); info.Title = strTitle == null?I18N.Get("common_title_tips") : strTitle; info.Message = msg; info.strOk = strOk == null?I18N.Get("common_ok") : strOk; info.strCancel = strCancel == null?I18N.Get("common_cancel") : strCancel; return(info); }
public void SetData(BattleCardData card, UIBattleForm form) { CardData = card; cacheForm = form; m_TexIconRight.Load(card.Data.IconRightID); m_TexIconLeft.Load(card.Data.IconLeftID); m_lblName.text = I18N.Get(CardData.Data.Name); if (CardData.Data.Type != 0) { m_spAttack.gameObject.SetActive(false); m_lblAttackCount.text = ""; } for (int i = 0; i < CardData.Data.ActionTypes.Count; i++) { switch ((BattleActionType)CardData.Data.ActionTypes[i]) { case BattleActionType.None: break; case BattleActionType.AddBuff: break; case BattleActionType.Attack: if (CardData.Data.Type == 0) { m_spAttack.gameObject.SetActive(true); m_lblAttackCount.text = CardData.Data.ActionParams[i].ToString(); } break; case BattleActionType.RecoverHP: break; case BattleActionType.RecoverMP: break; case BattleActionType.DrawCard: break; default: break; } } m_spExpand.gameObject.SetActive(true); m_lblExpandCount.text = CardData.Data.Spending.ToString(); if (card.Owner != Game.BattleManager.MyPlayer) { m_ContentRoot.SetActive(false); } }
private void InitEquip(int id) { if (CardId == id) { return; } CardId = id; BattleEquipTableSetting equip = BattleEquipTableSettings.Get(id); icon.Load(equip.IconID); labName.text = I18N.Get(equip.Name); describle.text = I18N.Get(equip.Desc); spSpending.gameObject.SetActive(false); }
private void InitBuff(int id) { if (CardId == id) { return; } CardId = id; BattleBuffTableSetting buff = BattleBuffTableSettings.Get(id); icon.Load(buff.IconID); labName.text = I18N.Get(buff.Name); describle.text = I18N.Get(buff.Desc); spSpending.gameObject.SetActive(false); }
void Start() { if (UseLangId && string.IsNullOrEmpty(text)) { if (!string.IsNullOrEmpty(LangId)) { text = I18N.Get(LangId, LangParams); } else { Log.LogError($"{KTool.GetRootPathName(this.transform)},lang id is null"); } } }
private void LoadReadme() { AboutText.Inlines.Clear(); try { AboutText.Inlines.Add(File.ReadAllText(HLVRPaths.VRReadme, Encoding.UTF8)); } catch (IOException e) { AboutText.Inlines.Clear(); var errorMsg = new I18N.I18NString("ErrorMsgCouldNotLoadReadme", "Couldn't load README.txt: %s"); AboutText.Inlines.Add(new Regex(Regex.Escape("%s")).Replace(I18N.Get(errorMsg), e.Message, 1)); } }
/// <summary> /// After Init Modules, coroutine /// </summary> /// <returns></returns> public override IEnumerator OnGameStart() { WaitForSeconds wait = new WaitForSeconds(1); while (DownloadManager.Instance.DownloadFinish == false) { yield return(wait); } Log.Info(I18N.Get("btn_billboard")); // Print AppConfigs // Log.Info("======================================= Read Settings from C# ================================="); foreach (BillboardSetting setting in BillboardSettings.GetAll()) { Debug.Log(string.Format("C# Read Setting, Key: {0}, Value: {1}", setting.Id, setting.Title)); } //加载公共图集 AssetBundleLoader.Load($"uiatlas/{UIModule.Instance.CommonAtlases[0]}", (isOk, ab) => { if (isOk && ab) { var atlas = ab.LoadAsset <SpriteAtlas>("atlas_common"); ABManager.SpriteAtlases["atlas_common"] = atlas; } }); yield return(null); UIModule.Instance.OpenWindow("UILogin", 888); // Test Load a scene in asset bundle SceneLoader.Load("Scene/Scene1001/Scene1001"); //预加载公告界面 // UIModule.Instance.PreLoadUIWindow("Billboard"); //UIModule.Instance.OpenWindow("Billboard"); // 测试Collect函数,立即回收所有资源 var path = "ui/UIRoleInfo"; var assetLoader = AssetBundleLoader.Load(path); while (!assetLoader.IsCompleted) { yield return(null); } yield return(new WaitForSeconds(1)); assetLoader.Release(); KResourceModule.Collect(); }
private void BtnRegistered_Click(object sender, EventArgs e) { try { string userName = this.txtRegistered_UserName.Text; if (string.IsNullOrEmpty(userName)) { throw new Exception(I18N.Get("请输入用户名")); } string userPwd = this.txtRegistered_UserPwd.Text; if (string.IsNullOrEmpty(userPwd)) { throw new Exception(I18N.Get("请输入密码")); } string userEmail = this.txtRegistered_Email.Text; if (string.IsNullOrEmpty(userPwd)) { throw new Exception(I18N.Get("请输入邮箱")); } if (!Regex.IsMatch(userEmail, @"^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$")) { throw new Exception(I18N.Get("请输入正确的邮箱号")); } UserInfo userInfoService = new UserInfo(); CustomMessage resouce = userInfoService.Register(JsonConvert.SerializeObject(new { userName, userPwd, emailAddress = userEmail })) as CustomMessage; if (resouce.Status != HttpStatus.OK) { MessageBoxExt.Show(resouce.Message.ToString(), MessageboxType.Error); } else { MessageBoxExt.Show(resouce.Message.ToString(), MessageboxType.Info); } } catch (Exception objException) { MessageBoxExt.Show(objException.Message, MessageboxType.Error); } }
/// <summary> /// 使用卡牌的表现 /// </summary> /// <returns></returns> public bool UseCard() { //判断使用条件,不允许返回false Debug.Log("释放卡牌: " + I18N.Get(CardData.Data.Name)); //if (CardData.Owner.AP < CardData.Data.Spending) //{ // return false; //} cacheCardPos = cacheChildCardTrans.position; m_Used = true; if (CardData.Owner != Game.BattleManager.MyPlayer) { m_ContentRoot.SetActive(true); } return(true); }
public void RefreshConfigTabs(bool mod = true, bool launcher = true) { UpdateSettingsAndLanguage(); if (mod) { if (HLVRSettingsManager.AreModSettingsInitialized) { ModConfig.Initialize(InputConfig, HLVRSettingsManager.ModSettings.InputSettings); ModConfig.Initialize(ImmersionConfig, HLVRSettingsManager.ModSettings.ImmersionSettings); ModConfig.Initialize(PerformanceConfig, HLVRSettingsManager.ModSettings.PerformanceSettings); ModConfig.Initialize(VisualsConfig, HLVRSettingsManager.ModSettings.VisualsSettings); ModConfig.Initialize(AudioConfig, HLVRSettingsManager.ModSettings.AudioSettings); ModConfig.Initialize(OtherConfig, HLVRSettingsManager.ModSettings.OtherSettings); } else { InputConfig.Children.Clear(); ImmersionConfig.Children.Clear(); PerformanceConfig.Children.Clear(); VisualsConfig.Children.Clear(); AudioConfig.Children.Clear(); OtherConfig.Children.Clear(); var errorMsg = I18N.Get(new I18N.I18NString("ErrorMsgCouldNotSynchronizeModSettings", "Couldn't synchronize mod settings. Config tabs are not available.")); AddNopeText(InputConfig, errorMsg); AddNopeText(ImmersionConfig, errorMsg); AddNopeText(PerformanceConfig, errorMsg); AddNopeText(VisualsConfig, errorMsg); AddNopeText(AudioConfig, errorMsg); AddNopeText(OtherConfig, errorMsg); } } if (launcher) { Utilities.UI.Config.LauncherConfig.Initialize(LauncherConfig); if (!HLVRSettingsManager.AreLauncherSettingsInitialized) { var errorMsg = I18N.Get(new I18N.I18NString("ErrorMsgCouldNotSynchronizeLauncherSettings", "Couldn't synchronize launcher settings. You can modify these settings, but they might be lost after closing HLVRConfig.")); AddNopeText(LauncherConfig, errorMsg); } } SkipTooManyLines(); }
private void AddDescription(StackPanel panel, I18N.I18NString description) { if (description == null) { return; } TextBlock textBlock = new TextBlock() { TextWrapping = TextWrapping.WrapWithOverflow, Padding = new Thickness(5, 0, 5, 5), Margin = new Thickness(5, 0, 5, 5), Focusable = true }; textBlock.FontSize *= 0.8; textBlock.Inlines.Add(new Run(I18N.Get(description))); panel.Children.Add(textBlock); }
static MyText SetDefaultTextValues(GameObject go, string langId = null) { var text = go.AddComponent <MyText>(); if (!string.IsNullOrEmpty(langId)) { text.LangId = langId; text.text = I18N.Get(langId); text.UseLangId = true; } text.raycastTarget = false; text.horizontalOverflow = HorizontalWrapMode.Overflow; text.verticalOverflow = VerticalWrapMode.Overflow; text.alignment = TextAnchor.MiddleCenter; text.color = Color.black; text.fontSize = 18; //lbl.font = Resources.Load<Font>("xxx"); //TODO 设置游戏中的字体 return(text); }
public void UpdateAI() { //每次决策执行 int i = 0; int count = player.Data.HandCardList.Count; while (i < count) { if (player.Data.HandCardList[i].Data.Spending <= player.Data.AP) { Debug.LogError("自动使用:" + I18N.Get(player.Data.HandCardList[i].Data.Name)); Game.BattleManager.UseCard(player.Data.HandCardList[i]); count--; i--; } i++; } player.EndRound(); }
/// <summary> /// 加载卡牌 /// </summary> /// <param name="id"></param> private void InitCard(int id) { if (CardId == id) { return; } CardId = id; BattleCardTableSetting card = BattleCardTableSettings.Get(id); icon.Load(card.ShowID); labName.text = I18N.Get(card.Name); spendingNum.text = card.Spending.ToString(); describle.text = I18N.Get(card.Desc); ShowCardType(card.Type); if (card.Type == 0 && card.ActionTypes[0] == 1) { labAttack.text = card.ActionParams[0].ToString(); } }
private void Work(bool reload) { if (!reload) { //Add plugins in "Plugins" dir var pluginsDir = new DirectoryInfo("Plugins"); foreach (var dir in pluginsDir.EnumerateDirectories()) { PluginManager.AddPlugin(new FileSystemRaw(dir)); } foreach (var file in pluginsDir.EnumerateFiles()) { PluginManager.AddPlugin(new FileSystemCompressed(file)); } } //Load resources PluginManager.LoadResources( (total, state, plugin) => { _progress = (int)(total * 50); _text = $"{I18N.Get(state)} {plugin} ({_progress}%)"; Logger.Debug($"{I18N.GetOrdinal(state)} {plugin} ({_progress}%)"); }); _progress = 50; _text = $"{I18N.Get("system.loading.resources.uploadTextures")} ({_progress}%)"; Logger.Debug($"{I18N.GetOrdinal("system.loading.resources.uploadTextures")} ({_progress}%)"); BlockTextureManager.Upload(); if (!reload) { //Load plugins PluginManager.LoadPlugins( (total, state, plugin) => { _progress = (int)(total * 50) + 50; _text = $"{I18N.Get(state)} {plugin} ({_progress}%)"; Logger.Debug($"{I18N.GetOrdinal(state)} {plugin} ({_progress}%)"); }); } }
private void OnClick_ClassItem(GameObject go) { //Debug.LogError(go.name); if (currentSelect != go.name) { Transform icon = go.transform.Find("icon"); DOTween.To(() => icon.localPosition, (v) => icon.localPosition = v, new Vector3(0f, -150f, 0f), 0.3f); DOTween.To(() => icon.localScale, (v) => icon.localScale = v, new Vector3(1.4f, 1.4f, 1.4f), 0.3f); if (!string.IsNullOrEmpty(currentSelect)) { Transform lastIcon = dicClassesGo[currentSelect].transform.Find("icon"); DOTween.To(() => lastIcon.localPosition, (v) => lastIcon.localPosition = v, new Vector3(0f, 0f, 0f), 0.3f); DOTween.To(() => lastIcon.localScale, (v) => lastIcon.localScale = v, new Vector3(1f, 1f, 1f), 0.3f); } ClassTableSetting classData = ClassTableSettings.Get((int)Enum.Parse(typeof(ClassType), go.name)); mLblDetail.text = I18N.Get(classData.Desc); currentSelect = go.name; } }
public void SetCard(int cardId, int count = 1, bool showTips = false) { CardId = cardId; CardNum = count; CardData = BattleCardTableSettings.Get(CardId); leftIcon.Load(CardData.IconLeftID); rightIcon.Load(CardData.IconRightID); lblName.text = I18N.Get(CardData.Name); labSpending.text = CardData.Spending.ToString(); ShowCardType(CardData.Type); if (CardData.Type == 0 && CardData.ActionTypes[0] == 1) { labAttack.text = CardData.ActionParams[0].ToString(); } if (showTips) { UIUtility.SetCardTips(gameObject, CardId, CardNum); } }
private static void InitModSettings() { if (AreModSettingsInitialized) { return; } ModSettings = new ModSettings(); if (!HLVRPaths.CheckHLDirectory() || !HLVRPaths.CheckModDirectory()) { AreModSettingsInitialized = false; return; } if (File.Exists(HLVRPaths.VRModSettingsFile)) { if (!TryLoadSettings(HLVRPaths.VRModSettingsFile)) { var errorMsg = new I18N.I18NString("ErrorMsgCouldNotLoadModSettings", "Couldn't load mod settings file. If you chose OK, HLVRConfig will replace settings with default values. If you chose Cancel, config tabs will not be available."); var errorTitle = new I18N.I18NString("Error", "Error"); var result = MessageBox.Show(I18N.Get(errorMsg), I18N.Get(errorTitle), MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (result != MessageBoxResult.OK) { AreModSettingsInitialized = false; return; } } } if (!TryStoreSettings(ModSettings, HLVRPaths.VRModSettingsFile)) { var errorMsg = new I18N.I18NString("ErrorMsgCouldNotSynchronizeModSettings", "Couldn't synchronize mod settings. Config tabs are not available."); var errorTitle = new I18N.I18NString("Error", "Error"); MessageBox.Show(I18N.Get(errorMsg), I18N.Get(errorTitle), MessageBoxButton.OK, MessageBoxImage.Warning); AreModSettingsInitialized = false; return; } AreModSettingsInitialized = true; }
static void Main() { using (Mutex mutex = new Mutex(false, $"Global\\SmartTools__{Application.StartupPath.GetHashCode()}")) { if (!mutex.WaitOne(0, false)) { Console.WriteLine(I18N.Get("初始化失败,Smart Tool已运行!"), I18N.Get("警告")); } Directory.SetCurrentDirectory(Application.StartupPath); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; FormController.Instance().Start(); Application.Run(); } }