Add Space+N/Tab/1,2,3 to handle tilemap modes

* Space+N to create new tilemaps
* Space+Tab to switch the tileset visibility
* Space+1,2,3 to change to manual/auto/stack tileset modes
This commit is contained in:
David Capello 2020-02-17 16:36:18 -03:00
parent d0f9429d03
commit 776b7862d3
6 changed files with 99 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Aseprite -->
<!-- Copyright (C) 2018-2019 Igara Studio S.A. -->
<!-- Copyright (C) 2018-2020 Igara Studio S.A. -->
<!-- Copyright (C) 2001-2018 David Capello -->
<gui version="1.3-dev">
<!-- Keyboard shortcuts -->
@ -84,6 +84,10 @@
<key command="NewLayer" shortcut="Ctrl+Shift+J" mac="Cmd+Shift+J">
<param name="viaCut" value="true" />
</key>
<key command="NewLayer" shortcut="Space+N">
<param name="ask" value="true" />
<param name="tilemap" value="true" />
</key>
<key command="GotoPreviousLayer" shortcut="Down" context="Normal" />
<key command="GotoNextLayer" shortcut="Up" context="Normal" />
<!-- Frame -->
@ -138,7 +142,16 @@
<key command="Timeline" shortcut="Tab">
<param name="switch" value="true" />
</key>
<key command="ToggleTilesMode" shortcut="Shift+Tab" />
<key command="ToggleTilesMode" shortcut="Space+Tab" />
<key command="TilesetMode" shortcut="Space+1">
<param name="mode" value="manual" />
</key>
<key command="TilesetMode" shortcut="Space+2">
<param name="mode" value="auto" />
</key>
<key command="TilesetMode" shortcut="Space+3">
<param name="mode" value="stack" />
</key>
<key command="PaletteEditor" shortcut="A" />
<key command="PaletteEditor" shortcut="F4">
<param name="edit" value="switch" />

View File

@ -1,5 +1,5 @@
# Aseprite
# Copyright (C) 2018-2019 Igara Studio S.A.
# Copyright (C) 2018-2020 Igara Studio S.A.
# Copyright (C) 2016-2018 David Capello
[advanced_mode]
@ -478,6 +478,10 @@ TiledMode = Tiled Mode
Timeline = Switch Timeline
TogglePreview = Toggle Preview
ToggleTilesMode = Toggle Tiles Mode
TilesetMode = Tileset Mode: {}
TilesetMode_Manual = Manual
TilesetMode_Auto = Auto
TilesetMode_Stack = Stack
ToggleTimelineThumbnails = Toggle Timeline Thumbnails
Undo = Undo
UndoHistory = Undo History

View File

@ -300,6 +300,7 @@ if(ENABLE_UI)
commands/filters/filter_target_buttons.cpp
commands/filters/filter_window.cpp
commands/screenshot.cpp
commands/tileset_mode.cpp
file_selector.cpp
modules/editors.cpp
modules/gfx.cpp

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -281,6 +281,14 @@ os::Shortcut get_os_shortcut_from_key(const Key* key)
{
if (key && !key->accels().empty()) {
const ui::Accelerator& accel = key->accels().front();
#ifdef __APPLE__
// Shortcuts with spacebar as modifier do not work well in macOS
// (they will be called when the space bar is unpressed too).
if ((accel.modifiers() & ui::kKeySpaceModifier) == ui::kKeySpaceModifier)
return os::Shortcut();
#endif
return os::Shortcut(
(accel.unicodeChar() ? accel.unicodeChar():
from_scancode_to_unicode(accel.scancode())),

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -156,6 +156,7 @@ FOR_EACH_COMMAND(Stroke)
FOR_EACH_COMMAND(SwitchColors)
FOR_EACH_COMMAND(SymmetryMode)
FOR_EACH_COMMAND(TiledMode)
FOR_EACH_COMMAND(TilesetMode)
FOR_EACH_COMMAND(Timeline)
FOR_EACH_COMMAND(TogglePreview)
FOR_EACH_COMMAND(ToggleTilesMode)

View File

@ -0,0 +1,67 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/app.h"
#include "app/commands/command.h"
#include "app/commands/params.h"
#include "app/i18n/strings.h"
#include "app/ui/color_bar.h"
#include "fmt/format.h"
namespace app {
using namespace gfx;
class TilesetModeCommand : public Command {
public:
TilesetModeCommand()
: Command(CommandId::TilesetMode(), CmdUIOnlyFlag) {
m_mode = TilesetMode::Auto;
}
protected:
void onLoadParams(const Params& params) override {
std::string mode = params.get("mode");
if (mode == "manual") m_mode = TilesetMode::Manual;
else if (mode == "stack") m_mode = TilesetMode::Stack;
else m_mode = TilesetMode::Auto;
}
bool onChecked(Context* context) override {
auto colorBar = ColorBar::instance();
return (colorBar->tilesetMode() == m_mode);
}
void onExecute(Context* context) override {
auto colorBar = ColorBar::instance();
colorBar->setTilesetMode(m_mode);
}
std::string onGetFriendlyName() const override {
std::string mode;
switch (m_mode) {
case TilesetMode::Manual: mode = Strings::commands_TilesetMode_Manual(); break;
case TilesetMode::Auto: mode = Strings::commands_TilesetMode_Auto(); break;
case TilesetMode::Stack: mode = Strings::commands_TilesetMode_Stack(); break;
}
return fmt::format(getBaseFriendlyName(), mode);
}
private:
TilesetMode m_mode;
};
Command* CommandFactory::createTilesetModeCommand()
{
return new TilesetModeCommand;
}
} // namespace app