Skip to content

Commit

Permalink
add a whole bunch of new keybinds (fix #355, fix #255, fix #175, fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jul 6, 2024
1 parent 8fa9f89 commit 716d39e
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 29 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v6.6.0
* Add keybinds for <cj>Save Level</c>, <co>Build Helper</c>, <cp>Align X</c>, <ca>Align Y</c>, <cb>Edit Object</c>, <co>Edit Group</c>, <cj>Edit Special</c>, <cr>Copy Values</c>, <cg>Paste State</c>, <cy>Paste Color</c>, and <cl>Toggle Link Controls</c>

## v6.5.0
* Add support for <cy>2.206</c>
* Add <cp>Quick Save</c> feature that significantly improves level saving speeds
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.1.1",
"version": "6.5.0",
"geode": "3.2.0",
"version": "6.6.0",
"gd": {
"win": "2.206",
"mac": "2.206",
Expand Down
138 changes: 131 additions & 7 deletions src/features/Keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,53 @@ struct $modify(EditorUI) {
this->activateScaleControl(scaleBtn);
}
});
this->defineKeybind("toggle-link-controls"_spr, [this]() {
GameManager::get()->toggleGameVariable("0097");
m_editorLayer->updateOptions();
});
this->defineKeybind("show-ui"_spr, [this]() {
this->showUI(true);
});
this->defineKeybind("hide-ui"_spr, [this]() {
this->showUI(false);
});

this->defineKeybind("open-edit-object"_spr, [this]() {
this->editObject(nullptr);
});
this->defineKeybind("open-edit-group"_spr, [this]() {
this->editGroup(nullptr);
});
this->defineKeybind("open-edit-special"_spr, [this]() {
this->editObject2(nullptr);
});
this->defineKeybind("copy-values"_spr, [this]() {
this->onCopyState(nullptr);
});
this->defineKeybind("paste-state"_spr, [this]() {
this->onPasteState(nullptr);
});
this->defineKeybind("paste-color"_spr, [this]() {
this->onPasteColor(nullptr);
});

this->defineKeybind("save-level"_spr, [this]() {
if (m_editorLayer->m_playbackMode != PlaybackMode::Not) {
this->onStopPlaytest(nullptr);
}
fakeEditorPauseLayer(m_editorLayer)->saveLevel();
Notification::create("Level saved", NotificationIcon::Success)->show();
});

this->defineKeybind("build-helper"_spr, [this]() {
fakeEditorPauseLayer(m_editorLayer)->onBuildHelper(nullptr);
});
this->defineKeybind("align-x"_spr, [this]() {
fakeEditorPauseLayer(m_editorLayer)->onAlignX(nullptr);
});
this->defineKeybind("align-y"_spr, [this]() {
fakeEditorPauseLayer(m_editorLayer)->onAlignY(nullptr);
});
this->defineKeybind("select-all"_spr, [this]() {
fakeEditorPauseLayer(m_editorLayer)->onSelectAll(nullptr);
});
Expand All @@ -47,6 +88,7 @@ struct $modify(EditorUI) {
this->defineKeybind("select-all-right"_spr, [this]() {
fakeEditorPauseLayer(m_editorLayer)->onSelectAllRight(nullptr);
});

this->defineKeybind("move-obj-half-left"_spr, [this] {
this->moveObjectCall(EditCommand::HalfLeft);
});
Expand Down Expand Up @@ -131,6 +173,95 @@ struct $modify(EditorUI) {
{},
Category::EDITOR_MODIFY
));
BindManager::get()->registerBindable(BindableAction(
"show-scale"_spr,
"Show Scale Control",
"Show the object scaling controls",
{},
Category::EDITOR_UI
));

BindManager::get()->registerBindable(BindableAction(
"save-level"_spr,
"Save Level",
"",
{},
Category::EDITOR_MODIFY
));
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
));
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
));
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
));
BindManager::get()->registerBindable(BindableAction(
"toggle-link-controls"_spr,
"Toggle Link Controls",
"",
{},
Category::EDITOR_UI
));

BindManager::get()->registerBindable(BindableAction(
"open-edit-object"_spr,
"Edit Object",
"Open the <cb>Edit Object</c> popup for the selected objects",
{},
Category::EDITOR_MODIFY
));
BindManager::get()->registerBindable(BindableAction(
"open-edit-group"_spr,
"Edit Group",
"Open the <co>Edit Group</c> popup for the selected objects",
{},
Category::EDITOR_MODIFY
));
BindManager::get()->registerBindable(BindableAction(
"open-edit-special"_spr,
"Edit Special",
"Open the <cj>Edit Special</c> popup for the selected objects",
{},
Category::EDITOR_MODIFY
));
BindManager::get()->registerBindable(BindableAction(
"copy-values"_spr,
"Copy Values",
"",
{},
Category::EDITOR_MODIFY
));
BindManager::get()->registerBindable(BindableAction(
"paste-state"_spr,
"Paste State",
"",
{},
Category::EDITOR_MODIFY
));
BindManager::get()->registerBindable(BindableAction(
"paste-color"_spr,
"Paste Color",
"",
{},
Category::EDITOR_MODIFY
));

BindManager::get()->registerBindable(BindableAction(
"select-all"_spr,
Expand All @@ -154,13 +285,6 @@ struct $modify(EditorUI) {
Category::EDITOR_MODIFY
));

BindManager::get()->registerBindable(BindableAction(
"show-scale"_spr,
"Show Scale Control",
"Show the object scaling controls",
{},
Category::EDITOR_UI
));
// todo: toggle UI
BindManager::get()->registerBindable(BindableAction(
"show-ui"_spr,
Expand Down
23 changes: 3 additions & 20 deletions src/features/about/ShowChangelogOnStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,9 @@ class $modify(LevelEditorLayer) {
if (!LevelEditorLayer::init(level, idk))
return false;

if (auto available = Mod::get()->hasAvailableUpdate()) {
auto popup = createQuickPopup(
"Update Available!",
fmt::format(
"<cy>BetterEdit</c> has a new update <ca>{}</c> available!\n\n"
"Visit the <cb>Geode mods list</c> to install it",
available.value()
),
"OK", "Update",
[](auto, bool btn2) {
if (btn2) {
openInfoPopup(Mod::get());
}
},
false
);
popup->m_scene = this;
popup->show();
}

// We don't really need to check for updates on startup anymore, since
// Geode is now really good at it by itself

// Check if new updates have been installed
auto lastShown = Mod::get()->template getSavedValue<VersionInfo>("last-shown-changelog");
if (lastShown < Mod::get()->getVersion()) {
Expand Down

0 comments on commit 716d39e

Please sign in to comment.