mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-06 06:50:07 +00:00
Show tile numbers when moving tilemaps
This commit is contained in:
parent
40a56a6281
commit
8b1f887720
@ -925,6 +925,7 @@
|
|||||||
<item command="ShowAutoGuides" text="@.view_show_auto_guides" />
|
<item command="ShowAutoGuides" text="@.view_show_auto_guides" />
|
||||||
<item command="ShowSlices" text="@.view_show_slices" />
|
<item command="ShowSlices" text="@.view_show_slices" />
|
||||||
<item command="ShowPixelGrid" text="@.view_show_pixel_grid" />
|
<item command="ShowPixelGrid" text="@.view_show_pixel_grid" />
|
||||||
|
<item command="ShowTileNumbers" text="@.view_show_tile_numbers" />
|
||||||
<separator />
|
<separator />
|
||||||
<item command="ShowBrushPreview" text="@.view_show_brush_preview" />
|
<item command="ShowBrushPreview" text="@.view_show_brush_preview" />
|
||||||
</menu>
|
</menu>
|
||||||
|
@ -526,6 +526,7 @@
|
|||||||
<option id="brush_preview" type="bool" default="true" />
|
<option id="brush_preview" type="bool" default="true" />
|
||||||
<option id="slices" type="bool" default="true" />
|
<option id="slices" type="bool" default="true" />
|
||||||
<option id="auto_guides" type="bool" default="true" />
|
<option id="auto_guides" type="bool" default="true" />
|
||||||
|
<option id="tile_numbers" type="bool" default="true" />
|
||||||
</section>
|
</section>
|
||||||
</document>
|
</document>
|
||||||
|
|
||||||
|
@ -470,6 +470,7 @@ ShowPaletteSortOptions = Show Palette Sort Options
|
|||||||
ShowPixelGrid = Show Pixel Grid
|
ShowPixelGrid = Show Pixel Grid
|
||||||
ShowSelectionEdges = Show Selection Edges
|
ShowSelectionEdges = Show Selection Edges
|
||||||
ShowSlices = Show Slices
|
ShowSlices = Show Slices
|
||||||
|
ShowTileNumbers = Show Tile Numbers
|
||||||
SliceProperties = Slice Properties
|
SliceProperties = Slice Properties
|
||||||
SnapToGrid = Snap to Grid
|
SnapToGrid = Snap to Grid
|
||||||
SpriteProperties = Sprite Properties
|
SpriteProperties = Sprite Properties
|
||||||
@ -973,6 +974,7 @@ view_show_auto_guides = &Auto Guides
|
|||||||
view_show_slices = Sl&ices
|
view_show_slices = Sl&ices
|
||||||
view_show_pixel_grid = &Pixel Grid
|
view_show_pixel_grid = &Pixel Grid
|
||||||
view_show_brush_preview = &Brush Preview
|
view_show_brush_preview = &Brush Preview
|
||||||
|
view_show_tile_numbers = &Tile Numbers
|
||||||
view_grid = &Grid
|
view_grid = &Grid
|
||||||
view_grid_settings = Gri&d Settings
|
view_grid_settings = Gri&d Settings
|
||||||
view_grid_selection_as_grid = Select&ion as Grid
|
view_grid_selection_as_grid = Select&ion as Grid
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
|
// Copyright (C) 2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -183,6 +184,24 @@ protected:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ShowTileNumbersCommand : public Command {
|
||||||
|
public:
|
||||||
|
ShowTileNumbersCommand()
|
||||||
|
: Command(CommandId::ShowTileNumbers(), CmdUIOnlyFlag) {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool onChecked(Context* ctx) override {
|
||||||
|
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
|
||||||
|
return docPref.show.tileNumbers();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onExecute(Context* ctx) override {
|
||||||
|
DocumentPreferences& docPref = Preferences::instance().document(ctx->activeDocument());
|
||||||
|
docPref.show.tileNumbers(!docPref.show.tileNumbers());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Command* CommandFactory::createShowExtrasCommand()
|
Command* CommandFactory::createShowExtrasCommand()
|
||||||
{
|
{
|
||||||
return new ShowExtrasCommand;
|
return new ShowExtrasCommand;
|
||||||
@ -223,4 +242,9 @@ Command* CommandFactory::createShowSlicesCommand()
|
|||||||
return new ShowSlicesCommand;
|
return new ShowSlicesCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Command* CommandFactory::createShowTileNumbersCommand()
|
||||||
|
{
|
||||||
|
return new ShowTileNumbersCommand;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -150,6 +150,7 @@ FOR_EACH_COMMAND(ShowOnionSkin)
|
|||||||
FOR_EACH_COMMAND(ShowPixelGrid)
|
FOR_EACH_COMMAND(ShowPixelGrid)
|
||||||
FOR_EACH_COMMAND(ShowSelectionEdges)
|
FOR_EACH_COMMAND(ShowSelectionEdges)
|
||||||
FOR_EACH_COMMAND(ShowSlices)
|
FOR_EACH_COMMAND(ShowSlices)
|
||||||
|
FOR_EACH_COMMAND(ShowTileNumbers)
|
||||||
FOR_EACH_COMMAND(SliceProperties)
|
FOR_EACH_COMMAND(SliceProperties)
|
||||||
FOR_EACH_COMMAND(SnapToGrid)
|
FOR_EACH_COMMAND(SnapToGrid)
|
||||||
FOR_EACH_COMMAND(SpriteProperties)
|
FOR_EACH_COMMAND(SpriteProperties)
|
||||||
|
@ -915,9 +915,39 @@ void Editor::drawSpriteUnclippedRect(ui::Graphics* g, const gfx::Rect& _rc)
|
|||||||
m_state->requireBrushPreview()) {
|
m_state->requireBrushPreview()) {
|
||||||
Cel* cel = (m_layer ? m_layer->cel(m_frame): nullptr);
|
Cel* cel = (m_layer ? m_layer->cel(m_frame): nullptr);
|
||||||
if (cel) {
|
if (cel) {
|
||||||
drawCelBounds(
|
gfx::Color color = color_utils::color_for_ui(Preferences::instance().guides.layerEdgesColor());
|
||||||
g, cel,
|
drawCelBounds(g, cel, color);
|
||||||
color_utils::color_for_ui(Preferences::instance().guides.layerEdgesColor()));
|
|
||||||
|
// Draw tile numbers
|
||||||
|
if (m_docPref.show.tileNumbers() &&
|
||||||
|
cel->layer()->isTilemap()) {
|
||||||
|
color = color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor());
|
||||||
|
gfx::Color fgColor = color_utils::blackandwhite_neg(color);
|
||||||
|
|
||||||
|
const doc::Grid grid = getSite().grid();
|
||||||
|
const gfx::Size tileSize = editorToScreen(grid.tileToCanvas(gfx::Rect(0, 0, 1, 1))).size();
|
||||||
|
if (tileSize.h > g->font()->height()) {
|
||||||
|
const gfx::Point offset(tileSize.w/2,
|
||||||
|
tileSize.h/2 - g->font()->height()/2);
|
||||||
|
const gfx::Rect rc = cel->bounds();
|
||||||
|
const doc::Image* image = cel->image();
|
||||||
|
std::string text;
|
||||||
|
for (int y=0; y<image->height(); ++y) {
|
||||||
|
for (int x=0; x<image->width(); ++x) {
|
||||||
|
doc::tile_t t = image->getPixel(x, y);
|
||||||
|
if (t != doc::tile_i_notile) {
|
||||||
|
gfx::Point pt = editorToScreen(grid.tileToCanvas(gfx::Point(x, y)));
|
||||||
|
pt -= bounds().origin();
|
||||||
|
pt += offset;
|
||||||
|
|
||||||
|
text = fmt::format("{}", (t & doc::tile_i_mask));
|
||||||
|
pt.x -= g->measureUIText(text).w/2;
|
||||||
|
g->drawText(text, fgColor, color, pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_showAutoCelGuides &&
|
if (m_showAutoCelGuides &&
|
||||||
m_showGuidesThisCel != cel) {
|
m_showGuidesThisCel != cel) {
|
||||||
@ -1157,9 +1187,8 @@ void Editor::drawCelGuides(ui::Graphics* g, const Cel* cel, const Cel* mouseCel)
|
|||||||
scrCmpBounds = getCelScreenBounds(mouseCel);
|
scrCmpBounds = getCelScreenBounds(mouseCel);
|
||||||
sprCmpBounds = mouseCel->bounds();
|
sprCmpBounds = mouseCel->bounds();
|
||||||
|
|
||||||
drawCelBounds(
|
const gfx::Color color = color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor());
|
||||||
g, mouseCel,
|
drawCelBounds(g, mouseCel, color);
|
||||||
color_utils::color_for_ui(Preferences::instance().guides.autoGuidesColor()));
|
|
||||||
}
|
}
|
||||||
// Use whole canvas
|
// Use whole canvas
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user