コード例 #1
0
        protected override void DisposeResources( )
        {
            if( _actorType != null )
                _actorType = null;

            if( AssetThumbnail != null )
                AssetThumbnail.Dispose( );

            base.DisposeResources( );
        }
コード例 #2
0
        public static void CreateGameActorFile( ActorTypeEd actorType, string filePath )
        {
            using( BinaryWriter file = new BinaryWriter( File.Create( filePath ) ) )
            {
                // ---- Write the header data

                file.Write( Consts.Editor.FILE_HEADER_ID );

                //Writes the file version
                file.Write( GAME_ACTOR_VERSION );

                // ---- Write the actor data

                //Write the name
                file.Write( actorType.Name );

                //Write the scale
                file.Write( actorType.Scale );

                //Write the rotation angle
                file.Write( actorType.Rotation );

                //Write the sprite name
                if( actorType.SpriteAsset.AssetName == null )
                    file.Write( NO_SPRITE );
                else
                    file.Write( actorType.SpriteAsset.AssetName );

                //Write the script name, if this actortype has one associated
                if( actorType.Script == null )
                    file.Write( NO_SCRIPT );
                else
                    file.Write( actorType.Script.Name );

                file.Write( actorType.Tags.Length );
                foreach( string tag in actorType.Tags )
                {
                    file.Write( tag );
                }

                file.Write( actorType.IsTextActor );
                if( actorType.IsTextActor )
                {
                    file.Write( actorType.FontAsset.Font.Name );
                    file.Write( actorType.Text );
                    file.Write( actorType.TextColor.R );
                    file.Write( actorType.TextColor.G );
                    file.Write( actorType.TextColor.B );
                    file.Write( actorType.TextColor.A );
                }

                file.Close( );
            }
        }
コード例 #3
0
        public NewActorWindow( )
        {
            InitializeComponent( );

            _txtActorName.GotFocus += ActorNameText_GotFocus;
            _txtActorName.LostFocus += ActorNameText_LostFocus;

            NoSpriteMenuItem_Click( _itemNoSprite, null );

            _LoadSpriteAssetsList( );
            _LoadScriptList( );
            _LoadFontList( );

            _actor = new ActorTypeEd( );
        }
コード例 #4
0
        public ActorAssetItem( ActorTypeEd actor )
            : base()
        {
            InitializeComponent( );

            if( actor.IsTextActor )
                _image.Image = LunarDevKit.Properties.Resources.FontIcon;
            else if( actor.SpriteAsset == Global.AssetsBrowser.NoSpriteItem )
                _image.Image = LunarDevKit.Properties.Resources.NoSprite32;
            else
                _image.ImageLocation = actor.SpriteAsset.FilePath;
            _actorType = actor;
            _actorType.Parent = this;
            _actorType.IsTextActorChanged += new EventHandler( _actorType_IsTextActorChanged );
            _actorType.SpriteChanged += new EventHandler( _actorType_SpriteChanged );
            this.LabelName = actor.Name;
        }
コード例 #5
0
        public ActorEd( ActorTypeEd parent )
        {
            _parent = parent;
            _name = "Actor";
            _visible = true;
            _bounds = new RectangleF( 0f, 0f, 1f, 1f );

            _properties.Actor = this;

            parent.SpriteChanged += new EventHandler( parent_SpriteChanged );
            parent.RotationChanged += new EventHandler( parent_RotationChanged );
            parent.ScaleChanged += new EventHandler( parent_ScaleChanged );

            parent.IsTextActorChanged += new EventHandler( parent_IsTextActorChanged );
            parent.TextChanged += new EventHandler( parent_TextChanged );
            parent.TextColorChanged += new EventHandler( parent_TextColorChanged );
        }
コード例 #6
0
        private void AddActorFromSprite( SpriteAssetItem spriteItem )
        {
            string actorName = spriteItem.AssetName;

            while( _actorItems.ContainsKey( actorName ) )
            {
                if( MessageBox.Show( Global.EditorTxt.ActorTypeWithSameNameExistsError + "\n" + Global.EditorTxt.ChooseNewNameMsg, "", MessageBoxButtons.YesNo, MessageBoxIcon.Question ) == DialogResult.Yes )
                    Helper.InputBox( Global.EditorTxt.NewActorTypeMsg, Global.EditorTxt.ActorTypeTypeNewName, ref actorName );
                else
                    return;
            }

            ActorTypeEd actor = new ActorTypeEd( );
            actor.Name = actorName;
            actor.Tags = new string[] { actorName };
            actor.Scale = 1f;
            actor.Rotation = 0f;
            actor.SpriteAsset = spriteItem;
            actor.Origin = new Microsoft.Xna.Framework.Vector2( spriteItem.Sprite.Width * 0.5f, spriteItem.Sprite.Height * 0.5f );
            actor.IsTextActor = false;
            actor.Text = "";
            actor.TextColor = Microsoft.Xna.Framework.Graphics.Color.White;

            actor.FilePath = Path.Combine( GetAssetFolder( AssetType.Actor ), actor.Name + Consts.Files.ACTORTYPE_EXTENSION );
            actor.Save( );

            AddActor( actor );

            Global.MainWindow.OnAssetAdded( );
        }
コード例 #7
0
        private void AddActor( ActorTypeEd actor )
        {
            ActorAssetItem actorItem = new ActorAssetItem( actor );
            _SetAssetItemProperties( actorItem );
            actorItem.AssetClicked += new AssetItemEventHandler( ActorAssetClicked );

            _actorsTabPanel.Controls.Add( actorItem );
            _actorItems.Add( actor.Name, actorItem );

            actor.ActorAdded = true;
        }
コード例 #8
0
        public void AddNewActor( )
        {
            ActorTypeEd actor = new ActorTypeEd( );
            string name = "";
            int i = 1;
            do
            {
                name = "Actor" + i;
                i++;
            } while( _actorItems.ContainsKey( name ) );
            actor.Name = name;
            actor.Tags = new string[] { name };
            actor.Scale = 1f;
            actor.Rotation = 0f;
            actor.IsTextActor = false;
            actor.Text = "";
            actor.TextColor = Microsoft.Xna.Framework.Graphics.Color.White;
            actor.SpriteAsset = NoSpriteItem;

            actor.FilePath = Path.Combine( GetAssetFolder( AssetType.Actor ), actor.Name + Consts.Files.ACTORTYPE_EXTENSION );
            actor.Save( );

            AddActor( actor );

            Global.MainWindow.OnAssetAdded( );
        }
コード例 #9
0
 private void _btnCancel_Click( object sender, EventArgs e )
 {
     _actor = null;
     this.Close( );
 }
コード例 #10
0
        public void NewActor( ActorTypeEd actorType, int x, int y )
        {
            Vector2 pos = Helper.ScreenToWorldPosition( Global.SelectedLevelDoc.Viewport.Camera, x, y );
            if( Global.Tools.IsDragSnapToGrid )
                Helper.DragSnap( ref pos );

            ActorEd actor = actorType.CreateActor( SelectedLayer.IdForNewActor );

            string name = "";
            int i = 1;
            do
            {
                name = actorType.Name + i;
                i++;
            } while( SelectedLayer.ActorExists( name ) );
            actor.Name = name;

            actor.Position = pos;

            SelectedLayer.AddActor( actor );
            actor.AddedToLevel = true;

            Global.MainWindow.OnLevelChanged( this.Parent );
        }
コード例 #11
0
        private void AddNewActor( )
        {
            ActorTypeEd actor = new ActorTypeEd( );
            string name = "";
            int i = 1;
            do
            {
                name = "Actor" + i;
                i++;
            } while( _actorItems.ContainsKey( name ) );
            actor.Name = name;
            actor.Scale = 1f;
            actor.Rotation = 0f;
            actor.IsTextActor = false;
            actor.Text = "";
            actor.TextColor = Color.White;

            actor.FilePath = Path.Combine( GetAssetFolder( AssetType.Actor ), actor.Name + Consts.Files.ACTORTYPE_EXTENSION );
            actor.Save( );

            AddActor( actor );

            Global.MainWindow.OnAssetAdded( );
        }
コード例 #12
0
        private void AddActor( ActorTypeEd actor )
        {
            try
            {
                AssetViewItem item = new AssetViewItem( AssetType.Actor, actor.Name );
                _listAssets.Items.Add( item );
                item.Init( );
                item.Actor = actor;

                _actorItems.Add( actor.Name, item );
            }
            catch( Exception e )
            {
                ErrorReport.Throw( e );
            }
        }
コード例 #13
0
        /// <summary>
        /// Opens an ActorType file given its path and returns an ActorType object with the data.
        /// </summary>
        internal static ActorTypeEd LoadActorTypeFile( string filePath )
        {
            ActorTypeEd actorType;

            if( !File.Exists( filePath ) )
            {
                MessageBox.Show( Path.GetFileName( filePath ) + Global.EditorTxt.FileNotFound, "", MessageBoxButtons.OK, MessageBoxIcon.Warning );
                return null;
            }

            using( BinaryReader file = new BinaryReader( File.OpenRead( filePath ) ) )
            {
                // ---- Reads the header

                if( file.ReadString( ) != Consts.Editor.FILE_HEADER_ID )
                {
                    file.Close( );
                    return null;
                }

                //Get the version of this file.
                int version = file.ReadInt32( );

                //Initialize a new ActorType instance
                actorType = new ActorTypeEd( );

                //Get the actortype name
                actorType.Name = file.ReadString( );

                //Get the actortype scale
                actorType.Scale = file.ReadSingle( );

                //Get the actortype rotation angle
                actorType.Rotation = file.ReadSingle( );

                //Get the sprite name reference. It will later be used to attach the correct sprite to this actortype
                actorType.TempSpriteName = file.ReadString( );

                //Get the script name reference. It will later be used to attach the correct script to this actortype
                actorType.TempScriptName = file.ReadString( );

                actorType.TempFontName = "";

                actorType.Tags = new string[] { actorType.Name };
                if( version >= 3 )
                {
                    int tagCount = file.ReadInt32( );

                    actorType.Tags = new string[tagCount];
                    for( int i = 0; i < tagCount; i++ )
                    {
                        actorType.Tags[i] = file.ReadString( );
                    }
                }

                //Checks for the version and get data supported by the current version
                //Includes the addition from version 3
                if( version >= 2 )
                {
                    //Get the value determining whether the actortype is a TextActor
                    actorType.IsTextActor = file.ReadBoolean( );

                    if( actorType.IsTextActor )
                    {
                        //Get the name of the font
                        actorType.TempFontName = file.ReadString( );

                        //Get the text of the actor
                        actorType.Text = file.ReadString( );

                        //Get the text's color
                        actorType.TextColor = new Color( file.ReadByte( ), file.ReadByte( ), file.ReadByte( ) );

                        if( version >= 3 )
                            actorType.TextColor = new Color( actorType.TextColor, file.ReadByte( ) );
                    }
                }

                file.Close( );
            }

            actorType.FilePath = filePath;

            return actorType;
        }
コード例 #14
0
        /// <summary>
        /// Creates an ActorType file given an ActorType object.
        /// </summary>
        internal static void CreateActorTypeFile( ActorTypeEd actorType )
        {
            try
            {
                using( BinaryWriter file = new BinaryWriter( File.Create( actorType.FilePath ) ) )
                {
                    // ---- Write the header data

                    file.Write( Consts.Editor.FILE_HEADER_ID );

                    //Writes the file version
                    file.Write( ACTOR_VERSION );

                    // ---- Write the actor data

                    //Write the name
                    file.Write( actorType.Name );

                    //Write the scale
                    file.Write( actorType.Scale );

                    //Write the rotation angle
                    file.Write( actorType.Rotation );

                    if( actorType.SpriteAsset != Global.AssetsBrowser.NoSpriteItem )
                        //Write the sprite name
                        file.Write( actorType.SpriteAsset.AssetName );
                    else
                        file.Write( NO_SPRITE );

                    //Write the script name, if this actortype has one associated
                    if( actorType.Script == null )
                        file.Write( NO_SCRIPT );
                    else
                        file.Write( actorType.Script.Name );

                    //Writes the number of tags
                    file.Write( actorType.Tags.Length );

                    //Write all tags
                    foreach( string tag in actorType.Tags )
                    {
                        file.Write( tag );
                    }

                    //Writes the IsTextActor flag
                    file.Write( actorType.IsTextActor );

                    //Checks if it's actually a TextActor, in order to write additional data
                    if( actorType.IsTextActor )
                    {
                        //Writes the font name
                        file.Write( actorType.FontAsset.Font.Name );

                        //Writes the text of the actor
                        file.Write( actorType.Text );

                        //Writes the text color
                        file.Write( actorType.TextColor.R );
                        file.Write( actorType.TextColor.G );
                        file.Write( actorType.TextColor.B );
                        file.Write( actorType.TextColor.A );
                    }

                    file.Close( );
                }
            }
            catch( Exception e )
            {
                ErrorReport.Throw( e );
            }
        }