2022-08-01 11:18:03 -04:00
|
|
|
#pragma once
|
|
|
|
|
2022-10-23 10:54:42 -04:00
|
|
|
#include "../DefaultInclude.hpp"
|
2022-10-30 14:59:20 -04:00
|
|
|
|
2022-10-23 10:54:42 -04:00
|
|
|
#include <cocos2d.h>
|
2024-10-30 14:28:41 -04:00
|
|
|
#include <vector>
|
|
|
|
#include <span>
|
|
|
|
#include <Geode/utils/cocos.hpp>
|
2022-08-01 11:18:03 -04:00
|
|
|
|
|
|
|
namespace geode {
|
2024-06-20 16:00:04 -04:00
|
|
|
class GEODE_DLL SceneManager final {
|
2022-08-01 11:18:03 -04:00
|
|
|
protected:
|
2024-10-30 14:28:41 -04:00
|
|
|
std::vector<Ref<cocos2d::CCNode>> m_persistedNodes;
|
2023-10-11 15:16:12 -04:00
|
|
|
cocos2d::CCScene* m_lastScene = nullptr;
|
2022-08-01 11:18:03 -04:00
|
|
|
|
|
|
|
virtual ~SceneManager();
|
|
|
|
|
|
|
|
public:
|
|
|
|
static SceneManager* get();
|
|
|
|
|
2024-10-30 14:28:41 -04:00
|
|
|
/**
|
|
|
|
* Adds a node to the list of persisted nodes, which are kept across scene changes.
|
|
|
|
* @param node The node to keep across scenes.
|
|
|
|
*/
|
2022-08-01 11:18:03 -04:00
|
|
|
void keepAcrossScenes(cocos2d::CCNode* node);
|
2024-10-30 14:28:41 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a node from the list of persisted nodes.
|
|
|
|
* @param node The node to forget.
|
|
|
|
*/
|
2022-08-01 11:18:03 -04:00
|
|
|
void forget(cocos2d::CCNode* node);
|
|
|
|
|
2024-10-30 14:28:41 -04:00
|
|
|
/**
|
|
|
|
* Gets a span of the persisted nodes. To add new nodes to the list, use keepAcrossScenes.
|
|
|
|
*/
|
|
|
|
std::span<Ref<cocos2d::CCNode> const> getPersistedNodes();
|
|
|
|
|
|
|
|
// This method should only be called by geode itself
|
|
|
|
// TODO(v4): hide this
|
2022-08-01 11:18:03 -04:00
|
|
|
void willSwitchToScene(cocos2d::CCScene* scene);
|
|
|
|
};
|
|
|
|
}
|