Exemple #1
0
 /// <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);
     }
 }
Exemple #2
0
        /// <summary>
        /// 在游戏即将结束时释放所有资源
        /// </summary>
        public static void CollapseWorld()
        {
            Director.IsCollapsing = true;
            var collaTimeStamp = DateTime.Now;

            LogUtils.LogLine("Yuri world began to collapse at " + collaTimeStamp, "Director", LogLevel.Important);
            PersistContextDAO.Assign("___YURIRI@LASTPLAYTIMESTAMP___", collaTimeStamp.ToString());
            PersistContextDAO.Assign("___YURIRI@ACCDURATION___", Director.LastGameTimeAcc + (collaTimeStamp - Director.StartupTimeStamp));
            PersistContextDAO.SaveToSteadyMemory();
            LogUtils.LogLine("Save persistence context OK", "Director", LogLevel.Important);
            if (GlobalConfigContext.UseBassEngine == false)
            {
                MusicianRouterHandler.TerminalFlag = true;
                Musician.GetInstance().Dispose();
            }
            LogUtils.LogLine("Dispose resource OK, program will shutdown soon", "Director", LogLevel.Important);
            var ct = DateTime.Now;

            GC.Collect();
            if (GlobalConfigContext.UseBassEngine == false)
            {
                while ((DateTime.Now - ct).TotalSeconds < 2 && !MusicianRouterHandler.IsCollapsed)
                {
                    System.Threading.Thread.Sleep(10);
                }
            }
            Environment.Exit(0);
        }
Exemple #3
0
 /// <summary>
 /// 左值运算一个变量
 /// </summary>
 /// <param name="varname">变量名</param>
 /// <param name="valuePolish">右值逆波兰式</param>
 /// <param name="vsm">关于哪个调用堆栈做动作</param>
 public void Assignment(string varname, string valuePolish, StackMachine vsm)
 {
     // 处理局部变量
     if (varname.StartsWith("$"))
     {
         // 非函数调用
         if (this.GameState(vsm) != StackMachineState.FunctionCalling)
         {
             this.Symbols.SceneCtxDao.Assign(vsm.EBP.ScriptName, varname.Replace("$", String.Empty), PolishEvaluator.Evaluate(valuePolish, vsm));
         }
         // 函数调用
         else
         {
             var functionFrame = vsm.ESP.BindingFunction;
             functionFrame.Symbols[varname.Replace("$", String.Empty)] = PolishEvaluator.Evaluate(valuePolish, vsm);
         }
     }
     // 处理全局变量
     else if (varname.StartsWith("&"))
     {
         this.Symbols.GlobalCtxDao.GlobalAssign(varname.Replace("&", String.Empty), PolishEvaluator.Evaluate(valuePolish, vsm));
     }
     // 处理持久化变量
     else if (varname.StartsWith("%"))
     {
         PersistContextDAO.Assign(varname.Replace("%", String.Empty), PolishEvaluator.Evaluate(valuePolish, vsm));
     }
 }
Exemple #4
0
        private void Chara_VOICE_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.RightButton == MouseButtonState.Pressed)
            {
                return;
            }
            bool?judger = null;
            var  name   = ((Image)sender).Name;

            switch (name)
            {
            case "Chara_VOICE_XW":
                voice_xw = !voice_xw;
                judger   = voice_xw;
                PersistContextDAO.Assign("system_config_audio_voice_xw", judger.ToString().ToLower());
                break;

            case "Chara_VOICE_QL":
                voice_ql = !voice_ql;
                judger   = voice_ql;
                PersistContextDAO.Assign("system_config_audio_voice_ql", judger.ToString().ToLower());
                break;
            }

            var sourcePath = ((Image)sender).Source.ToString();

            if (judger == true && sourcePath.EndsWith("On.png") || judger == false && sourcePath.EndsWith("Off.png"))
            {
                return;
            }
            else if (judger == true)
            {
                sourcePath = sourcePath.Replace("Off.png", "On.png");
            }
            else if (judger == false)
            {
                sourcePath = sourcePath.Replace("On.png", "Off.png");
            }

            BitmapImage rotating;

            if (this.cachingButtons.ContainsKey(sourcePath))
            {
                rotating = this.cachingButtons[sourcePath];
            }
            else
            {
                rotating = new BitmapImage();
                rotating.BeginInit();
                rotating.UriSource = new Uri(sourcePath);
                rotating.EndInit();
                this.cachingButtons[sourcePath] = rotating;
            }
            ((Image)sender).Source = rotating;
        }
Exemple #5
0
        private void Image_Btn_SetFont_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.RightButton == MouseButtonState.Pressed)
            {
                return;
            }
            var fontDialog = new System.Windows.Forms.FontDialog
            {
                AllowVerticalFonts = false,
                AllowScriptChange  = false,
                MinSize            = 8,
                ShowEffects        = false,
                ShowColor          = false,
                ShowHelp           = false,
                ShowApply          = false,
                FontMustExist      = true
            };

            var dr = fontDialog.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            var newFontName = fontDialog.Font.Name;
            var newFontSize = fontDialog.Font.Size;

            try
            {
                this.Label_FontName.Content    = newFontName;
                this.Label_FontName.FontSize   = newFontSize;
                this.Label_FontName.FontFamily = new FontFamily(newFontName);
            }
            catch (Exception fe)
            {
                LogUtils.LogLine("cannot load user custom font: " + fe.ToString(), nameof(LHSettingsPage), LogLevel.Error);
                GlobalConfigContext.GAME_FONT_NAME     = this.startupDefaultFontName;
                GlobalConfigContext.GAME_FONT_FONTSIZE = this.startupDefaultFontSize;
                Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontname", this.startupDefaultFontName);
                Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontsize", this.startupDefaultFontSize.ToString());
                return;
            }

            Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontname", newFontName);
            Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontsize", newFontSize.ToString());

            PersistContextDAO.Assign("system_config_userfont_name", newFontName);
            PersistContextDAO.Assign("system_config_userfont_size", newFontSize);

            GlobalConfigContext.GAME_FONT_NAME     = newFontName;
            GlobalConfigContext.GAME_FONT_FONTSIZE = Convert.ToInt32(newFontSize);
        }
Exemple #6
0
 private void Image_Btn_DefaultFont_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.RightButton == MouseButtonState.Pressed)
     {
         return;
     }
     GlobalConfigContext.GAME_FONT_NAME     = "default";
     GlobalConfigContext.GAME_FONT_FONTSIZE = 32;
     Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontname", "default");
     Director.GetInstance().GetMainRender().MsgLayerOpt(0, "fontsize", "32");
     PersistContextDAO.Assign("system_config_userfont_name", "default");
     PersistContextDAO.Assign("system_config_userfont_size", "32");
     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");
 }
Exemple #7
0
        private void LabelRadio_Grahpic_Typing_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.RightButton == MouseButtonState.Pressed)
            {
                return;
            }
            var name = ((Label)sender).Name;
            var id   = Convert.ToInt32(name.Replace("LabelRadio_Grahpic_Typing_", ""));

            for (int i = 1; i <= 5; i++)
            {
                var cl = (Label)this.FindName("LabelRadio_Grahpic_Typing_" + i);
                if (i != id)
                {
                    cl.Foreground = new SolidColorBrush(Colors.Black);
                }
                else
                {
                    cl.Foreground = new SolidColorBrush(this.xichengBlue);
                }
            }
            PersistContextDAO.Assign("system_config_typespeed", id.ToString());
            switch (id)
            {
            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;
            }
        }
Exemple #8
0
        private void LabelRadio_Others_Title_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.RightButton == MouseButtonState.Pressed)
            {
                return;
            }
            switch (((Label)sender).Name)
            {
            case "LabelRadio_Others_Title_Timing":
                PersistContextDAO.Assign("system_config_title_type", "Timing");
                this.LabelRadio_Others_Title_Timing.Foreground = new SolidColorBrush(this.xichengBlue);
                this.LabelRadio_Others_Title_Dusk.Foreground   = new SolidColorBrush(Colors.Black);
                break;

            case "LabelRadio_Others_Title_Dusk":
                PersistContextDAO.Assign("system_config_title_type", "Dusk");
                this.LabelRadio_Others_Title_Dusk.Foreground   = new SolidColorBrush(this.xichengBlue);
                this.LabelRadio_Others_Title_Timing.Foreground = new SolidColorBrush(Colors.Black);
                break;
            }
        }
Exemple #9
0
        private void LabelRadio_Others_Performance_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.RightButton == MouseButtonState.Pressed)
            {
                return;
            }
            switch (((Label)sender).Name)
            {
            case "LabelRadio_Others_Performance_Enable":
                PersistContextDAO.Assign("system_config_performance_set", "Enable");
                this.LabelRadio_Others_Performance_Enable.Foreground  = new SolidColorBrush(this.xichengBlue);
                this.LabelRadio_Others_Performance_Disable.Foreground = new SolidColorBrush(Colors.Black);
                break;

            case "LabelRadio_Others_Performance_Disable":
                PersistContextDAO.Assign("system_config_performance_set", "Disable");
                this.LabelRadio_Others_Performance_Disable.Foreground = new SolidColorBrush(this.xichengBlue);
                this.LabelRadio_Others_Performance_Enable.Foreground  = new SolidColorBrush(Colors.Black);
                break;
            }
        }
Exemple #10
0
        private void LabelRadio_Others_Rollback_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.RightButton == MouseButtonState.Pressed)
            {
                return;
            }
            var name = ((Label)sender).Name;

            if (name.Contains("Enable"))
            {
                this.LabelRadio_Others_Rollback_Enable.Foreground  = new SolidColorBrush(this.xichengBlue);
                this.LabelRadio_Others_Rollback_Disable.Foreground = new SolidColorBrush(Colors.Black);
                Director.IsAllowRollback = true;
                PersistContextDAO.Assign("system_config_rollback_enable", "true");
            }
            else if (name.Contains("Disable"))
            {
                this.LabelRadio_Others_Rollback_Disable.Foreground = new SolidColorBrush(this.xichengBlue);
                this.LabelRadio_Others_Rollback_Enable.Foreground  = new SolidColorBrush(Colors.Black);
                Director.IsAllowRollback = false;
                PersistContextDAO.Assign("system_config_rollback_enable", "false");
            }
        }
Exemple #11
0
        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();
        }
Exemple #12
0
        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);
                    }
                }
            }
        }
Exemple #13
0
        private void Rec_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.RightButton == MouseButtonState.Pressed)
            {
                return;
            }
            var selectedName  = ((Rectangle)sender).Name;
            var selectedCount = Convert.ToInt32(selectedName.Split('_').Last());
            var selectedTerm  = selectedName.Substring(0, selectedName.LastIndexOf('_') + 1);

            for (int i = 1; i <= selectedCount; i++)
            {
                var curRec = (Rectangle)this.FindName(selectedTerm + i);
                curRec.Fill = new SolidColorBrush(this.xichengBlue);
            }
            for (int i = selectedCount + 1; i <= 20; i++)
            {
                var curRec = (Rectangle)this.FindName(selectedTerm + i);
                curRec.Fill = new SolidColorBrush(Color.FromRgb(222, 222, 222));
            }
            if (selectedTerm.StartsWith("Rec_BGM_"))
            {
                if (selectedCount == 1)
                {
                    Musician.GetInstance().BGMVolumeRatio = 0.0;
                }
                else if (selectedCount == 20)
                {
                    Musician.GetInstance().BGMVolumeRatio = 1.0;
                }
                else
                {
                    Musician.GetInstance().BGMVolumeRatio = 1.0 / 20 * selectedCount;
                }
                PersistContextDAO.Assign("system_config_audio_bgm", selectedCount.ToString());
                Musician.GetInstance().SetBGMVolume(800);
            }
            else if (selectedTerm.StartsWith("Rec_SE_"))
            {
                if (selectedCount == 1)
                {
                    Musician.GetInstance().SEDefaultVolumeRatio = 0.0;
                }
                else if (selectedCount == 20)
                {
                    Musician.GetInstance().SEDefaultVolumeRatio = 1.0;
                }
                else
                {
                    Musician.GetInstance().SEDefaultVolumeRatio = 1.0 / 20 * selectedCount;
                }
                PersistContextDAO.Assign("system_config_audio_se", selectedCount.ToString());
            }
            else if (selectedTerm.StartsWith("Rec_VOICE_"))
            {
                if (selectedCount == 1)
                {
                    Musician.GetInstance().VocalDefaultVolumeRatio = 0.0;
                }
                else if (selectedCount == 20)
                {
                    Musician.GetInstance().VocalDefaultVolumeRatio = 1.0;
                }
                else
                {
                    Musician.GetInstance().VocalDefaultVolumeRatio = 1.0 / 20 * selectedCount;
                }
                PersistContextDAO.Assign("system_config_audio_voice", selectedCount.ToString());
            }
        }