Skip to content

Commit

Permalink
added more previews + preview downloading works :D
Browse files Browse the repository at this point in the history
  • Loading branch information
OmgRod committed Jan 24, 2025
1 parent 17a8241 commit 58a8752
Show file tree
Hide file tree
Showing 19 changed files with 98 additions and 25 deletions.
2 changes: 1 addition & 1 deletion about.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ Please create an [issue](https://github.com/OmgRod/Geodify/issues) on GitHub for
- Lead Developer: OmgRod
- Developers: OmgRod, Viper
- Alpha's Geode Utils: Alphalaneous
- Logo: hiimjustin000 and OmgRod
- Logo: hiimjasmine00 and OmgRod
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# v2.0.1

- Bugfix: BetterAchievements background didn't change
- Added Layers: `minemaker0430.gddp_integration/DPSearchLayer`, `minemaker0430.gddp_integration/RecommendedLayer`, `minemaker0430.gddp_integration/RouletteSafeLayer`
- Geodify layer previews
- justin0 lost credit -> jasmine thanks for making mod logo

# v2.0.0

Expand All @@ -11,7 +14,6 @@
- Bugfix: [Icon Ninja stuff (thanks undefined0 :D)](https://github.com/OmgRod/Geodify/issues/14)
- Changed color offset to change [each individual wave](https://github.com/OmgRod/Geodify/issues/13)
- Switched from External Hook API to Alpha's Geode Utils
- ~~Geodify layer previews~~ (delayed to v2.1.0)

```
Setting keys were changed. What does this mean?
Expand Down
22 changes: 20 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@
"default": true
},
"limegradient.betterachievements/BetterAchievementLayer": {
"name": "BetterAchivementLayer",
"description": "BetterAchivementLayer",
"name": "BetterAchievementLayer",
"description": "BetterAchievementLayer",
"type": "bool",
"default": true
},
Expand All @@ -315,6 +315,24 @@
"type": "bool",
"default": true
},
"minemaker0430.gddp_integration/DPSearchLayer": {
"name": "DPSearchLayer",
"description": "DPSearchLayer",
"type": "bool",
"default": true
},
"minemaker0430.gddp_integration/RecommendedLayer": {
"name": "RecommendedLayer",
"description": "RecommendedLayer",
"type": "bool",
"default": true
},
"minemaker0430.gddp_integration/RouletteSafeLayer": {
"name": "RouletteSafeLayer",
"description": "RouletteSafeLayer",
"type": "bool",
"default": true
},
"omgrod.garage_plus/GPFeedbackLayer": {
"name": "GPFeedbackLayer",
"description": "GPFeedbackLayer",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 52 additions & 20 deletions src/layers/GYScreenshotPopup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <Geode/Geode.hpp>
#include <Geode/modify/FLAlertLayer.hpp>
#include <Geode/utils/web.hpp>
#include <string>

#include "../Tags.hpp"
Expand All @@ -10,6 +11,10 @@ using namespace geode::prelude;

class GYScreenshotPopup : public geode::Popup<int const&> {
protected:
EventListener<web::WebTask> m_downloadListener;
Ref<CCImage> m_image;
CCSprite* m_sprite;

bool setup(int const& layer) override {
Tags tags;
auto layerName = tags.getStringFromTag(layer);
Expand All @@ -31,32 +36,58 @@ class GYScreenshotPopup : public geode::Popup<int const&> {
m_mainLayer->setContentSize({ winSize.width * 0.6f, winSize.height * 0.7f });
m_mainLayer->updateLayout();

/*auto sprite = CCSprite::createWithSpriteFrameName(fmt::format("{}Preview.png"_spr, layerName).c_str());
if (!sprite) {
log::error("Sprite not found for frame: {}", fmt::format("{}Preview.png", layerName));
return false;
}
// Construct URL for the raw GitHub image
std::string URL = fmt::format("https://raw.githubusercontent.com/OmgRod/Geodify/master/previews/{}Preview.png", layerName);

auto req = web::WebRequest();
m_downloadListener.bind([this](web::WebTask::Event* e) {
if (auto res = e->getValue()) {
if (!res->ok()) {
log::error("Failed to download image from URL.");
onDownloadFail();
} else {
auto data = res->data();
std::thread imageThread = std::thread([data, this]() {
m_image = new CCImage();
m_image->autorelease();
m_image->initWithImageData(const_cast<uint8_t*>(data.data()), data.size());
geode::Loader::get()->queueInMainThread([this]() {
imageCreationFinished(m_image);
});
});
imageThread.detach();
}
}
});
m_downloadListener.setFilter(req.get(URL));

log::debug("Loading sprite: {}", fmt::format("omgrod.geodify/{}Preview.png", layerName));
auto maxWidth = m_mainLayer->getContentSize().width * 0.75f;
auto maxHeight = m_mainLayer->getContentSize().height * 0.75f;
return true;
}

auto spriteWidth = sprite->getContentSize().width;
auto spriteHeight = sprite->getContentSize().height;
void imageCreationFinished(CCImage* image) {
CCTexture2D* texture = new CCTexture2D();
texture->autorelease();
texture->initWithImage(image);

float scale = std::min(maxWidth / spriteWidth, maxHeight / spriteHeight);
sprite->setScale(scale);
m_sprite = CCSprite::createWithTexture(texture);
if (m_sprite) {
auto maxWidth = m_mainLayer->getContentSize().width * 0.75f;
auto maxHeight = m_mainLayer->getContentSize().height * 0.75f;

m_mainLayer->addChildAtPosition(sprite, Anchor::Center);*/
auto spriteWidth = m_sprite->getContentSize().width;
auto spriteHeight = m_sprite->getContentSize().height;

auto warning = CCLabelBMFont::create("This feature is not yet implemented. Check back later.", "bigFont.fnt");
warning->setPosition({ winSize.width * .3f, winSize.height * .35f });
warning->setScale(0.3f);
float scale = std::min(maxWidth / spriteWidth, maxHeight / spriteHeight);
m_sprite->setScale(scale);

m_mainLayer->addChild(warning);
m_mainLayer->addChildAtPosition(m_sprite, Anchor::Center);
}
}

return true;
void onDownloadFail() {
// Handle failure if the image could not be downloaded
CCSprite* fallbackSprite = CCSprite::create("noPreview.png"_spr);
m_mainLayer->addChildAtPosition(fallbackSprite, Anchor::Center);
}

public:
Expand All @@ -67,6 +98,7 @@ class GYScreenshotPopup : public geode::Popup<int const&> {
}
return input;
}

static GYScreenshotPopup* create(int const& text) {
auto ret = new GYScreenshotPopup();
auto winSize = CCDirector::sharedDirector()->getWinSize();
Expand All @@ -78,4 +110,4 @@ class GYScreenshotPopup : public geode::Popup<int const&> {
delete ret;
return nullptr;
}
};
};
7 changes: 7 additions & 0 deletions src/modify/minemaker0430.gddp_integration/DPSearchLayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <Geode/Geode.hpp>
#include "../../SwelvyBG.hpp"
#include <alphalaneous.alphas_geode_utils/include/NodeModding.h>

using namespace geode::prelude;

SET_SWELVY(DPSearchLayer, "minemaker0430.gddp_integration/DPSearchLayer", "bg");
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <Geode/Geode.hpp>
#include "../../SwelvyBG.hpp"
#include <alphalaneous.alphas_geode_utils/include/NodeModding.h>

using namespace geode::prelude;

SET_SWELVY(RecommendedLayer, "minemaker0430.gddp_integration/RecommendedLayer", "bg");
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <Geode/Geode.hpp>
#include "../../SwelvyBG.hpp"
#include <alphalaneous.alphas_geode_utils/include/NodeModding.h>

using namespace geode::prelude;

SET_SWELVY(RouletteSafeLayer, "minemaker0430.gddp_integration/RouletteSafeLayer", "bg");
2 changes: 1 addition & 1 deletion src/modify/uproxide.textures/TextureWorkshopLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

using namespace geode::prelude;

SET_SWELVY_SPRITE(TextureWorkshopLayer, "uproxide.textures/TextureWorkshopLayer");
SET_SWELVY(TextureWorkshopLayer, "uproxide.textures/TextureWorkshopLayer", "background");

0 comments on commit 58a8752

Please sign in to comment.