Skip to content

Commit

Permalink
simplify utilities + fix Z layer input being clickthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Sep 23, 2024
1 parent 3597779 commit e1095c9
Show file tree
Hide file tree
Showing 25 changed files with 321 additions and 451 deletions.
5 changes: 4 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# BetterEdit 6

## v6.8.0-beta.2
* Fix being able to place objects through the Z layer input

## v6.8.0-beta.1
* Release candidate
* Release candidate; minor internal fixes & UI tweaks

## v6.8.0-alpha.7
* Add <cg>Scale Snapping</c>
Expand Down
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"geode": "3.7.1",
"version": "6.8.0-beta.1",
"version": "6.8.0-beta.2",
"gd": {
"win": "2.206",
"mac": "2.206",
Expand Down
2 changes: 1 addition & 1 deletion src/features/GridScaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <Geode/binding/CCMenuItemSpriteExtra.hpp>
#include <Geode/binding/LevelEditorLayer.hpp>
#include <Geode/ui/TextInput.hpp>
#include <utils/HandleUIHide.hpp>
#include <utils/Editor.hpp>

using namespace geode::prelude;

Expand Down
2 changes: 1 addition & 1 deletion src/features/HideUIButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <Geode/binding/CCMenuItemToggler.hpp>
#include <Geode/binding/LevelEditorLayer.hpp>
#include <Geode/ui/BasedButtonSprite.hpp>
#include <utils/HandleUIHide.hpp>
#include <utils/Editor.hpp>

using namespace geode::prelude;

Expand Down
34 changes: 5 additions & 29 deletions src/features/ImprovedScaleAndRotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@

using namespace geode::prelude;

// i hate touch prioi hate touch prioi hate touch prioi hate touch prioi hate
// touch prioi hate touch prioi hate touch prioi hate touch prioi hate touch
// aka fix that will make you audibly say "kill yourself"
class $modify(SuperExtraEvenMoreForcePrioUI, EditorUI) {
struct Fields {
std::unordered_set<CCTextInputNode*> forceTouchPrio;
};

$override
bool ccTouchBegan(CCTouch* touch, CCEvent* event) {
for (auto input : m_fields->forceTouchPrio) {
if (input->isVisible() && CCRect(
input->getPosition() - input->getScaledContentSize() / 2,
input->getScaledContentSize()
).containsPoint(input->getParent()->convertTouchToNodeSpace(touch))) {
return input->ccTouchBegan(touch, event);
}
}
return EditorUI::ccTouchBegan(touch, event);
}
};

// Returns radians
static float angleOfPointOnCircle(CCPoint const& point) {
return atan2f(point.y, point.x) * (180.f / std::numbers::pi_v<float>);
Expand Down Expand Up @@ -170,10 +148,9 @@ class $modify(GJScaleControl) {
this->updateInput(this->getInputY());
this->updateInput(this->getInputXY());

auto ui = static_cast<SuperExtraEvenMoreForcePrioUI*>(m_delegate);
ui->m_fields->forceTouchPrio.insert(this->getInputX()->getInputNode());
ui->m_fields->forceTouchPrio.insert(this->getInputY()->getInputNode());
ui->m_fields->forceTouchPrio.insert(this->getInputXY()->getInputNode());
be::evilForceTouchPrio(static_cast<EditorUI*>(m_delegate), this->getInputX()->getInputNode());
be::evilForceTouchPrio(static_cast<EditorUI*>(m_delegate), this->getInputY()->getInputNode());
be::evilForceTouchPrio(static_cast<EditorUI*>(m_delegate), this->getInputXY()->getInputNode());
}
$override
void updateLabelX(float scale) {
Expand Down Expand Up @@ -376,8 +353,7 @@ class $modify(InputRotationControl, GJRotationControl) {
this->setThumbValue(angle);
this->getInput()->setString(numToString(angle, 3));

auto ui = static_cast<SuperExtraEvenMoreForcePrioUI*>(m_delegate);
ui->m_fields->forceTouchPrio.insert(this->getInput()->getInputNode());
be::evilForceTouchPrio(static_cast<EditorUI*>(m_delegate), this->getInput()->getInputNode());
}

float getThumbValue() const {
Expand Down Expand Up @@ -412,7 +388,7 @@ class $modify(EditorUI) {
$override
void activateRotationControl(CCObject* sender) {
EditorUI::activateRotationControl(sender);
static_cast<InputRotationControl*>(m_rotationControl)->myLoadValues(::getSelectedObjects(this));
static_cast<InputRotationControl*>(m_rotationControl)->myLoadValues(be::getSelectedObjects(this));
}
// Make angleChanged be absolute rotation instead of relative
$override
Expand Down
2 changes: 1 addition & 1 deletion src/features/Keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include <geode.custom-keybinds/include/Keybinds.hpp>
#include <Geode/modify/EditorUI.hpp>
#include <utils/EditCommandExt.hpp>
#include <Geode/binding/EditButtonBar.hpp>
#include <utils/Editor.hpp>
#include <utils/HolyUB.hpp>
#include "GridScaling.hpp"

Expand Down
3 changes: 1 addition & 2 deletions src/features/MoveMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include <Geode/binding/CCMenuItemSpriteExtra.hpp>
#include <Geode/binding/GameManager.hpp>
#include <Geode/utils/cocos.hpp>
#include <utils/EditCommandExt.hpp>
#include <utils/HandleUIHide.hpp>
#include <utils/Editor.hpp>
#include <utils/Pro.hpp>

using namespace geode::prelude;
Expand Down
6 changes: 4 additions & 2 deletions src/features/TypeInZLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <Geode/binding/CCMenuItemSpriteExtra.hpp>
#include <Geode/binding/LevelEditorLayer.hpp>
#include <Geode/binding/GameManager.hpp>
#include <utils/HandleUIHide.hpp>
#include <utils/Editor.hpp>
#include <utils/Pro.hpp>

using namespace geode::prelude;
Expand Down Expand Up @@ -52,7 +52,7 @@ class $modify(TypeInUI, EditorUI) {

layerMenu->updateLayout();

m_currentLayerLabel = EditableBMLabelProxy::replace(
auto proxy = EditableBMLabelProxy::replace(
m_currentLayerLabel, this, 40.f, "Z",
[this](auto str) {
m_editorLayer->m_currentLayer = numFromString<int>(str).unwrapOr(-1);
Expand All @@ -61,6 +61,8 @@ class $modify(TypeInUI, EditorUI) {
this->updateLockBtn();
}
);
m_currentLayerLabel = proxy;
be::evilForceTouchPrio(this, proxy->getInput()->getInputNode());

// Delete the existing layer lock button that's just an overlay on the text
if (auto lock = this->getChildByIDRecursive("lock-layer-button")) {
Expand Down
2 changes: 1 addition & 1 deletion src/features/ViewTab/ViewTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <Geode/binding/GameManager.hpp>
#include <Geode/utils/cocos.hpp>
#include <geode.custom-keybinds/include/Keybinds.hpp>
#include <utils/HandleUIHide.hpp>
#include <utils/Editor.hpp>
#include <utils/HolyUB.hpp>

using namespace geode::prelude;
Expand Down
4 changes: 2 additions & 2 deletions src/features/backups/BackupItem.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "BackupItem.hpp"
#include "BackupListPopup.hpp"
#include <fmt/chrono.h>
#include <utils/EditorViewOnlyMode.hpp>
#include <utils/Editor.hpp>
#include <Geode/ui/BasedButtonSprite.hpp>
#include <Geode/binding/EditLevelLayer.hpp>

Expand Down Expand Up @@ -99,7 +99,7 @@ void BackupItem::onConvertAutomated(CCObject*) {
}
void BackupItem::onView(CCObject*) {
auto scene = CCScene::create();
scene->addChild(createViewOnlyEditor(m_backup->getLevel(), [level = m_backup->getOriginalLevel()]() {
scene->addChild(be::createViewOnlyEditor(m_backup->getLevel(), [level = m_backup->getOriginalLevel()]() {
auto layer = EditLevelLayer::create(level);
auto popup = BackupListPopup::create(level);
popup->m_scene = layer;
Expand Down
6 changes: 3 additions & 3 deletions src/features/backups/QuickSave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <cvolton.level-id-api/include/EditorIDs.hpp>
#include <hjfod.gmd-api/include/GMD.hpp>
#include <utils/HolyUB.hpp>
#include <utils/EditorViewOnlyMode.hpp>
#include <utils/Editor.hpp>

using namespace geode::prelude;

Expand Down Expand Up @@ -70,7 +70,7 @@ class $modify(EditorPauseLayer) {

$override
void FLAlert_Clicked(FLAlertLayer* fl, bool btn2) {
if (isViewOnlyEditor(m_editorLayer)) {
if (be::isViewOnlyEditor(m_editorLayer)) {
return EditorPauseLayer::FLAlert_Clicked(fl, btn2);
}

Expand All @@ -88,7 +88,7 @@ class $modify(EditorPauseLayer) {

$override
void onExitNoSave(CCObject* sender) {
if (isViewOnlyEditor(m_editorLayer)) {
if (be::isViewOnlyEditor(m_editorLayer)) {
return EditorPauseLayer::onExitNoSave(sender);
}

Expand Down
31 changes: 0 additions & 31 deletions src/utils/EditCommandExt.cpp

This file was deleted.

22 changes: 0 additions & 22 deletions src/utils/EditCommandExt.hpp

This file was deleted.

4 changes: 4 additions & 0 deletions src/utils/EditableBMLabelProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,7 @@ void EditableBMLabelProxy::textChanged(CCTextInputNode*) {
m_ignoreLabelUpdate = false;
}
}

TextInput* EditableBMLabelProxy::getInput() const {
return m_input;
}
2 changes: 2 additions & 0 deletions src/utils/EditableBMLabelProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ class EditableBMLabelProxy : public CCLabelBMFont, TextInputDelegate {
void setString(const char* str, bool needUpdateLabel) override;

void textChanged(CCTextInputNode*) override;

TextInput* getInput() const;
};
Loading

0 comments on commit e1095c9

Please sign in to comment.