2022-09-12 17:37:25 -04:00
|
|
|
#include <Geode/loader/SettingNode.hpp>
|
|
|
|
#include <Geode/utils/cocos.hpp>
|
|
|
|
|
|
|
|
USE_GEODE_NAMESPACE();
|
|
|
|
|
|
|
|
bool SettingNode::init(std::shared_ptr<Setting> setting) {
|
|
|
|
m_setting = setting;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-09-14 12:21:35 -04:00
|
|
|
void BoolSettingNode::valueChanged() {
|
|
|
|
GeodeSettingNode::valueChanged();
|
|
|
|
m_toggle->toggle(m_uncommittedValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BoolSettingNode::onToggle(CCObject*) {
|
|
|
|
m_uncommittedValue = !m_toggle->isToggled();
|
|
|
|
this->valueChanged();
|
|
|
|
m_toggle->toggle(!m_uncommittedValue);
|
|
|
|
}
|
|
|
|
|
2022-09-12 17:37:25 -04:00
|
|
|
bool BoolSettingNode::setup(std::shared_ptr<BoolSetting> setting, float width) {
|
2022-09-14 12:21:35 -04:00
|
|
|
m_toggle = CCMenuItemToggler::createWithStandardSprites(
|
|
|
|
this, menu_selector(BoolSettingNode::onToggle), .6f
|
2022-09-12 17:37:25 -04:00
|
|
|
);
|
2022-09-14 12:21:35 -04:00
|
|
|
m_toggle->setPosition(.0f, .0f);
|
|
|
|
m_toggle->toggle(m_uncommittedValue);
|
|
|
|
m_menu->addChild(m_toggle);
|
2022-09-12 17:37:25 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IntSettingNode::setup(std::shared_ptr<IntSetting> setting, float width) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FloatSettingNode::setup(std::shared_ptr<FloatSetting> setting, float width) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StringSettingNode::updateLabel() {
|
2022-09-14 12:21:35 -04:00
|
|
|
// hacky way to make setString not called textChanged
|
|
|
|
m_input->getInput()->setDelegate(nullptr);
|
2022-09-12 17:37:25 -04:00
|
|
|
m_input->setString(m_uncommittedValue);
|
2022-09-14 12:21:35 -04:00
|
|
|
m_input->getInput()->setDelegate(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StringSettingNode::textChanged(CCTextInputNode* input) {
|
|
|
|
m_uncommittedValue = input->getString();
|
|
|
|
this->valueChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StringSettingNode::valueChanged() {
|
|
|
|
GeodeSettingNode::valueChanged();
|
|
|
|
this->updateLabel();
|
2022-09-12 17:37:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool StringSettingNode::setup(std::shared_ptr<StringSetting> setting, float width) {
|
|
|
|
m_input = InputNode::create(180.f, "Text", "chatFont.fnt");
|
|
|
|
m_input->setPosition({ -50.f, .0f });
|
|
|
|
m_input->setScale(.65f);
|
2022-09-14 12:21:35 -04:00
|
|
|
m_input->getInput()->setDelegate(this);
|
2022-09-12 17:37:25 -04:00
|
|
|
m_menu->addChild(m_input);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|