i forgot to add the LayerBG header

This commit is contained in:
HJfod 2022-10-16 21:37:18 +03:00
parent a38743d01d
commit 0a1b5c9281
2 changed files with 31 additions and 0 deletions
loader
include/Geode/ui
src/ui/nodes

View file

@ -0,0 +1,13 @@
#pragma once
#include <Geode/DefaultInclude.hpp>
#include <cocos2d.h>
namespace geode {
/**
* Creates the usual blue gradient BG for a layer. You should use this over
* creating the sprite manually, as in the future we may provide texture
* packs the ability to override this function.
*/
GEODE_DLL cocos2d::CCSprite* createLayerBG();
}

View file

@ -0,0 +1,18 @@
#include <Geode/ui/LayerBG.hpp>
USE_GEODE_NAMESPACE();
CCSprite* geode::createLayerBG() {
auto winSize = CCDirector::get()->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 }); // todo: let mods customize this
return bg;
}