Skip to content

Commit

Permalink
make quarter and eighth movement relative to grid size
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed May 23, 2024
1 parent e218fc2 commit d691ac5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* View tab
* Better organized edit tab
* Hide UI button
* 1/4 and 1/8 moving is now relative to the current grid size

## v6.3.5

Expand Down
13 changes: 9 additions & 4 deletions src/features/MoveMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ class CustomEditMenu : public CCNode {
) {
std::string name;
switch (hash(group.c_str())) {
case hash("half-button"): name = "1/2"; break;
case hash("quarter-button"): name = "1/4"; break;
case hash("eighth-button"): name = "1/8"; break;
case hash("unit-button"): name = "1/30"; break;
case hash("half-button"): name = "1/2"; break;
case hash("quarter-button"): name = "1/4"; break;
case hash("eighth-button"): name = "1/8"; break;
case hash("unit-button"): name = "Pixel"; break;
default: break;
}
m_groups.push_back(MoveGroup::create(name, up, down, left, right));
Expand Down Expand Up @@ -322,6 +322,11 @@ class $modify(EditorUI) {
m_editButtonBar->m_buttonArray->addObject(btn);
}

$override
void clickOnPosition(CCPoint pos) {
EditorUI::clickOnPosition(pos);
CustomEditMenu::updateVisiblity(this);
}
$override
void toggleMode(CCObject* sender) {
EditorUI::toggleMode(sender);
Expand Down
27 changes: 14 additions & 13 deletions src/utils/EditCommandExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ class $modify(EditorUI) {
BE_ALLOW_START
BE_ALLOW_FAKE_ENUMS
CCPoint moveForCommand(EditCommand command) {
auto gridSize = EditorUI::get()->m_gridSize;
switch (command) {
case EditCommandExt::QuarterLeft: return ccp(-7.5f, 0);
case EditCommandExt::QuarterRight: return ccp(7.5f, 0);
case EditCommandExt::QuarterUp: return ccp(0, 7.5f);
case EditCommandExt::QuarterDown: return ccp(0, -7.5f);

case EditCommandExt::EighthLeft: return ccp(-3.75f, 0);
case EditCommandExt::EighthRight: return ccp(3.75f, 0);
case EditCommandExt::EighthUp: return ccp(0, 3.75f);
case EditCommandExt::EighthDown: return ccp(0, -3.75f);
case EditCommandExt::QuarterLeft: return ccp(-1 / 4.f, 0) * gridSize;
case EditCommandExt::QuarterRight: return ccp( 1 / 4.f, 0) * gridSize;
case EditCommandExt::QuarterUp: return ccp(0, 1 / 4.f) * gridSize;
case EditCommandExt::QuarterDown: return ccp(0, -1 / 4.f) * gridSize;

case EditCommandExt::UnitLeft: return ccp(-1, 0);
case EditCommandExt::UnitRight: return ccp(1, 0);
case EditCommandExt::UnitUp: return ccp(0, 1);
case EditCommandExt::UnitDown: return ccp(0, -1);
case EditCommandExt::EighthLeft: return ccp(-1 / 8.f, 0) * gridSize;
case EditCommandExt::EighthRight: return ccp( 1 / 8.f, 0) * gridSize;
case EditCommandExt::EighthUp: return ccp(0, 1 / 8.f) * gridSize;
case EditCommandExt::EighthDown: return ccp(0, -1 / 8.f) * gridSize;

case EditCommandExt::UnitLeft: return ccp(-.1f, 0);
case EditCommandExt::UnitRight: return ccp( .1f, 0);
case EditCommandExt::UnitUp: return ccp( 0, .1f);
case EditCommandExt::UnitDown: return ccp( 0, -.1f);

default: return EditorUI::moveForCommand(command);
}
Expand Down

0 comments on commit d691ac5

Please sign in to comment.