Skip to content

Commit

Permalink
new stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jul 15, 2024
1 parent caf5d5a commit b78aded
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 35 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# BetterEdit 6

## v6.6.4
* Add keybinds for <cp>Increase Grid Size</c> and <cg>Decrease Grid Size</c>
* Increase the hardcoded limits of <ca>Button Rows</c> and <cy>Buttons Per Row</c> to 12 and 48 respectively
* Bump <cb>Custom Keybinds</c> version to add support for assigning mouse side buttons to keybinds

## v6.6.3
* Add a <co>Support</c> button to the pause menu (that can be hidden through the popup)
* Add <ca>Developer Mode</c> setting
Expand Down
4 changes: 2 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "3.2.0",
"version": "6.6.3",
"version": "6.6.4",
"gd": {
"win": "2.206",
"mac": "2.206",
Expand All @@ -24,7 +24,7 @@
},
{
"id": "geode.custom-keybinds",
"version": "1.6.2",
"version": "1.7.1",
"importance": "required",
"platforms": ["win"]
},
Expand Down
20 changes: 20 additions & 0 deletions src/features/ButtonRowsBypass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <Geode/modify/EditorOptionsLayer.hpp>

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());
}
};
40 changes: 25 additions & 15 deletions src/features/GridScaling.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "GridScaling.hpp"
#include <Geode/modify/EditorUI.hpp>
#include <Geode/modify/ObjectToolbox.hpp>
#include <Geode/ui/TextInput.hpp>
Expand Down Expand Up @@ -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<float>("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
Expand All @@ -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<float>("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<GridUI*>(ui)->updateGridConstSize(value);
}
void incrementGridSize(EditorUI* ui) {
auto value = Mod::get()->template getSavedValue<float>("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<GridUI*>(ui)->updateGridConstSize(value);
}

#endif
8 changes: 8 additions & 0 deletions src/features/GridScaling.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include <Geode/binding/EditorUI.hpp>

using namespace geode::prelude;

void decrementGridSize(EditorUI* ui);
void incrementGridSize(EditorUI* ui);
79 changes: 61 additions & 18 deletions src/features/Keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <utils/EditCommandExt.hpp>
#include <Geode/binding/EditButtonBar.hpp>
#include <utils/HolyUB.hpp>
#include "GridScaling.hpp"

#include <utils/Pro.hpp>
#ifdef BETTEREDIT_PRO
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -184,118 +192,151 @@ 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(
"save-level"_spr,
"Save Level",
"",
{},
Category::EDITOR_MODIFY
Category::EDITOR_MODIFY,
false
));
BindManager::get()->registerBindable(BindableAction(
"build-helper"_spr,
"Build Helper",
"Executes the <cy>Build Helper</c> 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,
"Align X",
"Executes the <cy>Align X</c> 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,
"Align Y",
"Executes the <cy>Align Y</c> 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(
"open-edit-object"_spr,
"Edit Object",
"Open the <cb>Edit Object</c> popup for the selected objects",
{},
Category::EDITOR_MODIFY
Category::EDITOR_MODIFY,
false
));
BindManager::get()->registerBindable(BindableAction(
"open-edit-group"_spr,
"Edit Group",
"Open the <co>Edit Group</c> popup for the selected objects",
{},
Category::EDITOR_MODIFY
Category::EDITOR_MODIFY,
false
));
BindManager::get()->registerBindable(BindableAction(
"open-edit-special"_spr,
"Edit Special",
"Open the <cj>Edit Special</c> 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(
"select-all"_spr,
"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
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/features/NextFreeOffset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <utils/NextFreeOffsetInput.hpp>
#include <utils/Warn.hpp>
#include <Geode/binding/GameObject.hpp>
#include <Geode/binding/EffectGameObject.hpp>

using namespace geode::prelude;

Expand Down
1 change: 1 addition & 0 deletions src/utils/NextFreeOffsetInput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Geode/binding/LevelEditorLayer.hpp>
#include <Geode/binding/TextInputDelegate.hpp>
#include <Geode/utils/general.hpp>
#include <Geode/utils/cocos.hpp>
#include <Geode/ui/TextInput.hpp>
#include <span>

Expand Down

0 comments on commit b78aded

Please sign in to comment.