Skip to content

Commit 92bc3cf

Browse files
committed
set all hook priorities to very early
1 parent 8aa8532 commit 92bc3cf

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

mod.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"geode": "5.0.0-beta.2",
2+
"geode": "5.1.0",
33
"gd": {
4-
"win": "2.2074",
5-
"android": "2.2074",
6-
"mac": "2.2074",
7-
"ios": "2.2074"
4+
"win": "2.2081",
5+
"android": "2.2081",
6+
"mac": "2.2081",
7+
"ios": "2.2081"
88
},
99
"id": "ninkaz.editor_sfx",
1010
"name": "NinKaz's Editor SFX",

src/gd_hooks.cpp

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
#include <Geode/Geode.hpp>
1616
using namespace geode::prelude;
1717

18+
// mods shouldn't be able to overwrite sfx, preferring sfx::suppress in the optional api
19+
// unless they REALLY want to,,,,,, (Priority::First)
20+
21+
#define SET_ALL_HOOK_PRIORITY \
22+
static void onModify(auto& self) { \
23+
for (const auto& [ _, hook ] : self.m_hooks) { \
24+
hook->setPriority(Priority::VeryEarlyPre); \
25+
} \
26+
}
27+
1828
class $modify(SFXEditorUI, EditorUI) {
1929
struct Fields {
2030
bool selectionChanged = true;
@@ -23,14 +33,7 @@ class $modify(SFXEditorUI, EditorUI) {
2333
float prevRotationAngle;
2434
};
2535

26-
static void onModify(auto& self) {
27-
if (!self.setHookPriorityBeforePre("EditorUI::angleChanged", "hjfod.betteredit")) {
28-
log::warn("Failed to set hook priority for EditorUI::angleChanged");
29-
}
30-
if (!self.setHookPriorityBeforePre("EditorUI::scrollWheel", "hjfod.betteredit")) {
31-
log::warn("Failed to set hook priority for EditorUI::scrollWheel");
32-
}
33-
}
36+
SET_ALL_HOOK_PRIORITY;
3437

3538
$override
3639
bool init(LevelEditorLayer* lel) {
@@ -513,6 +516,8 @@ class $modify(SFXEditorUI, EditorUI) {
513516
};
514517

515518
class $modify(SFXLevelEditorLayer, LevelEditorLayer) {
519+
SET_ALL_HOOK_PRIORITY;
520+
516521
$override
517522
GameObject* createObject(int p0, CCPoint p1, bool p2) {
518523
sfx::queue(EditorSFX::Place);
@@ -581,6 +586,8 @@ class $modify(SFXLevelEditorLayer, LevelEditorLayer) {
581586
};
582587

583588
class $modify(SFXEditButtonBar, EditButtonBar) {
589+
SET_ALL_HOOK_PRIORITY;
590+
584591
$override
585592
void onLeft(CCObject* sender) {
586593
EditButtonBar::onLeft(sender);
@@ -595,6 +602,8 @@ class $modify(SFXEditButtonBar, EditButtonBar) {
595602
};
596603

597604
class $modify(SFXGJScaleControl, GJScaleControl) {
605+
SET_ALL_HOOK_PRIORITY;
606+
598607
$override
599608
void onToggleLockScale(CCObject* sender) {
600609
GJScaleControl::onToggleLockScale(sender);
@@ -608,6 +617,8 @@ class $modify(SFXGJScaleControl, GJScaleControl) {
608617
};
609618

610619
class $modify(SFXGJTransformControl, GJTransformControl) {
620+
SET_ALL_HOOK_PRIORITY;
621+
611622
$override
612623
void onToggleLockScale(CCObject* sender) {
613624
GJTransformControl::onToggleLockScale(sender);
@@ -621,6 +632,8 @@ class $modify(SFXGJTransformControl, GJTransformControl) {
621632
};
622633

623634
class $modify(SFXCCLayerColor, CCLayerColor) {
635+
SET_ALL_HOOK_PRIORITY;
636+
624637
// plays sfx for top-level popups
625638
// hooks cclayercolor because some popups skip over flalertlayer init
626639

@@ -655,6 +668,8 @@ class $modify(SFXFMODAudioEngine, FMODAudioEngine) {
655668
bool shouldUnloadAllEffects = true;
656669
};
657670

671+
SET_ALL_HOOK_PRIORITY;
672+
658673
$override
659674
void unloadAllEffects() {
660675
if (m_fields->shouldUnloadAllEffects) {
@@ -664,6 +679,8 @@ class $modify(SFXFMODAudioEngine, FMODAudioEngine) {
664679
};
665680

666681
class $modify(SFXEditorPauseLayer, EditorPauseLayer) {
682+
SET_ALL_HOOK_PRIORITY;
683+
667684
bool init(LevelEditorLayer* p0) {
668685
if (!EditorPauseLayer::init(p0)) return false;
669686

@@ -680,6 +697,7 @@ class $modify(SFXEditorPauseLayer, EditorPauseLayer) {
680697

681698
return true;
682699
}
700+
683701
$override
684702
void onExitEditor(CCObject* sender) {
685703
static_cast<SFXEditorUI*>(EditorUI::get())->unschedule(schedule_selector(SFXEditorUI::updateSFX));
@@ -741,6 +759,8 @@ class $modify(SFXEditorPauseLayer, EditorPauseLayer) {
741759
};
742760

743761
class $modify(SFXEditLevelLayer, EditLevelLayer) {
762+
SET_ALL_HOOK_PRIORITY;
763+
744764
$override
745765
void onEdit(CCObject* sender) {
746766
// i don't use the queue system here because it would play the sound
@@ -759,6 +779,8 @@ class $modify(SFXEditLevelLayer, EditLevelLayer) {
759779
};
760780

761781
class $modify(SFXEndLevelLayer, EndLevelLayer) {
782+
SET_ALL_HOOK_PRIORITY;
783+
762784
$override
763785
void goEdit() {
764786
EndLevelLayer::goEdit();
@@ -770,6 +792,8 @@ class $modify(SFXEndLevelLayer, EndLevelLayer) {
770792
};
771793

772794
class $modify(SFXPauseLayer, PauseLayer) {
795+
SET_ALL_HOOK_PRIORITY;
796+
773797
$override
774798
void goEdit() {
775799
PauseLayer::goEdit();

0 commit comments

Comments
 (0)