Skip to content

Commit 7bb6097

Browse files
authored
Merge pull request WolvenKit#2667 from WolvenKit/feat-scene-editor-buttons
feat: add scene editor button bar
2 parents bd6f62e + 36a5cd8 commit 7bb6097

File tree

9 files changed

+1437
-20
lines changed

9 files changed

+1437
-20
lines changed

WolvenKit.App/Helpers/CvmDropdownHelper.cs

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using WolvenKit.App.ViewModels.Shell;
@@ -518,6 +518,70 @@ public abstract class CvmDropdownHelper
518518

519519
break;
520520
}
521+
522+
// Special case for scnscreenplayItemId.Id - check if we're editing the Id property of a scnscreenplayItemId
523+
case scnscreenplayItemId:
524+
{
525+
var scene = GetSceneContext(cvm);
526+
if (scene != null)
527+
{
528+
// Check if we're in a definition context vs usage context
529+
var parentPath = GetParentPath(cvm);
530+
if (IsInDefinitionContext(parentPath))
531+
{
532+
return new Dictionary<string, string>();
533+
}
534+
535+
// Generate dropdown options for screenplay item IDs with embedded text preview
536+
var screenplayOptions = new Dictionary<string, string>();
537+
538+
// Determine if we're looking at lines or options based on parent path
539+
bool isForOptions = parentPath.Contains("options") || parentPath.Contains("choiceOption");
540+
541+
if (isForOptions && scene.ScreenplayStore?.Options != null)
542+
{
543+
// Handle screenplay options (choice options)
544+
foreach (var option in scene.ScreenplayStore.Options)
545+
{
546+
var itemId = option.ItemId.Id;
547+
var locStringId = option.LocstringId.Ruid;
548+
549+
// Try to find embedded text
550+
var embeddedText = scene.GetEmbeddedTextForLocString(locStringId);
551+
var previewText = !string.IsNullOrEmpty(embeddedText) ? embeddedText : $"LocString: {locStringId}";
552+
553+
var truncatedPreview = previewText.Length > 60 ? previewText.Substring(0, 57) + "..." : previewText;
554+
555+
var displayText = $"{itemId}: {truncatedPreview}";
556+
557+
screenplayOptions[displayText] = itemId.ToString();
558+
}
559+
}
560+
else if (scene.ScreenplayStore?.Lines != null)
561+
{
562+
// Handle screenplay lines (dialogue lines)
563+
foreach (var line in scene.ScreenplayStore.Lines)
564+
{
565+
var itemId = line.ItemId.Id;
566+
var locStringId = line.LocstringId.Ruid;
567+
568+
// Try to find embedded text
569+
var embeddedText = scene.GetEmbeddedTextForLocString(locStringId);
570+
var previewText = !string.IsNullOrEmpty(embeddedText) ? embeddedText : $"LocString: {locStringId}";
571+
572+
var truncatedPreview = previewText.Length > 60 ? previewText.Substring(0, 57) + "..." : previewText;
573+
574+
var displayText = $"{itemId}: {truncatedPreview}";
575+
576+
screenplayOptions[displayText] = itemId.ToString();
577+
}
578+
}
579+
580+
return screenplayOptions;
581+
}
582+
583+
break;
584+
}
521585
}
522586

523587
return null;
@@ -908,6 +972,9 @@ IRedArray<CName> when parent.Name is "names" &&
908972
// scnDynamicAnimSetSRRefId.Id dropdown
909973
scnDynamicAnimSetSRRefId when cvm.Name == "id" && GetSceneContext(cvm) != null => true,
910974

975+
// scnscreenplayItemId.Id dropdown for dialogue lines
976+
scnscreenplayItemId when cvm.Name == "id" && GetSceneContext(cvm) != null => true,
977+
911978
#endregion
912979

913980
#region questPhase
@@ -1008,7 +1075,9 @@ private static bool IsInDefinitionContext(string parentPath)
10081075
"props", // Prop definitions
10091076
"workspotInstances", // Workspot instance definitions
10101077
"effectInstances", // Effect instance definitions
1011-
"effectDefinitions" // Effect definitions
1078+
"effectDefinitions", // Effect definitions
1079+
"screenplayStore.lines", // Screenplay dialogue line definitions
1080+
"screenplayStore.options" // Screenplay choice option definitions
10121081
};
10131082

10141083
return definitionPaths.Any(parentPath.Contains);

WolvenKit.App/Interaction/Interactions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,12 @@ public static Func<
202202
public static Func<(string dialogueTitle, string defaultValue), string> AskForTextInput { get; set; } =
203203
_ => throw new NotImplementedException();
204204

205+
/// <summary>
206+
/// Ask user for scene input (unified dialog for actors, props, dialogue, options)
207+
/// </summary>
208+
public static Func<(string title, string primaryLabel, string primaryDefault, bool showSecondary, string secondaryLabel, string checkboxText, bool showDropdown, string dropdownLabel, IEnumerable<string>? dropdownOptions, string? defaultDropdownValue), (string? primaryInput, bool enableSecondary, string? secondaryInput, string? dropdownValue)> AskForSceneInput { get; set; } =
209+
_ => throw new NotImplementedException();
210+
205211

206212
/// <summary>
207213
/// Ask user for folder path. Will enforce validity for path-type arguments and check if directory exists.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
using CommunityToolkit.Mvvm.ComponentModel;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace WolvenKit.App.ViewModels.Dialogs;
6+
7+
/// <summary>
8+
/// ViewModel for unified scene input dialog that handles actors, props, dialogue lines, and choice options
9+
/// </summary>
10+
public partial class SceneInputDialogViewModel : DialogViewModel
11+
{
12+
public SceneInputDialogViewModel(
13+
string title = "Scene Input",
14+
string primaryLabel = "Value:",
15+
string primaryDefaultValue = "",
16+
bool showSecondaryInput = false,
17+
string secondaryLabel = "Secondary:",
18+
string checkboxText = "Enable secondary input",
19+
bool showDropdown = false,
20+
string dropdownLabel = "Type:",
21+
IEnumerable<string>? dropdownOptions = null,
22+
string? defaultDropdownValue = null)
23+
{
24+
Title = title;
25+
PrimaryLabel = primaryLabel;
26+
PrimaryInputValue = primaryDefaultValue;
27+
ShowSecondaryInput = showSecondaryInput;
28+
SecondaryLabel = secondaryLabel;
29+
CheckboxText = checkboxText;
30+
ShowDropdown = showDropdown;
31+
DropdownLabel = dropdownLabel;
32+
33+
if (dropdownOptions != null)
34+
{
35+
DropdownOptions = dropdownOptions.ToList();
36+
SelectedDropdownValue = defaultDropdownValue ?? DropdownOptions.FirstOrDefault();
37+
}
38+
else
39+
{
40+
DropdownOptions = new List<string>();
41+
}
42+
}
43+
44+
/// <summary>
45+
/// The primary input value (always visible)
46+
/// </summary>
47+
[ObservableProperty] private string? _primaryInputValue = "";
48+
49+
/// <summary>
50+
/// Whether to show the secondary input section
51+
/// </summary>
52+
[ObservableProperty] private bool _showSecondaryInput;
53+
54+
/// <summary>
55+
/// Whether the secondary input checkbox is checked
56+
/// </summary>
57+
[ObservableProperty] private bool _enableSecondaryInput;
58+
59+
/// <summary>
60+
/// The secondary input value (conditionally visible)
61+
/// </summary>
62+
[ObservableProperty] private string? _secondaryInputValue = "";
63+
64+
/// <summary>
65+
/// Whether to show the dropdown section
66+
/// </summary>
67+
[ObservableProperty] private bool _showDropdown;
68+
69+
/// <summary>
70+
/// The selected dropdown value
71+
/// </summary>
72+
[ObservableProperty] private string? _selectedDropdownValue;
73+
74+
/// <summary>
75+
/// The available dropdown options
76+
/// </summary>
77+
public List<string> DropdownOptions { get; set; } = new();
78+
79+
/// <summary>
80+
/// The label text for the primary input field
81+
/// </summary>
82+
public string PrimaryLabel { get; set; }
83+
84+
/// <summary>
85+
/// The label text for the secondary input field
86+
/// </summary>
87+
public string SecondaryLabel { get; set; }
88+
89+
/// <summary>
90+
/// The label text for the dropdown field
91+
/// </summary>
92+
public string DropdownLabel { get; set; }
93+
94+
/// <summary>
95+
/// The checkbox text
96+
/// </summary>
97+
public string CheckboxText { get; set; }
98+
99+
/// <summary>
100+
/// The dialog title
101+
/// </summary>
102+
public string Title { get; set; }
103+
}

0 commit comments

Comments
 (0)