private void ProcessDragDropMorphs(TreeNode node) { if (node.Tag is DragSource) { if ((node.Parent != null) && !node.Checked && node.StateImageIndex != (int)CheckState.Indeterminate) { return; } DragSource? dest = null; if (treeViewMorphClip.SelectedNode != null) { dest = treeViewMorphClip.SelectedNode.Tag as DragSource?; } DragSource source = (DragSource)node.Tag; if (source.Type == typeof(WorkspaceMorph)) { using (var dragOptions = new FormXADragDrop(Editor, true)) { var srcEditor = (ImportedEditor)Gui.Scripting.Variables[source.Variable]; dragOptions.textBoxName.Text = srcEditor.Morphs[(int)source.Id].Name; if (dragOptions.ShowDialog() == DialogResult.OK) { // repeating only final choices for repeatability of the script WorkspaceMorph wsMorph = srcEditor.Morphs[(int)source.Id]; foreach (ImportedMorphKeyframe keyframe in wsMorph.KeyframeList) { if (!wsMorph.isMorphKeyframeEnabled(keyframe)) { Gui.Scripting.RunScript(source.Variable + ".setMorphKeyframeEnabled(morphId=" + (int)source.Id + ", id=" + wsMorph.KeyframeList.IndexOf(keyframe) + ", enabled=false)"); } } int numKeyframes = Editor.Parser.MorphSection.KeyframeList.Count; Gui.Scripting.RunScript(EditorVar + ".ReplaceMorph(morph=" + source.Variable + ".Morphs[" + (int)source.Id + "], destMorphName=\"" + dragOptions.textBoxName.Text + "\", newName=\"" + dragOptions.textBoxNewName.Text + "\", replaceMorphMask=" + dragOptions.checkBoxReplaceMorphMask.Checked + ", replaceNormals=" + dragOptions.radioButtonReplaceNormalsYes.Checked + ", minSquaredDistance=" + ((float)dragOptions.numericUpDownMinimumDistanceSquared.Value).ToFloatString() + ", minKeyframes=" + dragOptions.radioButtonMorphMaskSize.Checked + ")"); Changed = Changed; UnloadXA(); LoadXA(); TreeNode clipNode = FindMorphClipTreeNode(dragOptions.textBoxName.Text, treeViewMorphClip.Nodes); if (clipNode != null) { clipNode.Expand(); } if (numKeyframes != Editor.Parser.MorphSection.KeyframeList.Count) { listViewMorphKeyframe.Items[listViewMorphKeyframe.Items.Count - 1].EnsureVisible(); } tabControlXA.SelectedTab = tabPageMorph; } } } } else { foreach (TreeNode child in node.Nodes) { ProcessDragDropMorphs(child); } } }
private void ProcessDragDropAnimations(TreeNode node) { if (node.Tag is DragSource) { if ((node.Parent != null) && !node.Checked && node.StateImageIndex != (int)CheckState.Indeterminate) { return; } DragSource source = (DragSource)node.Tag; if (source.Type == typeof(WorkspaceAnimation)) { var srcEditor = (ImportedEditor)Gui.Scripting.Variables[source.Variable]; WorkspaceAnimation wsAnimation = srcEditor.Animations[(int)source.Id]; if (!(wsAnimation.importedAnimation is ImportedKeyframedAnimation)) { Report.ReportLog("The animation has incompatible keyframes."); return; } using (var dragOptions = new FormXADragDrop(Editor, false)) { List<ImportedAnimationKeyframedTrack> trackList = ((ImportedKeyframedAnimation)wsAnimation.importedAnimation).TrackList; int resampleCount = trackList[0].Keyframes.Length; for (int i = 0; i < trackList.Count; i++) { ImportedAnimationKeyframedTrack track = trackList[i]; int numKeyframes = 0; for (int j = 0; j < track.Keyframes.Length; j++) { if (track.Keyframes[j] == null) continue; numKeyframes++; } if (numKeyframes != resampleCount) { resampleCount = -1; break; } } dragOptions.numericResample.Value = resampleCount; dragOptions.comboBoxMethod.SelectedIndex = (int)ReplaceAnimationMethod.ReplacePresent; if (dragOptions.ShowDialog() == DialogResult.OK) { // repeating only final choices for repeatability of the script foreach (ImportedAnimationKeyframedTrack track in trackList) { if (!wsAnimation.isTrackEnabled(track)) { Gui.Scripting.RunScript(source.Variable + ".setTrackEnabled(animationId=" + (int)source.Id + ", id=" + trackList.IndexOf(track) + ", enabled=false)"); } } Gui.Scripting.RunScript(EditorVar + ".ReplaceAnimation(animation=" + source.Variable + ".Animations[" + (int)source.Id + "], resampleCount=" + dragOptions.numericResample.Value + ", method=\"" + dragOptions.comboBoxMethod.SelectedItem + "\", insertPos=" + dragOptions.numericPosition.Value + ")"); Changed = Changed; UnloadXA(); LoadXA(); } } } } else { foreach (TreeNode child in node.Nodes) { ProcessDragDropAnimations(child); } } }