diff --git a/src/SerialLoops.Lib/Items/ChessPuzzleItem.cs b/src/SerialLoops.Lib/Items/ChessPuzzleItem.cs index 31f8735f..ae95a9a1 100644 --- a/src/SerialLoops.Lib/Items/ChessPuzzleItem.cs +++ b/src/SerialLoops.Lib/Items/ChessPuzzleItem.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using HaruhiChokuretsuLib.Archive; +using HaruhiChokuretsuLib.Archive; using HaruhiChokuretsuLib.Archive.Data; using HaruhiChokuretsuLib.Archive.Graphics; using HaruhiChokuretsuLib.Util; diff --git a/src/SerialLoops.Lib/Items/ScriptItem.cs b/src/SerialLoops.Lib/Items/ScriptItem.cs index a1e3222a..561dc7b6 100644 --- a/src/SerialLoops.Lib/Items/ScriptItem.cs +++ b/src/SerialLoops.Lib/Items/ScriptItem.cs @@ -38,6 +38,7 @@ public ScriptItem(EventFile evt, EventTable evtTbl, Func localiz public Dictionary> GetScriptCommandTree(Project project, ILogger log) { + ScriptCommandInvocation currentCommand = null; try { Dictionary> commands = []; @@ -46,6 +47,7 @@ public Dictionary> GetScriptCommandTree(P commands.Add(section, []); foreach (ScriptCommandInvocation command in section.Objects) { + currentCommand = command; commands[section].Add(ScriptItemCommand.FromInvocation(command, section, commands[section].Count, Event, project, _localize, log)); } @@ -56,8 +58,8 @@ public Dictionary> GetScriptCommandTree(P catch (Exception ex) { log.LogException( - string.Format(project.Localize("Error getting script command tree for script {0} ({1})"), - DisplayName, Name), ex); + string.Format(project.Localize("Error getting script command tree for script {0} ({1}): {2} {3}"), + DisplayName, Name, currentCommand?.Command.Mnemonic ?? "NULL_COMMAND", string.Join(", ", currentCommand?.Parameters ?? [])), ex); return null; } } @@ -207,7 +209,7 @@ public ScriptPreview GetScriptPreview(Dictionary 0) + { + preview.CurrentChocies.Add(((OptionScriptParameter)currentCommand.Parameters[0]).Option.Text); + } + if (((OptionScriptParameter)currentCommand.Parameters[1]).Option.Id > 0) + { + preview.CurrentChocies.Add(((OptionScriptParameter)currentCommand.Parameters[1]).Option.Text); + } + if (((OptionScriptParameter)currentCommand.Parameters[2]).Option.Id > 0) + { + preview.CurrentChocies.Add(((OptionScriptParameter)currentCommand.Parameters[2]).Option.Text); + } + if (((OptionScriptParameter)currentCommand.Parameters[3]).Option.Id > 0) + { + preview.CurrentChocies.Add(((OptionScriptParameter)currentCommand.Parameters[3]).Option.Text); + } + } + return preview; } @@ -1021,6 +1045,30 @@ public static (SKBitmap PreviewImage, string ErrorImage) GeneratePreviewImage(Sc canvas.DrawBitmap(topicFlyout, 256 - topicFlyout.Width, verticalOffset + 128); } + // Draw select choices + if (preview.CurrentChocies?.Count > 0) + { + List choiceGraphics = []; + foreach (string choice in preview.CurrentChocies) + { + SKBitmap choiceGraphic = new(218, 18); + SKCanvas choiceCanvas = new(choiceGraphic); + choiceCanvas.DrawRect(1, 1, 216, 16, new() { Color = new(146, 146, 146) }); + choiceCanvas.DrawRect(2, 2, 214, 14, new() { Color = new(69, 69, 69) }); + int choiceWidth = project.LangCode.Equals("ja") ? choice.Length * 14 : choice.Sum(c => project.FontReplacement.ReverseLookup(c).Offset); + choiceCanvas.DrawHaroohieText(choice, DialogueScriptParameter.Paint00, project, (218 - choiceWidth) / 2, 2); + choiceCanvas.Flush(); + choiceGraphics.Add(choiceGraphic); + } + + int graphicY = (192 - (choiceGraphics.Count * 18 + (choiceGraphics.Count - 1) * 8)) / 2 + 184; + foreach (SKBitmap choiceGraphic in choiceGraphics) + { + canvas.DrawBitmap(choiceGraphic, 19, graphicY); + graphicY += 26; + } + } + canvas.Flush(); return (previewBitmap, null); } diff --git a/src/SerialLoops.Lib/Script/Parameters/BgmModeScriptParameter.cs b/src/SerialLoops.Lib/Script/Parameters/BgmModeScriptParameter.cs index 501f6af7..22cd27e7 100644 --- a/src/SerialLoops.Lib/Script/Parameters/BgmModeScriptParameter.cs +++ b/src/SerialLoops.Lib/Script/Parameters/BgmModeScriptParameter.cs @@ -14,12 +14,12 @@ public BgmModeScriptParameter(string name, short mode) : base(name, ParameterTyp public enum BgmMode : short { - START = 2, - STOP = 4, + Start = 2, + Stop = 4, } public override BgmModeScriptParameter Clone(Project project, EventFile eventFile) { return new(Name, (short)Mode); } -} \ No newline at end of file +} diff --git a/src/SerialLoops.Lib/Script/Parameters/ColorMonochromeScriptParameter.cs b/src/SerialLoops.Lib/Script/Parameters/ColorMonochromeScriptParameter.cs index c5fbc675..85f38c12 100644 --- a/src/SerialLoops.Lib/Script/Parameters/ColorMonochromeScriptParameter.cs +++ b/src/SerialLoops.Lib/Script/Parameters/ColorMonochromeScriptParameter.cs @@ -19,8 +19,8 @@ public override ColorMonochromeScriptParameter Clone(Project project, EventFile public enum ColorMonochrome : short { - CUSTOM = 0, + CUSTOM_COLOR = 0, BLACK = 1, WHITE = 2, } -} \ No newline at end of file +} diff --git a/src/SerialLoops.Lib/Script/Parameters/PaletteEffectScriptParameter.cs b/src/SerialLoops.Lib/Script/Parameters/PaletteEffectScriptParameter.cs index 036e1e31..9dba7958 100644 --- a/src/SerialLoops.Lib/Script/Parameters/PaletteEffectScriptParameter.cs +++ b/src/SerialLoops.Lib/Script/Parameters/PaletteEffectScriptParameter.cs @@ -20,7 +20,7 @@ public override PaletteEffectScriptParameter Clone(Project project, EventFile ev public enum PaletteEffect : short { - DEFAULT = 216, + DEFAULT_PALETTE = 216, INVERTED = 217, GRAYSCALE = 218, SEPIA = 219, @@ -89,4 +89,4 @@ public static SKPaint GetPaletteEffectPaint(PaletteEffect effect) 0.00f, 0.00f, 0.00f, 1.00f, 0.00f, ]), }; -} \ No newline at end of file +} diff --git a/src/SerialLoops.Lib/Script/Parameters/SpriteShakeScriptParameter.cs b/src/SerialLoops.Lib/Script/Parameters/SpriteShakeScriptParameter.cs index 34e1befc..3b84ae61 100644 --- a/src/SerialLoops.Lib/Script/Parameters/SpriteShakeScriptParameter.cs +++ b/src/SerialLoops.Lib/Script/Parameters/SpriteShakeScriptParameter.cs @@ -19,11 +19,11 @@ public override SpriteShakeScriptParameter Clone(Project project, EventFile even public enum SpriteShakeEffect : short { - NONE = 0, + NO_SHAKE = 0, SHAKE_CENTER = 1, BOUNCE_HORIZONTAL_CENTER = 2, BOUNCE_HORIZONTAL_CENTER_WITH_SMALL_SHAKES = 3, SHAKE_RIGHT = 4, SHAKE_LEFT = 5, } -} \ No newline at end of file +} diff --git a/src/SerialLoops.Lib/Script/Parameters/TextEntranceEffectScriptParameter.cs b/src/SerialLoops.Lib/Script/Parameters/TextEntranceEffectScriptParameter.cs index a03f2c6e..7059af3c 100644 --- a/src/SerialLoops.Lib/Script/Parameters/TextEntranceEffectScriptParameter.cs +++ b/src/SerialLoops.Lib/Script/Parameters/TextEntranceEffectScriptParameter.cs @@ -19,8 +19,8 @@ public override TextEntranceEffectScriptParameter Clone(Project project, EventFi public enum TextEntranceEffect : short { - NORMAL = 0, + NORMAL_TEXT_ENTRANCE = 0, SHRINK_IN = 1, TERMINAL_TYPING = 2, } -} \ No newline at end of file +} diff --git a/src/SerialLoops.Lib/Script/ScriptItemCommand.cs b/src/SerialLoops.Lib/Script/ScriptItemCommand.cs index ec3c9620..1ac692b5 100644 --- a/src/SerialLoops.Lib/Script/ScriptItemCommand.cs +++ b/src/SerialLoops.Lib/Script/ScriptItemCommand.cs @@ -77,10 +77,7 @@ public List WalkCommandGraph(Dictionary commands = []; - Func weightFunction = new((ScriptSectionEdge edge) => - { - return 1; - }); + Func weightFunction = new((ScriptSectionEdge edge) => 1); if (Section != commandTree.Keys.First()) { diff --git a/src/SerialLoops.Lib/Script/ScriptPreview.cs b/src/SerialLoops.Lib/Script/ScriptPreview.cs index 06ec293c..11ad3d72 100644 --- a/src/SerialLoops.Lib/Script/ScriptPreview.cs +++ b/src/SerialLoops.Lib/Script/ScriptPreview.cs @@ -19,6 +19,7 @@ public class ScriptPreview public List Sprites { get; set; } = []; public ScriptItemCommand LastDialogueCommand { get; set; } public TopicItem Topic { get; set; } + public List CurrentChocies { get; set; } public bool ChessMode { get; set; } public ChessPuzzleItem ChessPuzzle { get; set; } public string ErrorImage { get; set; } diff --git a/src/SerialLoops.Lib/Util/Extensions.cs b/src/SerialLoops.Lib/Util/Extensions.cs index 7d3f6fda..29a85eae 100644 --- a/src/SerialLoops.Lib/Util/Extensions.cs +++ b/src/SerialLoops.Lib/Util/Extensions.cs @@ -106,6 +106,35 @@ public static void CollectGarbage(this EventFile evt) } } } + + // Collect dialogue garbage + IEnumerable dialogueContainingCommands = new[] { CommandVerb.DIALOGUE, CommandVerb.PIN_MNL }.Select(c => c.ToString()); + List dialogueUsedIndices = []; + foreach (ScriptCommandInvocation dialogueCommand in evt.ScriptSections.SelectMany(s => s.Objects) + .Where((c => dialogueContainingCommands.Contains(c.Command.Mnemonic)))) + { + dialogueUsedIndices.Add(new() { Command = dialogueCommand, Index = dialogueCommand.Parameters[0] }); + } + + if (dialogueUsedIndices.DistinctBy(i => i.Index).Count() < evt.DialogueSection.Objects.Count) + { + for (short i = 0; i < evt.DialogueSection.Objects.Count; i++) + { + if (dialogueUsedIndices.All(idx => idx.Index != i)) + { + evt.DialogueSection.Objects.RemoveAt(i); + evt.DialogueLines.RemoveAt(i--); + for (int j = 0; j < dialogueUsedIndices.Count; j++) + { + if (dialogueUsedIndices[j].Index >= i) + { + dialogueUsedIndices[j].Command.Parameters[0]--; + dialogueUsedIndices[j].Index--; + } + } + } + } + } } private class UsedIndex diff --git a/src/SerialLoops/Assets/Strings.Designer.cs b/src/SerialLoops/Assets/Strings.Designer.cs index d0538517..36e4e962 100644 --- a/src/SerialLoops/Assets/Strings.Designer.cs +++ b/src/SerialLoops/Assets/Strings.Designer.cs @@ -705,6 +705,15 @@ public static string BGMs { } } + /// + /// Looks up a localized string similar to Black. + /// + public static string BLACK { + get { + return ResourceManager.GetString("BLACK", resourceCulture); + } + } + /// /// Looks up a localized string similar to Black Space Begin. /// @@ -768,6 +777,24 @@ public static string Bottom_Screen { } } + /// + /// Looks up a localized string similar to Bounce Horizontal (Center). + /// + public static string BOUNCE_HORIZONTAL_CENTER { + get { + return ResourceManager.GetString("BOUNCE_HORIZONTAL_CENTER", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bounce Horizontal (Center) with Small Shakes. + /// + public static string BOUNCE_HORIZONTAL_CENTER_WITH_SMALL_SHAKES { + get { + return ResourceManager.GetString("BOUNCE_HORIZONTAL_CENTER_WITH_SMALL_SHAKES", resourceCulture); + } + } + /// /// Looks up a localized string similar to Build. /// @@ -1528,9 +1555,9 @@ public static string Ctrl_Scroll___Scale_Image { /// /// Looks up a localized string similar to Custom Color. /// - public static string Custom_Color { + public static string CUSTOM_COLOR { get { - return ResourceManager.GetString("Custom Color", resourceCulture); + return ResourceManager.GetString("CUSTOM_COLOR", resourceCulture); } } @@ -1570,6 +1597,15 @@ public static string Default_Font_Display { } } + /// + /// Looks up a localized string similar to Default. + /// + public static string DEFAULT_PALETTE { + get { + return ResourceManager.GetString("DEFAULT_PALETTE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Defaults. /// @@ -1724,6 +1760,15 @@ public static string Dialogue_Text { } } + /// + /// Looks up a localized string similar to Dimmed. + /// + public static string DIMMED { + get { + return ResourceManager.GetString("DIMMED", resourceCulture); + } + } + /// /// Looks up a localized string similar to Disable Lip Flap. /// @@ -2294,7 +2339,7 @@ public static string Error__duplicate_hack_detected__A_hack_with_the_same_name_h } /// - /// Looks up a localized string similar to Error getting script command tree for script {0} ({1}). + /// Looks up a localized string similar to Error getting script command tree for script {0} ({1}): {2} {3}. /// public static string Error_getting_script_command_tree_for_script__0____1__ { get { @@ -2509,6 +2554,15 @@ public static string Extras_unlocked_message_box { } } + /// + /// Looks up a localized string similar to Fade In Left. + /// + public static string FADE_IN_LEFT { + get { + return ResourceManager.GetString("FADE_IN_LEFT", resourceCulture); + } + } + /// /// Looks up a localized string similar to Fade In Percentage. /// @@ -2527,6 +2581,24 @@ public static string Fade_In_Time__Frames_ { } } + /// + /// Looks up a localized string similar to Fade Out Center. + /// + public static string FADE_OUT_CENTER { + get { + return ResourceManager.GetString("FADE_OUT_CENTER", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Fade Out Left. + /// + public static string FADE_OUT_LEFT { + get { + return ResourceManager.GetString("FADE_OUT_LEFT", resourceCulture); + } + } + /// /// Looks up a localized string similar to Fade Out Percentage. /// @@ -2554,6 +2626,15 @@ public static string Fade_Time__Frames_ { } } + /// + /// Looks up a localized string similar to Fade to Center. + /// + public static string FADE_TO_CENTER { + get { + return ResourceManager.GetString("FADE_TO_CENTER", resourceCulture); + } + } + /// /// Looks up a localized string similar to Failed attempting to cache audio file. /// @@ -3373,6 +3454,15 @@ public static string GIF_file { } } + /// + /// Looks up a localized string similar to Grayscale. + /// + public static string GRAYSCALE { + get { + return ResourceManager.GetString("GRAYSCALE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Greek. /// @@ -3661,6 +3751,15 @@ public static string Invalid_search_terms { } } + /// + /// Looks up a localized string similar to Inverted. + /// + public static string INVERTED { + get { + return ResourceManager.GetString("INVERTED", resourceCulture); + } + } + /// /// Looks up a localized string similar to Investigation phase options ticker tape. /// @@ -4320,6 +4419,15 @@ public static string No_emulator_path_has_been_set__nPlease_set_the_path_to_a_Ni } } + /// + /// Looks up a localized string similar to Don't Exit. + /// + public static string NO_EXIT { + get { + return ResourceManager.GetString("NO_EXIT", resourceCulture); + } + } + /// /// Looks up a localized string similar to No exported project selected. /// @@ -4392,6 +4500,24 @@ public static string No_saves_Load_Game_menu_ticker_tape { } } + /// + /// Looks up a localized string similar to None. + /// + public static string NO_SHAKE { + get { + return ResourceManager.GetString("NO_SHAKE", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to No Transition. + /// + public static string NO_TRANSITION { + get { + return ResourceManager.GetString("NO_TRANSITION", resourceCulture); + } + } + /// /// Looks up a localized string similar to No valid maps found.. /// @@ -4410,6 +4536,15 @@ public static string None_Selected { } } + /// + /// Looks up a localized string similar to Normal. + /// + public static string NORMAL_TEXT_ENTRANCE { + get { + return ResourceManager.GetString("NORMAL_TEXT_ENTRANCE", resourceCulture); + } + } + /// /// Looks up a localized string similar to Number of Moves. /// @@ -4707,6 +4842,15 @@ public static string Pause_menu_Title_ticker_tape { } } + /// + /// Looks up a localized string similar to Peek Right to Left. + /// + public static string PEEK_RIGHT_TO_LEFT { + get { + return ResourceManager.GetString("PEEK_RIGHT_TO_LEFT", resourceCulture); + } + } + /// /// Looks up a localized string similar to Piece 1. /// @@ -6068,6 +6212,15 @@ public static string Select_Template_to_Apply { } } + /// + /// Looks up a localized string similar to Sepia. + /// + public static string SEPIA { + get { + return ResourceManager.GetString("SEPIA", resourceCulture); + } + } + /// /// Looks up a localized string similar to Serial Loops Exported Project. /// @@ -6212,6 +6365,33 @@ public static string SFXs { } } + /// + /// Looks up a localized string similar to Shake (Center). + /// + public static string SHAKE_CENTER { + get { + return ResourceManager.GetString("SHAKE_CENTER", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shake (Left). + /// + public static string SHAKE_LEFT { + get { + return ResourceManager.GetString("SHAKE_LEFT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Shake (Right). + /// + public static string SHAKE_RIGHT { + get { + return ResourceManager.GetString("SHAKE_RIGHT", resourceCulture); + } + } + /// /// Looks up a localized string similar to Show. /// @@ -6221,6 +6401,15 @@ public static string Show { } } + /// + /// Looks up a localized string similar to Shrink In. + /// + public static string SHRINK_IN { + get { + return ResourceManager.GetString("SHRINK_IN", resourceCulture); + } + } + /// /// Looks up a localized string similar to Singularity. /// @@ -6257,6 +6446,150 @@ public static string Skip_Update { } } + /// + /// Looks up a localized string similar to Slide from Center to Left and Stay (Transition). + /// + public static string SLIDE_CENTER_TO_LEFT_AND_STAY { + get { + return ResourceManager.GetString("SLIDE_CENTER_TO_LEFT_AND_STAY", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide from Center to Right and Stay (Transition). + /// + public static string SLIDE_CENTER_TO_RIGHT_AND_STAY { + get { + return ResourceManager.GetString("SLIDE_CENTER_TO_RIGHT_AND_STAY", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide from Center to Left and Fade Out. + /// + public static string SLIDE_FROM_CENTER_TO_LEFT_FADE_OUT { + get { + return ResourceManager.GetString("SLIDE_FROM_CENTER_TO_LEFT_FADE_OUT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide from Center to Right and Fade Out. + /// + public static string SLIDE_FROM_CENTER_TO_RIGHT_FADE_OUT { + get { + return ResourceManager.GetString("SLIDE_FROM_CENTER_TO_RIGHT_FADE_OUT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Left to Center. + /// + public static string SLIDE_LEFT_TO_CENTER { + get { + return ResourceManager.GetString("SLIDE_LEFT_TO_CENTER", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Left to Left and Fade Out. + /// + public static string SLIDE_LEFT_TO_LEFT_FADE_OUT { + get { + return ResourceManager.GetString("SLIDE_LEFT_TO_LEFT_FADE_OUT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Left to Right. + /// + public static string SLIDE_LEFT_TO_RIGHT { + get { + return ResourceManager.GetString("SLIDE_LEFT_TO_RIGHT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Left to Right and Stay (Transition). + /// + public static string SLIDE_LEFT_TO_RIGHT_AND_STAY { + get { + return ResourceManager.GetString("SLIDE_LEFT_TO_RIGHT_AND_STAY", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Left to Right and Fade Out. + /// + public static string SLIDE_LEFT_TO_RIGHT_FADE_OUT { + get { + return ResourceManager.GetString("SLIDE_LEFT_TO_RIGHT_FADE_OUT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slight Left to Right (Fast). + /// + public static string SLIDE_LEFT_TO_RIGHT_FAST { + get { + return ResourceManager.GetString("SLIDE_LEFT_TO_RIGHT_FAST", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Left to Right (Slow). + /// + public static string SLIDE_LEFT_TO_RIGHT_SLOW { + get { + return ResourceManager.GetString("SLIDE_LEFT_TO_RIGHT_SLOW", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Right to Center. + /// + public static string SLIDE_RIGHT_TO_CENTER { + get { + return ResourceManager.GetString("SLIDE_RIGHT_TO_CENTER", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Right to Left. + /// + public static string SLIDE_RIGHT_TO_LEFT { + get { + return ResourceManager.GetString("SLIDE_RIGHT_TO_LEFT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Right to Left and Stay (Transition). + /// + public static string SLIDE_RIGHT_TO_LEFT_AND_STAY { + get { + return ResourceManager.GetString("SLIDE_RIGHT_TO_LEFT_AND_STAY", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Right to Left (Fast). + /// + public static string SLIDE_RIGHT_TO_LEFT_FAST { + get { + return ResourceManager.GetString("SLIDE_RIGHT_TO_LEFT_FAST", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slide Right to Left (Slow). + /// + public static string SLIDE_RIGHT_TO_LEFT_SLOW { + get { + return ResourceManager.GetString("SLIDE_RIGHT_TO_LEFT_SLOW", resourceCulture); + } + } + /// /// Looks up a localized string similar to Sound. /// @@ -6392,6 +6725,15 @@ public static string Starting_Chibis { } } + /// + /// Looks up a localized string similar to Stop. + /// + public static string Stop { + get { + return ResourceManager.GetString("Stop", resourceCulture); + } + } + /// /// Looks up a localized string similar to Sub-Topic. /// @@ -6537,6 +6879,15 @@ public static string Template_Properties { } } + /// + /// Looks up a localized string similar to Terminal Typing. + /// + public static string TERMINAL_TYPING { + get { + return ResourceManager.GetString("TERMINAL_TYPING", resourceCulture); + } + } + /// /// Looks up a localized string similar to Text Color. /// @@ -6645,7 +6996,7 @@ public static string This_system_texture_uses_a_common_palette__so_palette_repla } /// - /// Looks up a localized string similar to Time (Frames). + /// Looks up a localized string similar to Transition Time (Frames). /// public static string Time__Frames_ { get { @@ -7330,6 +7681,15 @@ public static string While_attempting_to_build___file___0_X3__in_archive__1__was } } + /// + /// Looks up a localized string similar to White. + /// + public static string WHITE { + get { + return ResourceManager.GetString("WHITE", resourceCulture); + } + } + /// /// Looks up a localized string similar to White Space Begin. /// diff --git a/src/SerialLoops/Assets/Strings.en-GB.resx b/src/SerialLoops/Assets/Strings.en-GB.resx index 04057073..45081a48 100644 --- a/src/SerialLoops/Assets/Strings.en-GB.resx +++ b/src/SerialLoops/Assets/Strings.en-GB.resx @@ -531,7 +531,7 @@ Ctrl+Scroll - Scale Image - + Custom Colour diff --git a/src/SerialLoops/Assets/Strings.it.resx b/src/SerialLoops/Assets/Strings.it.resx index dea47173..94f83aff 100644 --- a/src/SerialLoops/Assets/Strings.it.resx +++ b/src/SerialLoops/Assets/Strings.it.resx @@ -1457,7 +1457,7 @@ Le schede dell'editor non vengono fornite nella finestra di dialogo di creazione del progetto - + Colore personalizzato diff --git a/src/SerialLoops/Assets/Strings.resx b/src/SerialLoops/Assets/Strings.resx index 257895ae..699c47eb 100644 --- a/src/SerialLoops/Assets/Strings.resx +++ b/src/SerialLoops/Assets/Strings.resx @@ -579,7 +579,7 @@ This action is irreversible. Ctrl+Scroll - Scale Image - + Custom Color @@ -826,7 +826,7 @@ This action is irreversible. Error - Error getting script command tree for script {0} ({1}) + Error getting script command tree for script {0} ({1}): {2} {3} {0} is the script display name, {1} is the script's underlying name @@ -2319,7 +2319,7 @@ If you wish to ignore this, please check the "Ignore Hash" checkbox. This system texture uses a common palette, so palette replacement has been disabled - Time (Frames) + Transition Time (Frames) Times @@ -2641,6 +2641,126 @@ No project is currently open. Would you like to create a new project? Load SoundThe name of a parameter for the SND_PLAY command which indicates whether a sound should be loaded or not + + Stop + + + No Transition + + + Slide Left to Center + + + Slide Right to Center + + + Slide Left to Right + + + Slide Right to Left + + + Slide Left to Right (Slow) + + + Slide Right to Left (Slow) + + + Fade to Center + + + Slight Left to Right (Fast) + + + Slide Right to Left (Fast) + + + Peek Right to Left + + + Fade In Left + + + Don't Exit + + + Slide from Center to Right and Fade Out + + + Slide from Center to Left and Fade Out + + + Slide from Center to Right and Stay (Transition) + + + Slide from Center to Left and Stay (Transition) + + + Slide Left to Right and Fade Out + + + Slide Left to Left and Fade Out + + + Fade Out Center + + + Fade Out Left + + + Slide Left to Right and Stay (Transition) + + + Slide Right to Left and Stay (Transition) + + + None + + + Shake (Center) + + + Bounce Horizontal (Center) + + + Bounce Horizontal (Center) with Small Shakes + + + Shake (Right) + + + Shake (Left) + + + Normal + + + Shrink In + + + Terminal Typing + + + Black + + + White + + + Default + + + Inverted + + + Grayscale + + + Sepia + + + Dimmed + Number of MovesThe number of moves available in a given chess puzzle diff --git a/src/SerialLoops/Assets/Strings.zh-Hans.resx b/src/SerialLoops/Assets/Strings.zh-Hans.resx index 7041a24e..99452bfa 100644 --- a/src/SerialLoops/Assets/Strings.zh-Hans.resx +++ b/src/SerialLoops/Assets/Strings.zh-Hans.resx @@ -541,7 +541,7 @@ Ctrl+滚轮 - 缩放图片 - + 自定义颜色 diff --git a/src/SerialLoops/Behaviors/ChessItemsControlDropHandler.cs b/src/SerialLoops/Behaviors/ChessItemsControlDropHandler.cs index 12a3b1e2..0310a28f 100644 --- a/src/SerialLoops/Behaviors/ChessItemsControlDropHandler.cs +++ b/src/SerialLoops/Behaviors/ChessItemsControlDropHandler.cs @@ -1,11 +1,9 @@ using System.Collections.ObjectModel; -using System.Diagnostics.Tracing; using Avalonia.Controls; using Avalonia.Input; using Avalonia.VisualTree; using Avalonia.Xaml.Interactions.DragAndDrop; using HaruhiChokuretsuLib.Archive.Data; -using ReactiveUI; using SerialLoops.ViewModels.Editors; namespace SerialLoops.Behaviors; diff --git a/src/SerialLoops/Controls/SoundPlayerPanel.axaml b/src/SerialLoops/Controls/SoundPlayerPanel.axaml index bd6e0920..25b6c6de 100644 --- a/src/SerialLoops/Controls/SoundPlayerPanel.axaml +++ b/src/SerialLoops/Controls/SoundPlayerPanel.axaml @@ -5,7 +5,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:i="using:Avalonia.Xaml.Interactivity" xmlns:ia="using:Avalonia.Xaml.Interactions.Core" - xmlns:controls="using:SerialLoops.Controls" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:DataType="vm:SoundPlayerPanelViewModel" x:Class="SerialLoops.Controls.SoundPlayerPanel"> diff --git a/src/SerialLoops/Models/ScriptSectionTreeItem.cs b/src/SerialLoops/Models/ScriptSectionTreeItem.cs index f9a6d271..9ff6310a 100644 --- a/src/SerialLoops/Models/ScriptSectionTreeItem.cs +++ b/src/SerialLoops/Models/ScriptSectionTreeItem.cs @@ -3,13 +3,13 @@ using System.Linq; using Avalonia.Controls; using Avalonia.Layout; -using HaruhiChokuretsuLib.Archive.Event; using ReactiveUI; using SerialLoops.Lib.Script; +using SerialLoops.ViewModels.Editors; namespace SerialLoops.Models; -public class ScriptSectionTreeItem : ITreeItem, IViewFor +public class ScriptSectionTreeItem : ITreeItem, IViewFor { private TextBlock _textBlock = new(); StackPanel _panel = new() @@ -24,7 +24,7 @@ public class ScriptSectionTreeItem : ITreeItem, IViewFor public ObservableCollection Children { get; set; } public bool IsExpanded { get; set; } = true; - public ScriptSectionTreeItem(ScriptSection section, List commands) + public ScriptSectionTreeItem(ReactiveScriptSection section, List commands) { ViewModel = section; Children = new([.. commands.Select(c => new ScriptCommandTreeItem(c))]); @@ -41,8 +41,8 @@ public Control GetDisplay() object IViewFor.ViewModel { get => ViewModel; - set => ViewModel = (ScriptSection)value; + set => ViewModel = (ReactiveScriptSection)value; } - public ScriptSection ViewModel { get; set; } -} \ No newline at end of file + public ReactiveScriptSection ViewModel { get; set; } +} diff --git a/src/SerialLoops/SerialLoops.csproj b/src/SerialLoops/SerialLoops.csproj index f246ae89..e561e8be 100644 --- a/src/SerialLoops/SerialLoops.csproj +++ b/src/SerialLoops/SerialLoops.csproj @@ -50,6 +50,7 @@ + @@ -66,6 +67,7 @@ + @@ -76,7 +78,7 @@ - + diff --git a/src/SerialLoops/Utility/LoopyLogger.cs b/src/SerialLoops/Utility/LoopyLogger.cs index 8be1f3fb..e194557b 100644 --- a/src/SerialLoops/Utility/LoopyLogger.cs +++ b/src/SerialLoops/Utility/LoopyLogger.cs @@ -60,7 +60,6 @@ public void LogError(string message, bool lookForWarnings = false) private async Task LogErrorAsync(string message, bool lookForWarnings = false) { - await _owner.ShowMessageBoxAsync(Strings.Error, string.Format(Strings.ERROR___0_, message), ButtonEnum.Ok, Icon.Error, this); if (!string.IsNullOrEmpty(_logFile) && !string.IsNullOrEmpty(message)) { for (int i = 0; i < 10; i++) @@ -76,6 +75,7 @@ private async Task LogErrorAsync(string message, bool lookForWarnings = false) } } } + await _owner.ShowMessageBoxAsync(Strings.Error, string.Format(Strings.ERROR___0_, message), ButtonEnum.Ok, Icon.Error, this); } public void LogException(string message, Exception exception) @@ -121,4 +121,4 @@ public void LogCrash(Exception ex) } } } -} \ No newline at end of file +} diff --git a/src/SerialLoops/Utility/SLConverters.cs b/src/SerialLoops/Utility/SLConverters.cs index fc5f8c66..e42553c1 100644 --- a/src/SerialLoops/Utility/SLConverters.cs +++ b/src/SerialLoops/Utility/SLConverters.cs @@ -45,21 +45,18 @@ public object Convert(IList values, Type targetType, object parameter, C } } -public class TextSubstitutionConverter : IValueConverter +public class TextSubstitionConverter : IMultiValueConverter { - private static Project _project; - - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - return ((string)value).GetSubstitutedString(_project); - } - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - return ((string)value).GetOriginalString(_project); - } - public static void SetProject(Project project) + public object Convert(IList values, Type targetType, object parameter, CultureInfo culture) { - _project = project; + if (values[0] is not UnsetValueType && values[1] is not UnsetValueType) + { + string originalText = (string)values[0]; + Project project = (Project)values[1]; + + return originalText.GetSubstitutedString(project); + } + return string.Empty; } } diff --git a/src/SerialLoops/ViewModels/Editors/ChessPuzzleEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ChessPuzzleEditorViewModel.cs index 00848ada..c5a5d794 100644 --- a/src/SerialLoops/ViewModels/Editors/ChessPuzzleEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ChessPuzzleEditorViewModel.cs @@ -1,8 +1,6 @@ using System.Collections.ObjectModel; using System.Linq; -using HaruhiChokuretsuLib.Archive; using HaruhiChokuretsuLib.Archive.Data; -using HaruhiChokuretsuLib.Archive.Graphics; using HaruhiChokuretsuLib.Util; using ReactiveUI; using ReactiveUI.Fody.Helpers; diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/BgDispScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/BgDispScriptCommandEditorViewModel.cs index a0d8e7fa..7b8b5ed1 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/BgDispScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/BgDispScriptCommandEditorViewModel.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Threading.Tasks; using System.Windows.Input; +using HaruhiChokuretsuLib.Util; using ReactiveUI; using SerialLoops.Lib.Items; using SerialLoops.Lib.Script; @@ -34,7 +35,7 @@ public BackgroundItem Bg public ICommand ReplaceBgCommand { get; } - public BgDispScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, MainWindowViewModel window) : base(command, scriptEditor) + public BgDispScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, MainWindowViewModel window) : base(command, scriptEditor, log) { _window = window; Tabs = _window.EditorTabs; @@ -60,4 +61,4 @@ private async Task ReplaceBg() Bg = (BackgroundItem)bg; } } -} \ No newline at end of file +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/BgmPlayScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/BgmPlayScriptCommandEditorViewModel.cs index bc43238a..10926c5b 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/BgmPlayScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/BgmPlayScriptCommandEditorViewModel.cs @@ -1,7 +1,9 @@ using System; using System.Collections.ObjectModel; using System.Linq; +using HaruhiChokuretsuLib.Util; using ReactiveUI; +using SerialLoops.Assets; using SerialLoops.Lib.Items; using SerialLoops.Lib.Script; using SerialLoops.Lib.Script.Parameters; @@ -28,17 +30,18 @@ public BackgroundMusicItem Music } } - public ObservableCollection Modes { get; } = new(Enum.GetNames()); - private BgmModeScriptParameter.BgmMode _mode; - public string Mode + public ObservableCollection Modes { get; } = new(Enum.GetValues() + .Select(m => new BgmModeLocalized(m))); + private BgmModeLocalized _mode; + public BgmModeLocalized Mode { - get => _mode.ToString(); + get => _mode; set { - this.RaiseAndSetIfChanged(ref _mode, Enum.Parse(value)); - ((BgmModeScriptParameter)Command.Parameters[1]).Mode = _mode; + this.RaiseAndSetIfChanged(ref _mode, value); + ((BgmModeScriptParameter)Command.Parameters[1]).Mode = _mode.Mode; Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] - .Objects[Command.Index].Parameters[1] = (short)_mode; + .Objects[Command.Index].Parameters[1] = (short)_mode.Mode; Script.UnsavedChanges = true; } } @@ -84,16 +87,22 @@ public short FadeOutTime } } - public BgmPlayScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, MainWindowViewModel window) - : base(command, scriptEditor) + public BgmPlayScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, MainWindowViewModel window) + : base(command, scriptEditor, log) { Tabs = window.EditorTabs; Bgms = new(window.OpenProject.Items.Where(i => i.Type == ItemDescription.ItemType.BGM) .Cast()); _music = ((BgmScriptParameter)Command.Parameters[0]).Bgm; - _mode = ((BgmModeScriptParameter)Command.Parameters[1]).Mode; + _mode = new(((BgmModeScriptParameter)Command.Parameters[1]).Mode); _volume = ((ShortScriptParameter)Command.Parameters[2]).Value; _fadeInTime = ((ShortScriptParameter)Command.Parameters[3]).Value; _fadeOutTime = ((ShortScriptParameter)Command.Parameters[4]).Value; } -} \ No newline at end of file +} + +public readonly struct BgmModeLocalized(BgmModeScriptParameter.BgmMode mode) +{ + public string DisplayString { get; } = Strings.ResourceManager.GetString(mode.ToString()); + public BgmModeScriptParameter.BgmMode Mode { get; } = mode; +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ChessLoadScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ChessLoadScriptCommandEditorViewModel.cs index 9ad3ad35..ea530320 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ChessLoadScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ChessLoadScriptCommandEditorViewModel.cs @@ -1,7 +1,7 @@ using System.Collections.ObjectModel; using System.Linq; +using HaruhiChokuretsuLib.Util; using ReactiveUI; -using SerialLoops.Lib; using SerialLoops.Lib.Items; using SerialLoops.Lib.Script; using SerialLoops.Lib.Script.Parameters; @@ -29,8 +29,8 @@ public ChessPuzzleItem ChessPuzzle } } - public ChessLoadScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, MainWindowViewModel window) - : base(command, scriptEditor) + public ChessLoadScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, MainWindowViewModel window, ILogger log) + : base(command, scriptEditor, log) { ChessPuzzles = new(window.OpenProject.Items.Where(c => c.Type == ItemDescription.ItemType.Chess_Puzzle).Cast()); _chessPuzzle = ((ChessPuzzleScriptParameter)command.Parameters[0]).ChessPuzzle; diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/DialogueScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/DialogueScriptCommandEditorViewModel.cs index f897f8b1..c0c3f31d 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/DialogueScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/DialogueScriptCommandEditorViewModel.cs @@ -3,8 +3,11 @@ using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; +using System.Timers; using System.Windows.Input; +using HaruhiChokuretsuLib.Util; using ReactiveUI; +using SerialLoops.Assets; using SerialLoops.Lib.Items; using SerialLoops.Lib.Script; using SerialLoops.Lib.Script.Parameters; @@ -19,9 +22,10 @@ public partial class DialogueScriptCommandEditorViewModel : ScriptCommandEditorV { private MainWindowViewModel _window; public EditorTabsPanelViewModel Tabs { get; set; } - private Func _specialPredicate = (i => true); + private Func _specialPredicate; + private Timer _dialogueUpdateTimer; - public DialogueScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, MainWindowViewModel window) : base(command, scriptEditor) + public DialogueScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, MainWindowViewModel window) : base(command, scriptEditor, log) { _window = window; Tabs = _window.EditorTabs; @@ -31,17 +35,24 @@ public DialogueScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEdi _dialogueLine = ((DialogueScriptParameter)command.Parameters[0]).Line.Text; _characterSprite = ((SpriteScriptParameter)command.Parameters[1]).Sprite; SelectCharacterSpriteCommand = ReactiveCommand.CreateFromTask(SelectCharacterSpriteCommand_Executed); - _spriteEntranceTransition = ((SpriteEntranceScriptParameter)command.Parameters[2]).EntranceTransition; - _spriteExitTransition = ((SpriteExitScriptParameter)command.Parameters[3]).ExitTransition; - _spriteShakeEffect = ((SpriteShakeScriptParameter)command.Parameters[4]).ShakeEffect; + _spriteEntranceTransition = new(((SpriteEntranceScriptParameter)command.Parameters[2]).EntranceTransition); + _spriteExitTransition = new(((SpriteExitScriptParameter)command.Parameters[3]).ExitTransition); + _spriteShakeEffect = new(((SpriteShakeScriptParameter)command.Parameters[4]).ShakeEffect); VoicedLines = new(_window.OpenProject.Items.Where(i => i.Type == ItemDescription.ItemType.Voice).Cast()); _voicedLine = ((VoicedLineScriptParameter)command.Parameters[5]).VoiceLine; _textVoiceFont = ((DialoguePropertyScriptParameter)command.Parameters[6]).Character; _textSpeed = ((DialoguePropertyScriptParameter)command.Parameters[7]).Character; - _textEntranceEffect = ((TextEntranceEffectScriptParameter)command.Parameters[8]).EntranceEffect; + _textEntranceEffect = new(((TextEntranceEffectScriptParameter)command.Parameters[8]).EntranceEffect); _spriteLayer = ((ShortScriptParameter)command.Parameters[9]).Value; _dontClearText = ((BoolScriptParameter)command.Parameters[10]).Value; _disableLipFlap = ((BoolScriptParameter)command.Parameters[11]).Value; + + _dialogueUpdateTimer = new(TimeSpan.FromMilliseconds(250)); + _dialogueUpdateTimer.Elapsed += (sender, args) => + { + ScriptEditor.UpdatePreview(); + _dialogueUpdateTimer.Stop(); + }; } public ObservableCollection Characters { get; } @@ -106,7 +117,8 @@ public string DialogueLine Script.Event.DialogueSection.Objects[Command.Section.Objects[Command.Index].Parameters[0]].Text = _dialogueLine; } - ScriptEditor.UpdatePreview(); + _dialogueUpdateTimer.Stop(); + _dialogueUpdateTimer.Start(); Script.UnsavedChanges = true; Command.UpdateDisplay(); } @@ -148,48 +160,51 @@ private async Task SelectCharacterSpriteCommand_Executed() } } - public ObservableCollection SpriteEntranceTransitions { get; } = new(Enum.GetNames()); - private SpriteEntranceScriptParameter.SpriteEntranceTransition _spriteEntranceTransition; - public string SpriteEntranceTransition + public ObservableCollection SpriteEntranceTransitions { get; } = + new(Enum.GetValues().Select(e => new SpriteEntranceTransitionLocalized(e))); + private SpriteEntranceTransitionLocalized _spriteEntranceTransition; + public SpriteEntranceTransitionLocalized SpriteEntranceTransition { - get => _spriteEntranceTransition.ToString(); + get => _spriteEntranceTransition; set { - this.RaiseAndSetIfChanged(ref _spriteEntranceTransition, Enum.Parse(value)); - ((SpriteEntranceScriptParameter)Command.Parameters[2]).EntranceTransition = _spriteEntranceTransition; + this.RaiseAndSetIfChanged(ref _spriteEntranceTransition, value); + ((SpriteEntranceScriptParameter)Command.Parameters[2]).EntranceTransition = _spriteEntranceTransition.Entrance; Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] - .Objects[Command.Index].Parameters[2] = (short)_spriteEntranceTransition; + .Objects[Command.Index].Parameters[2] = (short)_spriteEntranceTransition.Entrance; ScriptEditor.UpdatePreview(); Script.UnsavedChanges = true; } } - public ObservableCollection SpriteExitTransitions { get; } = new(Enum.GetNames()); - private SpriteExitScriptParameter.SpriteExitTransition _spriteExitTransition; - public string SpriteExitTransition + public ObservableCollection SpriteExitTransitions { get; } = + new(Enum.GetValues().Select(e => new SpriteExitTransitionLocalized(e))); + private SpriteExitTransitionLocalized _spriteExitTransition; + public SpriteExitTransitionLocalized SpriteExitTransition { - get => _spriteExitTransition.ToString(); + get => _spriteExitTransition; set { - this.RaiseAndSetIfChanged(ref _spriteExitTransition, Enum.Parse(value)); - ((SpriteExitScriptParameter)Command.Parameters[3]).ExitTransition = _spriteExitTransition; + this.RaiseAndSetIfChanged(ref _spriteExitTransition, value); + ((SpriteExitScriptParameter)Command.Parameters[3]).ExitTransition = _spriteExitTransition.Exit; Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] - .Objects[Command.Index].Parameters[3] = (short)_spriteExitTransition; + .Objects[Command.Index].Parameters[3] = (short)_spriteExitTransition.Exit; Script.UnsavedChanges = true; } } - public ObservableCollection SpriteShakeEffects { get; } = new(Enum.GetNames()); - private SpriteShakeScriptParameter.SpriteShakeEffect _spriteShakeEffect; - public string SpriteShakeEffect + public ObservableCollection SpriteShakeEffects { get; } = + new(Enum.GetValues().Select(s => new SpriteShakeLocalized(s))); + private SpriteShakeLocalized _spriteShakeEffect; + public SpriteShakeLocalized SpriteShakeEffect { - get => _spriteShakeEffect.ToString(); + get => _spriteShakeEffect; set { - this.RaiseAndSetIfChanged(ref _spriteShakeEffect, Enum.Parse(value)); - ((SpriteShakeScriptParameter)Command.Parameters[4]).ShakeEffect = _spriteShakeEffect; + this.RaiseAndSetIfChanged(ref _spriteShakeEffect, value); + ((SpriteShakeScriptParameter)Command.Parameters[4]).ShakeEffect = _spriteShakeEffect.Shake; Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] - .Objects[Command.Index].Parameters[4] = (short)_spriteShakeEffect; + .Objects[Command.Index].Parameters[4] = (short)_spriteShakeEffect.Shake; Script.UnsavedChanges = true; } } @@ -237,17 +252,18 @@ public CharacterItem TextSpeed } } - public ObservableCollection TextEntranceEffects { get; } = new(Enum.GetNames()); - private TextEntranceEffectScriptParameter.TextEntranceEffect _textEntranceEffect; - public string TextEntranceEffect + public ObservableCollection TextEntranceEffects { get; } = + new(Enum.GetValues().Select(e => new TextEntranceEffectLocalized(e))); + private TextEntranceEffectLocalized _textEntranceEffect; + public TextEntranceEffectLocalized TextEntranceEffect { - get => _textEntranceEffect.ToString(); + get => _textEntranceEffect; set { - this.RaiseAndSetIfChanged(ref _textEntranceEffect, Enum.Parse(value)); - ((TextEntranceEffectScriptParameter)Command.Parameters[8]).EntranceEffect = _textEntranceEffect; + this.RaiseAndSetIfChanged(ref _textEntranceEffect, value); + ((TextEntranceEffectScriptParameter)Command.Parameters[8]).EntranceEffect = _textEntranceEffect.Effect; Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] - .Objects[Command.Index].Parameters[8] = (short)_textEntranceEffect; + .Objects[Command.Index].Parameters[8] = (short)_textEntranceEffect.Effect; Script.UnsavedChanges = true; } } @@ -299,4 +315,26 @@ public bool DisableLipFlap private static partial Regex StartStringQuotes(); [GeneratedRegex(@"(\s)""")] private static partial Regex MidStringOpenQuotes(); -} \ No newline at end of file +} + +public readonly struct SpriteEntranceTransitionLocalized(SpriteEntranceScriptParameter.SpriteEntranceTransition entrance) +{ + public SpriteEntranceScriptParameter.SpriteEntranceTransition Entrance { get; } = entrance; + public string DisplayText { get; } = Strings.ResourceManager.GetString(entrance.ToString()); +} +public readonly struct SpriteExitTransitionLocalized(SpriteExitScriptParameter.SpriteExitTransition exit) +{ + public SpriteExitScriptParameter.SpriteExitTransition Exit { get; } = exit; + public string DisplayText { get; } = Strings.ResourceManager.GetString(exit.ToString()); +} +public readonly struct SpriteShakeLocalized(SpriteShakeScriptParameter.SpriteShakeEffect shake) +{ + public SpriteShakeScriptParameter.SpriteShakeEffect Shake { get; } = shake; + public string DisplayText { get; } = Strings.ResourceManager.GetString(shake.ToString()); +} +public readonly struct TextEntranceEffectLocalized(TextEntranceEffectScriptParameter.TextEntranceEffect effect) +{ + public TextEntranceEffectScriptParameter.TextEntranceEffect Effect { get; } = effect; + public string DisplayText { get; } = Strings.ResourceManager.GetString(effect.ToString()); +} + diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/EmptyScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/EmptyScriptCommandEditorViewModel.cs index 88d1430f..52175b7e 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/EmptyScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/EmptyScriptCommandEditorViewModel.cs @@ -1,7 +1,8 @@ -using SerialLoops.Lib.Script; +using HaruhiChokuretsuLib.Util; +using SerialLoops.Lib.Script; namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; -public class EmptyScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor) : ScriptCommandEditorViewModel(command, scriptEditor) +public class EmptyScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : ScriptCommandEditorViewModel(command, scriptEditor, log) { -} \ No newline at end of file +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/FlagScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/FlagScriptCommandEditorViewModel.cs index 37901e7a..dac6589f 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/FlagScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/FlagScriptCommandEditorViewModel.cs @@ -1,11 +1,12 @@ +using HaruhiChokuretsuLib.Util; using ReactiveUI; using SerialLoops.Lib.Script; using SerialLoops.Lib.Script.Parameters; namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; -public class FlagScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor) - : ScriptCommandEditorViewModel(command, scriptEditor) +public class FlagScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) + : ScriptCommandEditorViewModel(command, scriptEditor, log) { private short _flagId = ((FlagScriptParameter)command.Parameters[0]).Id; public string Flag diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/GotoScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/GotoScriptCommandEditorViewModel.cs new file mode 100644 index 00000000..44d663f6 --- /dev/null +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/GotoScriptCommandEditorViewModel.cs @@ -0,0 +1,32 @@ +using System.Linq; +using HaruhiChokuretsuLib.Util; +using ReactiveUI; +using SerialLoops.Lib.Script; +using SerialLoops.Lib.Script.Parameters; + +namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; + +public class GotoScriptCommandEditorViewModel : ScriptCommandEditorViewModel +{ + private ReactiveScriptSection _sectionToJumpTo; + public ReactiveScriptSection SectionToJumpTo + { + get => _sectionToJumpTo; + set + { + this.RaiseAndSetIfChanged(ref _sectionToJumpTo, value); + ((ScriptSectionScriptParameter)Command.Parameters[0]).Section = _sectionToJumpTo.Section; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[0] = Script.Event.LabelsSection.Objects + .FirstOrDefault(l => l.Name.Replace("/", "").Equals(_sectionToJumpTo.Name))?.Id ?? 0; + Script.UnsavedChanges = true; + Command.UpdateDisplay(); + } + } + + public GotoScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : + base(command, scriptEditor, log) + { + _sectionToJumpTo = ScriptEditor.ScriptSections[Script.Event.ScriptSections.IndexOf(((ScriptSectionScriptParameter)command.Parameters[0]).Section)]; + } +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/HaruhiMeterScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/HaruhiMeterScriptCommandEditorViewModel.cs new file mode 100644 index 00000000..4b166621 --- /dev/null +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/HaruhiMeterScriptCommandEditorViewModel.cs @@ -0,0 +1,51 @@ +using HaruhiChokuretsuLib.Util; +using ReactiveUI; +using SerialLoops.Lib.Script; +using SerialLoops.Lib.Script.Parameters; + +namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; + +public class HaruhiMeterScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, bool noShow) + : ScriptCommandEditorViewModel(command, scriptEditor, log) +{ + public bool NoShow { get; } + + private short _addAmount = noShow ? (short)0 : ((ShortScriptParameter)command.Parameters[0]).Value; + public short AddAmount + { + get => _addAmount; + set + { + this.RaiseAndSetIfChanged(ref _addAmount, value); + ((ShortScriptParameter)Command.Parameters[0]).Value = _addAmount; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[1] = _addAmount; + } + } + + private short _setAmount = noShow ? (short)0 : ((ShortScriptParameter)command.Parameters[1]).Value; + public short SetAmount + { + get => _setAmount; + set + { + this.RaiseAndSetIfChanged(ref _setAmount, value); + ((ShortScriptParameter)Command.Parameters[1]).Value = _setAmount; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[2] = _setAmount; + } + } + + private short _addNoShowAmount = noShow ? ((ShortScriptParameter)command.Parameters[0]).Value : (short)0; + public short AddNoShowAmount + { + get => _addNoShowAmount; + set + { + this.RaiseAndSetIfChanged(ref _addNoShowAmount, value); + ((ShortScriptParameter)Command.Parameters[0]).Value = _addNoShowAmount; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[0] = _addNoShowAmount; + } + } +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/KbgDispScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/KbgDispScriptCommandEditorViewModel.cs index bb57f3b0..637000f9 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/KbgDispScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/KbgDispScriptCommandEditorViewModel.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using System.Windows.Input; using HaruhiChokuretsuLib.Archive.Data; +using HaruhiChokuretsuLib.Util; using ReactiveUI; using SerialLoops.Lib.Items; using SerialLoops.Lib.Script; @@ -41,7 +42,7 @@ public BackgroundItem Kbg } } - public KbgDispScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, MainWindowViewModel window) : base(command, scriptEditor) + public KbgDispScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, MainWindowViewModel window) : base(command, scriptEditor, log) { _kbg = ((BgScriptParameter)command.Parameters[0]).Background; ReplaceKbgCommand = ReactiveCommand.CreateFromTask(ReplaceKbg); @@ -70,4 +71,4 @@ private async Task ReplaceKbg() ScriptEditor.UpdatePreview(); Script.UnsavedChanges = true; } -} \ No newline at end of file +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/PalEffectScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/PalEffectScriptCommandEditorViewModel.cs new file mode 100644 index 00000000..2beddf46 --- /dev/null +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/PalEffectScriptCommandEditorViewModel.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.ObjectModel; +using System.Linq; +using HaruhiChokuretsuLib.Util; +using ReactiveUI; +using SerialLoops.Assets; +using SerialLoops.Lib.Script; +using SerialLoops.Lib.Script.Parameters; + +namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; + +public class PalEffectScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) + : ScriptCommandEditorViewModel(command, scriptEditor, log) +{ + public ObservableCollection PaletteEffects { get; } = + new(Enum.GetValues().Select(e => new PaletteEffectLocalized(e))); + private PaletteEffectLocalized _paletteEffect = new(((PaletteEffectScriptParameter)command.Parameters[0]).Effect); + public PaletteEffectLocalized PaletteEffect + { + get => _paletteEffect; + set + { + this.RaiseAndSetIfChanged(ref _paletteEffect, value); + ((PaletteEffectScriptParameter)Command.Parameters[0]).Effect = _paletteEffect.Effect; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[0] = (short)_paletteEffect.Effect; + Script.UnsavedChanges = true; + } + } + + private short _transitionTime = ((ShortScriptParameter)command.Parameters[1]).Value; + public short TransitionTime + { + get => _transitionTime; + set + { + this.RaiseAndSetIfChanged(ref _transitionTime, value); + ((ShortScriptParameter)Command.Parameters[1]).Value = _transitionTime; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[1] = _transitionTime; + Script.UnsavedChanges = true; + } + } + + private bool _unknown = ((BoolScriptParameter)command.Parameters[2]).Value; + public bool Unknown + { + get => _unknown; + set + { + this.RaiseAndSetIfChanged(ref _unknown, value); + ((BoolScriptParameter)Command.Parameters[2]).Value = _unknown; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[0] = _unknown ? ((BoolScriptParameter)Command.Parameters[2]).TrueValue : ((BoolScriptParameter)Command.Parameters[2]).FalseValue; + } + } +} + +public readonly struct PaletteEffectLocalized(PaletteEffectScriptParameter.PaletteEffect effect) +{ + public PaletteEffectScriptParameter.PaletteEffect Effect { get; } = effect; + public string DisplayText { get; } = Strings.ResourceManager.GetString(effect.ToString()); +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/PinMnlScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/PinMnlScriptCommandEditorViewModel.cs index fef2d914..35cb60c5 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/PinMnlScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/PinMnlScriptCommandEditorViewModel.cs @@ -1,6 +1,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text.RegularExpressions; +using HaruhiChokuretsuLib.Util; using ReactiveUI; using SerialLoops.Lib; using SerialLoops.Lib.Items; @@ -10,7 +11,7 @@ namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; -public partial class PinMnlScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, Project project) : ScriptCommandEditorViewModel(command, scriptEditor) +public partial class PinMnlScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, Project project) : ScriptCommandEditorViewModel(command, scriptEditor, log) { private Project _project = project; @@ -74,4 +75,4 @@ public string DialogueLine private static partial Regex StartStringQuotes(); [GeneratedRegex(@"(\s)""")] private static partial Regex MidStringOpenQuotes(); -} \ No newline at end of file +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SceneGotoScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SceneGotoScriptCommandEditorViewModel.cs new file mode 100644 index 00000000..57ea8842 --- /dev/null +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SceneGotoScriptCommandEditorViewModel.cs @@ -0,0 +1,52 @@ +using System.Collections.ObjectModel; +using System.Linq; +using HaruhiChokuretsuLib.Util; +using ReactiveUI; +using SerialLoops.Lib.Items; +using SerialLoops.Lib.Script; +using SerialLoops.Lib.Script.Parameters; +using SerialLoops.ViewModels.Panels; + +namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; + +public class SceneGotoScriptCommandEditorViewModel : ScriptCommandEditorViewModel +{ + public EditorTabsPanelViewModel Tabs { get; } + + public ObservableCollection Scripts { get; } + private ScriptItem _selectedScript; + + public ScriptItem SelectedScript + { + get => _selectedScript; + set + { + this.RaiseAndSetIfChanged(ref _selectedScript, value); + ((ConditionalScriptParameter)Command.Parameters[0]).Conditional = _selectedScript.Name; + if (Script.Event.ConditionalsSection.Objects.Contains(_selectedScript.Name)) + { + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[0] = + (short)Script.Event.ConditionalsSection.Objects.IndexOf(_selectedScript.Name); + } + else + { + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[0] = + (short)(Script.Event.ConditionalsSection.Objects.Count - 1); + Script.Event.ConditionalsSection.Objects.Insert(Script.Event.ConditionalsSection.Objects.Count - 1, _selectedScript.Name); + } + Script.UnsavedChanges = true; + } + } + + public SceneGotoScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, MainWindowViewModel window) : + base(command, scriptEditor, log) + { + Tabs = window.EditorTabs; + Scripts = new(window.OpenProject.Items.Where(i => i.Type == ItemDescription.ItemType.Script) + .Cast()); + _selectedScript = (ScriptItem)(window.OpenProject.Items.FirstOrDefault(i => i.Type == ItemDescription.ItemType.Script && ((ScriptItem)i).Name.Equals(((ConditionalScriptParameter)Command.Parameters[0]).Conditional)) + ?? window.OpenProject.Items.First(i => i.Type == ItemDescription.ItemType.Script)); + } +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFadeInScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFadeInScriptCommandEditorViewModel.cs index 5bd1f5de..cb70dc65 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFadeInScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFadeInScriptCommandEditorViewModel.cs @@ -1,7 +1,10 @@ using System; using System.Collections.ObjectModel; +using System.Linq; +using HaruhiChokuretsuLib.Util; using ReactiveUI; using ReactiveUI.Fody.Helpers; +using SerialLoops.Assets; using SerialLoops.Lib.Script; using SerialLoops.Lib.Script.Parameters; using SerialLoops.ViewModels.Controls; @@ -41,22 +44,23 @@ public short FadePercentage [Reactive] public ScreenSelectorViewModel ScreenSelector { get; set; } - public ObservableCollection Colors { get; } = new(Enum.GetNames()); - private ColorMonochromeScriptParameter.ColorMonochrome _color; - public string Color + public ObservableCollection Colors { get; } = + new(Enum.GetValues().Select(c => new ColorMonochromeLocalized(c))); + private ColorMonochromeLocalized _color; + public ColorMonochromeLocalized Color { - get => _color.ToString(); + get => _color; set { - this.RaiseAndSetIfChanged(ref _color, Enum.Parse(value)); - ((ColorMonochromeScriptParameter)Command.Parameters[3]).ColorType = _color; + this.RaiseAndSetIfChanged(ref _color, value); + ((ColorMonochromeScriptParameter)Command.Parameters[3]).ColorType = _color.Color; Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] - .Objects[Command.Index].Parameters[3] = (short)_color; + .Objects[Command.Index].Parameters[3] = (short)_color.Color; Script.UnsavedChanges = true; } } - public ScreenFadeInScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor) : base(command, scriptEditor) + public ScreenFadeInScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : base(command, scriptEditor, log) { _fadeTime = ((ShortScriptParameter)command.Parameters[0]).Value; _fadePercentage = ((ShortScriptParameter)command.Parameters[1]).Value; @@ -68,6 +72,12 @@ public ScreenFadeInScriptCommandEditorViewModel(ScriptItemCommand command, Scrip .Objects[Command.Index].Parameters[2] = (short)ScreenSelector.SelectedScreen; Script.UnsavedChanges = true; }; - _color = ((ColorMonochromeScriptParameter)command.Parameters[3]).ColorType; + _color = new(((ColorMonochromeScriptParameter)command.Parameters[3]).ColorType); } -} \ No newline at end of file +} + +public readonly struct ColorMonochromeLocalized(ColorMonochromeScriptParameter.ColorMonochrome color) +{ + public ColorMonochromeScriptParameter.ColorMonochrome Color { get; } = color; + public string DisplayText { get; } = Strings.ResourceManager.GetString(color.ToString()); +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFadeOutScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFadeOutScriptCommandEditorViewModel.cs index 549c8f32..4b087d65 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFadeOutScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFadeOutScriptCommandEditorViewModel.cs @@ -1,5 +1,7 @@ using System; using System.Collections.ObjectModel; +using System.Linq; +using HaruhiChokuretsuLib.Util; using ReactiveUI; using ReactiveUI.Fody.Helpers; using SerialLoops.Lib.Script; @@ -60,22 +62,23 @@ public SKColor CustomColor [Reactive] public ScreenSelectorViewModel ScreenSelector { get; set; } - public ObservableCollection Colors { get; } = new(Enum.GetNames()); - private ColorMonochromeScriptParameter.ColorMonochrome _color; - public string Color + public ObservableCollection Colors { get; } = + new(Enum.GetValues().Select(c => new ColorMonochromeLocalized(c))); + private ColorMonochromeLocalized _color; + public ColorMonochromeLocalized Color { - get => _color.ToString(); + get => _color; set { - this.RaiseAndSetIfChanged(ref _color, Enum.Parse(value)); - ((ColorMonochromeScriptParameter)Command.Parameters[4]).ColorType = _color; + this.RaiseAndSetIfChanged(ref _color, value); + ((ColorMonochromeScriptParameter)Command.Parameters[4]).ColorType = _color.Color; Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] - .Objects[Command.Index].Parameters[6] = (short)_color; + .Objects[Command.Index].Parameters[6] = (short)_color.Color; Script.UnsavedChanges = true; } } - public ScreenFadeOutScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor) : base(command, scriptEditor) + public ScreenFadeOutScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : base(command, scriptEditor, log) { _fadeTime = ((ShortScriptParameter)Command.Parameters[0]).Value; _fadePercentage = ((ShortScriptParameter)Command.Parameters[1]).Value; @@ -88,6 +91,6 @@ public ScreenFadeOutScriptCommandEditorViewModel(ScriptItemCommand command, Scri .Objects[Command.Index].Parameters[5] = (short)ScreenSelector.SelectedScreen; Script.UnsavedChanges = true; }; - _color = ((ColorMonochromeScriptParameter)Command.Parameters[4]).ColorType; + _color = new(((ColorMonochromeScriptParameter)Command.Parameters[4]).ColorType); } -} \ No newline at end of file +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFlashScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFlashScriptCommandEditorViewModel.cs index 26be8461..ad64d9c3 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFlashScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenFlashScriptCommandEditorViewModel.cs @@ -1,11 +1,12 @@ -using ReactiveUI; +using HaruhiChokuretsuLib.Util; +using ReactiveUI; using SerialLoops.Lib.Script; using SerialLoops.Lib.Script.Parameters; using SkiaSharp; namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; -public class ScreenFlashScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor) : ScriptCommandEditorViewModel(command, scriptEditor) +public class ScreenFlashScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : ScriptCommandEditorViewModel(command, scriptEditor, log) { private short _fadeInTime = ((ShortScriptParameter)command.Parameters[0]).Value; public short FadeInTime @@ -66,4 +67,4 @@ public SKColor Color Script.UnsavedChanges = true; } } -} \ No newline at end of file +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenShakeScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenShakeScriptCommandEditorViewModel.cs new file mode 100644 index 00000000..8a8281e4 --- /dev/null +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScreenShakeScriptCommandEditorViewModel.cs @@ -0,0 +1,59 @@ +using HaruhiChokuretsuLib.Util; +using ReactiveUI; +using SerialLoops.Lib.Script; +using SerialLoops.Lib.Script.Parameters; + +namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; + +public class ScreenShakeScriptCommandEditorViewModel : ScriptCommandEditorViewModel +{ + private short _duration; + public short Duration + { + get => _duration; + set + { + this.RaiseAndSetIfChanged(ref _duration, value); + ((ShortScriptParameter)Command.Parameters[0]).Value = _duration; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[0] = _duration; + Script.UnsavedChanges = true; + } + } + + private short _horizontalIntensity; + public short HorizontalIntensity + { + get => _horizontalIntensity; + set + { + this.RaiseAndSetIfChanged(ref _horizontalIntensity, value); + ((ShortScriptParameter)Command.Parameters[1]).Value = _horizontalIntensity; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[1] = _horizontalIntensity; + Script.UnsavedChanges = true; + } + } + + private short _verticalIntensity; + public short VerticalIntensity + { + get => _verticalIntensity; + set + { + this.RaiseAndSetIfChanged(ref _verticalIntensity, value); + ((ShortScriptParameter)Command.Parameters[2]).Value = _verticalIntensity; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[2] = _verticalIntensity; + Script.UnsavedChanges = true; + } + } + + public ScreenShakeScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : + base(command, scriptEditor, log) + { + _duration = ((ShortScriptParameter)Command.Parameters[0]).Value; + _horizontalIntensity = ((ShortScriptParameter)Command.Parameters[1]).Value; + _verticalIntensity = ((ShortScriptParameter)Command.Parameters[2]).Value; + } +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScriptCommandEditorViewModel.cs index 6d8028dc..8fd0b203 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ScriptCommandEditorViewModel.cs @@ -1,13 +1,15 @@ -using SerialLoops.Lib.Items; +using HaruhiChokuretsuLib.Util; +using SerialLoops.Lib.Items; using SerialLoops.Lib.Script; namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; -public class ScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor) : ViewModelBase +public class ScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : ViewModelBase { public ScriptItemCommand Command { get; set; } = command; public ScriptEditorViewModel ScriptEditor { get; set; } = scriptEditor; public ScriptItem Script { get; set; } = (ScriptItem)scriptEditor.Description; + public ILogger Log { get; set; } = log; public short MaxShort { get; } = short.MaxValue; public short MinShort { get; } = short.MinValue; } diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SelectScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SelectScriptCommandEditorViewModel.cs new file mode 100644 index 00000000..aa41f926 --- /dev/null +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SelectScriptCommandEditorViewModel.cs @@ -0,0 +1,134 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using HaruhiChokuretsuLib.Archive.Event; +using HaruhiChokuretsuLib.Util; +using ReactiveUI; +using SerialLoops.Lib; +using SerialLoops.Lib.Script; +using SerialLoops.Lib.Script.Parameters; + +namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; + +public class SelectScriptCommandEditorViewModel : ScriptCommandEditorViewModel +{ + public Project OpenProject { get; } + public ObservableCollection AvailableChoices { get; } + + private ChoicesSectionEntry _option1; + public ChoicesSectionEntry Option1 + { + get => _option1; + set + { + this.RaiseAndSetIfChanged(ref _option1, value); + EditOptionParameter(0, _option1); + } + } + private ChoicesSectionEntry _option2; + public ChoicesSectionEntry Option2 + { + get => _option2; + set + { + this.RaiseAndSetIfChanged(ref _option2, value); + EditOptionParameter(1, _option2); + } + } + private ChoicesSectionEntry _option3; + public ChoicesSectionEntry Option3 + { + get => _option3; + set + { + this.RaiseAndSetIfChanged(ref _option3, value); + EditOptionParameter(2, _option3); + } + } + private ChoicesSectionEntry _option4; + public ChoicesSectionEntry Option4 + { + get => _option4; + set + { + this.RaiseAndSetIfChanged(ref _option4, value); + EditOptionParameter(3, _option4); + } + } + + private short _displayFlag1; + public short DisplayFlag1 + { + get => _displayFlag1; + set + { + this.RaiseAndSetIfChanged(ref _displayFlag1, value); + EditDisplayFlag(0, _displayFlag1); + } + } + private short _displayFlag2; + public short DisplayFlag2 + { + get => _displayFlag2; + set + { + this.RaiseAndSetIfChanged(ref _displayFlag2, value); + EditDisplayFlag(1, _displayFlag2); + } + } + private short _displayFlag3; + public short DisplayFlag3 + { + get => _displayFlag3; + set + { + this.RaiseAndSetIfChanged(ref _displayFlag3, value); + EditDisplayFlag(2, _displayFlag3); + } + } + private short _displayFlag4; + public short DisplayFlag4 + { + get => _displayFlag4; + set + { + this.RaiseAndSetIfChanged(ref _displayFlag4, value); + EditDisplayFlag(3, _displayFlag4); + } + } + + public SelectScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, Project project) : + base(command, scriptEditor, log) + { + OpenProject = project; + AvailableChoices = + new(new List() { new() { Text = "NONE", Id = 0 } }.Concat(Script.Event.ChoicesSection + .Objects.Skip(1).SkipLast(1))); + _option1 = ((OptionScriptParameter)Command.Parameters[0]).Option.Id == 0 ? AvailableChoices[0] : ((OptionScriptParameter)Command.Parameters[0]).Option; + _option2 = ((OptionScriptParameter)Command.Parameters[1]).Option.Id == 0 ? AvailableChoices[0] : ((OptionScriptParameter)Command.Parameters[1]).Option; + _option3 = ((OptionScriptParameter)Command.Parameters[2]).Option.Id == 0 ? AvailableChoices[0] : ((OptionScriptParameter)Command.Parameters[2]).Option; + _option4 = ((OptionScriptParameter)Command.Parameters[3]).Option.Id == 0 ? AvailableChoices[0] : ((OptionScriptParameter)Command.Parameters[3]).Option; + _displayFlag1 = ((ShortScriptParameter)Command.Parameters[4]).Value; + _displayFlag2 = ((ShortScriptParameter)Command.Parameters[5]).Value; + _displayFlag3 = ((ShortScriptParameter)Command.Parameters[6]).Value; + _displayFlag4 = ((ShortScriptParameter)Command.Parameters[7]).Value; + } + + private void EditOptionParameter(int index, ChoicesSectionEntry option) + { + ((OptionScriptParameter)Command.Parameters[index]).Option = option; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[index] = Script.Event.ChoicesSection.Objects.IndexOf(option) == -1 ? (short)0 : (short)Script.Event.ChoicesSection.Objects.IndexOf(option) ; + Script.UnsavedChanges = true; + ScriptEditor.UpdatePreview(); + Script.Refresh(OpenProject, Log); + } + + private void EditDisplayFlag(int index, short displayFlag) + { + ((ShortScriptParameter)Command.Parameters[index + 4]).Value = displayFlag; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[index + 4] = displayFlag; + Script.UnsavedChanges = true; + } +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SndPlayScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SndPlayScriptCommandEditorViewModel.cs index 6d73da46..a9365d0f 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SndPlayScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/SndPlayScriptCommandEditorViewModel.cs @@ -1,8 +1,10 @@ using System; using System.Collections.ObjectModel; using System.Linq; +using HaruhiChokuretsuLib.Util; using ReactiveUI; using ReactiveUI.Fody.Helpers; +using SerialLoops.Assets; using SerialLoops.Lib.Items; using SerialLoops.Lib.Script; using SerialLoops.Lib.Script.Parameters; @@ -30,17 +32,18 @@ public SfxItem SelectedSfx } } - public ObservableCollection SfxPlayModes { get; } = new(Enum.GetNames()); - private SfxModeScriptParameter.SfxMode _sfxMode; - public string SfxMode + public ObservableCollection SfxPlayModes { get; } = + new(Enum.GetValues().Select(m => new SfxModeLocalized(m))); + private SfxModeLocalized _sfxMode; + public SfxModeLocalized SfxMode { - get => _sfxMode.ToString(); + get => _sfxMode; set { - this.RaiseAndSetIfChanged(ref _sfxMode, Enum.Parse(value)); - ((SfxModeScriptParameter)Command.Parameters[1]).Mode = _sfxMode; + this.RaiseAndSetIfChanged(ref _sfxMode, value); + ((SfxModeScriptParameter)Command.Parameters[1]).Mode = _sfxMode.Mode; Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] - .Objects[Command.Index].Parameters[1] = (short)_sfxMode; + .Objects[Command.Index].Parameters[1] = (short)_sfxMode.Mode; Script.UnsavedChanges = true; } } @@ -105,15 +108,21 @@ public short CrossfadeTime } } - public SndPlayScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, MainWindowViewModel window) : - base(command, scriptEditor) + public SndPlayScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, MainWindowViewModel window) : + base(command, scriptEditor, log) { Tabs = window.EditorTabs; SfxChoices = new(window.OpenProject.Items.Where(i => i.Type == ItemDescription.ItemType.SFX && ((SfxItem)i).AssociatedGroups.Contains(window.OpenProject.Snd.Groups[Script.SfxGroupIndex].Name)).Cast()); _selectedSfx = ((SfxScriptParameter)Command.Parameters[0]).Sfx; - _sfxMode = ((SfxModeScriptParameter)Command.Parameters[1]).Mode; + _sfxMode = new(((SfxModeScriptParameter)Command.Parameters[1]).Mode); _volume = ((ShortScriptParameter)Command.Parameters[2]).Value; _crossfadeTime = ((ShortScriptParameter)Command.Parameters[4]).Value; _loadSound = ((BoolScriptParameter)Command.Parameters[3]).Value && _crossfadeTime < 0; } -} \ No newline at end of file +} + +public readonly struct SfxModeLocalized(SfxModeScriptParameter.SfxMode mode) +{ + public SfxModeScriptParameter.SfxMode Mode { get; } = mode; + public string DisplayText { get; } = Strings.ResourceManager.GetString(mode.ToString()); +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ToggleDialogueScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ToggleDialogueScriptCommandEditorViewModel.cs index 877141f9..e7a8b503 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ToggleDialogueScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/ToggleDialogueScriptCommandEditorViewModel.cs @@ -1,10 +1,11 @@ +using HaruhiChokuretsuLib.Util; using ReactiveUI; using SerialLoops.Lib.Script; using SerialLoops.Lib.Script.Parameters; namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; -public class ToggleDialogueScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor) : ScriptCommandEditorViewModel(command, scriptEditor) +public class ToggleDialogueScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : ScriptCommandEditorViewModel(command, scriptEditor, log) { private bool _dialogueVisible = ((BoolScriptParameter)command.Parameters[0]).Value; public bool DialogueVisible diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/TopicGetScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/TopicGetScriptCommandEditorViewModel.cs index 306f29ca..4912b917 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/TopicGetScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/TopicGetScriptCommandEditorViewModel.cs @@ -1,6 +1,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Windows.Input; +using HaruhiChokuretsuLib.Util; using ReactiveUI; using ReactiveUI.Fody.Helpers; using SerialLoops.Lib.Items; @@ -35,8 +36,8 @@ public TopicItem SelectedTopic public ICommand SelectTopicCommand { get; } - public TopicGetScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, MainWindowViewModel window) - : base(command, scriptEditor) + public TopicGetScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, MainWindowViewModel window) + : base(command, scriptEditor, log) { Tabs = window.EditorTabs; Topics = new(window.OpenProject.Items.Where(i => i.Type == ItemDescription.ItemType.Topic).Cast()); diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/VcePlayScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/VcePlayScriptCommandEditorViewModel.cs index a699736e..43c6d412 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/VcePlayScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/VcePlayScriptCommandEditorViewModel.cs @@ -1,5 +1,6 @@ using System.Collections.ObjectModel; using System.Linq; +using HaruhiChokuretsuLib.Util; using ReactiveUI; using SerialLoops.Lib.Items; using SerialLoops.Lib.Script; @@ -27,8 +28,8 @@ public VoicedLineItem Vce } } - public VcePlayScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, MainWindowViewModel window) : - base(command, scriptEditor) + public VcePlayScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log, MainWindowViewModel window) : + base(command, scriptEditor, log) { Tabs = window.EditorTabs; Vces = new(window.OpenProject.Items.Where(i => i.Type == ItemDescription.ItemType.Voice).Cast()); diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/VgotoScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/VgotoScriptCommandEditorViewModel.cs new file mode 100644 index 00000000..ae5eaa4e --- /dev/null +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/VgotoScriptCommandEditorViewModel.cs @@ -0,0 +1,53 @@ +using System.Linq; +using HaruhiChokuretsuLib.Util; +using ReactiveUI; +using SerialLoops.Lib.Script; +using SerialLoops.Lib.Script.Parameters; + +namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; + +public class VgotoScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) + : ScriptCommandEditorViewModel(command, scriptEditor, log) +{ + private string _conditional = ((ConditionalScriptParameter)command.Parameters[0]).Conditional; + public string Conditional + { + get => _conditional; + set + { + this.RaiseAndSetIfChanged(ref _conditional, value); + ((ConditionalScriptParameter)Command.Parameters[0]).Conditional = value; + if (Script.Event.ConditionalsSection.Objects.Contains(_conditional)) + { + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[0] = + (short)Script.Event.ConditionalsSection.Objects.IndexOf(_conditional); + } + else + { + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[0] = + (short)(Script.Event.ConditionalsSection.Objects.Count - 1); + Script.Event.ConditionalsSection.Objects.Insert(Script.Event.ConditionalsSection.Objects.Count - 1, _conditional); + } + Script.UnsavedChanges = true; + Command.UpdateDisplay(); + } + } + + private ReactiveScriptSection _sectionToJumpTo = scriptEditor.ScriptSections[command.Script.ScriptSections.IndexOf(((ScriptSectionScriptParameter)command.Parameters[1]).Section)]; + public ReactiveScriptSection SectionToJumpTo + { + get => _sectionToJumpTo; + set + { + this.RaiseAndSetIfChanged(ref _sectionToJumpTo, value); + ((ScriptSectionScriptParameter)Command.Parameters[1]).Section = _sectionToJumpTo.Section; + Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] + .Objects[Command.Index].Parameters[1] = Script.Event.LabelsSection.Objects + .FirstOrDefault(l => l.Name.Replace("/", "").Equals(_sectionToJumpTo.Name))?.Id ?? 0; + Script.UnsavedChanges = true; + Command.UpdateDisplay(); + } + } +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/WaitScriptCommandEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/WaitScriptCommandEditorViewModel.cs index 57e08e24..a0fa429b 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/WaitScriptCommandEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptCommandEditors/WaitScriptCommandEditorViewModel.cs @@ -1,10 +1,11 @@ -using ReactiveUI; +using HaruhiChokuretsuLib.Util; +using ReactiveUI; using SerialLoops.Lib.Script; using SerialLoops.Lib.Script.Parameters; namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; -public class WaitScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor) : ScriptCommandEditorViewModel(command, scriptEditor) +public class WaitScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : ScriptCommandEditorViewModel(command, scriptEditor, log) { private short _waitTime = ((ShortScriptParameter)command.Parameters[0]).Value; public short WaitTime @@ -20,4 +21,4 @@ public short WaitTime Command.UpdateDisplay(); } } -} \ No newline at end of file +} diff --git a/src/SerialLoops/ViewModels/Editors/ScriptEditorViewModel.cs b/src/SerialLoops/ViewModels/Editors/ScriptEditorViewModel.cs index 49d1f260..2fe954f3 100644 --- a/src/SerialLoops/ViewModels/Editors/ScriptEditorViewModel.cs +++ b/src/SerialLoops/ViewModels/Editors/ScriptEditorViewModel.cs @@ -1,13 +1,14 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.IO; using System.Linq; -using System.Reflection; using System.Windows.Input; using Avalonia.Controls; using Avalonia.Controls.Models.TreeDataGrid; using Avalonia.Controls.Selection; using Avalonia.Controls.Templates; +using Avalonia.Platform; using HaruhiChokuretsuLib.Archive.Event; using HaruhiChokuretsuLib.Util; using ReactiveUI; @@ -43,13 +44,13 @@ public ScriptItemCommand SelectedCommand UpdatePreview(); } } - [Reactive] - public ScriptSection SelectedSection { get; set; } - [Reactive] - public SKBitmap PreviewBitmap { get; set; } - [Reactive] - public ScriptCommandEditorViewModel CurrentCommandViewModel { get; set; } + [Reactive] public ScriptSection SelectedSection { get; set; } + + [Reactive] public SKBitmap PreviewBitmap { get; set; } + [Reactive] public ScriptCommandEditorViewModel CurrentCommandViewModel { get; set; } + + public ObservableCollection ScriptSections { get; } public Dictionary> Commands { @@ -57,15 +58,14 @@ public Dictionary> Commands set { this.RaiseAndSetIfChanged(ref _commands, value); - Source = new(_commands.Keys.Select(s => new ScriptSectionTreeItem(s, _commands[s]))) + Source = new(_commands.Keys.Select(s => new ScriptSectionTreeItem(ScriptSections[_script.Event.ScriptSections.IndexOf(s)], _commands[s]))) { Columns = { new HierarchicalExpanderColumn( - new TemplateColumn(null, new FuncDataTemplate((val, namescope) => - { - return val?.GetDisplay(); - }), options: new TemplateColumnOptions() { IsTextSearchEnabled = true }), + new TemplateColumn(null, + new FuncDataTemplate((val, namescope) => val?.GetDisplay()), + options: new TemplateColumnOptions() { IsTextSearchEnabled = true }), i => i.Children ) } @@ -82,6 +82,7 @@ public Dictionary> Commands public ScriptEditorViewModel(ScriptItem script, MainWindowViewModel window, ILogger log) : base(script, window, log) { _script = script; + ScriptSections = new(script.Event.ScriptSections.Select(s => new ReactiveScriptSection(s))); _project = window.OpenProject; PopulateScriptCommands(); _script.CalculateGraphEdges(_commands, _log); @@ -93,6 +94,7 @@ public void PopulateScriptCommands(bool refresh = false) { _script.Refresh(_project, _log); } + Commands = _script.GetScriptCommandTree(_project, _log); } @@ -106,35 +108,43 @@ private void UpdateCommandViewModel() { CurrentCommandViewModel = _selectedCommand.Verb switch { - CommandVerb.INIT_READ_FLAG => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.DIALOGUE => new DialogueScriptCommandEditorViewModel(_selectedCommand, this, _window), - CommandVerb.KBG_DISP => new KbgDispScriptCommandEditorViewModel(_selectedCommand, this, _window), - CommandVerb.PIN_MNL => new PinMnlScriptCommandEditorViewModel(_selectedCommand, this, _window.OpenProject), - CommandVerb.BG_DISP => new BgDispScriptCommandEditorViewModel(_selectedCommand, this, _window), - CommandVerb.SCREEN_FADEIN => new ScreenFadeInScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.SCREEN_FADEOUT => new ScreenFadeOutScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.SCREEN_FLASH => new ScreenFlashScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.SND_PLAY => new SndPlayScriptCommandEditorViewModel(_selectedCommand, this, _window), - CommandVerb.REMOVED => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.SND_STOP => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.BGM_PLAY => new BgmPlayScriptCommandEditorViewModel(_selectedCommand, this, _window), - CommandVerb.VCE_PLAY => new VcePlayScriptCommandEditorViewModel(_selectedCommand, this, _window), - CommandVerb.FLAG => new FlagScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.TOPIC_GET => new TopicGetScriptCommandEditorViewModel(_selectedCommand, this, _window), - CommandVerb.TOGGLE_DIALOGUE => new ToggleDialogueScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.SCREEN_SHAKE_STOP => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.WAIT => new WaitScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.HOLD => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.NOOP1 => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.BACK => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.STOP => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.NOOP2 => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.INVEST_END => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.NEXT_SCENE => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.AVOID_DISP => new EmptyScriptCommandEditorViewModel(_selectedCommand, this), - CommandVerb.CHESS_LOAD => new ChessLoadScriptCommandEditorViewModel(_selectedCommand, this, _window), - CommandVerb.BG_DISP2 => new BgDispScriptCommandEditorViewModel(_selectedCommand, this, _window), - _ => new ScriptCommandEditorViewModel(_selectedCommand, this) + CommandVerb.INIT_READ_FLAG => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.DIALOGUE => new DialogueScriptCommandEditorViewModel(_selectedCommand, this, _log, _window), + CommandVerb.KBG_DISP => new KbgDispScriptCommandEditorViewModel(_selectedCommand, this, _log, _window), + CommandVerb.PIN_MNL => new PinMnlScriptCommandEditorViewModel(_selectedCommand, this, _log, _window.OpenProject), + CommandVerb.BG_DISP => new BgDispScriptCommandEditorViewModel(_selectedCommand, this, _log, _window), + CommandVerb.SCREEN_FADEIN => new ScreenFadeInScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.SCREEN_FADEOUT => new ScreenFadeOutScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.SCREEN_FLASH => new ScreenFlashScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.REMOVED => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.SND_STOP => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.BGM_PLAY => new BgmPlayScriptCommandEditorViewModel(_selectedCommand, this, _log, _window), + CommandVerb.VCE_PLAY => new VcePlayScriptCommandEditorViewModel(_selectedCommand, this, _log, _window), + CommandVerb.FLAG => new FlagScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.TOPIC_GET => new TopicGetScriptCommandEditorViewModel(_selectedCommand, this, _log, _window), + CommandVerb.TOGGLE_DIALOGUE => new ToggleDialogueScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.SELECT => new SelectScriptCommandEditorViewModel(_selectedCommand, this, _log, _window.OpenProject), + CommandVerb.SCREEN_SHAKE => new ScreenShakeScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.SCREEN_SHAKE_STOP => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.GOTO => new GotoScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.SCENE_GOTO => new SceneGotoScriptCommandEditorViewModel(_selectedCommand, this, _log, _window), + CommandVerb.WAIT => new WaitScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.HOLD => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.NOOP1 => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.VGOTO => new VgotoScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.HARUHI_METER => new HaruhiMeterScriptCommandEditorViewModel(_selectedCommand, this, _log, noShow: false), + CommandVerb.HARUHI_METER_NOSHOW => new HaruhiMeterScriptCommandEditorViewModel(_selectedCommand, this, _log, noShow: true), + CommandVerb.PALEFFECT => new PalEffectScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.BACK => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.STOP => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.NOOP2 => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.INVEST_END => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.NEXT_SCENE => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.AVOID_DISP => new EmptyScriptCommandEditorViewModel(_selectedCommand, this, _log), + CommandVerb.CHESS_LOAD => new ChessLoadScriptCommandEditorViewModel(_selectedCommand, this, _window, _log), + CommandVerb.SCENE_GOTO_CHESS => new SceneGotoScriptCommandEditorViewModel(_selectedCommand, this, _log, _window), + CommandVerb.BG_DISP2 => new BgDispScriptCommandEditorViewModel(_selectedCommand, this, _log, _window), + _ => new ScriptCommandEditorViewModel(_selectedCommand, this, _log) }; } } @@ -149,16 +159,18 @@ public void UpdatePreview() } else { - (SKBitmap previewBitmap, string errorImage) = _script.GeneratePreviewImage(_commands, SelectedCommand, _project, _log); + (SKBitmap previewBitmap, string errorImage) = + _script.GeneratePreviewImage(_commands, SelectedCommand, _project, _log); if (previewBitmap is null) { previewBitmap = new(256, 384); SKCanvas canvas = new(previewBitmap); canvas.DrawColor(SKColors.Black); - using Stream noPreviewStream = Assembly.GetCallingAssembly().GetManifestResourceStream(errorImage); + using Stream noPreviewStream = AssetLoader.Open(new(errorImage)); canvas.DrawImage(SKImage.FromEncodedData(noPreviewStream), new SKPoint(0, 0)); canvas.Flush(); } + PreviewBitmap = previewBitmap; } } @@ -175,6 +187,7 @@ private void RowSelection_SelectionChanged(object sender, TreeSelectionModelSele SelectedCommand = null; SelectedSection = null; } + if (e.SelectedIndexes[0].Count > 1) { SelectedCommand = Commands[Commands.Keys.ElementAt(e.SelectedIndexes[0][0])][e.SelectedIndexes[0][1]]; @@ -187,3 +200,28 @@ private void RowSelection_SelectionChanged(object sender, TreeSelectionModelSele } } } + +public class ReactiveScriptSection(ScriptSection section) : ReactiveObject +{ + public ScriptSection Section { get; } = section; + + private string _name = section.Name; + + public string Name + { + get => _name; + set + { + this.RaiseAndSetIfChanged(ref _name, value); + Section.Name = _name; + } + } + + public ObservableCollection Commands { get; } = new(section.Objects); + + public void InsertCommand(int index, ScriptCommandInvocation command) + { + Commands.Insert(index, command); + Section.Objects.Insert(index, command); + } +} diff --git a/src/SerialLoops/ViewModels/Panels/EditorTabsPanelViewModel.cs b/src/SerialLoops/ViewModels/Panels/EditorTabsPanelViewModel.cs index 2eae28e7..7294c952 100644 --- a/src/SerialLoops/ViewModels/Panels/EditorTabsPanelViewModel.cs +++ b/src/SerialLoops/ViewModels/Panels/EditorTabsPanelViewModel.cs @@ -12,9 +12,8 @@ namespace SerialLoops.ViewModels.Panels; public class EditorTabsPanelViewModel : ViewModelBase { - private Project _project; - private ILogger _log; - private EditorViewModel _selectedTab; + private readonly Project _project; + private readonly ILogger _log; public MainWindowViewModel MainWindow { get; private set; } [Reactive] diff --git a/src/SerialLoops/Views/Dialogs/ProjectCreationDialog.axaml b/src/SerialLoops/Views/Dialogs/ProjectCreationDialog.axaml index 1b130016..6fa4b0b6 100644 --- a/src/SerialLoops/Views/Dialogs/ProjectCreationDialog.axaml +++ b/src/SerialLoops/Views/Dialogs/ProjectCreationDialog.axaml @@ -4,7 +4,6 @@ xmlns:vm="using:SerialLoops.ViewModels.Dialogs" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:assets="using:SerialLoops.Assets" - xmlns:utility="using:SerialLoops.Utility" xmlns:gbox="using:GroupBox.Avalonia.Controls" xmlns:i="using:Avalonia.Xaml.Interactivity" mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="275" diff --git a/src/SerialLoops/Views/Dialogs/ProjectSettingsDialog.axaml b/src/SerialLoops/Views/Dialogs/ProjectSettingsDialog.axaml index 814db1b6..7b986f01 100644 --- a/src/SerialLoops/Views/Dialogs/ProjectSettingsDialog.axaml +++ b/src/SerialLoops/Views/Dialogs/ProjectSettingsDialog.axaml @@ -5,7 +5,6 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:assets="using:SerialLoops.Assets" mc:Ignorable="d" d:DesignWidth="550" d:DesignHeight="370" - xmlns:controls="using:SerialLoops.Controls" xmlns:utility="using:SerialLoops.Utility" x:DataType="vm:ProjectSettingsDialogViewModel" x:Class="SerialLoops.Views.Dialogs.ProjectSettingsDialog" diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/BgmPlayScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/BgmPlayScriptCommandEditorView.axaml index a39dce07..feab5dff 100644 --- a/src/SerialLoops/Views/Editors/ScriptCommandEditors/BgmPlayScriptCommandEditorView.axaml +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/BgmPlayScriptCommandEditorView.axaml @@ -28,7 +28,18 @@ - + + + + + + + + + + + + + SelectedItem="{Binding SpriteEntranceTransition}"> + + + + + + + + + + + + SelectedItem="{Binding SpriteExitTransition}"> + + + + + + + + + + + + SelectedItem="{Binding SpriteShakeEffect}"> + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/GotoScriptCommandEditorView.axaml.cs b/src/SerialLoops/Views/Editors/ScriptCommandEditors/GotoScriptCommandEditorView.axaml.cs new file mode 100644 index 00000000..c40c3219 --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/GotoScriptCommandEditorView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace SerialLoops.Views.Editors.ScriptCommandEditors; + +public partial class GotoScriptCommandEditorView : UserControl +{ + public GotoScriptCommandEditorView() + { + InitializeComponent(); + } +} + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/HaruhiMeterScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/HaruhiMeterScriptCommandEditorView.axaml new file mode 100644 index 00000000..ada7a71a --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/HaruhiMeterScriptCommandEditorView.axaml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/HaruhiMeterScriptCommandEditorView.axaml.cs b/src/SerialLoops/Views/Editors/ScriptCommandEditors/HaruhiMeterScriptCommandEditorView.axaml.cs new file mode 100644 index 00000000..ac98476d --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/HaruhiMeterScriptCommandEditorView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace SerialLoops.Views.Editors.ScriptCommandEditors; + +public partial class HaruhiMeterScriptCommandEditorView : UserControl +{ + public HaruhiMeterScriptCommandEditorView() + { + InitializeComponent(); + } +} + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/PalEffectScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/PalEffectScriptCommandEditorView.axaml new file mode 100644 index 00000000..fc480b19 --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/PalEffectScriptCommandEditorView.axaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/PalEffectScriptCommandEditorView.axaml.cs b/src/SerialLoops/Views/Editors/ScriptCommandEditors/PalEffectScriptCommandEditorView.axaml.cs new file mode 100644 index 00000000..233d39b1 --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/PalEffectScriptCommandEditorView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace SerialLoops.Views.Editors.ScriptCommandEditors; + +public partial class PalEffectScriptCommandEditorView : UserControl +{ + public PalEffectScriptCommandEditorView() + { + InitializeComponent(); + } +} + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/SceneGotoScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/SceneGotoScriptCommandEditorView.axaml new file mode 100644 index 00000000..5438a77c --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/SceneGotoScriptCommandEditorView.axaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/SceneGotoScriptCommandEditorView.axaml.cs b/src/SerialLoops/Views/Editors/ScriptCommandEditors/SceneGotoScriptCommandEditorView.axaml.cs new file mode 100644 index 00000000..6696b12e --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/SceneGotoScriptCommandEditorView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace SerialLoops.Views.Editors.ScriptCommandEditors; + +public partial class SceneGotoScriptCommandEditorView : UserControl +{ + public SceneGotoScriptCommandEditorView() + { + InitializeComponent(); + } +} + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFadeInScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFadeInScriptCommandEditorView.axaml index 5cba24ff..c172c259 100644 --- a/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFadeInScriptCommandEditorView.axaml +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFadeInScriptCommandEditorView.axaml @@ -21,6 +21,17 @@ - + + + + + + + + + + + + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFadeOutScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFadeOutScriptCommandEditorView.axaml index 1470a04b..89ae507b 100644 --- a/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFadeOutScriptCommandEditorView.axaml +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFadeOutScriptCommandEditorView.axaml @@ -20,11 +20,22 @@ - + - + + + + + + + + + + + + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFlashScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFlashScriptCommandEditorView.axaml index 513399d7..25911a7d 100644 --- a/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFlashScriptCommandEditorView.axaml +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenFlashScriptCommandEditorView.axaml @@ -4,7 +4,6 @@ xmlns:vm="using:SerialLoops.ViewModels.Editors.ScriptCommandEditors" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:assets="using:SerialLoops.Assets" - xmlns:controls="using:SerialLoops.Controls" xmlns:utility="using:SerialLoops.Utility" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:DataType="vm:ScreenFlashScriptCommandEditorViewModel" @@ -25,7 +24,7 @@ - + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenShakeScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenShakeScriptCommandEditorView.axaml new file mode 100644 index 00000000..46184dd8 --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenShakeScriptCommandEditorView.axaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenShakeScriptCommandEditorView.axaml.cs b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenShakeScriptCommandEditorView.axaml.cs new file mode 100644 index 00000000..013d8ce2 --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/ScreenShakeScriptCommandEditorView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace SerialLoops.Views.Editors.ScriptCommandEditors; + +public partial class ScreenShakeScriptCommandEditorView : UserControl +{ + public ScreenShakeScriptCommandEditorView() + { + InitializeComponent(); + } +} + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/SelectScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/SelectScriptCommandEditorView.axaml new file mode 100644 index 00000000..81434cb4 --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/SelectScriptCommandEditorView.axaml @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/SelectScriptCommandEditorView.axaml.cs b/src/SerialLoops/Views/Editors/ScriptCommandEditors/SelectScriptCommandEditorView.axaml.cs new file mode 100644 index 00000000..f1366192 --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/SelectScriptCommandEditorView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace SerialLoops.Views.Editors.ScriptCommandEditors; + +public partial class SelectScriptCommandEditorView : UserControl +{ + public SelectScriptCommandEditorView() + { + InitializeComponent(); + } +} + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/VgotoScriptCommandEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptCommandEditors/VgotoScriptCommandEditorView.axaml new file mode 100644 index 00000000..66f2adf2 --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/VgotoScriptCommandEditorView.axaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SerialLoops/Views/Editors/ScriptCommandEditors/VgotoScriptCommandEditorView.axaml.cs b/src/SerialLoops/Views/Editors/ScriptCommandEditors/VgotoScriptCommandEditorView.axaml.cs new file mode 100644 index 00000000..78f0faad --- /dev/null +++ b/src/SerialLoops/Views/Editors/ScriptCommandEditors/VgotoScriptCommandEditorView.axaml.cs @@ -0,0 +1,12 @@ +using Avalonia.Controls; + +namespace SerialLoops.Views.Editors.ScriptCommandEditors; + +public partial class VgotoScriptCommandEditorView : UserControl +{ + public VgotoScriptCommandEditorView() + { + InitializeComponent(); + } +} + diff --git a/src/SerialLoops/Views/Editors/ScriptEditorView.axaml b/src/SerialLoops/Views/Editors/ScriptEditorView.axaml index ee7cf66d..ccc1278d 100644 --- a/src/SerialLoops/Views/Editors/ScriptEditorView.axaml +++ b/src/SerialLoops/Views/Editors/ScriptEditorView.axaml @@ -28,17 +28,11 @@ Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Width="256"/> - - - - - - + + - - - + diff --git a/src/SerialLoops/Views/Editors/VoicedLineEditorView.axaml b/src/SerialLoops/Views/Editors/VoicedLineEditorView.axaml index 644e0cd2..d0db3e14 100644 --- a/src/SerialLoops/Views/Editors/VoicedLineEditorView.axaml +++ b/src/SerialLoops/Views/Editors/VoicedLineEditorView.axaml @@ -3,8 +3,6 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:vm="using:SerialLoops.ViewModels.Editors" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:i="using:Avalonia.Xaml.Interactivity" - xmlns:ia="using:Avalonia.Xaml.Interactions.Core" xmlns:assets="using:SerialLoops.Assets" xmlns:controls="using:SerialLoops.Controls" xmlns:utility="using:SerialLoops.Utility" diff --git a/src/SerialLoops/Views/MainWindow.axaml b/src/SerialLoops/Views/MainWindow.axaml index 24d17d3c..c9b50bb7 100644 --- a/src/SerialLoops/Views/MainWindow.axaml +++ b/src/SerialLoops/Views/MainWindow.axaml @@ -3,10 +3,6 @@ xmlns:vm="using:SerialLoops.ViewModels" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:views="using:SerialLoops.Views" - xmlns:panels="using:SerialLoops.Views.Panels" - xmlns:panelsvm="using:SerialLoops.ViewModels.Panels" - xmlns:assets="using:SerialLoops.Assets" xmlns:toolbar="using:MiniToolbar.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="SerialLoops.Views.MainWindow" @@ -28,8 +24,7 @@ - - + diff --git a/src/SerialLoops/Views/Panels/EditorTabsPanel.axaml b/src/SerialLoops/Views/Panels/EditorTabsPanel.axaml index bfc81c2b..2762dce9 100644 --- a/src/SerialLoops/Views/Panels/EditorTabsPanel.axaml +++ b/src/SerialLoops/Views/Panels/EditorTabsPanel.axaml @@ -6,16 +6,11 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" xmlns:i="using:Avalonia.Xaml.Interactivity" xmlns:ia="using:Avalonia.Xaml.Interactions.Core" - xmlns:controls="using:SerialLoops.Controls" - xmlns:assets="using:SerialLoops.Assets" xmlns:editors="using:SerialLoops.ViewModels.Editors" xmlns:utility="using:SerialLoops.Utility" xmlns:tab="using:Tabalonia.Controls" x:DataType="vm:EditorTabsPanelViewModel" x:Class="SerialLoops.Views.Panels.EditorTabsPanel"> - - - diff --git a/src/SerialLoops/Views/Panels/EditorTabsPanel.axaml.cs b/src/SerialLoops/Views/Panels/EditorTabsPanel.axaml.cs index a6366138..928036c2 100644 --- a/src/SerialLoops/Views/Panels/EditorTabsPanel.axaml.cs +++ b/src/SerialLoops/Views/Panels/EditorTabsPanel.axaml.cs @@ -14,6 +14,6 @@ public EditorTabsPanel() private void Tabs_ContainerClearing(object? sender, ContainerClearingEventArgs e) { - ((EditorTabsPanelViewModel)DataContext).OnTabClosed((EditorViewModel)e.Container.DataContext); + ((EditorTabsPanelViewModel)DataContext!).OnTabClosed((EditorViewModel)e.Container.DataContext); } }