Skip to content

Commit

Permalink
some pro stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Jul 19, 2024
1 parent dd6f5c2 commit 9f60da1
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 37 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode)

setup_geode_mod(${PROJECT_NAME})

target_compile_definitions(${PROJECT_NAME} PUBLIC "BETTEREDIT_VERSION_STR=${MOD_VERSION}")

# Bad code will NOT be deployed!
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
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.2.0",
"version": "6.6.5",
"version": "6.7.0",
"gd": {
"win": "2.206",
"mac": "2.206",
Expand Down
10 changes: 4 additions & 6 deletions src/features/Keybinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,11 @@ struct $modify(EditorUI) {
this->moveObjectCall(EditCommand::BigDown);
});

if (isProEnabled()) {
BE_PRO_FEATURE(
this->defineKeybind("group-summary"_spr, [this] {
#ifdef BETTEREDIT_PRO
GroupSummaryPopup::create()->show();
#endif
});
}
);

return true;
}
Expand Down Expand Up @@ -469,15 +467,15 @@ struct $modify(EditorUI) {
Category::EDITOR_MOVE, true
});

if (isProEnabled()) {
BE_PRO_FEATURE_GLOBAL(
BindManager::get()->registerBindable({
"group-summary"_spr,
"Open Group Summary",
"",
{},
Category::EDITOR, false
});
}
);
}

#endif
7 changes: 4 additions & 3 deletions src/features/MoveMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ class CustomEditMenu : public CCNode {
return nullptr;
}

if (isProUIEnabled()) {
return nullptr;
}
// todo: pro
// if (isProUIEnabled()) {
// return nullptr;
// }

if (create) {
auto winSize = CCDirector::get()->getWinSize();
Expand Down
7 changes: 4 additions & 3 deletions src/features/TypeInZLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ class $modify(TypeInUI, EditorUI) {
if (!EditorUI::init(lel))
return false;

if (isProUIEnabled()) {
return true;
}
// todo: pro
// if (isProUIEnabled()) {
// return true;
// }

auto layerMenu = this->getChildByID("layer-menu");
layerMenu->setContentSize({ 130, layerMenu->getContentSize().height });
Expand Down
7 changes: 7 additions & 0 deletions src/features/about/AboutBEButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <Geode/binding/GameToolbox.hpp>
#include "AboutBEPopup.hpp"
#include "SupportPopup.hpp"
#include <utils/Pro.hpp>

using namespace geode::prelude;

Expand Down Expand Up @@ -70,6 +71,12 @@ class $modify(AboutBEPauseLayer, EditorPauseLayer) {
topMenu->addChild(supportBtn);
topMenu->updateLayout();
}

BE_PRO_FEATURE(
if (auto btn = this->querySelector("support-be-btn"_spr)) {
btn->removeFromParent();
}
);
}

auto menu = this->getChildByID("guidelines-menu");
Expand Down
28 changes: 23 additions & 5 deletions src/features/about/AboutBEPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include <Geode/ui/MDTextArea.hpp>
#include <Geode/binding/ButtonSprite.hpp>
#include <Geode/utils/web.hpp>
#include <utils/Pro.hpp>

#ifdef BETTEREDIT_PRO
#include <pro/ui/SupportersPopup.hpp>
#endif

struct Dev {
const char* name;
Expand Down Expand Up @@ -51,7 +56,7 @@ bool AboutBEPopup::setup() {

auto developedBy = CCLabelBMFont::create("Developed by", "goldFont.fnt");
developedBy->setScale(.7f);
m_mainLayer->addChildAtPosition(developedBy, Anchor::Center, ccp(0, 85));
m_mainLayer->addChildAtPosition(developedBy, Anchor::Center, ccp(0, 90));

auto hjfod = Dev {
.name = "HJfod",
Expand All @@ -62,13 +67,13 @@ bool AboutBEPopup::setup() {
{ "geode.loader/gift.png", "https://ko-fi.com/hjfod" },
}
}.create(this, true);
m_mainLayer->addChildAtPosition(hjfod, Anchor::Center, ccp(0, 55));
m_mainLayer->addChildAtPosition(hjfod, Anchor::Center, ccp(0, 60));

// other devs

auto credits = CCLabelBMFont::create("Contributors", "goldFont.fnt");
credits->setScale(.6f);
m_mainLayer->addChildAtPosition(credits, Anchor::Center, ccp(0, 10));
m_mainLayer->addChildAtPosition(credits, Anchor::Center, ccp(0, 15));

auto devs = CCNode::create();
devs->setContentSize({ 325, 90 });
Expand Down Expand Up @@ -126,7 +131,7 @@ bool AboutBEPopup::setup() {
->setCrossAxisOverflow(true)
->setGap(20.f)
);
m_mainLayer->addChildAtPosition(devs, Anchor::Center, ccp(0, -20));
m_mainLayer->addChildAtPosition(devs, Anchor::Center, ccp(0, -15));

// actions

Expand All @@ -140,6 +145,7 @@ bool AboutBEPopup::setup() {
{ "Changelog", menu_selector(AboutBEPopup::onChangelog) },
{ "Special Thanks", menu_selector(AboutBEPopup::onSpecialThanks) },
{ "Support BE", menu_selector(AboutBEPopup::onSupport) },
{ "Supporters", menu_selector(AboutBEPopup::onSupporters) },
}) {
auto spr = ButtonSprite::create(pair.first, "goldFont.fnt", "GJ_button_05.png", .8f);
spr->setScale(.55f);
Expand All @@ -148,7 +154,14 @@ bool AboutBEPopup::setup() {
}

menu->setLayout(RowLayout::create()->setGrowCrossAxis(true));
m_mainLayer->addChildAtPosition(menu, Anchor::Center, ccp(0, -70));
m_mainLayer->addChildAtPosition(menu, Anchor::Center, ccp(0, -60));

BE_PRO_FEATURE(
auto label = CCLabelBMFont::create("Thank You for Supporting BetterEdit <3", "bigFont.fnt");
label->setColor({ 55, 255, 255 });
label->setScale(.35f);
m_mainLayer->addChildAtPosition(label, Anchor::Center, ccp(0, -95));
);

// BE links

Expand Down Expand Up @@ -188,6 +201,11 @@ void AboutBEPopup::onSupport(CCObject*) {
SupportPopup::create(false)->show();
// openSupportPopup(Mod::get());
}
void AboutBEPopup::onSupporters(CCObject*) {
#ifdef BETTEREDIT_PRO
pro::SupportersPopup::create()->show();
#endif
}

void AboutBEPopup::onSuggestFeature(CCObject*) {
createQuickPopup(
Expand Down
1 change: 1 addition & 0 deletions src/features/about/AboutBEPopup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class AboutBEPopup : public PopupWithCorners<> {
void onReportBug(CCObject*);
void onSuggestFeature(CCObject*);
void onSupport(CCObject*);
void onSupporters(CCObject*);
void onChangelog(CCObject*);
void onSpecialThanks(CCObject*);
void onDevLink(CCObject* sender);
Expand Down
8 changes: 1 addition & 7 deletions src/features/scaling/EditorUIScaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class $modify(ScaledUI, EditorUI) {
if (!EditorUI::init(p0))
return false;

if (isProUIEnabled()) {
return true;
}
// todo: pro compatability

float scale = Mod::get()->getSettingValue<double>("scale-factor");
auto size = CCDirector::get()->getWinSize();
Expand Down Expand Up @@ -158,10 +156,6 @@ class $modify(ScaledUI, EditorUI) {
}

void centerBuildTabs() {
if (isProUIEnabled()) {
return;
}

// This centers the build tab
auto winSize = CCDirector::get()->getWinSize();
for (auto c : CCArrayExt<CCNode*>(this->getChildren())) {
Expand Down
1 change: 0 additions & 1 deletion src/utils/NextFreeOffsetInput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class NextFreeOffsetInput : public CCNode {
m_input->setString(numToString(s_value));
}
m_input->setCallback([](auto str) {
log::info("hi: {}", str);
if (auto value = numFromString<ValueType>(str)) {
s_value = clamp(value.unwrap(), Source::MIN_VALUE, Source::MAX_VALUE);
}
Expand Down
28 changes: 17 additions & 11 deletions src/utils/Pro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@
BE_ALLOW_START
BE_ALLOW_UNUSED_FUNCTION

static bool isProUIEnabled() {
#ifdef BETTEREDIT_PRO
return pro::isNewUIEnabled();
#else
return false;
#endif
}
static bool isProEnabled() {
#ifdef BETTEREDIT_PRO
return pro::isProEnabled();
#define BE_PRO_FEATURE(...) \
pro::checkProEnabled() \
.listen([this](auto* value) { \
if (pro::verifyPro<__LINE__>(*value) == (__LINE__ + pro::ssl::MAGIC_OK)) { \
__VA_ARGS__; \
} \
})

#define BE_PRO_FEATURE_GLOBAL(...) \
pro::checkProEnabled() \
.listen([](auto* value) { \
if (pro::verifyPro<__LINE__>(*value) == (__LINE__ + pro::ssl::MAGIC_OK)) { \
__VA_ARGS__; \
} \
})
#else
return false;
#define BE_PRO_FEATURE(...)
#define BE_PRO_FEATURE_GLOBAL(...)
#endif
}

BE_ALLOW_END

1 comment on commit 9f60da1

@DarkKingTurkey
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm It's like something is cooking

Please sign in to comment.