Beispiel #1
0
        private void zPhys_TextChanged(object sender, EventArgs e)
        {
            if (ActiveDGRPSprites == null || InternalChange)
            {
                return;
            }
            float value = 0;

            float.TryParse(zPhys.Text, out value);
            GameContent.Get.Changes.BlockingResMod(new ResAction(() =>
            {
                foreach (var dgrpSpr in ActiveDGRPSprites)
                {
                    dgrpSpr.ObjectOffset.Z = value;
                }
            }, ActiveDGRP));
            DGRPEdit.ForceUpdate();
        }
Beispiel #2
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;
            }
        }