Пример #1
0
        public void SetActiveObject(GameObject active)
        {
            ActiveObject = active;
            ActiveIff    = active.Resource;
            ActiveDGRP   = null;

            SelectSpriteBox.Enabled = false;
            groupBox3.Enabled       = false;

            int sprID = active.OBJ.DynamicSpriteBaseId;
            var spr2  = ActiveIff.Get <SPR2>((ushort)sprID);

            if (spr2 != null)
            {
                FirstDynLabel.Text = spr2.ChunkLabel;
            }
            else if (sprID == 0)
            {
                FirstDynLabel.Text = "None Selected";
            }
            else
            {
                FirstDynLabel.Text = "Unknown SPR2#" + sprID;
            }

            sprID = active.OBJ.DynamicSpriteBaseId + active.OBJ.NumDynamicSprites - 1;
            if (active.OBJ.NumDynamicSprites == 0)
            {
                sprID = 0;
            }
            spr2 = ActiveIff.Get <SPR2>((ushort)sprID);

            if (spr2 != null)
            {
                LastDynLabel.Text = spr2.ChunkLabel;
            }
            else if (sprID < 1)
            {
                LastDynLabel.Text = "None Selected";
            }
            else
            {
                LastDynLabel.Text = "Unknown SPR2#" + sprID;
            }

            DGRPEdit.ShowObject(active.OBJ.GUID);

            UpdateDGRPList(true);
            var allowEdit = (ActiveObject.OBJ.ObjectType != OBJDType.Person);

            groupBox1.Enabled = allowEdit;
            DGRPBox.Enabled   = allowEdit;
        }
Пример #2
0
        public string GetTuningVariableLabel(GameIffResource res, uint tableID, uint keyID)
        {
            var bcon = res.Get <BCON>((ushort)(tableID));

            if (bcon != null)
            {
                var trcn = res.Get <TRCN>((ushort)(tableID));
                if (trcn != null && keyID < trcn.Entries.Length)
                {
                    return(trcn.Entries[keyID].Label);
                }
                return(bcon.ChunkLabel + " #" + keyID);
            }

            var tuning = res.Get <OTFTable>((ushort)(tableID));

            if (tuning != null)
            {
                return(tuning.GetKey((int)keyID)?.Label ?? "");
            }
            return(tableID + ":" + keyID);
        }
Пример #3
0
        private void ResList_DoubleClick(object sender, EventArgs e)
        {
            if (ResList.SelectedItem != null)
            {
                var item         = (ObjectResourceEntry)ResList.SelectedItem;
                var selectedType = (ComboChunkType)ResTypeCombo.SelectedItem;

                if (selectedType.ChunkType == typeof(BHAV))
                {
                    var bhav = ActiveIff.Get <BHAV>(item.ID);
                    MainWindow.Instance.BHAVManager.OpenEditor(bhav, ActiveObject);
                }
            }
        }
Пример #4
0
 public BHAV GetBHAV(ushort id)
 {
     if (id >= 8192 && Object != null)
     {
         return(Object.Resource.SemiGlobal.Get <BHAV>(id));                             //semiglobal
     }
     else if (id >= 4096)
     {
         return(Resource.Get <BHAV>(id));                //private
     }
     else
     {
         return(EditorScope.Globals.Resource.Get <BHAV>(id)); //global
     }
 }
Пример #5
0
        private void DGRPList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DGRPList.SelectedIndices.Count == 0 || !DGRPChunkIDs.ContainsKey(DGRPList.SelectedItems[0]))
            {
                return;
            }
            ActiveDGRP = ActiveIff.Get <DGRP>(DGRPChunkIDs[DGRPList.SelectedItems[0]]);

            if (ActiveDGRP != null)
            {
                //change selected graphic
                Debug3D.ChangeGraphic(ActiveDGRP.ChunkID);
                //UpdateImage();
            }
            SetCustomMode(false);
        }
Пример #6
0
        public void SetActiveResource(IffChunk chunk, GameIffResource res)
        {
            Resource   = res;
            Strings    = res.Get <TTAs>(chunk.ChunkID);
            ActiveTTAB = (TTAB)chunk;

            if (Strings == null)
            {
                //we have a problem... make us some strings!
                Strings                = new TTAs();
                Strings.ChunkLabel     = chunk.ChunkLabel;
                Strings.ChunkID        = chunk.ChunkID;
                Strings.ChunkProcessed = true;
                res.MainIff.AddChunk(Strings);
            }

            UpdateListing();
            UpdateSelection(-1);
        }
Пример #7
0
        private void UpdateImage()
        {
            var oldIndex = SpriteList.SelectedIndex;

            DGRPEdit.ChangeWorld((int)RotationTrack.Value, (int)ZoomTrack.Value);
            DGRPEdit.ForceUpdate();
            if (ActiveDGRP == null)
            {
                SelectSpriteBox.Enabled = false;
                groupBox3.Enabled       = false;
                return;
            }
            else
            {
                //todo: verify that images can be zoom synced

                if (AutoRot.Checked)
                {
                    var dgrps = new List <DGRPImage>();
                    for (int i = 0; i < 4; i++)
                    {
                        dgrps.Add(ActiveDGRP.GetImage(0x10, 3, (uint)i));
                        dgrps.Add(ActiveDGRP.GetImage(0x10, 2, (uint)i));
                        dgrps.Add(ActiveDGRP.GetImage(0x10, 1, (uint)i));
                    }
                    ActiveDGRPImages = dgrps.ToArray();
                }
                else if (AutoZoom.Checked)
                {
                    ActiveDGRPImages = new DGRPImage[] {
                        ActiveDGRP.GetImage(0x10, 3, (uint)RotationTrack.Value),
                        ActiveDGRP.GetImage(0x10, 2, (uint)RotationTrack.Value),
                        ActiveDGRP.GetImage(0x10, 1, (uint)RotationTrack.Value)
                    };
                }
                else
                {
                    ActiveDGRPImages = new DGRPImage[] {
                        ActiveDGRP.GetImage(0x10, (uint)(3 - ZoomTrack.Value), (uint)RotationTrack.Value)
                    };
                }

                //populate sprite list

                SelectSpriteBox.Enabled = true;
                groupBox3.Enabled       = true;

                SpriteList.Items.Clear();
                foreach (var frame in ActiveDGRPImages[0].Sprites)
                {
                    //attempt to get spr
                    var sprID  = (ushort)frame.SpriteID;
                    var baseID = ActiveObject.OBJ.DynamicSpriteBaseId;
                    var isDyn  = (sprID >= baseID && sprID < baseID + ActiveObject.OBJ.NumDynamicSprites);

                    var spr  = ActiveIff.Get <SPR2>(sprID);
                    var dyn  = (isDyn) ? ("(^" + (sprID - baseID) + ") "):"";
                    var name = (spr != null) ? spr.ChunkLabel : ("SPR#" + frame.SpriteID);
                    SpriteList.Items.Add(dyn + name + " (" + frame.SpriteOffset.X + "," + frame.SpriteOffset.Y + ")");
                }
                if (SpriteList.Items.Count == 0)
                {
                    SelectSpriteBox.Enabled = false;
                }
                else
                {
                    SelectSpriteBox.Enabled = true;
                    if (OldDGRP == ActiveDGRP)
                    {
                        SpriteList.SelectedIndex = Math.Max(0, Math.Min(SpriteList.Items.Count - 1, oldIndex));
                    }
                    else
                    {
                        SpriteList.SelectedIndex = 0;
                    }
                }
                OldDGRP = ActiveDGRP;
            }
        }
Пример #8
0
 public void SetActiveResource(IffChunk chunk, GameIffResource res)
 {
     ActiveConst      = (BCON)chunk;
     ActiveConstLabel = res.Get <TRCN>(chunk.ChunkID);
     UpdateStrings();
 }
Пример #9
0
 public void SetActiveResource(IffChunk chunk, GameIffResource res)
 {
     ActiveChunk = (BHAV)chunk;
     ActiveMeta  = res.Get <TPRP>(chunk.ChunkID);
     RefreshDisplay();
 }
Пример #10
0
        public void SetActiveResource(IffChunk chunk, GameIffResource res)
        {
            Resource = res;
            Strings = res.Get<TTAs>(chunk.ChunkID);
            ActiveTTAB = (TTAB)chunk;

            if (Strings == null)
            {
                //we have a problem... make us some strings!
                Strings = new TTAs();
                Strings.ChunkLabel = chunk.ChunkLabel;
                Strings.ChunkID = chunk.ChunkID;
                Strings.ChunkProcessed = true;
                res.MainIff.AddChunk(Strings);
            }

            UpdateListing();
            UpdateSelection(-1);
        }
Пример #11
0
 public void SetActiveResource(IffChunk chunk,GameIffResource res)
 {
     ActiveSLOT      = (SLOT)chunk;
     ActiveSLOTLabel = res.Get <STR>(257);
     UpdateStrings();
 }
Пример #12
0
 public void SetActiveResource(IffChunk chunk, GameIffResource res)
 {
     ActiveChunk = (BHAV)chunk;
     ActiveMeta = res.Get<TPRP>(chunk.ChunkID);
     RefreshDisplay();
 }