Skip to content

Commit

Permalink
#5776: Change TexToolShiftSelected command signature
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 10, 2021
1 parent 15a9ac2 commit 10e2668
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
29 changes: 25 additions & 4 deletions radiant/textool/TexTool.cpp
Expand Up @@ -127,14 +127,14 @@ wxWindow* TexTool::createManipulationPanel()
{
auto panel = loadNamedPanel(this, "TextureToolManipulatorPanel");

makeLabelBold(panel, "ShiftLabel");
makeLabelBold(panel, "ScaleLabel");

findNamedObject<wxButton>(panel, "ShiftUpButton")->Bind(wxEVT_BUTTON, [this] (wxCommandEvent&) { onShiftSelected("up"); });
findNamedObject<wxButton>(panel, "ShiftDownButton")->Bind(wxEVT_BUTTON, [this] (wxCommandEvent&) { onShiftSelected("down"); });
findNamedObject<wxButton>(panel, "ShiftLeftButton")->Bind(wxEVT_BUTTON, [this] (wxCommandEvent&) { onShiftSelected("left"); });
findNamedObject<wxButton>(panel, "ShiftRightButton")->Bind(wxEVT_BUTTON, [this] (wxCommandEvent&) { onShiftSelected("right"); });

makeLabelBold(panel, "ShiftLabel");
makeLabelBold(panel, "ScaleLabel");

findNamedObject<wxButton>(panel, "ScaleHorizSmallerButton")->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { onScaleSelected("left"); });
findNamedObject<wxButton>(panel, "ScaleHorizLargerButton")->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { onScaleSelected("right"); });
findNamedObject<wxButton>(panel, "ScaleVertSmallerButton")->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { onScaleSelected("down"); });
Expand Down Expand Up @@ -967,7 +967,28 @@ void TexTool::determineThemeBasedOnPixelData(const std::vector<unsigned char>& p

void TexTool::onShiftSelected(const std::string& direction)
{
GlobalCommandSystem().executeCommand("TexToolShiftSelected", direction);
Vector2 translation(0, 0);

auto gridSize = GlobalGrid().getGridSize(grid::Space::Texture);

if (direction == "up")
{
translation = Vector2(0, -gridSize);
}
else if (direction == "down")
{
translation = Vector2(0, gridSize);
}
else if (direction == "left")
{
translation = Vector2(-gridSize, 0);
}
else if (direction == "right")
{
translation = Vector2(gridSize, 0);
}

GlobalCommandSystem().executeCommand("TexToolShiftSelected", translation);
}

void TexTool::onScaleSelected(const std::string& direction)
Expand Down
27 changes: 3 additions & 24 deletions radiantcore/selection/textool/TextureToolSelectionSystem.cpp
Expand Up @@ -59,7 +59,7 @@ void TextureToolSelectionSystem::initialiseModule(const IApplicationContext& ctx

GlobalCommandSystem().addCommand("TexToolShiftSelected",
std::bind(&TextureToolSelectionSystem::shiftSelectionCmd, this, std::placeholders::_1),
{ cmd::ARGTYPE_STRING });
{ cmd::ARGTYPE_VECTOR2 });
GlobalCommandSystem().addCommand("TexToolScaleSelected",
std::bind(&TextureToolSelectionSystem::scaleSelectionCmd, this, std::placeholders::_1),
{ cmd::ARGTYPE_VECTOR2 });
Expand Down Expand Up @@ -751,30 +751,9 @@ void TextureToolSelectionSystem::shiftSelectionCmd(const cmd::ArgumentList& args
{
UndoableCommand cmd("shiftTexcoords");

Vector2 translation(0, 0);

if (args.size() > 0)
{
auto gridSize = GlobalGrid().getGridSize(grid::Space::Texture);

if (args[0].getString() == "up")
{
translation = Vector2(0, -gridSize);
}
else if (args[0].getString() == "down")
{
translation = Vector2(0, gridSize);
}
else if (args[0].getString() == "left")
{
translation = Vector2(-gridSize, 0);
}
else if (args[0].getString() == "right")
{
translation = Vector2(gridSize, 0);
}
}
if (args.empty()) return;

auto translation = args[0].getVector2();
auto transform = Matrix3::getTranslation(translation);

foreachSelectedNodeOfAnyType([&](const INode::Ptr& node)
Expand Down

0 comments on commit 10e2668

Please sign in to comment.