コード例 #1
0
        public void DeleteFont( FontAssetItem fontItem )
        {
            Classes.Collections.ActorEdPool actorPool = new Classes.Collections.ActorEdPool( );
            //In here, it searches for all TextActors and delete them if they share the same SpriteFont
            foreach( LevelEd level in Global.World.Levels )
            {
                foreach( LayerEd layer in level.Layers )
                {
                    if( layer.Actors.Count == 0 )
                        continue;

                    foreach( ActorEd actor in layer.Actors )
                    {
                        if( actor.IsTextActor )
                            if( actor.FontAsset == fontItem )
                                actorPool.Add( actor );
                    }
                    foreach( ActorEd actor in layer.Actors )
                    {
                        layer.RemoveActor( actor );
                    }

                    actorPool.Clear( );
                }
            }

            File.Delete( fontItem.FilePath );

            _fontsTabPanel.Controls.Remove( fontItem );
            _fontItems.Remove( fontItem.AssetName );

            fontItem.Dispose( );

            Global.MainWindow.OnAssetRemoved( );
        }
コード例 #2
0
        public void DeleteActor( ActorAssetItem actorItem )
        {
            ActorTypeEd actorType = actorItem.Actor;

            Classes.Collections.ActorEdPool pool = new Classes.Collections.ActorEdPool( );

            foreach( LevelEd level in Global.World.Levels )
            {
                foreach( LayerEd layer in level.Layers )
                {
                    if( layer.Actors.Count == 0 )
                        continue;

                    foreach( ActorEd actor in layer.Actors )
                    {
                        if( actor.Parent == actorType )
                            pool.Add( actor );
                    }
                    foreach( ActorEd actor in pool )
                    {
                        layer.RemoveActor( actor );
                    }

                    pool.Clear( );
                }
            }

            File.Delete( actorItem.FilePath );

            _actorsTabPanel.Controls.Remove( actorItem );
            _actorItems.Remove( actorType.Name );
            _selectedActorItem = null;

            actorItem.Dispose( );

            Global.MainWindow.OnAssetRemoved( );
        }