mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-22 02:45:49 -04:00
preliminary stuff
- customize hardcoded colors api (no impl yet) - more ids
This commit is contained in:
parent
8953cdc85f
commit
2d0bbebfef
5 changed files with 173 additions and 3 deletions
loader
include/Geode/ui
src
47
loader/include/Geode/ui/Colors.hpp
Normal file
47
loader/include/Geode/ui/Colors.hpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#pragma once
|
||||
|
||||
#include "../DefaultInclude.hpp"
|
||||
#include "../loader/Mod.hpp"
|
||||
#include <cocos2d.h>
|
||||
|
||||
namespace geode {
|
||||
// Credit to https://github.com/Ikszyon/UI-Recolor for many of these addresses!
|
||||
|
||||
/**
|
||||
* Hardcoded GD colors
|
||||
*/
|
||||
enum class GDColor {
|
||||
NormalModeProgressBar,
|
||||
PracticeModeProgressBar,
|
||||
|
||||
ProfilePostBG,
|
||||
};
|
||||
|
||||
class GEODE_DLL ColorManager {
|
||||
protected:
|
||||
struct Value {
|
||||
cocos2d::ccColor3B value;
|
||||
Mod* setter;
|
||||
};
|
||||
|
||||
std::unordered_map<GDColor, std::vector<Value>> m_colors;
|
||||
|
||||
ColorManager();
|
||||
|
||||
public:
|
||||
static ColorManager* get();
|
||||
|
||||
cocos2d::ccColor3B getColor(GDColor color) const;
|
||||
void setColor(GDColor color, Mod* setter, cocos2d::ccColor3B const& value);
|
||||
void resetColor(GDColor color, Mod* setter);
|
||||
|
||||
template<class = void>
|
||||
void setColor(GDColor color, cocos2d::ccColor3B const& value) {
|
||||
this->setColor(color, Mod::get(), value);
|
||||
}
|
||||
template<class = void>
|
||||
void resetColor(GDColor color) {
|
||||
this->resetColor(color, Mod::get());
|
||||
}
|
||||
};
|
||||
}
|
|
@ -6,6 +6,8 @@
|
|||
USE_GEODE_NAMESPACE();
|
||||
|
||||
$register_ids(CreatorLayer) {
|
||||
setIDSafe<CCSprite>(this, 0, "background");
|
||||
|
||||
if (auto menu = getChildOfType<CCMenu>(this, 0)) {
|
||||
menu->setID("creator-buttons-menu");
|
||||
|
||||
|
@ -37,8 +39,8 @@ $register_ids(CreatorLayer) {
|
|||
}
|
||||
|
||||
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
|
||||
menu->setID("go-back-menu");
|
||||
setIDSafe(menu, 0, "back-button");
|
||||
menu->setID("exit-menu");
|
||||
setIDSafe(menu, 0, "exit-button");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
91
loader/src/ids/LevelInfoLayer.cpp
Normal file
91
loader/src/ids/LevelInfoLayer.cpp
Normal file
|
@ -0,0 +1,91 @@
|
|||
#include "AddIDs.hpp"
|
||||
#include <Geode/modify/LevelInfoLayer.hpp>
|
||||
|
||||
$register_ids(LevelInfoLayer) {
|
||||
auto winSize = CCDirector::get()->getWinSize();
|
||||
|
||||
setIDSafe<CCSprite>(this, 0, "background");
|
||||
|
||||
size_t iconOffset = 0;
|
||||
|
||||
setIDSafe<CCSprite>(this, 1, "bottom-left-art");
|
||||
setIDSafe<CCSprite>(this, 2, "bottom-right-art");
|
||||
|
||||
if (m_level->m_highObjectsEnabled) {
|
||||
setIDSafe<CCSprite>(this, 4, "high-object-indicator");
|
||||
iconOffset++;
|
||||
}
|
||||
|
||||
setIDSafe<CCSprite>(this, 4 + iconOffset, "length-icon");
|
||||
setIDSafe<CCSprite>(this, 5 + iconOffset, "downloads-icon");
|
||||
setIDSafe<CCSprite>(this, 6 + iconOffset, "orbs-icon");
|
||||
setIDSafe<CCSprite>(this, 7 + iconOffset, "likes-icon");
|
||||
setIDSafe<CCLabelBMFont>(this, 1, "downloads-label");
|
||||
setIDSafe<CCLabelBMFont>(this, 2, "length-label");
|
||||
setIDSafe<CCLabelBMFont>(this, 3, "likes-label");
|
||||
setIDSafe<CCLabelBMFont>(this, 4, "orbs-label");
|
||||
|
||||
if (m_level->m_stars) {
|
||||
setIDSafe<CCSprite>(this, 8 + iconOffset, "stars-icon");
|
||||
setIDSafe<CCLabelBMFont>(this, 5, "stars-label");
|
||||
}
|
||||
|
||||
setIDSafe<CustomSongWidget>(this, 0, "custom-songs-widget");
|
||||
|
||||
if (auto menu = getChildOfType<CCMenu>(this, 0)) {
|
||||
menu->setID("exit-menu");
|
||||
setIDSafe(menu, 0, "exit-button");
|
||||
}
|
||||
|
||||
if (auto menu = getChildOfType<CCMenu>(this, 1)) {
|
||||
menu->setID("right-side-menu");
|
||||
|
||||
if (auto name = setIDSafe(menu, 0, "creator-name")) {
|
||||
detachIntoOwnMenu(
|
||||
this, name, "creator-info-menu",
|
||||
ColumnLayout::create()->setAlignment(Alignment::Begin)
|
||||
);
|
||||
}
|
||||
|
||||
auto leftSideMenu = CCMenu::create();
|
||||
leftSideMenu->setPosition(winSize / 2 + ccp(-254.f, 30.f));
|
||||
leftSideMenu->setLayout(ColumnLayout::create());
|
||||
leftSideMenu->setID("left-side-menu");
|
||||
this->addChild(leftSideMenu);
|
||||
|
||||
menu->setPosition(winSize / 2 + ccp(254.f, 0.f));
|
||||
|
||||
for (auto child : CCArrayExt<CCNode>(menu->getChildren())) {
|
||||
if (child->getPositionX() < 0.f) {
|
||||
child->retain();
|
||||
child->removeFromParent();
|
||||
leftSideMenu->addChild(child);
|
||||
child->release();
|
||||
}
|
||||
child->setPositionX(0.f);
|
||||
}
|
||||
|
||||
setIDSafe(menu, 0, "delete-button");
|
||||
setIDSafe(menu, 1, "refresh-button");
|
||||
setIDSafe(menu, 2, "info-button");
|
||||
setIDSafe(menu, 3, "leaderboards-button");
|
||||
setIDSafe(menu, 4, "like-button");
|
||||
setIDSafe(menu, 5, "rate-button");
|
||||
|
||||
setIDSafe(leftSideMenu, 0, "copy-button");
|
||||
|
||||
menu->updateLayout();
|
||||
leftSideMenu->updateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
class $modify(LevelInfoLayer) {
|
||||
bool init(GJGameLevel* level) {
|
||||
if (!LevelInfoLayer::init(level))
|
||||
return false;
|
||||
|
||||
NodeStringIDManager::get()->provide(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
$register_ids(LevelSearchLayer) {
|
||||
// set the funny ids
|
||||
setIDSafe(this, 0, "creator-layer-bg");
|
||||
setIDSafe(this, 0, "background");
|
||||
getChildOfType<CCTextInputNode>(this, 0)->setID("search-bar");
|
||||
getChildOfType<CCScale9Sprite>(this, 0)->setID("level-search-bg");
|
||||
getChildOfType<CCScale9Sprite>(this, 1)->setID("level-search-bar-bg");
|
||||
|
|
30
loader/src/ui/nodes/Colors.cpp
Normal file
30
loader/src/ui/nodes/Colors.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include <Geode/ui/Colors.hpp>
|
||||
#include <Geode/utils/ranges.hpp>
|
||||
#include <Geode/modify/LevelInfoLayer.hpp>
|
||||
|
||||
USE_GEODE_NAMESPACE();
|
||||
|
||||
ColorManager::ColorManager() : m_colors({
|
||||
{ GDColor::NormalModeProgressBar, {{ ccColor3B { 0, 255, 0 }, Mod::get() }} },
|
||||
{ GDColor::PracticeModeProgressBar, {{ ccColor3B { 0, 255, 255 }, Mod::get() }} },
|
||||
{ GDColor::ProfilePostBG, {{ ccColor3B { 191, 114, 62 }, Mod::get() }} },
|
||||
}) {}
|
||||
|
||||
ColorManager* ColorManager::get() {
|
||||
static auto inst = new ColorManager;
|
||||
return inst;
|
||||
}
|
||||
|
||||
ccColor3B ColorManager::getColor(GDColor color) const {
|
||||
return m_colors.at(color).back().value;
|
||||
}
|
||||
|
||||
void ColorManager::setColor(GDColor color, Mod* setter, ccColor3B const& value) {
|
||||
m_colors.at(color).push_back({ value, setter });
|
||||
}
|
||||
|
||||
void ColorManager::resetColor(GDColor color, Mod* setter) {
|
||||
ranges::remove(m_colors.at(color), [setter](Value const& value) {
|
||||
return value.setter == setter;
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue