From 53e01fd94e21e7d43423ee36b077dab0053e8905 Mon Sep 17 00:00:00 2001 From: mat <26722564+matcool@users.noreply.github.com> Date: Thu, 4 Jan 2024 09:57:56 -0300 Subject: [PATCH] remove completely unused internal nodes --- loader/CMakeLists.txt | 2 - loader/src/ui/internal/dev/HookListLayer.cpp | 27 ---- loader/src/ui/internal/dev/HookListLayer.hpp | 13 -- loader/src/ui/internal/dev/HookListView.cpp | 135 ------------------ loader/src/ui/internal/dev/HookListView.hpp | 46 ------ loader/src/ui/internal/dev/HotReloadLayer.cpp | 45 ------ loader/src/ui/internal/dev/HotReloadLayer.hpp | 14 -- loader/src/ui/internal/info/ModInfoPopup.cpp | 1 - 8 files changed, 283 deletions(-) delete mode 100644 loader/src/ui/internal/dev/HookListLayer.cpp delete mode 100644 loader/src/ui/internal/dev/HookListLayer.hpp delete mode 100644 loader/src/ui/internal/dev/HookListView.cpp delete mode 100644 loader/src/ui/internal/dev/HookListView.hpp delete mode 100644 loader/src/ui/internal/dev/HotReloadLayer.cpp delete mode 100644 loader/src/ui/internal/dev/HotReloadLayer.hpp diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index fd0d9f50..97677541 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -53,8 +53,6 @@ file(GLOB SOURCES CONFIGURE_DEPENDS src/ui/*.cpp src/ui/nodes/*.cpp src/ui/internal/*.cpp - src/ui/internal/credits/*.cpp - src/ui/internal/dev/*.cpp src/ui/internal/info/*.cpp src/ui/internal/list/*.cpp src/ui/internal/settings/*.cpp diff --git a/loader/src/ui/internal/dev/HookListLayer.cpp b/loader/src/ui/internal/dev/HookListLayer.cpp deleted file mode 100644 index 1ad7c51c..00000000 --- a/loader/src/ui/internal/dev/HookListLayer.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "HookListLayer.hpp" - -#include - -bool HookListLayer::init(Mod* mod) { - if (!GJDropDownLayer::init("Hooks", 220.f)) return false; - - auto winSize = CCDirector::sharedDirector()->getWinSize(); - auto hooks = CCArray::create(); - for (auto const& hook : mod->getHooks()) { - hooks->addObject(new HookItem(hook)); - } - m_listLayer->m_listView = HookListView::create(hooks, mod, 356.f, 220.f); - m_listLayer->addChild(m_listLayer->m_listView); - - return true; -} - -HookListLayer* HookListLayer::create(Mod* mod) { - auto ret = new HookListLayer; - if (ret && ret->init(mod)) { - ret->autorelease(); - return ret; - } - CC_SAFE_DELETE(ret); - return nullptr; -} diff --git a/loader/src/ui/internal/dev/HookListLayer.hpp b/loader/src/ui/internal/dev/HookListLayer.hpp deleted file mode 100644 index 8959e98c..00000000 --- a/loader/src/ui/internal/dev/HookListLayer.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include "HookListView.hpp" - -#include - -class HookListLayer : public GJDropDownLayer { -protected: - bool init(Mod* mod); - -public: - static HookListLayer* create(Mod* mod); -}; diff --git a/loader/src/ui/internal/dev/HookListView.cpp b/loader/src/ui/internal/dev/HookListView.cpp deleted file mode 100644 index 9704c716..00000000 --- a/loader/src/ui/internal/dev/HookListView.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "HookListView.hpp" - -#include -#include -#include -#include -#include -#include - -HookCell::HookCell(char const* name, CCSize size) : TableViewCell(name, size.width, size.height) {} - -void HookCell::draw() { - reinterpret_cast(this)->StatsCell::draw(); -} - -void HookCell::updateBGColor(int index) { - if (index & 1) m_backgroundLayer->setColor(ccc3(0xc2, 0x72, 0x3e)); - else m_backgroundLayer->setColor(ccc3(0xa1, 0x58, 0x2c)); - m_backgroundLayer->setOpacity(0xff); -} - -void HookCell::onEnable(CCObject* pSender) { - auto toggle = as(pSender); - if (!toggle->isToggled()) { - auto res = m_mod->enableHook(m_hook); - if (!res) { - FLAlertLayer::create( - nullptr, "Error Enabling Hook", std::string(res.unwrapErr()), "OK", nullptr, 280.f - ) - ->show(); - } - } - else { - auto res = m_mod->disableHook(m_hook); - if (!res) { - FLAlertLayer::create( - nullptr, "Error Disabling Hook", std::string(res.unwrapErr()), "OK", nullptr, 280.f - ) - ->show(); - } - } - toggle->toggle(!m_hook->isEnabled()); -} - -void HookCell::loadFromHook(Hook* hook, Mod* Mod) { - m_hook = hook; - m_mod = Mod; - - m_mainLayer->setVisible(true); - m_backgroundLayer->setOpacity(255); - - auto menu = CCMenu::create(); - menu->setPosition(m_width - m_height, m_height / 2); - m_mainLayer->addChild(menu); - - auto enableBtn = - CCMenuItemToggler::createWithStandardSprites(this, menu_selector(HookCell::onEnable), .6f); - enableBtn->setPosition(0, 0); - enableBtn->toggle(hook->isEnabled()); - menu->addChild(enableBtn); - - std::stringstream moduleName; - - // #ifdef GEODE_IS_WINDOWS // add other platforms? - // HMODULE module; - // if (GetModuleHandleExA( - // GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | - // GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - // as(hook->getAddress()), - // &module - // )) { - // addr -= as(module); - // char name[MAX_PATH]; - // if (GetModuleFileNameA( - // module, name, sizeof name - // )) { - // auto fileName = std::filesystem::path(name).stem(); - // moduleName << fileName.string() << " + "; - // } - // } - // #endif - if (hook->getDisplayName() != "") moduleName << hook->getDisplayName(); - else moduleName << "0x" << std::hex << hook->getAddress(); - auto label = CCLabelBMFont::create(moduleName.str().c_str(), "chatFont.fnt"); - label->setPosition(m_height / 2, m_height / 2); - label->setScale(.7f); - label->setAnchorPoint({ .0f, .5f }); - m_mainLayer->addChild(label); -} - -HookCell* HookCell::create(char const* key, CCSize size) { - auto pRet = new HookCell(key, size); - if (pRet) { - return pRet; - } - CC_SAFE_DELETE(pRet); - return nullptr; -} - -void HookListView::setupList(float) { - m_itemSeparation = 30.0f; - - if (!m_entries->count()) return; - - m_tableView->reloadData(); - - if (m_entries->count() == 1) - m_tableView->moveToTopWithOffset(m_itemSeparation); - - m_tableView->moveToTop(); -} - -TableViewCell* HookListView::getListCell(char const* key) { - return HookCell::create(key, CCSize { m_width, m_itemSeparation }); -} - -void HookListView::loadCell(TableViewCell* cell, int index) { - as(cell)->loadFromHook( - as(m_entries->objectAtIndex(index))->m_hook, m_mod - ); - as(cell)->updateBGColor(index); -} - -HookListView* HookListView::create(CCArray* hooks, Mod* Mod, float width, float height) { - auto pRet = new HookListView; - if (pRet) { - pRet->m_mod = Mod; - if (pRet->init(hooks, kBoomListType_Hooks, width, height)) { - pRet->autorelease(); - return pRet; - } - } - CC_SAFE_DELETE(pRet); - return nullptr; -} diff --git a/loader/src/ui/internal/dev/HookListView.hpp b/loader/src/ui/internal/dev/HookListView.hpp deleted file mode 100644 index adbc2149..00000000 --- a/loader/src/ui/internal/dev/HookListView.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include -#include - -using namespace geode::prelude; - -static constexpr const BoomListType kBoomListType_Hooks = static_cast(0x358); - -struct HookItem : public CCObject { - Hook* m_hook; - - HookItem(Hook* h) : m_hook(h) { - this->autorelease(); - } -}; - -class HookCell : public TableViewCell { -protected: - Mod* m_mod; - Hook* m_hook; - - HookCell(char const* name, CCSize size); - - void draw() override; - - void onEnable(CCObject*); - -public: - void updateBGColor(int index); - void loadFromHook(Hook*, Mod*); - - static HookCell* create(char const* key, CCSize size); -}; - -class HookListView : public CustomListView { -protected: - Mod* m_mod; - - void setupList(float) override; - TableViewCell* getListCell(char const* key) override; - void loadCell(TableViewCell* cell, int index) override; - -public: - static HookListView* create(CCArray* hooks, Mod* Mod, float width, float height); -}; diff --git a/loader/src/ui/internal/dev/HotReloadLayer.cpp b/loader/src/ui/internal/dev/HotReloadLayer.cpp deleted file mode 100644 index 066d2db4..00000000 --- a/loader/src/ui/internal/dev/HotReloadLayer.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "HotReloadLayer.hpp" - -bool HotReloadLayer::init(std::string const& name) { - if (!CCLayer::init()) return false; - - auto winSize = CCDirector::sharedDirector()->getWinSize(); - - auto bg = CCSprite::create("GJ_gradientBG.png"); - auto bgSize = bg->getTextureRect().size; - - bg->setAnchorPoint({ 0.0f, 0.0f }); - bg->setScaleX((winSize.width + 10.0f) / bgSize.width); - bg->setScaleY((winSize.height + 10.0f) / bgSize.height); - bg->setPosition({ -5.0f, -5.0f }); - bg->setColor({ 0, 102, 255 }); - - this->addChild(bg); - - std::string text = "Reloading " + name + "..."; - auto label = CCLabelBMFont::create(text.c_str(), "bigFont.fnt"); - label->setPosition(this->getContentSize() / 2); - label->setZOrder(1); - label->setScale(.5f); - this->addChild(label); - - return true; -} - -HotReloadLayer* HotReloadLayer::create(std::string const& name) { - auto ret = new HotReloadLayer; - if (ret && ret->init(name)) { - ret->autorelease(); - return ret; - } - CC_SAFE_DELETE(ret); - return nullptr; -} - -HotReloadLayer* HotReloadLayer::scene(std::string const& name) { - auto scene = CCScene::create(); - auto layer = HotReloadLayer::create(name); - scene->addChild(layer); - CCDirector::sharedDirector()->replaceScene(scene); - return layer; -} diff --git a/loader/src/ui/internal/dev/HotReloadLayer.hpp b/loader/src/ui/internal/dev/HotReloadLayer.hpp deleted file mode 100644 index 737e65d1..00000000 --- a/loader/src/ui/internal/dev/HotReloadLayer.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -using namespace geode::prelude; - -class HotReloadLayer : public CCLayer { -protected: - bool init(std::string const& name); - -public: - static HotReloadLayer* create(std::string const& name); - static HotReloadLayer* scene(std::string const& name); -}; diff --git a/loader/src/ui/internal/info/ModInfoPopup.cpp b/loader/src/ui/internal/info/ModInfoPopup.cpp index 06883a6b..489bb3de 100644 --- a/loader/src/ui/internal/info/ModInfoPopup.cpp +++ b/loader/src/ui/internal/info/ModInfoPopup.cpp @@ -1,6 +1,5 @@ #include "ModInfoPopup.hpp" -#include "../dev/HookListLayer.hpp" #include "../list/ModListLayer.hpp" #include "../settings/ModSettingsPopup.hpp" #include