Example #1
0
        public BlitCharacter(char charTarget, CharacterInfo charInfoReference, Image texture)
        {
            InitializeComponent();

            CharInfoReference = charInfoReference;

            ComboSelectionMode.SelectedIndex = 0;
            LabelTagDialogDescription.Text = LabelTagDialogDescription.Text.Replace("$CHAR", charTarget.ToString());

            CharInfoEditing = charInfoReference != null ?
                charInfoReference.Clone() :
                new CharacterInfo();

            PicturePreview.BackgroundImage = texture;
            PicturePreview.Size = texture.Size;
            PanelPreviewContainer.AutoScrollMinSize = texture.Size;

            PenBlitOrigin = new Pen(Color.Red);
            PenBlitDestination = new Pen(Color.Blue);
            BrushBlitFill = new SolidBrush(Color.FromArgb(100, Color.Magenta));

            NumericBlitOriginX.Maximum = texture.Size.Width;
            NumericBlitOriginY.Maximum = texture.Size.Height;
            NumericBlitDestinationX.Maximum = texture.Size.Width;
            NumericBlitDestinationY.Maximum = texture.Size.Height;

            try
            {
                NumericBlitOriginX.Value = charInfoReference.BlitOrigin.X;
                NumericBlitOriginY.Value = charInfoReference.BlitOrigin.Y;
                NumericBlitDestinationX.Value = charInfoReference.BlitDestination.X;
                NumericBlitDestinationY.Value = charInfoReference.BlitDestination.Y;
            }
            catch (ArgumentOutOfRangeException argEx)
            {
                // The blitting coordinates are invalid, alert the user
                if (MessageBox.Show("The blitting coordinates appear to be out of range of this texture, this may happen if the texture selected is not the same as the original used to create these coordinates.\n\nWould you like to continue and reset the coordinates anyway?",
                    "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    NumericBlitOriginX.Value = 0;
                    NumericBlitOriginY.Value = 0;
                    NumericBlitDestinationX.Value = 0;
                    NumericBlitDestinationY.Value = 0;
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                }
            }

            PicturePreview.Image = new Bitmap(texture.Size.Width, texture.Size.Height);

            LegalValueInput = true;

            UpdatePreview();
        }
Example #2
0
        /// <summary>
        /// Creates a new copy of this CharacterInfo.
        /// </summary>
        /// <returns>A new CharacterInfo that is a copy of this instance.</returns>
        public CharacterInfo Clone()
        {
            var cloneCharInfo = new CharacterInfo();

            cloneCharInfo.BlitOrigin = this.BlitOrigin;
            cloneCharInfo.BlitDestination = this.BlitDestination;
            cloneCharInfo.Before = this.Before;
            cloneCharInfo.After = this.After;
            cloneCharInfo.YOffset = this.YOffset;

            return cloneCharInfo;
        }
Example #3
0
        /// <summary>
        /// (For internal use) Attempts to read the next character from a GUIOMETRY file into a CharacterInfo object.
        /// </summary>
        /// <param name="data">The GUIOMETRY data to read from.</param>
        /// <param name="currentIndex">The current index pointer.</param>
        /// <returns>A new CharacterInfo object containing as much of the character info that could be read.</returns>
        private static CharacterInfo NextCharacter(IList<byte> data, ref int currentIndex)
        {
            CharacterInfo charInfo = new CharacterInfo(); // Build the character up

            short blitOriginX = ByteParse.NextShort(data, ref currentIndex);
            short blitOriginY = ByteParse.NextShort(data, ref currentIndex);
            charInfo.BlitOrigin = new Point(blitOriginX, blitOriginY);

            short blitDestinationX = ByteParse.NextShort(data, ref currentIndex);
            short blitDestinationY = ByteParse.NextShort(data, ref currentIndex);
            charInfo.BlitDestination = new Point(blitDestinationX, blitDestinationY);

            charInfo.Before = ByteParse.NextSByte(data, ref currentIndex);
            charInfo.After = ByteParse.NextSByte(data, ref currentIndex);
            charInfo.YOffset = ByteParse.NextSByte(data, ref currentIndex);

            return charInfo;
        }