Skip to content

Commit

Permalink
move settings to a dedicated About popup
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Feb 10, 2024
1 parent 4afaee4 commit 682c720
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 32 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ file(GLOB SOURCES
src/features/*.cpp
src/features/scaling/*.cpp
src/features/ZoomLevelText/*.cpp
src/features/about/*.cpp
src/utils/*.cpp
src/*.cpp
)
Expand Down
7 changes: 7 additions & 0 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
"platforms": ["windows"]
}
],
"resources": {
"spritesheets": {
"UISheet": [
"resources/*.png"
]
}
},
"settings": {
"mouse-move-on-zoom": {
"type": "bool",
Expand Down
Binary file added resources/be-button-base.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/be-button-top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/be-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 0 additions & 32 deletions src/features/BESettingsButton.cpp

This file was deleted.

78 changes: 78 additions & 0 deletions src/features/about/AboutBEButton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

#include <Geode/modify/EditorPauseLayer.hpp>
#include <Geode/ui/BasedButtonSprite.hpp>
#include "AboutBEPopup.hpp"

using namespace geode::prelude;

class $modify(AboutBEPauseLayer, EditorPauseLayer) {
$override
bool init(LevelEditorLayer* lel) {
if (!EditorPauseLayer::init(lel))
return false;

auto menu = this->getChildByID("guidelines-menu");

auto spr = CCSprite::createWithSpriteFrameName("be-button.png"_spr);
spr->setScale(.92f);
auto btn = CCMenuItemSpriteExtra::create(
spr, this, menu_selector(AboutBEPauseLayer::onAbout)
);
btn->setID("about"_spr);
menu->addChild(btn);
menu->updateLayout();

if (!Mod::get()->template getSavedValue<bool>("highlighted-be-button")) {
auto overlay = CCLayerColor::create({ 0, 0, 0, 150 });
overlay->setOpacity(0);
overlay->runAction(CCFadeTo::create(.25f, 185));
overlay->setZOrder(500);
overlay->setID("be-highlight-overlay"_spr);
this->addChild(overlay);

btn->setPosition(btn->getParent()->convertToWorldSpace(btn->getPosition()));
{
auto ref = Ref(btn);
btn->removeFromParent();
overlay->addChild(btn);
}

btn->runAction(CCSequence::create(
CCDelayTime::create(.1f),
CCEaseElasticOut::create(CCScaleTo::create(.75f, 2.f), 2.f),
CCTintTo::create(.15f, 0, 155, 255),
CCTintTo::create(.15f, 255, 255, 255),
CCDelayTime::create(.1f),
CCTintTo::create(.15f, 0, 155, 255),
CCTintTo::create(.15f, 255, 255, 255),
CCEaseElasticIn::create(CCScaleTo::create(.75f, .92f), 2.f),
CCCallFunc::create(this, callfunc_selector(AboutBEPauseLayer::markButtonAsHighlighted)),
nullptr
));
}

return true;
}

void markButtonAsHighlighted() {
Mod::get()->setSavedValue("highlighted-be-button", true);
auto overlay = this->getChildByID("be-highlight-overlay"_spr);
{
auto btn = overlay->getChildByID("about"_spr);
auto menu = this->getChildByID("guidelines-menu");
auto ref = Ref(btn);
btn->removeFromParent();
menu->addChild(btn);
menu->updateLayout();
}
overlay->runAction(CCSequence::create(
CCFadeTo::create(.25f, 0),
CCRemoveSelf::create(),
nullptr
));
}

void onAbout(CCObject*) {
AboutBEPopup::create()->show();
}
};
105 changes: 105 additions & 0 deletions src/features/about/AboutBEPopup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include "AboutBEPopup.hpp"
#include <Geode/ui/GeodeUI.hpp>

bool AboutBEPopup::setup() {
m_noElasticity = true;

this->setTitle("About BetterEdit");

auto cornerBL = CCSprite::createWithSpriteFrameName("dailyLevelCorner_001.png");
m_mainLayer->addChildAtPosition(cornerBL, Anchor::BottomLeft, ccp(25, 25));

auto cornerBR = CCSprite::createWithSpriteFrameName("dailyLevelCorner_001.png");
cornerBR->setFlipX(true);
m_mainLayer->addChildAtPosition(cornerBR, Anchor::BottomRight, ccp(-25, 25));

auto cornerTL = CCSprite::createWithSpriteFrameName("rewardCorner_001.png");
cornerTL->setFlipY(true);
m_mainLayer->addChildAtPosition(cornerTL, Anchor::TopLeft, ccp(25, -25));

auto cornerTR = CCSprite::createWithSpriteFrameName("rewardCorner_001.png");
cornerTR->setFlipY(true);
cornerTR->setFlipX(true);
m_mainLayer->addChildAtPosition(cornerTR, Anchor::TopRight, ccp(-25, -25));

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

auto hjfod = CCLabelBMFont::create("HJfod", "bigFont.fnt");
hjfod->setScale(.65f);
m_mainLayer->addChildAtPosition(hjfod, Anchor::Center, ccp(0, 40));

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

auto devs = CCNode::create();
devs->setContentSize({ 300.f, 90.f });
devs->setAnchorPoint({ .5f, .5f });
for (auto dev : { "ninXout", "TheSillyDoggo", "Fleym" }) {
auto label = CCLabelBMFont::create(dev, "bigFont.fnt");
label->setLayoutOptions(AxisLayoutOptions::create()->setMaxScale(.45f));
devs->addChild(label);
}
devs->setLayout(
RowLayout::create()
->setCrossAxisOverflow(true)
->setGap(50.f)
);
m_mainLayer->addChildAtPosition(devs, Anchor::Center, ccp(0, -25));

auto supportSpr = ButtonSprite::create("Support BE!", "goldFont.fnt", "GJ_button_05.png");
supportSpr->setScale(.8f);
auto supportBtn = CCMenuItemSpriteExtra::create(
supportSpr, this, menu_selector(AboutBEPopup::onSupport)
);
m_buttonMenu->addChildAtPosition(supportBtn, Anchor::Center, ccp(0, -85));

auto spr = CCSprite::createWithSpriteFrameName("GJ_optionsBtn02_001.png");
auto btn = CCMenuItemSpriteExtra::create(
spr, this, menu_selector(AboutBEPopup::onSettings)
);
btn->setID("settings"_spr);
m_buttonMenu->addChildAtPosition(btn, Anchor::TopRight, ccp(-3, -3));

return true;
}

void AboutBEPopup::onSupport(CCObject*) {
createQuickPopup(
"Support BetterEdit",
"BetterEdit is first and foremost <cy>a passion project</c>, "
"but if you would like to support development, <cg>I have a Ko-fi</c>!\n\n"
"I'm also planning on making a <cb>Pro version</c> in the future with some "
"cool extra features :)\n\n"
"However, please <cr>don't donate just for the purpose of getting Pro</c>! "
"While I fully do intend to make it, I know from past experience that "
"something might come in the way, and <cr>I do not want to receive money "
"for a product until I can guarantee it exists</c>.",
"Cancel", "Open Ko-fi",
400.f,
[](auto layer, bool btn2) {
if (btn2) {
web::openLinkInBrowser("https://ko-fi.com/hjfod");
}
}
);

// todo: on next Geode release, just use this instead
// openSupportPopup(Mod::get());
}

void AboutBEPopup::onSettings(CCObject*) {
openSettingsPopup(Mod::get());
}

AboutBEPopup* AboutBEPopup::create() {
auto ret = new AboutBEPopup();
if (ret && ret->initAnchored(358.f, 250.f, "GJ_square02.png")) {
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
return nullptr;
}
17 changes: 17 additions & 0 deletions src/features/about/AboutBEPopup.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <Geode/DefaultInclude.hpp>
#include <Geode/ui/Popup.hpp>

using namespace geode::prelude;

class AboutBEPopup : public Popup<> {
protected:
bool setup() override;

public:
static AboutBEPopup* create();

void onSettings(CCObject*);
void onSupport(CCObject*);
};
12 changes: 12 additions & 0 deletions support.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

BetterEdit is first and foremost <cy>a passion project</c>, but if you would like to support development, I have a Ko-fi!

[Link to my Ko-fi](https://ko-fi.com/hjfod)

I'm also planning on making a <cb>paid Pro version</c> in the future with some cool extra features :)

However, please <cr>don't donate just for the purpose of getting Pro</c>! While I fully intended to make it, I know from past experience that something might come in the way, and <cr>I do not want to receive money for a product until I can guarantee it exists</c>.

## <cy>Do not donate any money you need yourself</c>.

I don't want starving students to give me their last pennies! Take care of yourself first!

0 comments on commit 682c720

Please sign in to comment.