Exemple #1
0
        private void RoomObjectsTree_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete)
            {
                UndertaleRoom   room        = this.DataContext as UndertaleRoom;
                UndertaleObject selectedObj = ObjectEditor.Content as UndertaleObject;

                if (selectedObj is UndertaleRoom.Background)
                {
                    UndertaleRoom.Background bg = selectedObj as UndertaleRoom.Background;
                    bg.Enabled = false;
                    bg.BackgroundDefinition = null;
                    ObjectEditor.Content    = null;
                }
                else if (selectedObj is UndertaleRoom.View)
                {
                    UndertaleRoom.View view = selectedObj as UndertaleRoom.View;
                    view.Enabled         = false;
                    ObjectEditor.Content = null;
                }
                else if (selectedObj is UndertaleRoom.Tile)
                {
                    UndertaleRoom.Tile tile = selectedObj as UndertaleRoom.Tile;
                    room.Tiles.Remove(tile);
                    ObjectEditor.Content = null;
                }
                else if (selectedObj is UndertaleRoom.GameObject)
                {
                    UndertaleRoom.GameObject gameObj = selectedObj as UndertaleRoom.GameObject;
                    room.GameObjects.Remove(gameObj);
                    ObjectEditor.Content = null;
                }
            }
        }
        private void AddLegacyTile(UndertaleRoom.Layer layer)
        {
            // add pointer list if one doesn't already exist
            if (layer.AssetsData.LegacyTiles == null)
            {
                layer.AssetsData.LegacyTiles = new UndertalePointerList <UndertaleRoom.Tile>();
            }

            // add sprite pointer list if one doesn't already exist
            if (layer.AssetsData.Sprites == null)
            {
                layer.AssetsData.Sprites = new UndertalePointerList <UndertaleRoom.SpriteInstance>();
            }

            // add tile to list
            var tile = new UndertaleRoom.Tile {
                InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastTile++
            };

            tile._SpriteMode = true;
            layer.AssetsData.LegacyTiles.Add(tile);

            if (layer != null)
            {
                SelectObject(tile);
            }
        }
        private void AddGMS1Tile(UndertaleRoom room)
        {
            // add tile to list
            var tile = new UndertaleRoom.Tile {
                InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastTile++
            };

            room.Tiles.Add(tile);
            SelectObject(tile);
        }
Exemple #4
0
 public void Command_Paste(object sender, ExecutedRoutedEventArgs e)
 {
     /*IDataObject data = Clipboard.GetDataObject();
      * UndertaleObject obj = data.GetData(data.GetFormats()[0]) as UndertaleObject;
      * if (obj != null)
      * {
      *  Debug.WriteLine("Paste");
      *  Debug.WriteLine(obj);
      * }*/
     if (copied != null)
     {
         UndertaleRoom room = this.DataContext as UndertaleRoom;
         if (copied is UndertaleRoom.GameObject)
         {
             var other = copied as UndertaleRoom.GameObject;
             var obj   = new UndertaleRoom.GameObject();
             obj.X = other.X;
             obj.Y = other.Y;
             obj.ObjectDefinition = other.ObjectDefinition;
             obj.InstanceID       = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastObj++;
             obj.CreationCode     = other.CreationCode;
             obj.ScaleX           = other.ScaleX;
             obj.ScaleY           = other.ScaleY;
             obj.Color            = other.Color;
             obj.Rotation         = other.Rotation;
             obj.PreCreateCode    = other.PreCreateCode;
             room.GameObjects.Add(obj);
             SelectObject(obj);
         }
         if (copied is UndertaleRoom.Tile)
         {
             var other = copied as UndertaleRoom.Tile;
             var obj   = new UndertaleRoom.Tile();
             obj.X = other.X;
             obj.Y = other.Y;
             obj.BackgroundDefinition = other.BackgroundDefinition;
             obj.SourceX    = other.SourceX;
             obj.SourceY    = other.SourceY;
             obj.Width      = other.Width;
             obj.Height     = other.Height;
             obj.TileDepth  = other.TileDepth;
             obj.InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastTile++;
             obj.ScaleX     = other.ScaleX;
             obj.ScaleY     = other.ScaleY;
             obj.Color      = other.Color;
             room.Tiles.Add(obj);
             SelectObject(obj);
         }
     }
 }
        public void Command_Paste(object sender, ExecutedRoutedEventArgs e)
        {
            /*IDataObject data = Clipboard.GetDataObject();
             * UndertaleObject obj = data.GetData(data.GetFormats()[0]) as UndertaleObject;
             * if (obj != null)
             * {
             *  Debug.WriteLine("Paste");
             *  Debug.WriteLine(obj);
             * }*/

            if (copied != null)
            {
                UndertaleRoom room = this.DataContext as UndertaleRoom;

                UndertaleRoom.Layer layer = ObjectEditor.Content as UndertaleRoom.Layer;
                if ((Application.Current.MainWindow as MainWindow).IsGMS2 == Visibility.Visible && layer == null)
                {
                    MessageBox.Show("Must paste onto a layer", "UndertaleModTool", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (copied is UndertaleRoom.GameObject)
                {
                    if (layer != null && layer.InstancesData == null)
                    {
                        MessageBox.Show("Must be on an instances layer", "UndertaleModTool", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    var other = copied as UndertaleRoom.GameObject;
                    var obj   = new UndertaleRoom.GameObject();
                    obj.X = other.X;
                    obj.Y = other.Y;
                    obj.ObjectDefinition = other.ObjectDefinition;
                    obj.InstanceID       = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastObj++;
                    obj.CreationCode     = other.CreationCode;
                    obj.ScaleX           = other.ScaleX;
                    obj.ScaleY           = other.ScaleY;
                    obj.Color            = other.Color;
                    obj.Rotation         = other.Rotation;
                    obj.PreCreateCode    = other.PreCreateCode;
                    room.GameObjects.Add(obj);
                    if (layer != null)
                    {
                        layer.InstancesData.Instances.Add(obj);
                    }
                    SelectObject(obj);
                }
                if (copied is UndertaleRoom.Tile)
                {
                    if (layer != null && layer.AssetsData == null)
                    {
                        MessageBox.Show("Must be on an assets layer", "UndertaleModTool", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }
                    var other = copied as UndertaleRoom.Tile;
                    var obj   = new UndertaleRoom.Tile();
                    obj.X                = -(int)other.Height; //other.X;
                    obj.Y                = -(int)other.Height; //other.Y;
                    obj._SpriteMode      = other._SpriteMode;
                    obj.ObjectDefinition = other.ObjectDefinition;
                    obj.SourceX          = other.SourceX;
                    obj.SourceY          = other.SourceY;
                    obj.Width            = other.Width;
                    obj.Height           = other.Height;
                    obj.TileDepth        = other.TileDepth;
                    obj.InstanceID       = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastTile++;
                    obj.ScaleX           = other.ScaleX;
                    obj.ScaleY           = other.ScaleY;
                    obj.Color            = other.Color;
                    if (layer != null)
                    {
                        layer.AssetsData.LegacyTiles.Add(obj);
                    }
                    else
                    {
                        room.Tiles.Add(obj);
                    }
                    SelectObject(obj);
                }
            }

            (this.DataContext as UndertaleRoom)?.SetupRoom();
        }
        private void RoomObjectsTree_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete)
            {
                UndertaleRoom   room        = this.DataContext as UndertaleRoom;
                UndertaleObject selectedObj = ObjectEditor.Content as UndertaleObject;

                if (selectedObj is UndertaleRoom.Background)
                {
                    UndertaleRoom.Background bg = selectedObj as UndertaleRoom.Background;
                    bg.Enabled = false;
                    bg.BackgroundDefinition = null;
                    ObjectEditor.Content    = null;
                }
                else if (selectedObj is UndertaleRoom.View)
                {
                    UndertaleRoom.View view = selectedObj as UndertaleRoom.View;
                    view.Enabled         = false;
                    ObjectEditor.Content = null;
                }
                else if (selectedObj is UndertaleRoom.Tile)
                {
                    UndertaleRoom.Tile tile = selectedObj as UndertaleRoom.Tile;
                    if ((Application.Current.MainWindow as MainWindow).IsGMS2 == Visibility.Visible)
                    {
                        foreach (var layer in room.Layers)
                        {
                            if (layer.AssetsData != null)
                            {
                                layer.AssetsData.LegacyTiles.Remove(tile);
                            }
                        }
                    }
                    room.Tiles.Remove(tile);
                    ObjectEditor.Content = null;
                }
                else if (selectedObj is UndertaleRoom.GameObject)
                {
                    UndertaleRoom.GameObject gameObj = selectedObj as UndertaleRoom.GameObject;
                    if ((Application.Current.MainWindow as MainWindow).IsGMS2 == Visibility.Visible)
                    {
                        foreach (var layer in room.Layers)
                        {
                            if (layer.InstancesData != null)
                            {
                                layer.InstancesData.Instances.Remove(gameObj);
                            }
                        }
                    }
                    room.GameObjects.Remove(gameObj);
                    ObjectEditor.Content = null;
                }
                else if (selectedObj is UndertaleRoom.Layer)
                {
                    UndertaleRoom.Layer layer = selectedObj as UndertaleRoom.Layer;
                    if (layer.InstancesData != null)
                    {
                        foreach (var go in layer.InstancesData.Instances)
                        {
                            room.GameObjects.Remove(go);
                        }
                    }
                    room.Layers.Remove(layer);
                    ObjectEditor.Content = null;
                }
            }
        }