Ejemplo n.º 1
0
        public void Add(IWadObjectId newId, IWadObject wadObject)
        {
            // Change id if necessary
            if (newId != wadObject.Id)
            {
                var property = wadObject.GetType().GetProperty("Id");
                property.SetValue(wadObject, newId);
            }

            // Add object
            if (newId is WadMoveableId)
            {
                Moveables.Add((WadMoveableId)newId, (WadMoveable)wadObject);
            }
            else if (newId is WadStaticId)
            {
                Statics.Add((WadStaticId)newId, (WadStatic)wadObject);
            }
            else if (newId is WadSpriteSequenceId)
            {
                SpriteSequences.Add((WadSpriteSequenceId)newId, (WadSpriteSequence)wadObject);
            }
            else
            {
                throw new ArgumentException("Argument not of a valid type.");
            }
        }
Ejemplo n.º 2
0
        private void treeDestWad_SelectedWadObjectIdsChanged(object sender, EventArgs e)
        {
            IWadObjectId currentSelection = treeDestWad.SelectedWadObjectIds.FirstOrDefault();

            if (currentSelection != null)
            {
                _tool.MainSelection = new MainSelection {
                    WadArea = WadArea.Destination, Id = currentSelection
                }
            }
            ;

            // Update context menu
            if (currentSelection is WadMoveableId)
            {
                treeDestWad.ContextMenuStrip = contextMenuMoveableItem;
            }
            else if (currentSelection is WadStaticId)
            {
                treeDestWad.ContextMenuStrip = cmStatics;
            }
            else
            {
                treeDestWad.ContextMenuStrip = null;
            }
        }
Ejemplo n.º 3
0
        private void cbSlots_Format(object sender, ListControlConvertEventArgs e)
        {
            TRVersion.Game?gameVersion = _editor?.Level?.Settings?.GameVersion;
            IWadObjectId   listItem    = e.ListItem as IWadObjectId;

            if (gameVersion != null && listItem != null)
            {
                e.Value = listItem.ToString(_editor.Level.Settings.GameVersion);
            }
        }
Ejemplo n.º 4
0
        private void treeSourceWad_SelectedWadObjectIdsChanged(object sender, EventArgs e)
        {
            IWadObjectId currentSelection = treeSourceWad.SelectedWadObjectIds.FirstOrDefault();

            if (currentSelection != null)
            {
                _tool.MainSelection = new MainSelection {
                    WadArea = WadArea.Source, Id = currentSelection
                }
            }
            ;
        }
Ejemplo n.º 5
0
        public void AssignNewId(IWadObjectId oldId, IWadObjectId newId)
        {
            if (Contains(newId))
            {
                throw new ArgumentException("Id " + newId.ToString(GameVersion) + " already exists.");
            }
            IWadObject @object = TryGet(oldId);

            if (@object == null)
            {
                throw new KeyNotFoundException("Id " + newId.ToString(GameVersion) + " not found.");
            }
            Remove(oldId);
            Add(newId, @object);
        }
Ejemplo n.º 6
0
        public FormSelectSlot(Wad2 wad, IWadObjectId currentId, List <uint> additionalObjectsToHide = null)
        {
            InitializeComponent();

            NewId       = currentId;
            TypeClass   = currentId.GetType();
            GameVersion = wad.GameVersion.Native();

            _wad = wad;
            _additionalObjectsToHide = additionalObjectsToHide;

            if (TypeClass == typeof(WadMoveableId))
            {
                chosenId.Value = ((WadMoveableId)currentId).TypeId;
            }
            else if (TypeClass == typeof(WadStaticId))
            {
                chosenId.Value = ((WadStaticId)currentId).TypeId;
            }
            else if (TypeClass == typeof(WadSpriteSequenceId))
            {
                chosenId.Value = ((WadSpriteSequenceId)currentId).TypeId;
            }
            else if (TypeClass == typeof(WadFixedSoundInfoId))
            {
                chosenId.Value = ((WadFixedSoundInfoId)currentId).TypeId;
            }
            else if (TypeClass == typeof(WadAdditionalSoundInfoId))
            {
                chosenId.Visible      = false;
                chosenIdText.Visible  = true;
                lstSlots.Enabled      = false;
                tbSearchLabel.Enabled = false;
                tbSearch.Enabled      = false;

                chosenIdText.Text = ((WadAdditionalSoundInfoId)currentId).Name;
            }
            else
            {
                throw new NotImplementedException("The " + TypeClass + " is not implemented yet.");
            }

            ReloadSlots();
            if (lstSlots.Items.Count > 0)
            {
                chosenId.Value = (decimal)(uint)lstSlots.Items.First().Tag;
            }
        }
Ejemplo n.º 7
0
 public void Remove(IWadObjectId wadObjectId)
 {
     if (wadObjectId is WadMoveableId)
     {
         Moveables.Remove((WadMoveableId)wadObjectId);
     }
     else if (wadObjectId is WadStaticId)
     {
         Statics.Remove((WadStaticId)wadObjectId);
     }
     else if (wadObjectId is WadSpriteSequenceId)
     {
         SpriteSequences.Remove((WadSpriteSequenceId)wadObjectId);
     }
     else
     {
         throw new ArgumentException("Argument not of a valid type.");
     }
 }
Ejemplo n.º 8
0
 public IWadObject TryGet(IWadObjectId wadObjectId)
 {
     if (wadObjectId is WadMoveableId)
     {
         return(Moveables.TryGetOrDefault((WadMoveableId)wadObjectId));
     }
     else if (wadObjectId is WadStaticId)
     {
         return(Statics.TryGetOrDefault((WadStaticId)wadObjectId));
     }
     else if (wadObjectId is WadSpriteSequenceId)
     {
         return(SpriteSequences.TryGetOrDefault((WadSpriteSequenceId)wadObjectId));
     }
     else
     {
         throw new ArgumentException("Argument not of a valid type.");
     }
 }
Ejemplo n.º 9
0
        private void ConfirmAndClose()
        {
            if (lstSlots.Items.Count == 0 || lstSlots.SelectedItems.Count == 0)
            {
                DialogResult = DialogResult.Cancel;
            }
            else
            {
                uint newId = (uint)lstSlots.SelectedItems[0].Tag;

                if (TypeClass == typeof(WadMoveableId))
                {
                    NewId = new WadMoveableId(newId);
                }
                else if (TypeClass == typeof(WadStaticId))
                {
                    NewId = new WadStaticId(newId);
                }
                else if (TypeClass == typeof(WadSpriteSequenceId))
                {
                    NewId = new WadSpriteSequenceId(newId);
                }

                // FIXME: Are we still handling copying/moving/etc of deprecated sound info objects?

                else if (TypeClass == typeof(WadFixedSoundInfoId))
                {
                    NewId = new WadFixedSoundInfoId((uint)chosenId.Value);
                }
                else if (TypeClass == typeof(WadAdditionalSoundInfoId))
                {
                    NewId = new WadAdditionalSoundInfoId(chosenIdText.Text);
                }
                else
                {
                    throw new NotImplementedException("The " + TypeClass + " is not implemented yet.");
                }

                DialogResult = DialogResult.OK;
            }

            Close();
        }
Ejemplo n.º 10
0
        private void wadTree_SelectedWadObjectIdsChanged(object sender, System.EventArgs e)
        {
            IWadObjectId selectedObjectId = wadTree.SelectedWadObjectIds.FirstOrDefault();

            panelItem.CurrentObject = selectedObjectId == null ? null : _wad.TryGet(selectedObjectId);
        }
Ejemplo n.º 11
0
 public MeshTreeNode(IWadObjectId obj, WadMesh wadMesh)
 {
     ObjectId = obj;
     WadMesh  = wadMesh;
 }
Ejemplo n.º 12
0
 private void CbSlots_SelectedValueChanged(object sender, EventArgs e)
 {
     selectedValue = (IWadObjectId)cbSlots.SelectedValue;
 }
Ejemplo n.º 13
0
 public void Select(IWadObjectId Id) => Select(new List <IWadObjectId>()
 {
     Id
 });
Ejemplo n.º 14
0
 public bool Contains(IWadObjectId wadObjectId)
 {
     return(TryGet(wadObjectId) != null);
 }