-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some more script command editors (#442)
- Loading branch information
Showing
24 changed files
with
660 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...alLoops/ViewModels/Editors/ScriptCommandEditors/ChibiEmoteScriptCommandEditorViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using DynamicData; | ||
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; | ||
|
||
namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; | ||
|
||
public class ChibiEmoteScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : ScriptCommandEditorViewModel(command, scriptEditor, log) | ||
{ | ||
public ObservableCollection<ChibiItem> Chibis { get; } = new(scriptEditor.Window.OpenProject.Items | ||
.Where(i => i.Type == ItemDescription.ItemType.Chibi).Cast<ChibiItem>()); | ||
public ChibiItem Chibi | ||
{ | ||
get => ((ChibiScriptParameter)Command.Parameters[0]).Chibi; | ||
set | ||
{ | ||
((ChibiScriptParameter)Command.Parameters[0]).Chibi = value; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[0] = (short)value.TopScreenIndex; | ||
this.RaisePropertyChanged(); | ||
ScriptEditor.UpdatePreview(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
|
||
public ObservableCollection<LocalizedChibiEmote> ChibiEmotes { get; } = new(Enum | ||
.GetValues<ChibiEmoteScriptParameter.ChibiEmote>() | ||
.Select(e => new LocalizedChibiEmote(e))); | ||
|
||
public LocalizedChibiEmote ChibiEmote | ||
{ | ||
get => new(((ChibiEmoteScriptParameter)Command.Parameters[1]).Emote); | ||
set | ||
{ | ||
((ChibiEmoteScriptParameter)Command.Parameters[1]).Emote = value.Emote; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[1] = (short)value.Emote; | ||
this.RaisePropertyChanged(); | ||
ScriptEditor.UpdatePreview(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
} | ||
|
||
public struct LocalizedChibiEmote(ChibiEmoteScriptParameter.ChibiEmote chibiEmote) | ||
{ | ||
public ChibiEmoteScriptParameter.ChibiEmote Emote { get; } = chibiEmote; | ||
|
||
public string DisplayName => Strings.ResourceManager.GetString(Emote.ToString()); | ||
} |
66 changes: 66 additions & 0 deletions
66
...ops/ViewModels/Editors/ScriptCommandEditors/ChibiEnterExitScriptCommandEditorViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Runtime.InteropServices.JavaScript; | ||
using HaruhiChokuretsuLib.Util; | ||
using ReactiveUI; | ||
using SerialLoops.Assets; | ||
using SerialLoops.Lib.Items; | ||
using SerialLoops.Lib.Script; | ||
using SerialLoops.Lib.Script.Parameters; | ||
|
||
namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; | ||
|
||
public class ChibiEnterExitScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : ScriptCommandEditorViewModel(command, scriptEditor, log) | ||
{ | ||
public ObservableCollection<ChibiItem> Chibis { get; } = new(scriptEditor.Window.OpenProject.Items.Where( | ||
i => i.Type == ItemDescription.ItemType.Chibi).Cast<ChibiItem>()); | ||
public ChibiItem Chibi | ||
{ | ||
get => ((ChibiScriptParameter)Command.Parameters[0]).Chibi; | ||
set | ||
{ | ||
((ChibiScriptParameter)Command.Parameters[0]).Chibi = value; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[0] = (short)value.TopScreenIndex; | ||
this.RaisePropertyChanged(); | ||
ScriptEditor.UpdatePreview(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
|
||
public ObservableCollection<LocalizedChibiEnterExitType> EnterExitModes { get; } = new(Enum.GetValues<ChibiEnterExitScriptParameter.ChibiEnterExitType>() | ||
.Select(t => new LocalizedChibiEnterExitType(t))); | ||
public LocalizedChibiEnterExitType EnterExitMode | ||
{ | ||
get => new(((ChibiEnterExitScriptParameter)Command.Parameters[1]).Mode); | ||
set | ||
{ | ||
((ChibiEnterExitScriptParameter)Command.Parameters[1]).Mode = value.Mode; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[1] = (short)value.Mode; | ||
this.RaisePropertyChanged(); | ||
ScriptEditor.UpdatePreview(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
|
||
public short Delay | ||
{ | ||
get => ((ShortScriptParameter)Command.Parameters[2]).Value; | ||
set | ||
{ | ||
((ShortScriptParameter)Command.Parameters[2]).Value = value; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[2] = value; | ||
this.RaisePropertyChanged(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
} | ||
|
||
public readonly struct LocalizedChibiEnterExitType(ChibiEnterExitScriptParameter.ChibiEnterExitType type) | ||
{ | ||
public ChibiEnterExitScriptParameter.ChibiEnterExitType Mode { get; } = type; | ||
public string DisplayName { get; } = Strings.ResourceManager.GetString(type.ToString()); | ||
} |
22 changes: 22 additions & 0 deletions
22
...rialLoops/ViewModels/Editors/ScriptCommandEditors/Global2DScriptCommandEditorViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using HaruhiChokuretsuLib.Util; | ||
using ReactiveUI; | ||
using SerialLoops.Lib.Script; | ||
using SerialLoops.Lib.Script.Parameters; | ||
|
||
namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; | ||
|
||
public class Global2DScriptCommandEditorViewModel(ScriptItemCommand command, ScriptEditorViewModel scriptEditor, ILogger log) : ScriptCommandEditorViewModel(command, scriptEditor, log) | ||
{ | ||
public short Value | ||
{ | ||
get => ((ShortScriptParameter)Command.Parameters[0]).Value; | ||
set | ||
{ | ||
((ShortScriptParameter)Command.Parameters[0]).Value = value; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[0] = value; | ||
this.RaisePropertyChanged(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...lLoops/ViewModels/Editors/ScriptCommandEditors/InvestStartScriptCommandEditorViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using System.Linq; | ||
using HaruhiChokuretsuLib.Util; | ||
using ReactiveUI; | ||
using SerialLoops.Lib.Script; | ||
using SerialLoops.Lib.Script.Parameters; | ||
|
||
namespace SerialLoops.ViewModels.Editors.ScriptCommandEditors; | ||
|
||
public class InvestStartScriptCommandEditorViewModel( | ||
ScriptItemCommand scriptCommand, | ||
ScriptEditorViewModel scriptEditor, | ||
ILogger log) | ||
: ScriptCommandEditorViewModel(scriptCommand, scriptEditor, log) | ||
{ | ||
public short MapCharacterSet | ||
{ | ||
get => ((ShortScriptParameter)Command.Parameters[0]).Value; | ||
set | ||
{ | ||
((ShortScriptParameter)Command.Parameters[0]).Value = value; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[0] = value; | ||
this.RaisePropertyChanged(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
public short Unknown1 | ||
{ | ||
get => ((ShortScriptParameter)Command.Parameters[1]).Value; | ||
set | ||
{ | ||
((ShortScriptParameter)Command.Parameters[1]).Value = value; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[1] = value; | ||
this.RaisePropertyChanged(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
|
||
public short Unknown2 | ||
{ | ||
get => ((ShortScriptParameter)Command.Parameters[2]).Value; | ||
set | ||
{ | ||
((ShortScriptParameter)Command.Parameters[2]).Value = value; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[2] = value; | ||
this.RaisePropertyChanged(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
|
||
public short Unknown3 | ||
{ | ||
get => ((ShortScriptParameter)Command.Parameters[3]).Value; | ||
set | ||
{ | ||
((ShortScriptParameter)Command.Parameters[3]).Value = value; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[3] = value; | ||
this.RaisePropertyChanged(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
|
||
public ReactiveScriptSection EndScriptSection | ||
{ | ||
get => ScriptEditor.ScriptSections.First(s => | ||
s.Section.Name.Equals(((ScriptSectionScriptParameter)Command.Parameters[4]).Section.Name)); | ||
set | ||
{ | ||
((ScriptSectionScriptParameter)Command.Parameters[4]).Section = value.Section; | ||
Script.Event.ScriptSections[Script.Event.ScriptSections.IndexOf(Command.Section)] | ||
.Objects[Command.Index].Parameters[4] = | ||
Script.Event.LabelsSection.Objects.First(l => l.Name.Replace("/", "").Equals(value.Name)).Id; | ||
this.RaisePropertyChanged(); | ||
Script.UnsavedChanges = true; | ||
} | ||
} | ||
} |
Oops, something went wrong.