/// <summary> /// 初始化游戏设置并载入持久化数据 /// </summary> private void InitConfig() { try { // 读取游戏设置 ConfigParser.ConfigParse(); // 第一次打开游戏就创建持久性上下文 if (System.IO.File.Exists(GlobalConfigContext.PersistenceFileName) == false) { PersistContextDAO.Assign("___YURIRI@ACCDURATION___", 0); PersistContextDAO.Assign("___YURIRI@FIRSTPLAYTIMESTAMP___", DateTime.Now.ToString()); PersistContextDAO.SaveToSteadyMemory(); } // 非第一次打开游戏就读取持久性上下文 else { PersistContextDAO.LoadFromSteadyMemory(); Director.LastGameTimeAcc = TimeSpan.Parse(PersistContextDAO.Exist("___YURIRI@ACCDURATION___") ? PersistContextDAO.Fetch("___YURIRI@ACCDURATION___").ToString() : "0"); } Director.StartupTimeStamp = DateTime.Now; } catch (Exception ex) { LogUtils.LogLine("No config file is detected, use defualt value." + ex, "Director", LogLevel.Error); } }
/// <summary> /// 取一个变量作右值 /// </summary> /// <param name="varName">变量名</param> /// <param name="vsm">关于哪个调用堆栈做动作</param> /// <returns>变量的引用</returns> public object Fetch(string varName, StackMachine vsm) { // 处理局部变量 if (varName.StartsWith("$")) { // 非函数调用 if (this.GameState(vsm) != StackMachineState.FunctionCalling) { return(this.Symbols.SceneCtxDao.Fetch(ResourceManager.GetInstance().GetScene(vsm.EBP.ScriptName), varName.Replace("$", String.Empty))); } // 函数调用 var funFrame = vsm.ESP.BindingFunction; return(funFrame.Symbols[varName.Replace("$", String.Empty)]); } // 处理全局变量 if (varName.StartsWith("&")) { return(this.Symbols.GlobalCtxDao.GlobalFetch(varName.Replace("&", String.Empty))); } // 处理持久化变量 if (varName.StartsWith("%")) { return(PersistContextDAO.Fetch(varName.Replace("%", String.Empty))); } return(null); }
private void refreshGalleryInto(string type) { lock (this) { if (this.isGalleryAnimating) { return; } this.isGalleryAnimating = true; } this.Canvas_Gallery_ButtonsWarp.IsHitTestVisible = false; foreach (var wrapper in this.Canvas_Gallery_ContentWarp.Children) { if (wrapper is Canvas) { var wrapperCanvas = (Canvas)wrapper; if (wrapperCanvas.Name.EndsWith("_Wrapper")) { if (wrapperCanvas.Name == ("Canvas_Gallery_" + type + "_Wrapper")) { wrapperCanvas.Visibility = Visibility.Visible; wrapperCanvas.Opacity = 1; } else { wrapperCanvas.Visibility = Visibility.Hidden; wrapperCanvas.Opacity = 0; } } } } foreach (var btn in this.Canvas_Gallery_ButtonsWarp.Children) { if (btn is Image) { if (((Image)btn).Name.StartsWith("Warp_Gallery_Btn_") && ((Image)btn).Name != ("Warp_Gallery_Btn_" + type)) { ((Image)btn).Opacity = 0.3; } } } // 进入刷新的具体逻辑 switch (type) { case "EDCard": var loopEndFool = (double)PersistContextDAO.Fetch("loop_end_fool") > 0; if (loopEndFool) { var endPath = this.Image_Gallery_EDCard_FoolEnd.Source.ToString(); if (endPath.EndsWith("NoOpen.png")) { endPath = endPath.Replace("NoOpen.png", "FoolEnd.png"); BitmapImage endRotating; endRotating = new BitmapImage(); endRotating.BeginInit(); endRotating.UriSource = new Uri(endPath); endRotating.EndInit(); this.Image_Gallery_EDCard_FoolEnd.Source = endRotating; } } var loopBadBad = (double)PersistContextDAO.Fetch("loop_end_bad") > 0; if (loopBadBad) { var endPath = this.Image_Gallery_EDCard_BadEnd.Source.ToString(); if (endPath.EndsWith("NoOpen.png")) { endPath = endPath.Replace("NoOpen.png", "BadEnd.png"); BitmapImage endRotating; endRotating = new BitmapImage(); endRotating.BeginInit(); endRotating.UriSource = new Uri(endPath); endRotating.EndInit(); this.Image_Gallery_EDCard_BadEnd.Source = endRotating; } } var loopEndNormal = (double)PersistContextDAO.Fetch("loop_end_normal") > 0; if (loopEndNormal) { var endPath = this.Image_Gallery_EDCard_NormalEnd.Source.ToString(); if (endPath.EndsWith("NoOpen.png")) { endPath = endPath.Replace("NoOpen.png", "NormalEnd.png"); BitmapImage endRotating; endRotating = new BitmapImage(); endRotating.BeginInit(); endRotating.UriSource = new Uri(endPath); endRotating.EndInit(); this.Image_Gallery_EDCard_NormalEnd.Source = endRotating; } } var loopEndTrue = (double)PersistContextDAO.Fetch("loop_end_true") > 0; if (loopEndTrue) { var endPath = this.Image_Gallery_EDCard_TrueEnd.Source.ToString(); if (endPath.EndsWith("NoOpen.png")) { endPath = endPath.Replace("NoOpen.png", "TrueEnd.png"); BitmapImage endRotating; endRotating = new BitmapImage(); endRotating.BeginInit(); endRotating.UriSource = new Uri(endPath); endRotating.EndInit(); this.Image_Gallery_EDCard_TrueEnd.Source = endRotating; } } string loopTimesStr; try { var loopTimes = PersistContextDAO.Fetch("Game_LoopTime"); int loopTimeRaw = Convert.ToInt32(loopTimes); if (loopTimeRaw >= 100) { loopTimesStr = "99+"; } else { loopTimesStr = loopTimeRaw.ToString(); } } catch (Exception e) { loopTimesStr = "N/A"; } this.Label_Gallery_EDCard_LoopTime_Hint.Content = $"通关次数:{loopTimesStr}"; string accTimesStr; try { TimeSpan accTimes = (TimeSpan)PersistContextDAO.Fetch("___YURIRI@ACCDURATION___"); accTimesStr = ""; if (accTimes.Days != 0) { accTimesStr += accTimes.Days + "天"; } if (accTimes.Hours != 0) { accTimesStr += accTimes.Hours + "小时"; } accTimesStr += accTimes.Minutes + "分钟"; } catch (Exception e) { accTimesStr = "N/A"; } this.Label_Gallery_EDCard_AccTime_Hint.Content = $"累计时长:{accTimesStr}"; break; case "Music": this.RefreshMusicPlayingStatus(); break; case "Bonus": try { ((LongStoryPage)this.Frame_BonusStory.Content).PrepareOpen(); } catch (Exception e) { LogUtils.LogLine("cannot open bonus long story page, " + e.ToString(), nameof(LHStartPage), LogLevel.Error); } break; default: break; } this.GalleryContentWarpSprite.DisplayBinding.Visibility = Visibility.Visible; this.GalleryContentWarpSprite.DisplayBinding.IsHitTestVisible = false; this.GalleryContentWarpSprite.Descriptor.ToOpacity = 1; SpriteAnimation.OpacityToAnimation(this.GalleryContentWarpSprite, new Duration(TimeSpan.FromMilliseconds(300)), 1, 0, cb: (_, __) => { this.GalleryContentWarpSprite.DisplayBinding.IsHitTestVisible = true; this.currentGalleryStage = type; this.isGalleryAnimating = false; }); }
public void PrepareOpen() { ((LHSettingsPage)this.Frame_Settings.Content).RefreshSteadyConfig(); this.currentSubStage = "root"; this.titlePlayingBGM = "2"; this.isLoading = false; this.isTrueEndArrival = (double)PersistContextDAO.Fetch("Game_EndArrival_TE") > 0; this.Warp_Btn_Gallery.Visibility = this.isTrueEndArrival ? Visibility.Visible : Visibility.Hidden; if (isTrueEndArrival) { this.Art_Image_Background_Window.Source = new BitmapImage(new Uri("pack://application:,,,/Yuri;component/Resources/Title_Ground_T2_bg2.png")); this.Art_Image_Fore.Source = new BitmapImage(new Uri("pack://application:,,,/Yuri;component/Resources/Title_Ground_T2_fore.png")); this.Warp_Image_Title.Source = new BitmapImage(new Uri("pack://application:,,,/Yuri;component/Resources/Title_Logo_2.png")); } string titleType = PersistContextDAO.Fetch("system_config_title_type")?.ToString(); if (titleType == "0") { PersistContextDAO.Assign("system_config_title_type", "Timing"); titleType = "Timing"; } if (false == isTrueEndArrival) { String cloudSourcePath; if (((DateTime.Now.Hour >= 5 && DateTime.Now.Hour < 17) || titleType != "Timing")) { cloudSourcePath = ((Image)this.Art_Image_Background_Cloud_1).Source.ToString(); if (cloudSourcePath.EndsWith("_sunset.png")) { cloudSourcePath = cloudSourcePath.Replace("_sunset.png", ".png"); } } else { cloudSourcePath = ((Image)this.Art_Image_Background_Cloud_1).Source.ToString(); if (!cloudSourcePath.EndsWith("_sunset.png")) { cloudSourcePath = cloudSourcePath.Replace(".png", "_sunset.png"); } } BitmapImage rotating; if (this.cachingButtons.ContainsKey(cloudSourcePath)) { rotating = this.cachingButtons[cloudSourcePath]; } else { rotating = new BitmapImage(); rotating.BeginInit(); rotating.UriSource = new Uri(cloudSourcePath); rotating.EndInit(); this.cachingButtons[cloudSourcePath] = rotating; } ((Image)Art_Image_Background_Cloud_1).Source = rotating; ((Image)Art_Image_Background_Cloud_2).Source = rotating; ((Image)Art_Image_Background_Cloud_Static).Source = null; } else { ((Image)Art_Image_Background_Cloud_1).Source = new BitmapImage(new Uri("pack://application:,,,/Yuri;component/Resources/Title_Ground_TE_float.png")); ((Image)Art_Image_Background_Cloud_2).Source = new BitmapImage(new Uri("pack://application:,,,/Yuri;component/Resources/Title_Ground_TE_float.png")); ((Image)Art_Image_Background_Cloud_Static).Source = new BitmapImage(new Uri("pack://application:,,,/Yuri;component/Resources/Title_Ground_TE_bg.png")); } callbackTarget = SymbolTable.GetInstance().GlobalCtxDao.GlobalSymbolTable.Fetch("tracing_callback").ToString(); this.BackGroundSprite.Descriptor.ToScaleX = 1.2; this.BackGroundSprite.Descriptor.ToScaleY = 1.2; this.BackGroundSprite.Descriptor.ToOpacity = 0; SpriteAnimation.ScaleToAnimation(this.BackGroundSprite, new Duration(TimeSpan.FromMilliseconds(0)), 1.2, 1.2, 0, 0); SpriteAnimation.OpacityToAnimation(this.BackGroundSprite, new Duration(TimeSpan.FromMilliseconds(0)), 0, 0); this.CloudSpriteA.Descriptor.ToX = 1920 / 2; this.CloudSpriteB.Descriptor.ToX = 1920 * 1.5; SpriteAnimation.XMoveToAnimation(this.CloudSpriteA, new Duration(TimeSpan.FromSeconds(0)), 1920 / 2, 0); SpriteAnimation.XMoveToAnimation(this.CloudSpriteB, new Duration(TimeSpan.FromSeconds(0)), 1920 * 1.5, 0); this.RootButtonSprite.Descriptor.ToOpacity = 1; SpriteAnimation.OpacityToAnimation(this.RootButtonSprite, new Duration(TimeSpan.FromMilliseconds(0)), 0, 0); this.UiSprite.Descriptor.ToOpacity = 0; SpriteAnimation.OpacityToAnimation(this.UiSprite, new Duration(TimeSpan.FromMilliseconds(0)), 0, 0); this.CloudHolderSprite.Descriptor.ToOpacity = 0; SpriteAnimation.OpacityToAnimation(this.CloudHolderSprite, new Duration(TimeSpan.FromMilliseconds(0)), 0, 0); this.MaskSprite.Descriptor.ToOpacity = 0; SpriteAnimation.OpacityToAnimation(this.MaskSprite, new Duration(TimeSpan.FromMilliseconds(0)), 0, 0); this.MaskSprite.DisplayBinding.Visibility = Visibility.Hidden; this.GalleryWarpSprite.Descriptor.ToOpacity = 0; SpriteAnimation.OpacityToAnimation(this.GalleryWarpSprite, new Duration(TimeSpan.FromMilliseconds(0)), 0, 0); this.Canvas_Gallery.Visibility = Visibility.Hidden; this.BackGroundSprite.Descriptor.ToScaleX = 1.0; this.BackGroundSprite.Descriptor.ToScaleY = 1.0; this.BackGroundSprite.Descriptor.ToOpacity = 1; SpriteAnimation.ScaleToAnimation(this.BackGroundSprite, new Duration(TimeSpan.FromMilliseconds(1000)), 1.0, 1.0, -0.7, -0.7); SpriteAnimation.OpacityToAnimation(this.BackGroundSprite, new Duration(TimeSpan.FromMilliseconds(500)), 1, -0.6); this.ForeGroundSprite.Descriptor.ToScaleX = 1.4; this.ForeGroundSprite.Descriptor.ToScaleY = 1.4; this.ForeGroundSprite.Descriptor.ToOpacity = 0; SpriteAnimation.ScaleToAnimation(this.ForeGroundSprite, new Duration(TimeSpan.FromMilliseconds(0)), 1.4, 1.4, 0, 0); SpriteAnimation.OpacityToAnimation(this.ForeGroundSprite, new Duration(TimeSpan.FromMilliseconds(0)), 0, 0); this.ForeGroundSprite.Descriptor.ToScaleX = 1.0; this.ForeGroundSprite.Descriptor.ToScaleY = 1.0; this.ForeGroundSprite.Descriptor.ToOpacity = 1; SpriteAnimation.ScaleToAnimation(this.ForeGroundSprite, new Duration(TimeSpan.FromMilliseconds(1000)), 1.0, 1.0, -0.7, -0.7, cb: (_, __) => { this.UiSprite.Descriptor.ToOpacity = 1; SpriteAnimation.OpacityToAnimation(this.UiSprite, new Duration(TimeSpan.FromMilliseconds(500)), 1, -0.6); this.Grid_WarpHolder.IsHitTestVisible = true; }); SpriteAnimation.OpacityToAnimation(this.ForeGroundSprite, new Duration(TimeSpan.FromMilliseconds(500)), 1, -0.6); this.CloudHolderSprite.Descriptor.ToOpacity = 1; SpriteAnimation.OpacityToAnimation(this.CloudHolderSprite, new Duration(TimeSpan.FromMilliseconds(500)), 1, -0.6); this.cloudSb = new Storyboard(); this.CloudSpriteA.Descriptor.ToX = -1920 / 2; this.CloudSpriteB.Descriptor.ToX = 1920 / 2; SpriteAnimation.XMoveToAnimation(this.CloudSpriteA, new Duration(TimeSpan.FromSeconds(300)), -1920 / 2, 0, null, cloudSb); SpriteAnimation.XMoveToAnimation(this.CloudSpriteB, new Duration(TimeSpan.FromSeconds(300)), 1920 / 2, 0, null, cloudSb); this.cloudSb.RepeatBehavior = new RepeatBehavior(int.MaxValue); this.cloudSb.Begin(); }
public void RefreshSteadyConfig() { string rawRollback = PersistContextDAO.Fetch("system_config_rollback_enable")?.ToString(); if (rawRollback == "0") { PersistContextDAO.Assign("system_config_rollback_enable", "true"); rawRollback = "true"; } Director.IsAllowRollback = rawRollback == "true"; if (Director.IsAllowRollback) { this.LabelRadio_Others_Rollback_Enable.Foreground = new SolidColorBrush(this.xichengBlue); this.LabelRadio_Others_Rollback_Disable.Foreground = new SolidColorBrush(Colors.Black); } else { this.LabelRadio_Others_Rollback_Disable.Foreground = new SolidColorBrush(this.xichengBlue); this.LabelRadio_Others_Rollback_Enable.Foreground = new SolidColorBrush(Colors.Black); } string titleType = PersistContextDAO.Fetch("system_config_title_type")?.ToString(); if (titleType == "0") { PersistContextDAO.Assign("system_config_title_type", "Timing"); titleType = "Timing"; } if (titleType == "Timing") { this.LabelRadio_Others_Title_Timing.Foreground = new SolidColorBrush(this.xichengBlue); this.LabelRadio_Others_Title_Dusk.Foreground = new SolidColorBrush(Colors.Black); } else { this.LabelRadio_Others_Title_Dusk.Foreground = new SolidColorBrush(this.xichengBlue); this.LabelRadio_Others_Title_Timing.Foreground = new SolidColorBrush(Colors.Black); } string performanceType = PersistContextDAO.Fetch("system_config_performance_set")?.ToString(); if (performanceType == "0") { PersistContextDAO.Assign("system_config_performance_set", "Enable"); performanceType = "Enable"; } if (performanceType == "Enable") { this.LabelRadio_Others_Performance_Enable.Foreground = new SolidColorBrush(this.xichengBlue); this.LabelRadio_Others_Performance_Disable.Foreground = new SolidColorBrush(Colors.Black); } else { this.LabelRadio_Others_Performance_Disable.Foreground = new SolidColorBrush(this.xichengBlue); this.LabelRadio_Others_Performance_Enable.Foreground = new SolidColorBrush(Colors.Black); } string autoSpeedRaw = PersistContextDAO.Fetch("system_config_autospeed")?.ToString(); if (autoSpeedRaw == "0") { PersistContextDAO.Assign("system_config_autospeed", "3"); autoSpeedRaw = "3"; } var autoSpeed = Convert.ToInt32(autoSpeedRaw); for (int i = 1; i <= 5; i++) { var cl = (Label)this.FindName("LabelRadio_Grahpic_Auto_" + i); if (i != autoSpeed) { cl.Foreground = new SolidColorBrush(Colors.Black); } else { cl.Foreground = new SolidColorBrush(this.xichengBlue); } } switch (autoSpeed) { case 1: GlobalConfigContext.GAME_MSG_AUTOPLAY_DELAY = 7000; break; case 2: GlobalConfigContext.GAME_MSG_AUTOPLAY_DELAY = 3500; break; case 3: GlobalConfigContext.GAME_MSG_AUTOPLAY_DELAY = 2000; break; case 4: GlobalConfigContext.GAME_MSG_AUTOPLAY_DELAY = 1500; break; case 5: GlobalConfigContext.GAME_MSG_AUTOPLAY_DELAY = 600; break; } string typeSpeedRaw = PersistContextDAO.Fetch("system_config_typespeed")?.ToString(); if (typeSpeedRaw == "0") { PersistContextDAO.Assign("system_config_typespeed", "3"); typeSpeedRaw = "3"; } var typeSpeed = Convert.ToInt32(typeSpeedRaw); for (int i = 1; i <= 5; i++) { var cl = (Label)this.FindName("LabelRadio_Grahpic_Typing_" + i); if (i != typeSpeed) { cl.Foreground = new SolidColorBrush(Colors.Black); } else { cl.Foreground = new SolidColorBrush(this.xichengBlue); } } switch (typeSpeed) { case 1: GlobalConfigContext.GAME_MSG_TYPING_DELAY = 120; break; case 2: GlobalConfigContext.GAME_MSG_TYPING_DELAY = 90; break; case 3: GlobalConfigContext.GAME_MSG_TYPING_DELAY = 30; break; case 4: GlobalConfigContext.GAME_MSG_TYPING_DELAY = 10; break; case 5: GlobalConfigContext.GAME_MSG_TYPING_DELAY = 0; break; } string bgmRaw = PersistContextDAO.Fetch("system_config_audio_bgm")?.ToString(); if (bgmRaw == "0") { PersistContextDAO.Assign("system_config_audio_bgm", "18"); bgmRaw = "18"; } var bgmRatio = Convert.ToInt32(bgmRaw); for (int i = 1; i <= bgmRatio; i++) { var curRec = (Rectangle)this.FindName("Rec_BGM_" + i); curRec.Fill = new SolidColorBrush(this.xichengBlue); } for (int i = bgmRatio + 1; i <= 20; i++) { var curRec = (Rectangle)this.FindName("Rec_BGM_" + i); curRec.Fill = new SolidColorBrush(Color.FromRgb(222, 222, 222)); } if (!musicianInit) { if (bgmRatio == 1) { Musician.GetInstance().BGMVolumeRatio = 0.0; } else if (bgmRatio == 20) { Musician.GetInstance().BGMVolumeRatio = 1.0; } else { Musician.GetInstance().BGMVolumeRatio = 1.0 / 20 * bgmRatio; } Musician.GetInstance().SetBGMVolume(800); } string seRaw = PersistContextDAO.Fetch("system_config_audio_se")?.ToString(); if (seRaw == "0") { PersistContextDAO.Assign("system_config_audio_se", "18"); seRaw = "18"; } var seRatio = Convert.ToInt32(seRaw); for (int i = 1; i <= seRatio; i++) { var curRec = (Rectangle)this.FindName("Rec_SE_" + i); curRec.Fill = new SolidColorBrush(this.xichengBlue); } for (int i = seRatio + 1; i <= 20; i++) { var curRec = (Rectangle)this.FindName("Rec_SE_" + i); curRec.Fill = new SolidColorBrush(Color.FromRgb(222, 222, 222)); } if (!musicianInit) { if (seRatio == 1) { Musician.GetInstance().SEDefaultVolumeRatio = 0.0; } else if (seRatio == 20) { Musician.GetInstance().SEDefaultVolumeRatio = 1.0; } else { Musician.GetInstance().SEDefaultVolumeRatio = 1.0 / 20 * seRatio; } } string voiceRaw = PersistContextDAO.Fetch("system_config_audio_voice")?.ToString(); if (voiceRaw == "0") { PersistContextDAO.Assign("system_config_audio_voice", "20"); voiceRaw = "20"; } var voiceRatio = Convert.ToInt32(voiceRaw); for (int i = 1; i <= voiceRatio; i++) { var curRec = (Rectangle)this.FindName("Rec_VOICE_" + i); curRec.Fill = new SolidColorBrush(this.xichengBlue); } for (int i = voiceRatio + 1; i <= 20; i++) { var curRec = (Rectangle)this.FindName("Rec_VOICE_" + i); curRec.Fill = new SolidColorBrush(Color.FromRgb(222, 222, 222)); } if (!musicianInit) { if (voiceRatio == 1) { Musician.GetInstance().VocalDefaultVolumeRatio = 0.0; } else if (voiceRatio == 20) { Musician.GetInstance().VocalDefaultVolumeRatio = 1.0; } else { Musician.GetInstance().VocalDefaultVolumeRatio = 1.0 / 20 * voiceRatio; } } musicianInit = true; string xwVoiceRaw = PersistContextDAO.Fetch("system_config_audio_voice_xw")?.ToString(); if (xwVoiceRaw == "0") { PersistContextDAO.Assign("system_config_audio_voice_xw", "true"); xwVoiceRaw = "true"; } voice_xw = xwVoiceRaw == "true"; var xwVoiceSourcePath = this.Chara_VOICE_XW.Source.ToString(); if (voice_xw == true && xwVoiceSourcePath.EndsWith("On.png") || voice_xw == false && xwVoiceSourcePath.EndsWith("Off.png")) { // nothing } else if (voice_xw == true) { xwVoiceSourcePath = xwVoiceSourcePath.Replace("Off.png", "On.png"); } else if (voice_xw == false) { xwVoiceSourcePath = xwVoiceSourcePath.Replace("On.png", "Off.png"); } BitmapImage voiceXWRotating; if (this.cachingButtons.ContainsKey(xwVoiceSourcePath)) { voiceXWRotating = this.cachingButtons[xwVoiceSourcePath]; } else { voiceXWRotating = new BitmapImage(); voiceXWRotating.BeginInit(); voiceXWRotating.UriSource = new Uri(xwVoiceSourcePath); voiceXWRotating.EndInit(); this.cachingButtons[xwVoiceSourcePath] = voiceXWRotating; } this.Chara_VOICE_XW.Source = voiceXWRotating; string qlVoiceRaw = PersistContextDAO.Fetch("system_config_audio_voice_ql")?.ToString(); if (qlVoiceRaw == "0") { PersistContextDAO.Assign("system_config_audio_voice_ql", "true"); qlVoiceRaw = "true"; } voice_ql = qlVoiceRaw == "true"; var qlVoiceSourcePath = this.Chara_VOICE_QL.Source.ToString(); if (voice_ql == true && qlVoiceSourcePath.EndsWith("On.png") || voice_ql == false && qlVoiceSourcePath.EndsWith("Off.png")) { // nothing } else if (voice_ql == true) { qlVoiceSourcePath = qlVoiceSourcePath.Replace("Off.png", "On.png"); } else if (voice_ql == false) { qlVoiceSourcePath = qlVoiceSourcePath.Replace("On.png", "Off.png"); } BitmapImage voiceQLRotating; if (this.cachingButtons.ContainsKey(qlVoiceSourcePath)) { voiceQLRotating = this.cachingButtons[qlVoiceSourcePath]; } else { voiceQLRotating = new BitmapImage(); voiceQLRotating.BeginInit(); voiceQLRotating.UriSource = new Uri(qlVoiceSourcePath); voiceQLRotating.EndInit(); this.cachingButtons[qlVoiceSourcePath] = voiceQLRotating; } this.Chara_VOICE_QL.Source = voiceQLRotating; string userFontName = PersistContextDAO.Fetch("system_config_userfont_name")?.ToString(); if (userFontName == "0") { PersistContextDAO.Assign("system_config_userfont_name", "default"); userFontName = "default"; } string userFontSize = PersistContextDAO.Fetch("system_config_userfont_size")?.ToString(); if (userFontSize == "0") { PersistContextDAO.Assign("system_config_userfont_size", GlobalConfigContext.GAME_FONT_FONTSIZE.ToString()); userFontSize = GlobalConfigContext.GAME_FONT_FONTSIZE.ToString(); } lock (LHSettingsPage.syncObj) { if (fontInit == false) { try { this.startupDefaultFontName = GlobalConfigContext.GAME_FONT_NAME; this.startupDefaultFontSize = GlobalConfigContext.GAME_FONT_FONTSIZE; this.Label_FontName.Content = userFontName; this.Label_FontName.FontSize = Convert.ToDouble(userFontSize); this.Label_FontName.FontFamily = new FontFamily(userFontName); Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontname", userFontName); Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontsize", userFontSize); GlobalConfigContext.GAME_FONT_NAME = userFontName; GlobalConfigContext.GAME_FONT_FONTSIZE = int.Parse(userFontSize); } catch (Exception fe) { LogUtils.LogLine("cannot load user custom font: " + fe.ToString(), nameof(LHSettingsPage), LogLevel.Error); Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontname", this.startupDefaultFontName); Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontsize", this.startupDefaultFontSize.ToString()); GlobalConfigContext.GAME_FONT_NAME = this.startupDefaultFontName; GlobalConfigContext.GAME_FONT_FONTSIZE = this.startupDefaultFontSize; } fontInit = true; } else { if (userFontName == "default") { this.Label_FontName.Content = "(默认)Source Han Serif"; this.Label_FontName.FontSize = 32; this.Label_FontName.FontFamily = new FontFamily(new Uri("pack://application:,,,/"), "Resources/#Source Han Serif CN SemiBold"); } else { this.Label_FontName.Content = userFontName; this.Label_FontName.FontSize = Convert.ToDouble(userFontSize); this.Label_FontName.FontFamily = new FontFamily(userFontName); } } } }
/// <summary> /// 初始化精灵对象,它只能被执行一次 /// </summary> /// <param name="resName">资源名称</param> /// <param name="resType">资源类型</param> /// <param name="ms">材质的内存流</param> /// <param name="cutrect">材质切割矩形</param> public void Init(string resName, ResourceType resType, MemoryStream ms, Int32Rect?cutrect = null) { this.memoryStreamRef = ms; if (!this.IsInit) { this.ResourceName = resName; this.ResourceType = resType; var highPerformanceFlag = PersistContextDAO.Fetch("system_config_performance_set")?.ToString() == "Disable"; if (highPerformanceFlag || resType != ResourceType.Stand || resName.StartsWith("@") || !resName.Contains("_@")) { this.SpriteBitmapImage = new BitmapImage(); this.SpriteBitmapImage.BeginInit(); this.SpriteBitmapImage.StreamSource = ms; if (cutrect != null) { this.CutRect = (Int32Rect)cutrect; this.SpriteBitmapImage.SourceRect = this.CutRect; } this.SpriteBitmapImage.EndInit(); this.IsInit = true; // 加载Mask var rm = ResourceManager.GetInstance(); var maskPath = GlobalConfigContext.PictureMaskPrefix + resName; this.IsMaskTriggerable = rm.IsResourceExist(maskPath, ResourceType.Pictures); if (this.IsMaskTriggerable) { this.MaskSprite = rm.GetPicture(maskPath, ResourceManager.FullImageRect); } this.IsAutoAnimateable = false; } // 如果是立绘,就看是否需要加载帧动画 else { this.IsAutoAnimateable = true; var splitor = resName.LastIndexOf("."); var prefix = resName.Substring(0, splitor); var postfix = resName.Substring(splitor, resName.Length - splitor); this.AutoAnimationCount = 4; this.animationImageList = new List <BitmapImage>(); var rm = ResourceManager.GetInstance(); for (int i = 1; i <= this.AutoAnimationCount; i++) { var actualName = $"@{prefix}@{i}{postfix}"; var tSprite = rm.GetCharacterStand(actualName, ResourceManager.FullImageRect); this.animationImageList.Add(tSprite.SpriteBitmapImage); } this.autoAnimationTimer = new System.Windows.Forms.Timer { Interval = 5000 }; this.autoAnimationTimer.Tick += AutoAnimationTimer_Tick; this.autoAnimationTimer.Start(); this.SpriteBitmapImage = this.animationImageList[0]; this.IsInit = true; // fast wink when loaded try { this.AutoAnimationTimer_Tick(null, null); } catch (Exception e) { LogUtils.LogLine("fast wink failed: " + e.ToString(), "YuriSprite", LogLevel.Warning); } } } else { LogUtils.LogLine($"Sprite Init again: {resName}", "MySprite", LogLevel.Error); } }