mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-15 22:44:42 -04:00
remove SafeCreate for being pointless
This commit is contained in:
parent
c1b5a16e27
commit
ef55605b5b
2 changed files with 9 additions and 55 deletions
loader
|
@ -405,53 +405,6 @@ namespace geode::cocos {
|
|||
return node ? node : T::create(args...);
|
||||
}
|
||||
|
||||
template <class T = cocos2d::CCNode>
|
||||
struct SafeCreate final {
|
||||
T* result;
|
||||
|
||||
SafeCreate<T>& with(T* node) {
|
||||
result = node;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
SafeCreate<T>& make(Args... args) {
|
||||
result = T::create(args...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// convenience for CCSprite
|
||||
template <class... Args>
|
||||
SafeCreate<T>& makeWithFrame(Args... args) {
|
||||
result = T::createWithSpriteFrameName(args...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
SafeCreate<T>& makeUsing(T* (*func)(Args...), Args... args) {
|
||||
result = func(args...);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class O = T, class... Args>
|
||||
T* orMakeUsing(O* (*func)(Args...), Args... args) {
|
||||
if (result) return result;
|
||||
return func(args...);
|
||||
}
|
||||
|
||||
template <class O = T, class... Args>
|
||||
T* orMake(Args... args) {
|
||||
if (result) return result;
|
||||
return O::create(args...);
|
||||
}
|
||||
|
||||
template <class O = T, class... Args>
|
||||
T* orMakeWithFrame(Args... args) {
|
||||
if (result) return result;
|
||||
return O::createWithSpriteFrameName(args...);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get bounds for a set of nodes. Based on content
|
||||
* size
|
||||
|
|
|
@ -55,14 +55,15 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
|
|||
|
||||
// add geode button
|
||||
|
||||
m_fields->m_geodeButton = SafeCreate<CCSprite>()
|
||||
.with(CircleButtonSprite::createWithSpriteFrameName(
|
||||
"geode-logo-outline-gold.png"_spr,
|
||||
1.0f,
|
||||
CircleBaseColor::Green,
|
||||
CircleBaseSize::Medium2
|
||||
))
|
||||
.orMake<ButtonSprite>("!!");
|
||||
m_fields->m_geodeButton = CircleButtonSprite::createWithSpriteFrameName(
|
||||
"geode-logo-outline-gold.png"_spr,
|
||||
1.0f,
|
||||
CircleBaseColor::Green,
|
||||
CircleBaseSize::Medium2
|
||||
);
|
||||
if (!m_fields->m_geodeButton) {
|
||||
m_fields->m_geodeButton = ButtonSprite::create("!!");
|
||||
}
|
||||
|
||||
auto bottomMenu = static_cast<CCMenu*>(this->getChildByID("bottom-menu"));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue