Skip to content

Commit

Permalink
fixed? video
Browse files Browse the repository at this point in the history
  • Loading branch information
0mgRod committed Jul 13, 2024
1 parent e7d8510 commit 1a06006
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 11 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.1.0

- Added Ko-fi promo video

# v2.0.0

- Removed Creator Points error messages - check console for errors
Expand Down
10 changes: 10 additions & 0 deletions src/GPVideoPlayer/VideoPlayer.hpp → include/VideoPlayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ namespace videoplayer {
*/
void setWidth(float width);

/**
* @brief Sets the position of the video player, maintaining aspect ratio
*
* @param x The X position of the video player
*
* @param y The Y position of the video player
*/

void setPosition(float x, float y);

/**
* @brief Modifies the content size of the video player to fit a given size, maintaining aspect ratio
*
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": "v2.0.0",
"version": "v2.1.0",
"gd": {
"win": "2.206",
"android": "2.206"
Expand Down
File renamed without changes.
Binary file removed res/videos/kofiPromo.mp4
Binary file not shown.
Binary file added res/videos/kofiPromo.mpg
Binary file not shown.
75 changes: 75 additions & 0 deletions src/GPKofiLayer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#pragma once

#include <chrono>
#include <iostream>
#include <Geode/Geode.hpp>
#include <Geode/modify/GJGarageLayer.hpp>
#include <Geode/binding/GJGarageLayer.hpp>
#include <Geode/utils/web.hpp>
#include <Geode/ui/GeodeUI.hpp>
#include <Geode/ui/Notification.hpp>

#include "VideoPlayer.hpp"

using namespace geode::prelude;

class GPKofiLayer : public CCLayer {
public:
struct Fields {
EventListener<web::WebTask> m_listener;
};

virtual void KeyBackClicked() {
CCDirector::get()->popScene();
}

static CCScene* garageScene() {
auto scene = CCScene::create();
scene->addChild(GJGarageLayer::scene());
return scene;
}

static CCScene* scene() {
auto scene = CCScene::create();
scene->addChild(GPKofiLayer::create());
return scene;
}

static GPKofiLayer* create() {
GPKofiLayer* ret = new GPKofiLayer();
if (ret && ret->init()) {
ret->autorelease();
return ret;
}
delete ret;
return nullptr;
}

bool init() {
if (!CCLayer::init())
return false;

setKeypadEnabled(true);

auto winSize = CCDirector::sharedDirector()->getWinSize();
auto menu = CCMenu::create();

// geode::utils::web::openLinkInBrowser("https://ko-fi.com/omgrod");
std::filesystem::path videoPath = Mod::get()->getResourcesDir() / "kofiPromo.mpg";

// Create a VideoPlayer instance
auto player = videoplayer::VideoPlayer::create(videoPath, true);

player->setWidth(0.7 * winSize.width);

player->setPosition(winSize.width * 0.5, winSize.height * 0.5);

this->addChild(player);

this->addChild(menu);
return true;
}

private:
geode::EventListener<web::WebTask> m_listener;
};
15 changes: 6 additions & 9 deletions src/GPSceneManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <Geode/ui/Notification.hpp>

#include "GPShopsLayer.hpp"
#include "GPVideoPlayer/VideoPlayer.hpp"
#include "GPKofiLayer.hpp"

using namespace geode::prelude;

Expand Down Expand Up @@ -51,6 +51,11 @@ class GPSceneManager : public CCLayer
return true;
}

void onKofiBtn(CCObject* sender) {
auto scenePrev = CCTransitionFade::create(0.5f, GPKofiLayer::scene());
CCDirector::sharedDirector()->replaceScene(scenePrev);
}

void onModSettings(CCObject* sender)
{
openSettingsPopup(Mod::get());
Expand All @@ -68,14 +73,6 @@ class GPSceneManager : public CCLayer
CCDirector::sharedDirector()->replaceScene(scenePrev);
}

void onKofiBtn(CCObject* sender) {
// geode::utils::web::openLinkInBrowser("https://ko-fi.com/omgrod");
std::filesystem::path videoPath = Mod::get()->getResourcesDir() / "kofiPromo.mp4";

// Create a VideoPlayer instance
auto player = videoplayer::VideoPlayer::create(videoPath, true);
}

void demonInfo(CCObject* sender)
{
FLAlertLayer::create("Garage Plus", "This feature may or may not be coming soon", "OK")->show();
Expand Down
5 changes: 5 additions & 0 deletions src/GPVideoPlayer/VideoPlayer.cpp → src/VideoPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ namespace videoplayer {
setContentSize({width, width / m_dimensions.aspect()});
}

void VideoPlayer::setPosition(float x, float y) {
setPositionX(x);
setPositionY(y);
}

void VideoPlayer::fillSize(CCSize size) {
if (m_dimensions.aspect() > size.aspect()) {
setWidth(size.width);
Expand Down
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#include "GPFeedbackLayer.hpp"
#include "GPSceneManager.hpp"
#include "GPShopsLayer.hpp"
#include "GPVideoPlayer/VideoPlayer.hpp"
#include "GPKofiLayer.hpp"
#include "VideoPlayer.hpp"

using namespace geode::prelude;

Expand Down

0 comments on commit 1a06006

Please sign in to comment.