diff --git a/changelog.md b/changelog.md index 5f92839..704a052 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # BetterEdit 6 +## v6.6.4 + * Add keybinds for Increase Grid Size and Decrease Grid Size + * Increase the hardcoded limits of Button Rows and Buttons Per Row to 12 and 48 respectively + * Bump Custom Keybinds version to add support for assigning mouse side buttons to keybinds + ## v6.6.3 * Add a Support button to the pause menu (that can be hidden through the popup) * Add Developer Mode setting diff --git a/mod.json b/mod.json index 1a91d7e..089a264 100644 --- a/mod.json +++ b/mod.json @@ -1,6 +1,6 @@ { "geode": "3.2.0", - "version": "6.6.3", + "version": "6.6.4", "gd": { "win": "2.206", "mac": "2.206", @@ -24,7 +24,7 @@ }, { "id": "geode.custom-keybinds", - "version": "1.6.2", + "version": "1.7.1", "importance": "required", "platforms": ["win"] }, diff --git a/src/features/ButtonRowsBypass.cpp b/src/features/ButtonRowsBypass.cpp new file mode 100644 index 0000000..5c94cb6 --- /dev/null +++ b/src/features/ButtonRowsBypass.cpp @@ -0,0 +1,20 @@ +#include + +using namespace geode::prelude; + +class $modify(EditorOptionsLayer) { + $override + void onButtonRows(CCObject* sender) { + if (0) EditorOptionsLayer::onButtonRows(sender); + + m_buttonRows = clamp(m_buttonRows + (sender->getTag() ? 1 : -1), 2, 12); + m_buttonRowsLabel->setString(std::to_string(m_buttonRows).c_str()); + } + $override + void onButtonsPerRow(CCObject* sender) { + if (0) EditorOptionsLayer::onButtonsPerRow(sender); + + m_buttonsPerRow = clamp(m_buttonsPerRow + (sender->getTag() ? 1 : -1), 6, 48); + m_buttonsPerRowLabel->setString(std::to_string(m_buttonsPerRow).c_str()); + } +}; diff --git a/src/features/GridScaling.cpp b/src/features/GridScaling.cpp index 7a11b25..4d4bcb4 100644 --- a/src/features/GridScaling.cpp +++ b/src/features/GridScaling.cpp @@ -1,3 +1,4 @@ +#include "GridScaling.hpp" #include #include #include @@ -105,25 +106,12 @@ class $modify(GridUI, EditorUI) { } void onGridSize(CCObject* sender) { - static std::array SNAP_GRID_SIZES { - 3.75f, 7.5f, 15.f, 30.f, 60.f, 90.f, 120.f - }; - auto value = Mod::get()->template getSavedValue("grid-size"); if (sender->getTag() == -1) { - auto next = std::lower_bound(SNAP_GRID_SIZES.begin(), SNAP_GRID_SIZES.end(), value); - if (next != SNAP_GRID_SIZES.begin()) { - next--; - } - value = *next; + decrementGridSize(this); } else { - auto next = std::upper_bound(SNAP_GRID_SIZES.begin(), SNAP_GRID_SIZES.end(), value); - if (next == SNAP_GRID_SIZES.end()) { - next--; - } - value = *next; + incrementGridSize(this); } - this->updateGridConstSize(value); } $override @@ -142,4 +130,26 @@ class $modify(GridUI, EditorUI) { } }; +static std::array SNAP_GRID_SIZES { + 3.75f, 7.5f, 15.f, 30.f, 60.f, 90.f, 120.f +}; +void decrementGridSize(EditorUI* ui) { + auto value = Mod::get()->template getSavedValue("grid-size"); + auto next = std::lower_bound(SNAP_GRID_SIZES.begin(), SNAP_GRID_SIZES.end(), value); + if (next != SNAP_GRID_SIZES.begin()) { + next--; + } + value = *next; + static_cast(ui)->updateGridConstSize(value); +} +void incrementGridSize(EditorUI* ui) { + auto value = Mod::get()->template getSavedValue("grid-size"); + auto next = std::upper_bound(SNAP_GRID_SIZES.begin(), SNAP_GRID_SIZES.end(), value); + if (next == SNAP_GRID_SIZES.end()) { + next--; + } + value = *next; + static_cast(ui)->updateGridConstSize(value); +} + #endif diff --git a/src/features/GridScaling.hpp b/src/features/GridScaling.hpp new file mode 100644 index 0000000..367b126 --- /dev/null +++ b/src/features/GridScaling.hpp @@ -0,0 +1,8 @@ +#pragma once + +#include + +using namespace geode::prelude; + +void decrementGridSize(EditorUI* ui); +void incrementGridSize(EditorUI* ui); diff --git a/src/features/Keybinds.cpp b/src/features/Keybinds.cpp index 8547eda..98ef600 100644 --- a/src/features/Keybinds.cpp +++ b/src/features/Keybinds.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "GridScaling.hpp" #include #ifdef BETTEREDIT_PRO @@ -67,6 +68,13 @@ struct $modify(EditorUI) { this->onPasteColor(nullptr); }); + this->defineKeybind("enlarge-grid-size"_spr, [this]() { + incrementGridSize(this); + }); + this->defineKeybind("ensmallen-grid-size"_spr, [this]() { + decrementGridSize(this); + }); + this->defineKeybind("save-level"_spr, [this]() { if (m_editorLayer->m_playbackMode != PlaybackMode::Not) { this->onStopPlaytest(nullptr); @@ -184,14 +192,16 @@ struct $modify(EditorUI) { "Rotate Snap", "Rotate the Selected Object(s) to Match Adjacent Slopes", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "show-scale"_spr, "Show Scale Control", "Show the object scaling controls", {}, - Category::EDITOR_UI + Category::EDITOR_UI, + false )); BindManager::get()->registerBindable(BindableAction( @@ -199,7 +209,8 @@ struct $modify(EditorUI) { "Save Level", "", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "build-helper"_spr, @@ -207,7 +218,8 @@ struct $modify(EditorUI) { "Executes the Build Helper feature, aka remaps Groud and Color " "IDs of the selected objects to unused ones", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "align-x"_spr, @@ -215,7 +227,8 @@ struct $modify(EditorUI) { "Executes the Align X feature, aka aligns all of the selected " "objects along the X axis", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "align-y"_spr, @@ -223,14 +236,16 @@ struct $modify(EditorUI) { "Executes the Align Y feature, aka aligns all of the selected " "objects along the Y axis", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "toggle-link-controls"_spr, "Toggle Link Controls", "", {}, - Category::EDITOR_UI + Category::EDITOR_UI, + false )); BindManager::get()->registerBindable(BindableAction( @@ -238,42 +253,65 @@ struct $modify(EditorUI) { "Edit Object", "Open the Edit Object popup for the selected objects", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "open-edit-group"_spr, "Edit Group", "Open the Edit Group popup for the selected objects", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "open-edit-special"_spr, "Edit Special", "Open the Edit Special popup for the selected objects", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "copy-values"_spr, "Copy Values", "", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "paste-state"_spr, "Paste State", "", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "paste-color"_spr, "Paste Color", "", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false + )); + + BindManager::get()->registerBindable(BindableAction( + "enlarge-grid-size"_spr, + "Increase Grid Size", + "", + {}, + Category::EDITOR_UI, + false + )); + BindManager::get()->registerBindable(BindableAction( + "ensmallen-grid-size"_spr, + "Decrease Grid Size", + "", + {}, + Category::EDITOR_UI, + false )); BindManager::get()->registerBindable(BindableAction( @@ -281,21 +319,24 @@ struct $modify(EditorUI) { "Select All", "Select All Object(s)", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "select-all-left"_spr, "Select All Left", "Select All Object(s) Left of the Screen", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); BindManager::get()->registerBindable(BindableAction( "select-all-right"_spr, "Select All Right", "Select All Object(s) Right of the Screen", {}, - Category::EDITOR_MODIFY + Category::EDITOR_MODIFY, + false )); // todo: toggle UI @@ -304,14 +345,16 @@ struct $modify(EditorUI) { "Show UI", "", {}, - Category::EDITOR_UI + Category::EDITOR_UI, + false )); BindManager::get()->registerBindable(BindableAction( "hide-ui"_spr, "Hide UI", "", {}, - Category::EDITOR_UI + Category::EDITOR_UI, + false )); BindManager::get()->registerBindable({ "move-obj-half-left"_spr, diff --git a/src/features/NextFreeOffset.cpp b/src/features/NextFreeOffset.cpp index 0c6869e..a0d0fc9 100644 --- a/src/features/NextFreeOffset.cpp +++ b/src/features/NextFreeOffset.cpp @@ -3,6 +3,7 @@ #include #include #include +#include using namespace geode::prelude; diff --git a/src/utils/NextFreeOffsetInput.hpp b/src/utils/NextFreeOffsetInput.hpp index 98cca40..dc26ce2 100644 --- a/src/utils/NextFreeOffsetInput.hpp +++ b/src/utils/NextFreeOffsetInput.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include