Пример #1
0
 public AnimationGroup(AnimationGroup other)
 {
     DeepCopyFrom(other);
 }
Пример #2
0
 private void animationGroupControl_ConfirmPressed(AnimationGroup info)
 {
     AnimationListBox.SelectedItem = info;
 }
Пример #3
0
 public void MergeFrom(AnimationGroup other)
 {
     nodeGuids.AddRange(other.nodeGuids);
     IsDirty = true;
 }
Пример #4
0
 // Typically called when the user presses confirm, but can also happen when scene changes are detected.
 private void animationGroupControl_InfoChanged(AnimationGroup info)
 {
     info.SaveToData();
     animationListBinding.ResetBindings(false);
     Loader.Global.SetSaveRequiredFlag(true, false);
 }
Пример #5
0
        private void confirmButton_Click(object sender, EventArgs e)
        {
            if (currentInfo == null)
            {
                return;
            }

            AnimationGroup confirmedInfo = currentInfo;

            string newName = nameTextBox.Text;

            int newFrameStart;

            if (!int.TryParse(startTextBox.Text, out newFrameStart))
            {
                newFrameStart = confirmedInfo.FrameStart;
            }
            int newFrameEnd;

            if (!int.TryParse(endTextBox.Text, out newFrameEnd))
            {
                newFrameEnd = confirmedInfo.FrameEnd;
            }

            List <uint> newHandles;
            bool        nodesChanged = MaxNodeTree.ApplyQueuedChanges(out newHandles);

            bool changed = newName != confirmedInfo.Name || newFrameStart != confirmedInfo.FrameStart || newFrameEnd != confirmedInfo.FrameEnd || nodesChanged;

            if (!changed)
            {
                return;
            }

            confirmedInfo.Name       = newName;
            confirmedInfo.FrameStart = newFrameStart;
            confirmedInfo.FrameEnd   = newFrameEnd;

            if (nodesChanged)
            {
                confirmedInfo.NodeGuids = newHandles.ToGuids();
                if (confirmedInfo.AnimationGroupNodes == null)
                {
                    confirmedInfo.AnimationGroupNodes = new List <AnimationGroupNode>();
                }

                foreach (uint handle in newHandles)
                {
                    IINode node = Loader.Core.GetINodeByHandle(handle);
                    if (node != null)
                    {
                        string             name       = node.Name;
                        string             parentName = node.ParentNode.Name;
                        AnimationGroupNode nodeData   = new AnimationGroupNode(node.GetGuid(), name, parentName);
                        confirmedInfo.AnimationGroupNodes.Add(nodeData);
                    }
                }
            }

            ResetChangedTextBoxColors();
            MaxNodeTree.SelectedNode = null;

            InfoChanged?.Invoke(confirmedInfo);
            ConfirmPressed?.Invoke(confirmedInfo);
        }
Пример #6
0
 public int GetTimeRange(AnimationGroup info)
 {
     return(Tools.CalculateEndFrameFromAnimationGroupNodes(info));
 }
Пример #7
0
        void SetFieldsFromInfo(AnimationGroup info)
        {
            maxMaterialView.Reset();

            if (info != null)
            {
                nameTextBox.Enabled        = true;
                startTextBox.Enabled       = true;
                endTextBox.Enabled         = true;
                keepStaticAnimBox.Enabled  = true;
                keepNonAnimatedBox.Enabled = true;
                nameTextBox.Text           = info.Name.ToString();
                startTextBox.Text          = info.FrameStart.ToString();
                endTextBox.Text            = info.FrameEnd.ToString();
                keepStaticAnimBox.Checked  = info.KeepStaticAnimation;
                keepNonAnimatedBox.Checked = info.KeepNonAnimated;

                // a color can still be red after setting the string:
                // possible if we change a name, don't confirm and switch to another item with the same name
                ResetChangedTextBoxColors();

                MaxNodeTree.BeginUpdate();
                //here we garanty retrocompatibility
                MaxNodeTree.QueueSetNodes(info.NodeGuids.ToHandles(), false);
                List <uint> handles;
                MaxNodeTree.ApplyQueuedChanges(out handles, false);

                MaxNodeTree.EndUpdate();

                maxMaterialView.FillMaterialsView(info.MaterialGuids);

                // if the nodes changed on max' side, even though the data has not changed, the list may be different (e.g. deleted nodes)
                // since we haven't loaded the list before, we can't compare it to the node tree
                // thus, we save it, and the property checks for actual differences (and set isdirty to true)
                info.NodeGuids     = handles.ToGuids();
                info.MaterialGuids = maxMaterialView.GetMaterialGUIDs();

                if (info.IsDirty)
                {
                    //this is causing the event select changed to be triggered multiple times
                    //InfoChanged?.Invoke(info);
                }
            }
            else
            {
                nameTextBox.Enabled        = false;
                startTextBox.Enabled       = false;
                endTextBox.Enabled         = false;
                keepStaticAnimBox.Enabled  = false;
                keepNonAnimatedBox.Enabled = false;
                nameTextBox.Text           = "";
                startTextBox.Text          = "";
                endTextBox.Text            = "";
                keepStaticAnimBox.Checked  = false;

                MaxNodeTree.BeginUpdate();
                MaxNodeTree.QueueSetNodes(null, false);
                List <uint> handles;
                MaxNodeTree.ApplyQueuedChanges(out handles, false);
                MaxNodeTree.EndUpdate();
            }
        }
Пример #8
0
        private void confirmButton_Click(object sender, EventArgs e)
        {
            if (currentInfo == null)
            {
                return;
            }

            AnimationGroup confirmedInfo = currentInfo;

            string newName = nameTextBox.Text;

            bool newKeepEmpty       = keepStaticAnimBox.Checked;
            bool newKeepNonAnimated = keepNonAnimatedBox.Checked;

            int newFrameStart;

            if (!int.TryParse(startTextBox.Text, out newFrameStart))
            {
                newFrameStart = confirmedInfo.FrameStart;
            }
            int newFrameEnd;

            if (!int.TryParse(endTextBox.Text, out newFrameEnd))
            {
                newFrameEnd = confirmedInfo.FrameEnd;
            }

            List <uint>  newHandles;
            bool         nodesChanged = MaxNodeTree.ApplyQueuedChanges(out newHandles);
            IList <Guid> newMaterialGUIDs;
            bool         materialsChanged = maxMaterialView.ApplyMaterialsChanges(out newMaterialGUIDs);

            bool changed = newKeepEmpty != confirmedInfo.KeepStaticAnimation ||
                           newName != confirmedInfo.Name ||
                           newFrameStart != confirmedInfo.FrameStart ||
                           newFrameEnd != confirmedInfo.FrameEnd ||
                           nodesChanged ||
                           materialsChanged ||
                           newKeepNonAnimated != confirmedInfo.KeepNonAnimated;

            if (!changed)
            {
                return;
            }

            confirmedInfo.Name                = newName;
            confirmedInfo.FrameStart          = newFrameStart;
            confirmedInfo.FrameEnd            = newFrameEnd;
            confirmedInfo.KeepStaticAnimation = newKeepEmpty;
            confirmedInfo.KeepNonAnimated     = newKeepNonAnimated;

            if (nodesChanged)
            {
                confirmedInfo.NodeGuids = newHandles.ToGuids();
                if (confirmedInfo.AnimationGroupNodes == null)
                {
                    confirmedInfo.AnimationGroupNodes = new List <AnimationGroupNode>();
                }

                foreach (uint handle in newHandles)
                {
                    IINode node = Loader.Core.GetINodeByHandle(handle);
                    if (node != null)
                    {
                        string             name       = node.Name;
                        string             parentName = node.ParentNode.Name;
                        AnimationGroupNode nodeData   = new AnimationGroupNode(node.GetGuid(), name, parentName);
                        confirmedInfo.AnimationGroupNodes.Add(nodeData);
                    }
                }
            }

            if (materialsChanged)
            {
                confirmedInfo.MaterialGuids = newMaterialGUIDs;

                if (confirmedInfo.AnimationGroupMaterials == null)
                {
                    confirmedInfo.AnimationGroupMaterials = new List <AnimationGroupMaterial>();
                }

                foreach (Guid guid in newMaterialGUIDs)
                {
                    IMtl mat = Tools.GetIMtlByGuid(guid);
                    if (mat != null)
                    {
                        string name = mat.Name;
                        AnimationGroupMaterial matData = new AnimationGroupMaterial(guid, name);
                        confirmedInfo.AnimationGroupMaterials.Add(matData);
                    }
                }
            }

            ResetChangedTextBoxColors();
            MaxNodeTree.SelectedNode = null;

            InfoChanged?.Invoke(confirmedInfo);
            ConfirmPressed?.Invoke(confirmedInfo);
        }