Browse Source

commit: remove NJS HACK, and patchs about ruby

The level tewaker plugin can change NJS in game.
HOME 3 years ago
parent
commit
f1e473ab69

+ 21 - 8
BeatLyrics.Tool/UserControls/TextArrangeUserControl.cs

@@ -99,7 +99,7 @@ namespace BeatLyrics.Tool.UserControls
 
         protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
         {
-            if (false == ActiveControl is TextBox && (keyData == Keys.Space||keyData==Keys.ProcessKey))
+            if (false == ActiveControl is TextBox && (keyData == Keys.Space || keyData == Keys.ProcessKey))
             {
                 if (OggAudioPlayer.IsPlaying) OggAudioPlayer.Stop();
                 else OggAudioPlayer.Play();
@@ -170,13 +170,13 @@ namespace BeatLyrics.Tool.UserControls
 
         private void RemoveRubyButton_Click(object sender, EventArgs e)
         {
-            //TODO: follow ruby format
             foreach (LyricDetailExt item in LeftLyricsObjectListView.SelectedObjects)
             {
                 item.Text = RegRemoveRuby1.Replace(item.Text, "");
                 item.Text = RegRemoveRuby2.Replace(item.Text, "");
                 item.Text = RegRemoveRuby3.Replace(item.Text, "");
                 item.Text = RegRubyConvert.Replace(item.Text, match => match.Groups[2].Value);
+                item.TextWithRuby = null;
                 LeftLyricsObjectListView.UpdateObject(item);
             }
         }
@@ -261,14 +261,27 @@ namespace BeatLyrics.Tool.UserControls
             if (e.KeyCode == Keys.F2 && olv.SelectedObject != null)
             {
                 var item = (LyricDetailExt)olv.SelectedObject;
-                ContextDialog.PopTextBox(MousePosition, item.Text, (r, s) =>
+                if (ModifierKeys == Keys.Shift) //TODO: Double Line Input Box
                 {
-                    if (r == DialogResult.OK)
+                    ContextDialog.PopTextBox(MousePosition, item.TextWithRuby, (r, s) =>
                     {
-                        item.Text = s;
-                        olv.UpdateObject(item);
-                    }
-                });
+                        if (r == DialogResult.OK)
+                        {
+                            item.TextWithRuby = s;
+                        }
+                    });
+                }
+                else
+                {
+                    ContextDialog.PopTextBox(MousePosition, item.Text, (r, s) =>
+                    {
+                        if (r == DialogResult.OK)
+                        {
+                            item.Text = s;
+                            olv.UpdateObject(item);
+                        }
+                    });
+                }
             }
         }
     }

+ 58 - 0
BeatLyrics.Tool/Utils/JapanesePhonetic.cs

@@ -19,6 +19,9 @@ namespace BeatLyrics.Tool.Utils
 
         private static readonly Regex RegexSplitPattern1 = new Regex(@"^(\p{IsCJKUnifiedIdeographs}+)(\p{IsHiragana}+)(\p{IsCJKUnifiedIdeographs}+)$", RegexOptions.Compiled);
         private static readonly Regex RegexSplitPattern2 = new Regex(@"^(\p{IsHiragana}+)(\p{IsCJKUnifiedIdeographs}+)$", RegexOptions.Compiled);
+        private static readonly Regex RegexSplitPattern3 = new Regex(@"^(\p{IsCJKUnifiedIdeographs}+)(\p{IsHiragana}+)$", RegexOptions.Compiled);
+        private static readonly Regex RegexSplitPattern4 = new Regex(@"^(\p{IsHiragana}+)(\p{IsCJKUnifiedIdeographs}+)(\p{IsHiragana}+)$", RegexOptions.Compiled);
+        private static readonly Regex RegexSplitPattern5 = new Regex(@"^(\p{IsCJKUnifiedIdeographs}+)(\p{IsHiragana}+)(\p{IsCJKUnifiedIdeographs}+)(\p{IsHiragana}+)$", RegexOptions.Compiled);
 
         static JapanesePhonetic()
         {
@@ -44,6 +47,12 @@ namespace BeatLyrics.Tool.Utils
             foreach (var item in ret)
             {
                 var displayText = GetDisplayText(item);
+                if (displayText == " ")
+                {
+                    lst.Add(new TextTuple { Text = " ", Ruby = " " });
+                    continue;
+                }
+
                 var yomiText = GetYomiText(item);
 
                 {
@@ -91,6 +100,55 @@ namespace BeatLyrics.Tool.Utils
                     }
                 }
 
+                {
+                    var match = RegexSplitPattern3.Match(displayText);
+                    if (match.Success)
+                    {
+                        var hira = match.Groups[2].Value;
+                        var split = yomiText.Split(new[] { hira }, StringSplitOptions.RemoveEmptyEntries);
+
+                        lst.Add(new TextTuple { Text = match.Groups[1].Value, Ruby = split[0] });
+                        lst.Add(new TextTuple { Text = hira, Ruby = hira });
+                        continue;
+                    }
+                }
+
+                {
+                    var match = RegexSplitPattern4.Match(displayText);
+                    if (match.Success)
+                    {
+                        var leadingHira = match.Groups[1].Value;
+                        var suffixHira = match.Groups[3].Value;
+
+                        var split = yomiText.Substring(leadingHira.Length);
+                        split = split.Substring(0, split.Length - suffixHira.Length);
+
+                        lst.Add(new TextTuple { Text = leadingHira, Ruby = leadingHira });
+                        lst.Add(new TextTuple { Text = match.Groups[2].Value, Ruby = split });
+                        lst.Add(new TextTuple { Text = suffixHira, Ruby = suffixHira });
+                        continue;
+                    }
+                }
+
+                {
+                    var match = RegexSplitPattern5.Match(displayText);
+                    if (match.Success)
+                    {
+                        var kan1 = match.Groups[1].Value;
+                        var hira1 = match.Groups[2].Value;
+                        var kan2 = match.Groups[3].Value;
+                        var hira2 = match.Groups[4].Value;
+
+                        var split = yomiText.Split(new[] { hira1, hira2 }, StringSplitOptions.RemoveEmptyEntries);
+
+                        lst.Add(new TextTuple { Text = kan1, Ruby = split[0] });
+                        lst.Add(new TextTuple { Text = hira1, Ruby = hira1 });
+                        lst.Add(new TextTuple { Text = kan2, Ruby = split[1] });
+                        lst.Add(new TextTuple { Text = hira2, Ruby = hira2 });
+                        continue;
+                    }
+                }
+
                 lst.Add(new TextTuple { Text = displayText, Ruby = yomiText });
             }
 

+ 1 - 0
BeatLyrics.sln.DotSettings

@@ -1,4 +1,5 @@
 <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+	<s:Boolean x:Key="/Default/UserDictionary/Words/=Hira/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Hiragana/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Kanji/@EntryIndexedValue">True</s:Boolean>
 	<s:Boolean x:Key="/Default/UserDictionary/Words/=Netease/@EntryIndexedValue">True</s:Boolean>

+ 0 - 13
BeatLyrics/LyricsComponent.cs

@@ -68,19 +68,6 @@ namespace BeatLyrics
             var sceneSetup = FindObjectOfType<GameplayCoreSceneSetup>();
             _data = (GameplayCoreSceneSetupData)sceneSetup?.GetField("_sceneSetupData");
 
-            //HACK: NJS Cheat
-            if (_data != null) //TODO: Create New Plugin  - OR -  Load from Config
-            {
-                try
-                {
-                    _data.difficultyBeatmap.SetField("_noteJumpMovementSpeed", 18);
-                }
-                catch (Exception e)
-                {
-                    System.Diagnostics.Debug.Print(e.ToString());
-                }
-            }
-
             try
             {
                 LoadLrc();

+ 1 - 1
BeatLyrics/Plugin.cs

@@ -53,7 +53,7 @@ namespace BeatLyrics
             {
                 if (_lastUsedLyricsComponent != null)
                 {
-                    //TODO: cleanup
+                    //TODO: free resources
                 }
             }
         }