Skip to content

Commit

Permalink
BEGONE INCOMPATS
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMario211 committed Sep 1, 2024
1 parent a4c649e commit dfa2ed2
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
- name: Windows
os: windows-latest

#- name: macOS
#os: macos-latest
- name: macOS
os: macos-latest

- name: Android32
os: ubuntu-latest
Expand Down
13 changes: 9 additions & 4 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"resources/*.png"
]
},
"links": {
"community": "https://discord.gg/XGBMVVvJ7J",
"source": "https://github.com/FireMario211/Object-Workshop"
},
"tags": ["online", "utility", "content", "editor", "interface"],
"settings": {
"enabled": {
"name": "Enabled",
Expand Down Expand Up @@ -48,13 +53,13 @@
},
"dependencies": [
{
"id": "geode.node-ids",
"version": ">=v1.13.1",
"id": "fig.authentication",
"version": ">=v1.0.1",
"importance": "required"
},
{
"id": "fig.authentication",
"version": ">=v1.0.1",
"id": "alphalaneous.editortab_api",
"version": ">=v1.0.0-alpha.19",
"importance": "required"
}
]
Expand Down
66 changes: 44 additions & 22 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using namespace geode::prelude;
#include "ui/AuthMenu.hpp"
#include "config.hpp"
#include <fig.authentication/include/authentication.hpp>
#include <alphalaneous.editortab_api/include/EditorTabs.hpp>

// 13 = custom objects
void CustomObjects::setupCustomMenu(EditButtonBar* bar, bool hideItems) {
Expand All @@ -24,6 +25,8 @@ void CustomObjects::setupCustomMenu(EditButtonBar* bar, bool hideItems) {
m_fields->customObjsLabel = CCMenuItemSpriteExtra::create(label, this, menu_selector(CustomObjects::onBackLbl));
menu->addChildAtPosition(m_fields->customObjsLabel, Anchor::Top, {0, -9});

menu->setPositionX(0);

m_fields->myObjsLabel = CCLabelBMFont::create("• My Objects", "bigFont.fnt");
m_fields->myObjsLabel->setScale(0.4F);
m_fields->myObjsLabel->setVisible(false);
Expand Down Expand Up @@ -154,35 +157,21 @@ void CustomObjects::setupCustomMenu(EditButtonBar* bar, bool hideItems) {
m_fields->m_listener.setFilter(req.post(fmt::format("{}/user/@me", HOST_URL)));
}
}

void CustomObjects::setupCreateMenu() {
EditorUI::setupCreateMenu();
if (auto bar = getChildOfType<EditButtonBar>(this, 13)) {
//if (auto bar = typeinfo_cast<EditButtonBar*>(getChildByID("custom-tab-bar"))) {
CustomObjects::setupCustomMenu(bar, false);
}
}
void CustomObjects::reloadCustomItems() { // rebuild it!
EditorUI::reloadCustomItems();
if (auto bar = typeinfo_cast<EditButtonBar*>(getChildByID("custom-tab-bar"))) {
CustomObjects::setupCustomMenu(bar, true);
}
}
void CustomObjects::onBackLbl(CCObject*) {
if (auto bar = typeinfo_cast<EditButtonBar*>(getChildByID("custom-tab-bar"))) {
if (auto boomlist = getChildOfType<BoomScrollLayer>(bar, 0)) {
//if (auto bar = typeinfo_cast<EditButtonBar*>(getChildByID("custom-tab-bar"))) {
if (auto boomlist = getChildOfType<BoomScrollLayer>(m_fields->m_customBar, 0)) {
boomlist->setVisible(false);
}
if (m_fields->oldChildrenCount >= 2) {
if (auto menu = getChildOfType<CCMenu>(bar, 0)) {
if (auto menu = getChildOfType<CCMenu>(m_fields->m_customBar, 0)) {
menu->setVisible(false);
}
}
m_fields->btn1->setVisible(true);
m_fields->btn2->setVisible(true);
m_fields->myObjsLabel->setVisible(false);
m_fields->customObjsLabel->updateAnchoredPosition(Anchor::Top, {0, -9});
}
//}
}
void CustomObjects::onWorkshop(CCObject*) {
int authServer = Mod::get()->getSettingValue<int64_t>("auth-server");
Expand Down Expand Up @@ -219,18 +208,18 @@ void CustomObjects::onWorkshop(CCObject*) {
}
}
void CustomObjects::onMyObjects(CCObject*) {
if (auto bar = typeinfo_cast<EditButtonBar*>(getChildByID("custom-tab-bar"))) {
if (auto boomlist = getChildOfType<BoomScrollLayer>(bar, 0)) {
//if (auto bar = typeinfo_cast<EditButtonBar*>(getChildByID("custom-tab-bar"))) {
if (auto boomlist = getChildOfType<BoomScrollLayer>(m_fields->m_customBar, 0)) {
boomlist->setVisible(true);
}
if (auto menu = getChildOfType<CCMenu>(bar, 0)) {
if (auto menu = getChildOfType<CCMenu>(m_fields->m_customBar, 0)) {
menu->setVisible(true);
}
m_fields->btn1->setVisible(false);
m_fields->btn2->setVisible(false);
m_fields->myObjsLabel->setVisible(true);
m_fields->customObjsLabel->updateAnchoredPosition(Anchor::Top, {-44, -9});
}
//}
}

/*
Expand All @@ -249,3 +238,36 @@ class $modify(LevelEditorLayer) {
}
};
*/

bool CustomObjects::init(LevelEditorLayer* editorLayer) {
if (!EditorUI::init(editorLayer)) return false;
EditorTabs::addTab(this, TabType::BUILD, "workshop"_spr, [this](EditorUI* ui, CCMenuItemToggler* toggler) -> CCNode* { //create the tab
auto arr = ui->createCustomItems();
auto folder = CCSprite::createWithSpriteFrameName("gj_folderBtn_001.png");
arr->removeLastObject();
arr->removeLastObject();
arr->removeLastObject();
arr->removeLastObject();
folder->setScale(0.4F);
auto label = CCLabelBMFont::create("C+", "bigFont.fnt");
label->setScale(0.4F);
folder->addChildAtPosition(label, Anchor::Center);
CCLabelBMFont* textLabelOn = CCLabelBMFont::create("C+", "bigFont.fnt");
textLabelOn->setScale(0.4f);
CCLabelBMFont* textLabelOff = CCLabelBMFont::create("C+", "bigFont.fnt");
textLabelOff->setScale(0.4f);

EditorTabUtils::setTabIcons(toggler, folder, folder);

auto bar = EditorTabUtils::createEditButtonBar(arr, ui);
m_fields->m_customBar = bar;
return bar;
}, [this](EditorUI* ui, bool state, CCNode*) { //toggled the tab (activates on every tab click)
if (state && !m_fields->m_hasMade) {
m_fields->m_hasMade = true;
CustomObjects::setupCustomMenu(m_fields->m_customBar, false);
}
});

return true;
}
6 changes: 4 additions & 2 deletions src/ui/ObjectWorkshop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ struct CustomObjects : Modify<CustomObjects, EditorUI> {
std::string currentObjString;
EventListener<web::WebTask> m_listener;
bool hasCheckedUploads;

bool m_hasMade = false;
EditButtonBar* m_customBar;
};
bool init(LevelEditorLayer* editorLayer);
void setupCustomMenu(EditButtonBar* bar, bool hideItems);
void setupCreateMenu();
void reloadCustomItems();
void onBackLbl(CCObject*);
void onWorkshop(CCObject*);
void onMyObjects(CCObject*);
Expand Down

0 comments on commit dfa2ed2

Please sign in to comment.