mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.19k stars 1.76k forks source link

Make the eraser tool's size changeable? #391

Open zacx-z opened 11 years ago

zacx-z commented 11 years ago

I get frustrated if I would erase all the sky tiles in one layer and create a new 'sky' layer. I searched the document and didn't find a way to change the size of the eraser tool.

Oh... I've found a method just now. I could select and cut it using COMMAND+X - It's weird that I can't select and just delete it.

I use tiled 0.9.0 on Mac.

bjorn commented 11 years ago

Yep, the method you found is the only fast way to delete larger areas right now. The eraser definitely needs to be made more efficient, so thanks for opening this issue.

McFunkypants commented 11 years ago

One fun idea that would reuse code would be a flood-fill eraser. Maybe just hold ctrl when flood mode is on?

Another fun idea: ctrl-click a tile in the tiles palette, select all matching world map tiles that use it!

bjorn commented 11 years ago

My plan for flood-fill eraser would to have a "magic wand" selection tool, though of course it could also be added under a modifier key in the eraser itself.

As for ctrl-click on a tile in the palette, that is taken because it will add the clicked tile to the stamp. @Ablu suggested to add this feature in the right-click menu in issue #7.

bjorn commented 8 years ago

Several enhancements have been made since this issue was opened:

I wonder if I should close this issue, or whether it still makes sense to actually allow the size of the eraser to be changed. Implementing that mainly raises the question of where to put it in the UI, which probably needs some generic place for tool-specific settings (which would be useful for some other tools as well).

AxiomVerge commented 5 years ago

I just ran into a situation where I am editing such large chunks of the map at once that a resizable eraser would make it easier. Basically I am zoomed out far enough that it is almost like editing a bitmap in photoshop. I notice the "Execute Command" button has a dropdown next to it; maybe the eraser could have one with options like "1x, 2x, 4x, 8x". Otherwise you could end up going down the rabbit hole of each tool having its own options toolbar like Photoshop (which could be useful but is probably more work than it's worth)

bjorn commented 5 years ago

@AxiomVerge Each tool already has its own options tool bar, so adding this option just for the eraser for now would be possible. Does in your case the right-click rectangular area erase mode not help?

AxiomVerge commented 5 years ago

@AxiomVerge Each tool already has its own options tool bar, so adding this option just for the eraser for now would be possible. Does in your case the right-click rectangular area erase mode not help?

No, I'm basically trying to sculpt large areas of tiles by swiping my mouse in a curving motion, so the rectangular shape isn't that helpful.

bjorn commented 5 years ago

@AxiomVerge If you use a recent development snapshot, you can add an eraser of any size by adding a custom script like the following:

/*
 * Example big (5x5) eraser tool.
 */
let eraser = tiled.registerTool('BigEraser', {
    name: "Big Eraser",

    doErase(x, y) {
        for (let _x = -2; _x < 3; ++_x)
            for (let _y = -2; _y < 3; ++_y)
                this.edit.setTile(x + _x, y + _y, null)
        this.edit.apply()
    },

    activated() { this.edit = null },
    tilePositionChanged(x, y) {
        if (this.edit)
            this.doErase(x, y)
    },
    mousePressed(button, x, y, modifiers) {
        const tileLayer = this.map.currentLayer
        if (!tileLayer.isTileLayer)
            return

        this.edit = tileLayer.edit()
        this.doErase(this.tilePosition.x, this.tilePosition.y)
    },
    mouseReleased(button, x, y, modifiers) {
        this.edit = null
    },
})

Unfortunately the tool will have no preview to show which area will get erased. I realized the scripting API currently does not have any way to set up a preview for removing tiles, only for setting tiles.

To use this script:

You should then see a "Big Eraser" entry in the tool bar, which allows you to erase 5x5 sections. Just note that since it's a bit simplistic, it will skip areas if you move your mouse very fast (whereas the built-in eraser tool will draw a line from the previous location).

I hope this helps for now.

AxiomVerge commented 5 years ago

Wow, that is VERY cool. I can't wait to see what other kind of scripts show up once this feature is in the release build. THANKS!!