Skip to content

Commit

Permalink
cool new menu
Browse files Browse the repository at this point in the history
  • Loading branch information
LimeGradient committed Jun 21, 2024
1 parent 080a1ca commit 610fdbb
Show file tree
Hide file tree
Showing 26 changed files with 427 additions and 214 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project(ModProfiles VERSION 1.0.0)

file(GLOB_RECURSE SOURCES
src/*.cpp src/*.h
src/geode_impl/*.cpp src/geode_impl/*.h
)

include_directories(src)
Expand Down
2 changes: 1 addition & 1 deletion about.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Share your mod list with other people! This mod allows you to send your friend a file that will allow them to get all the mods you have installed.

This mod will require a internet connection to import profiles.
This mod requires an internet connection to import profiles.

For support, join the [Discord](https://discord.gg/44ANAhXz7r)

Expand Down
10 changes: 8 additions & 2 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "3.0.0-beta.1",
"geode": "3.0.0-beta.4",
"gd": {
"android": "2.206",
"win": "2.206",
Expand All @@ -11,8 +11,14 @@
"developer": "LimeGradient",
"description": "Share your mods with others!",
"resources": {
"spritesheets": {
"ModProfilesSheet": [
"resources/*.png",
"resources/geode/*.png"
]
},
"sprites": [
"resources/*.png"
"resources/geode/swelve/*.png"
]
}
}
Binary file added resources/geode/geode-bottom.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/geode/geode-side.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/geode/geode-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/geode/swelve/swelve-layer0.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/geode/swelve/swelve-layer1.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/geode/swelve/swelve-layer2.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/geode/swelve/swelve-layer3.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/geode/tab-bg.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 modified resources/mod-profiles-button.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/mod-profiles-profile-selection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions src/ExportModsLayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <Geode/Geode.hpp>

using namespace geode::prelude;

#include "ExportModsLayer.h"

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

auto director = CCDirector::sharedDirector();
auto winSize = director->getWinSize();

m_background = createLayerBG();
m_background->setID("mod-profiles-background");
this->addChild(m_background);

outline = CCSprite::createWithSpriteFrameName("mod-profiles-profile-selection.png"_spr);
this->addChild(outline);
outline->setPosition(winSize / 2);
outline->setZOrder(1);

return true;
}

ExportModsLayer* ExportModsLayer::create() {
auto ret = new ExportModsLayer();
if (ret && ret->init()) {
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
return nullptr;
}

CCScene* ExportModsLayer::scene() {
auto layer = ExportModsLayer::create();
auto scene = CCScene::create();
scene->addChild(layer);
return scene;
}
17 changes: 17 additions & 0 deletions src/ExportModsLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <Geode/Geode.hpp>

class ExportModsLayer : public cocos2d::CCLayer {
protected:
cocos2d::CCSprite* m_background;
ScrollLayer* scrollLayer = nullptr;

CCSprite* outline;

public:
static ExportModsLayer* create();
static cocos2d::CCScene* scene();
bool init();
void onClose();
};
Empty file removed src/ExportModsPopup.cpp
Empty file.
Empty file removed src/ExportModsPopup.h
Empty file.
125 changes: 125 additions & 0 deletions src/ModProfilesLayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
A lot (if not all) of the UI code is straight from Geode github
i wanted it to look as close as possible to the actual geode menu
https://github.com/geode-sdk/geode
*/

#include <Geode/Geode.hpp>
#include <Geode/utils/ColorProvider.hpp>

using namespace geode::prelude;

#include "ModProfilesLayer.h"
#include "geode_impl/GeodeTabSprite.h"
#include "geode_impl/SwelvyBG.h"

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

this->setID("ModProfilesLayer");

ColorProvider::get()->define("geode-bg"_spr, { 25, 17, 37, 255 });

auto director = CCDirector::sharedDirector();
auto winSize = director->getWinSize();

this->addChild(SwelvyBG::create());

CCSprite* backSpr = CCSprite::createWithSpriteFrameName("GJ_arrow_03_001.png");
CCMenuItemSpriteExtra* backBtn = CCMenuItemSpriteExtra::create(backSpr, this, menu_selector(ModProfilesLayer::onClose));
CCMenu* backMenu = CCMenu::create();
backMenu->addChild(backBtn);
backMenu->setContentWidth(100.f);
backMenu->setAnchorPoint({.0f, .5f});
backMenu->setLayout(
RowLayout::create()
->setAxisAlignment(AxisAlignment::Start)
);
backMenu->setZOrder(1);
this->addChildAtPosition(backMenu, Anchor::TopLeft, ccp(12, -25), false);

auto frame = CCNode::create();
frame->setID("mod-profiles-frame");
frame->setAnchorPoint({.5f, .5f});
frame->setContentSize({380, 205});

auto frameBG = CCLayerColor::create(ColorProvider::get()->color("geode-bg"_spr));
frameBG->setID("frame-bg");
frameBG->setContentSize(frame->getContentSize());
frameBG->ignoreAnchorPointForPosition(false);
frame->addChildAtPosition(frameBG, Anchor::Center);

auto tabsTop = CCSprite::createWithSpriteFrameName("geode-top.png"_spr);
tabsTop->setID("frame-top-sprite");
tabsTop->setAnchorPoint({ .5f, .0f });
frame->addChildAtPosition(tabsTop, Anchor::Top, ccp(0, -2));

auto tabsLeft = CCSprite::createWithSpriteFrameName("geode-side.png"_spr);
tabsLeft->setID("frame-left-sprite");
tabsLeft->setScaleY(frame->getContentHeight() / tabsLeft->getContentHeight());
frame->addChildAtPosition(tabsLeft, Anchor::Left, ccp(6, 0));

auto tabsRight = CCSprite::createWithSpriteFrameName("geode-side.png"_spr);
tabsRight->setID("frame-right-sprite");
tabsRight->setFlipX(true);
tabsRight->setScaleY(frame->getContentHeight() / tabsRight->getContentHeight());
frame->addChildAtPosition(tabsRight, Anchor::Right, ccp(-6, 0));

auto tabsBottom = CCSprite::createWithSpriteFrameName("geode-bottom.png"_spr);
tabsBottom->setID("frame-bottom-sprite");
tabsBottom->setAnchorPoint({ .5f, 1.f });
frame->addChildAtPosition(tabsBottom, Anchor::Bottom, ccp(0, 2));

this->addChildAtPosition(frame, Anchor::Center, ccp(0, -10), false);

auto mainTabs = CCMenu::create();
mainTabs->setID("tabs-menu");
mainTabs->setContentWidth(tabsTop->getContentWidth() - 45);
mainTabs->setAnchorPoint({ .5f, .0f });
mainTabs->setPosition(frame->convertToWorldSpace(tabsTop->getPosition() + ccp(0, 8)));
// Increment touch priority so the mods in the list don't override
mainTabs->setTouchPriority(-150);

for (auto item : std::initializer_list<std::tuple<const char*, const char*, const char*>> {
{ "GJ_shareBtn_001.png", "Export", "export-button" },
{ "GJ_downloadBtn_001.png", "Import", "import-button" },
{ "GJ_duplicateBtn_001.png", "Packs", "packs-button" },
{ "GJ_statsBtn_001.png", "Pack Index", "pack-index-button" }
}) {
auto btn = CCMenuItemSpriteExtra::create(
GeodeTabSprite::create(std::get<0>(item), std::get<1>(item), 120),
this, menu_selector(ModProfilesLayer::onClose)
);
btn->setID(std::get<2>(item));
mainTabs->addChild(btn);
}

mainTabs->setLayout(RowLayout::create());
this->addChild(mainTabs);

return true;
}

void ModProfilesLayer::onClose(CCObject*) {
auto mainMenu = MenuLayer::scene(false);
CCDirector::sharedDirector()->pushScene(CCTransitionFade::create(0.5f, mainMenu));
}

ModProfilesLayer* ModProfilesLayer::create() {
auto ret = new ModProfilesLayer();
if (ret && ret->init()) {
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
return nullptr;
}

CCScene* ModProfilesLayer::scene() {
auto layer = ModProfilesLayer::create();
auto scene = CCScene::create();
scene->addChild(layer);
return scene;
}
18 changes: 18 additions & 0 deletions src/ModProfilesLayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <Geode/Geode.hpp>
using namespace geode::prelude;

class ModProfilesLayer : public cocos2d::CCLayer {
protected:
cocos2d::CCSprite* m_background;
ScrollLayer* scrollLayer = nullptr;

CCSprite* outline;

public:
static ModProfilesLayer* create();
static cocos2d::CCScene* scene();
bool init();
void onClose(CCObject*);
};
Loading

0 comments on commit 610fdbb

Please sign in to comment.