mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
remove all warnings
This commit is contained in:
parent
34e51ff868
commit
08da8ca774
8 changed files with 270 additions and 131 deletions
|
@ -76,7 +76,7 @@ namespace geode::modifier {
|
|||
// field intermediate is the first member of Modify
|
||||
// meaning we can get the base from ourself
|
||||
auto node = reinterpret_cast<Parent*>(reinterpret_cast<std::byte*>(this) - sizeof(Base));
|
||||
static_assert(sizeof(Base) == offsetof(Parent, m_fields), "offsetof not correct");
|
||||
// static_assert(sizeof(Base) + sizeof() == sizeof(Intermediate), "offsetof not correct");
|
||||
|
||||
// generating the container if it doesn't exist
|
||||
auto container = FieldContainer::from(node, typeid(Base).name());
|
||||
|
@ -100,18 +100,7 @@ namespace geode::modifier {
|
|||
}
|
||||
|
||||
auto operator->() {
|
||||
// workaround for "static assertion is not an integral constant expression" in CLion
|
||||
// while the solution in https://github.com/microsoft/STL/issues/3311 works, you can't provide
|
||||
// cli args to clang-tidy in clion, so we use this workaround instead
|
||||
// https://youtrack.jetbrains.com/issue/CPP-27446/spurious-offsetof-in-staticassert-error-from-clangd#focus=Comments-27-8172811.0-0
|
||||
// update: that workaround didn't work,
|
||||
// undefining and re-defining offsetof caused another error further down
|
||||
// so we're doing this now
|
||||
#ifdef __CLION_IDE__
|
||||
return reinterpret_cast<typename Parent::Fields*>(69420);
|
||||
#else
|
||||
return this->self();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Popup.hpp"
|
||||
#include "InputNode.hpp"
|
||||
#include "TextInput.hpp"
|
||||
#include "Popup.hpp"
|
||||
|
||||
#include <Geode/binding/TextInputDelegate.hpp>
|
||||
|
@ -21,11 +21,11 @@ namespace geode {
|
|||
cocos2d::ccColor4B m_originalColor;
|
||||
cocos2d::extension::CCControlColourPicker* m_picker;
|
||||
Slider* m_opacitySlider = nullptr;
|
||||
InputNode* m_rInput;
|
||||
InputNode* m_gInput;
|
||||
InputNode* m_bInput;
|
||||
InputNode* m_hexInput;
|
||||
InputNode* m_opacityInput = nullptr;
|
||||
TextInput* m_rInput;
|
||||
TextInput* m_gInput;
|
||||
TextInput* m_bInput;
|
||||
TextInput* m_hexInput;
|
||||
TextInput* m_opacityInput = nullptr;
|
||||
ColorPickPopupDelegate* m_delegate = nullptr;
|
||||
cocos2d::CCSprite* m_newColorSpr;
|
||||
CCMenuItemSpriteExtra* m_resetBtn;
|
||||
|
|
|
@ -61,14 +61,14 @@ static typename T::ValueType valueFromSlider(T const& setting, float num) {
|
|||
}
|
||||
|
||||
template<class C, class T>
|
||||
InputNode* createInput(C* node, GeodeSettingValue<T>* setting, float width) {
|
||||
auto input = InputNode::create(width / 2 - 70.f, "Text", "chatFont.fnt");
|
||||
TextInput* createInput(C* node, GeodeSettingValue<T>* setting, float width) {
|
||||
auto input = TextInput::create(width / 2 - 70.f, "Text", "chatFont.fnt");
|
||||
input->setPosition({
|
||||
-(width / 2 - 70.f) / 2,
|
||||
setting->castDefinition().controls.slider ? 5.f : 0.f
|
||||
});
|
||||
input->setScale(.65f);
|
||||
input->getInput()->setDelegate(node);
|
||||
input->setDelegate(node);
|
||||
return input;
|
||||
}
|
||||
|
||||
|
@ -177,9 +177,7 @@ void IntSettingNode::updateSlider() {
|
|||
void IntSettingNode::updateLabel() {
|
||||
if (m_input) {
|
||||
// hacky way to make setString not called textChanged
|
||||
m_input->getInput()->setDelegate(nullptr);
|
||||
m_input->setString(numToString(m_uncommittedValue));
|
||||
m_input->getInput()->setDelegate(this);
|
||||
m_input->setString(numToString(m_uncommittedValue), false);
|
||||
}
|
||||
else {
|
||||
m_label->setString(numToString(m_uncommittedValue).c_str());
|
||||
|
@ -200,7 +198,7 @@ void IntSettingNode::textChanged(CCTextInputNode* input) {
|
|||
bool IntSettingNode::setup(IntSettingValue* setting, float width) {
|
||||
if (setting->castDefinition().controls.input) {
|
||||
m_menu->addChild(m_input = createInput(this, setting, width));
|
||||
m_input->getInput()->setAllowedChars("0123456789-");
|
||||
m_input->setCommonFilter(CommonFilter::Int);
|
||||
}
|
||||
else {
|
||||
m_label = CCLabelBMFont::create("", "bigFont.fnt");
|
||||
|
@ -261,9 +259,7 @@ void FloatSettingNode::updateSlider() {
|
|||
void FloatSettingNode::updateLabel() {
|
||||
if (m_input) {
|
||||
// hacky way to make setString not called textChanged
|
||||
m_input->getInput()->setDelegate(nullptr);
|
||||
m_input->setString(numToString(m_uncommittedValue));
|
||||
m_input->getInput()->setDelegate(this);
|
||||
m_input->setString(numToString(m_uncommittedValue), false);
|
||||
}
|
||||
else {
|
||||
m_label->setString(numToString(m_uncommittedValue).c_str());
|
||||
|
@ -284,7 +280,7 @@ void FloatSettingNode::textChanged(CCTextInputNode* input) {
|
|||
bool FloatSettingNode::setup(FloatSettingValue* setting, float width) {
|
||||
if (setting->castDefinition().controls.input) {
|
||||
m_menu->addChild(m_input = createInput(this, setting, width));
|
||||
m_input->getInput()->setAllowedChars("0123456789.-");
|
||||
m_input->setCommonFilter(CommonFilter::Float);
|
||||
}
|
||||
else {
|
||||
m_label = CCLabelBMFont::create("", "bigFont.fnt");
|
||||
|
@ -315,9 +311,7 @@ bool FloatSettingNode::setup(FloatSettingValue* setting, float width) {
|
|||
|
||||
void StringSettingNode::updateLabel() {
|
||||
// hacky way to make setString not called textChanged
|
||||
m_input->getInput()->setDelegate(nullptr);
|
||||
m_input->setString(m_uncommittedValue);
|
||||
m_input->getInput()->setDelegate(this);
|
||||
m_input->setString(m_uncommittedValue, false);
|
||||
}
|
||||
|
||||
void StringSettingNode::textChanged(CCTextInputNode* input) {
|
||||
|
@ -331,15 +325,15 @@ void StringSettingNode::valueChanged(bool updateText) {
|
|||
}
|
||||
|
||||
bool StringSettingNode::setup(StringSettingValue* setting, float width) {
|
||||
m_input = InputNode::create(width / 2 - 10.f, "Text", "chatFont.fnt");
|
||||
m_input = TextInput::create(width / 2 - 10.f, "Text", "chatFont.fnt");
|
||||
m_input->setPosition({ -(width / 2 - 70.f) / 2, .0f });
|
||||
m_input->setScale(.65f);
|
||||
|
||||
if (setting->castDefinition().filter.has_value()) {
|
||||
m_input->getInput()->setAllowedChars(setting->castDefinition().filter.value());
|
||||
m_input->setFilter(setting->castDefinition().filter.value());
|
||||
}
|
||||
|
||||
m_input->getInput()->setDelegate(this);
|
||||
m_input->setDelegate(this);
|
||||
m_menu->addChild(m_input);
|
||||
|
||||
return true;
|
||||
|
@ -349,9 +343,7 @@ bool StringSettingNode::setup(StringSettingValue* setting, float width) {
|
|||
|
||||
void FileSettingNode::updateLabel() {
|
||||
// hacky way to make setString not called textChanged
|
||||
m_input->getInput()->setDelegate(nullptr);
|
||||
m_input->setString(m_uncommittedValue.string());
|
||||
m_input->getInput()->setDelegate(this);
|
||||
m_input->setString(m_uncommittedValue.string(), false);
|
||||
}
|
||||
|
||||
void FileSettingNode::textChanged(CCTextInputNode* input) {
|
||||
|
@ -383,10 +375,10 @@ void FileSettingNode::onPickFile(CCObject*) {
|
|||
}
|
||||
|
||||
bool FileSettingNode::setup(FileSettingValue* setting, float width) {
|
||||
m_input = InputNode::create(width / 2 - 30.f, "Path to File", "chatFont.fnt");
|
||||
m_input = TextInput::create(width / 2 - 30.f, "Path to File", "chatFont.fnt");
|
||||
m_input->setPosition({ -(width / 2 - 80.f) / 2 - 15.f, .0f });
|
||||
m_input->setScale(.65f);
|
||||
m_input->getInput()->setDelegate(this);
|
||||
m_input->setDelegate(this);
|
||||
m_menu->addChild(m_input);
|
||||
|
||||
auto fileBtnSpr = CCSprite::createWithSpriteFrameName("gj_folderBtn_001.png");
|
||||
|
|
|
@ -208,7 +208,7 @@ class IntSettingNode :
|
|||
public TextInputDelegate
|
||||
{
|
||||
protected:
|
||||
InputNode* m_input = nullptr;
|
||||
TextInput* m_input = nullptr;
|
||||
CCLabelBMFont* m_label = nullptr;
|
||||
Slider* m_slider = nullptr;
|
||||
CCMenuItemSpriteExtra* m_decArrow = nullptr;
|
||||
|
@ -237,7 +237,7 @@ class FloatSettingNode :
|
|||
public TextInputDelegate
|
||||
{
|
||||
protected:
|
||||
InputNode* m_input = nullptr;
|
||||
TextInput* m_input = nullptr;
|
||||
CCLabelBMFont* m_label = nullptr;
|
||||
Slider* m_slider = nullptr;
|
||||
CCMenuItemSpriteExtra* m_decArrow = nullptr;
|
||||
|
@ -266,7 +266,7 @@ class StringSettingNode :
|
|||
public TextInputDelegate
|
||||
{
|
||||
protected:
|
||||
InputNode* m_input;
|
||||
TextInput* m_input;
|
||||
|
||||
void textChanged(CCTextInputNode* input) override;
|
||||
void valueChanged(bool updateText) override;
|
||||
|
@ -283,7 +283,7 @@ class FileSettingNode :
|
|||
public TextInputDelegate
|
||||
{
|
||||
protected:
|
||||
InputNode* m_input;
|
||||
TextInput* m_input;
|
||||
|
||||
void textChanged(CCTextInputNode* input) override;
|
||||
void valueChanged(bool updateText) override;
|
||||
|
|
|
@ -43,31 +43,69 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
|||
auto bg = cocos2d::extension::CCScale9Sprite::create(
|
||||
"square02b_001.png", { 0.0f, 0.0f, 80.0f, 80.0f }
|
||||
);
|
||||
bg->setID("popup-bg");
|
||||
bg->setScale(.5f);
|
||||
bg->setColor({ 0, 0, 0 });
|
||||
bg->setOpacity(85);
|
||||
bg->setContentSize({ m_size.width * 2 - 40.f, m_size.height * 2 - 140.f });
|
||||
bg->setPosition(winSize / 2);
|
||||
m_mainLayer->addChild(bg);
|
||||
m_mainLayer->addChildAtPosition(bg, Anchor::Center, ccp(0, 0));
|
||||
|
||||
auto opacityColumn = CCLayer::create();
|
||||
opacityColumn->setLayout(
|
||||
ColumnLayout::create()
|
||||
->setGap(5.f)
|
||||
->setAxisReverse(true)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
opacityColumn->setID("opacity-column");
|
||||
m_mainLayer->addChildAtPosition(opacityColumn, Anchor::Center, ccp(0, 0));
|
||||
|
||||
auto pickerRow = CCLayer::create();
|
||||
pickerRow->setLayout(
|
||||
RowLayout::create()
|
||||
->setGap(10.f)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
pickerRow->setID("picker-row");
|
||||
opacityColumn->addChild(pickerRow);
|
||||
|
||||
// color difference
|
||||
|
||||
auto colorMenu = CCMenu::create();
|
||||
colorMenu->setLayout(
|
||||
ColumnLayout::create()
|
||||
->setGap(0.f)
|
||||
->setAxisReverse(true)
|
||||
->setAutoScale(false)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
colorMenu->setID("color-menu");
|
||||
pickerRow->addChild(colorMenu);
|
||||
|
||||
// picker
|
||||
|
||||
m_picker = CCControlColourPicker::colourPicker();
|
||||
m_picker->setPosition(winSize.width / 2 - 45.f, winSize.height / 2 + (isRGBA ? 25.f : 0.f));
|
||||
m_picker->setDelegate(this);
|
||||
m_mainLayer->addChild(m_picker);
|
||||
m_picker->setID("color-picker");
|
||||
|
||||
// color difference
|
||||
auto pickerWrapper = CCNode::create();
|
||||
pickerWrapper->setContentSize(m_picker->getContentSize());
|
||||
pickerWrapper->setID("picker-wrapper");
|
||||
pickerWrapper->addChildAtPosition(m_picker, Anchor::Center, ccp(0, 0));
|
||||
pickerRow->addChild(pickerWrapper);
|
||||
|
||||
auto oldColorSpr = CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
|
||||
oldColorSpr->setPosition({ winSize.width / 2 - 165.f, winSize.height / 2 + 15.f });
|
||||
oldColorSpr->setColor(to3B(m_color));
|
||||
m_mainLayer->addChild(oldColorSpr);
|
||||
oldColorSpr->setID("old-color-spr");
|
||||
colorMenu->addChild(oldColorSpr);
|
||||
|
||||
m_newColorSpr = CCSprite::createWithSpriteFrameName("whiteSquare60_001.png");
|
||||
m_newColorSpr->setPosition({ winSize.width / 2 - 165.f, winSize.height / 2 - 15.f });
|
||||
m_newColorSpr->setColor(to3B(m_color));
|
||||
m_mainLayer->addChild(m_newColorSpr);
|
||||
m_newColorSpr->setID("new-color-spr");
|
||||
colorMenu->addChild(m_newColorSpr);
|
||||
|
||||
auto resetBtnSpr = ButtonSprite::create(
|
||||
CCSprite::createWithSpriteFrameName("reset-gold.png"_spr), 0x20, true, 0.f,
|
||||
|
@ -78,84 +116,211 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
|||
m_resetBtn =
|
||||
CCMenuItemSpriteExtra::create(resetBtnSpr, this, menu_selector(ColorPickPopup::onReset));
|
||||
m_resetBtn->setPosition({ -165.f, -50.f });
|
||||
m_buttonMenu->addChild(m_resetBtn);
|
||||
m_resetBtn->setLayoutOptions(
|
||||
AxisLayoutOptions::create()
|
||||
->setPrevGap(10.f)
|
||||
->setNextGap(10.f)
|
||||
);
|
||||
m_resetBtn->setID("reset-btn");
|
||||
colorMenu->addChild(m_resetBtn);
|
||||
|
||||
|
||||
|
||||
auto inputColumn = CCLayer::create();
|
||||
inputColumn->setLayout(
|
||||
ColumnLayout::create()
|
||||
->setGap(3.f)
|
||||
->setAxisReverse(true)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
inputColumn->setID("input-column");
|
||||
pickerRow->addChild(inputColumn);
|
||||
|
||||
auto rgbRow = CCLayer::create();
|
||||
rgbRow->setLayout(
|
||||
RowLayout::create()
|
||||
->setGap(5.f)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
rgbRow->setID("rgb-row");
|
||||
inputColumn->addChild(rgbRow);
|
||||
|
||||
// r
|
||||
|
||||
auto rText = CCLabelBMFont::create("R", "goldFont.fnt");
|
||||
rText->setPosition(winSize.width / 2 + 75.f, winSize.height / 2 + (isRGBA ? 60.f : 35.f));
|
||||
rText->setScale(.55f);
|
||||
m_mainLayer->addChild(rText);
|
||||
auto rColumn = CCLayer::create();
|
||||
rColumn->setLayout(
|
||||
ColumnLayout::create()
|
||||
->setGap(3.f)
|
||||
->setAxisReverse(true)
|
||||
->setAutoScale(false)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
rColumn->setID("r-column");
|
||||
rgbRow->addChild(rColumn);
|
||||
|
||||
m_rInput = InputNode::create(50.f, "R");
|
||||
m_rInput->setPosition(75.f, (isRGBA ? 40.f : 15.f));
|
||||
auto rText = CCLabelBMFont::create("R", "goldFont.fnt");
|
||||
rText->setScale(.55f);
|
||||
rText->setID("r-text");
|
||||
rColumn->addChild(rText);
|
||||
|
||||
m_rInput = TextInput::create(50.f, "R");
|
||||
m_rInput->setScale(.7f);
|
||||
m_rInput->getInput()->setTag(TAG_R_INPUT);
|
||||
m_rInput->getInput()->setDelegate(this);
|
||||
m_buttonMenu->addChild(m_rInput);
|
||||
m_rInput->setDelegate(this, TAG_R_INPUT);
|
||||
m_rInput->setID("r-input");
|
||||
rColumn->addChild(m_rInput);
|
||||
|
||||
rColumn->updateLayout();
|
||||
auto rRect = calculateChildCoverage(rColumn);
|
||||
rColumn->setContentSize(rRect.size);
|
||||
|
||||
// g
|
||||
|
||||
auto gText = CCLabelBMFont::create("G", "goldFont.fnt");
|
||||
gText->setPosition(winSize.width / 2 + 115.f, winSize.height / 2 + (isRGBA ? 60.f : 35.f));
|
||||
gText->setScale(.55f);
|
||||
m_mainLayer->addChild(gText);
|
||||
auto gColumn = CCLayer::create();
|
||||
gColumn->setLayout(
|
||||
ColumnLayout::create()
|
||||
->setGap(3.f)
|
||||
->setAxisReverse(true)
|
||||
->setAutoScale(false)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
gColumn->setID("g-column");
|
||||
rgbRow->addChild(gColumn);
|
||||
|
||||
m_gInput = InputNode::create(50.f, "G");
|
||||
m_gInput->setPosition(115.f, (isRGBA ? 40.f : 15.f));
|
||||
auto gText = CCLabelBMFont::create("G", "goldFont.fnt");
|
||||
gText->setScale(.55f);
|
||||
gText->setID("g-text");
|
||||
gColumn->addChild(gText);
|
||||
|
||||
m_gInput = TextInput::create(50.f, "G");
|
||||
m_gInput->setScale(.7f);
|
||||
m_gInput->getInput()->setTag(TAG_G_INPUT);
|
||||
m_gInput->getInput()->setDelegate(this);
|
||||
m_buttonMenu->addChild(m_gInput);
|
||||
m_gInput->setDelegate(this, TAG_G_INPUT);
|
||||
m_gInput->setID("g-input");
|
||||
gColumn->addChild(m_gInput);
|
||||
|
||||
gColumn->updateLayout();
|
||||
auto gRect = calculateChildCoverage(gColumn);
|
||||
gColumn->setContentSize(gRect.size);
|
||||
|
||||
// b
|
||||
|
||||
auto bText = CCLabelBMFont::create("B", "goldFont.fnt");
|
||||
bText->setPosition(winSize.width / 2 + 155.f, winSize.height / 2 + (isRGBA ? 60.f : 35.f));
|
||||
bText->setScale(.55f);
|
||||
m_mainLayer->addChild(bText);
|
||||
auto bColumn = CCLayer::create();
|
||||
bColumn->setLayout(
|
||||
ColumnLayout::create()
|
||||
->setGap(3.f)
|
||||
->setAxisReverse(true)
|
||||
->setAutoScale(false)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
bColumn->setID("b-column");
|
||||
rgbRow->addChild(bColumn);
|
||||
|
||||
m_bInput = InputNode::create(50.f, "B");
|
||||
m_bInput->setPosition(155.f, (isRGBA ? 40.f : 15.f));
|
||||
auto bText = CCLabelBMFont::create("B", "goldFont.fnt");
|
||||
bText->setScale(.55f);
|
||||
bText->setID("b-text");
|
||||
bColumn->addChild(bText);
|
||||
|
||||
m_bInput = TextInput::create(50.f, "B");
|
||||
m_bInput->setScale(.7f);
|
||||
m_bInput->getInput()->setTag(TAG_B_INPUT);
|
||||
m_bInput->getInput()->setDelegate(this);
|
||||
m_buttonMenu->addChild(m_bInput);
|
||||
m_bInput->setDelegate(this, TAG_B_INPUT);
|
||||
m_bInput->setID("b-input");
|
||||
bColumn->addChild(m_bInput);
|
||||
|
||||
bColumn->updateLayout();
|
||||
auto bRect = calculateChildCoverage(bColumn);
|
||||
log::debug("bRect: {}", bRect.size);
|
||||
bColumn->setContentSize(bRect.size);
|
||||
|
||||
// hex
|
||||
|
||||
auto hexText = CCLabelBMFont::create("Hex", "goldFont.fnt");
|
||||
hexText->setPosition(winSize.width / 2 + 115.f, winSize.height / 2 + (isRGBA ? 20.f : -5.f));
|
||||
hexText->setScale(.55f);
|
||||
m_mainLayer->addChild(hexText);
|
||||
auto hexColumn = CCLayer::create();
|
||||
hexColumn->setLayout(
|
||||
ColumnLayout::create()
|
||||
->setGap(3.f)
|
||||
->setAxisReverse(true)
|
||||
->setAutoScale(false)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
hexColumn->setID("hex-column");
|
||||
inputColumn->addChild(hexColumn);
|
||||
|
||||
m_hexInput = InputNode::create(165.f, "Hex");
|
||||
m_hexInput->setPosition(115.f, (isRGBA ? 0.f : -25.f));
|
||||
auto hexText = CCLabelBMFont::create("Hex", "goldFont.fnt");
|
||||
hexText->setScale(.55f);
|
||||
hexText->setID("hex-text");
|
||||
hexColumn->addChild(hexText);
|
||||
|
||||
m_hexInput = TextInput::create(165.f, "Hex");
|
||||
m_hexInput->setScale(.7f);
|
||||
m_hexInput->getInput()->setTag(TAG_HEX_INPUT);
|
||||
m_hexInput->getInput()->setDelegate(this);
|
||||
m_buttonMenu->addChild(m_hexInput);
|
||||
m_hexInput->setDelegate(this, TAG_HEX_INPUT);
|
||||
m_hexInput->setID("hex-input");
|
||||
hexColumn->addChild(m_hexInput);
|
||||
|
||||
hexColumn->updateLayout();
|
||||
rgbRow->updateLayout();
|
||||
inputColumn->updateLayout();
|
||||
colorMenu->updateLayout();
|
||||
pickerRow->updateLayout();
|
||||
|
||||
if (isRGBA) {
|
||||
auto opacitySection = CCLayer::create();
|
||||
opacitySection->setLayout(
|
||||
RowLayout::create()
|
||||
->setGap(10.f)
|
||||
->setAutoScale(false)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setCrossAxisLineAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
opacitySection->setID("opacity-section");
|
||||
opacityColumn->addChild(opacitySection);
|
||||
|
||||
auto sliderColumn = CCLayer::create();
|
||||
sliderColumn->setLayout(
|
||||
ColumnLayout::create()
|
||||
->setGap(7.f)
|
||||
->setAxisReverse(true)
|
||||
->setAutoScale(false)
|
||||
->setAxisAlignment(AxisAlignment::Start)
|
||||
->setAutoGrowAxis(0)
|
||||
);
|
||||
sliderColumn->setID("slider-column");
|
||||
opacitySection->addChild(sliderColumn);
|
||||
|
||||
|
||||
auto opacityText = CCLabelBMFont::create("Opacity", "goldFont.fnt");
|
||||
opacityText->setPosition(winSize.width / 2 - 30.f, winSize.height / 2 - 75.f);
|
||||
opacityText->setScale(.55f);
|
||||
m_mainLayer->addChild(opacityText);
|
||||
opacityText->setID("opacity-text");
|
||||
sliderColumn->addChild(opacityText);
|
||||
|
||||
m_opacitySlider =
|
||||
Slider::create(this, menu_selector(ColorPickPopup::onOpacitySlider), .75f);
|
||||
m_opacitySlider->setPosition(winSize.width / 2 - 30.f, winSize.height / 2 - 95.f);
|
||||
m_opacitySlider->setValue(color.a / 255.f);
|
||||
m_mainLayer->addChild(m_opacitySlider);
|
||||
m_opacitySlider->setID("opacity-slider");
|
||||
|
||||
auto sliderWrapper = CCNode::create();
|
||||
sliderWrapper->setContentSize(ccp(m_opacitySlider->m_width, m_opacitySlider->m_height) * .75f);
|
||||
sliderWrapper->setID("slider-wrapper");
|
||||
sliderWrapper->addChildAtPosition(m_opacitySlider, Anchor::Center, ccp(0, 0));
|
||||
sliderColumn->addChild(sliderWrapper);
|
||||
|
||||
m_opacityInput = InputNode::create(60.f, "0.00");
|
||||
m_opacityInput = TextInput::create(60.f, "0.00");
|
||||
m_opacityInput->setPosition(85.f, -95.f);
|
||||
m_opacityInput->setScale(.7f);
|
||||
m_opacityInput->getInput()->setTag(TAG_OPACITY_INPUT);
|
||||
m_opacityInput->getInput()->setDelegate(this);
|
||||
m_buttonMenu->addChild(m_opacityInput);
|
||||
m_opacityInput->setDelegate(this, TAG_OPACITY_INPUT);
|
||||
m_opacityInput->setID("opacity-input");
|
||||
opacitySection->addChild(m_opacityInput);
|
||||
|
||||
sliderColumn->updateLayout();
|
||||
opacitySection->updateLayout();
|
||||
}
|
||||
|
||||
opacityColumn->updateLayout();
|
||||
|
||||
this->updateState();
|
||||
|
||||
auto okBtnSpr = ButtonSprite::create("OK");
|
||||
|
@ -163,18 +328,16 @@ bool ColorPickPopup::setup(ccColor4B const& color, bool isRGBA) {
|
|||
|
||||
auto okBtn =
|
||||
CCMenuItemSpriteExtra::create(okBtnSpr, this, menu_selector(ColorPickPopup::onClose));
|
||||
okBtn->setPosition(.0f, -m_size.height / 2 + 20.f);
|
||||
m_buttonMenu->addChild(okBtn);
|
||||
// okBtn->setPosition(.0f, -m_size.height / 2 + 20.f);
|
||||
m_buttonMenu->addChildAtPosition(okBtn, Anchor::Bottom, ccp(0, 20.f));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ColorPickPopup::updateState(CCNode* except) {
|
||||
#define IF_NOT_EXCEPT(inp, value) \
|
||||
if (inp->getInput() != except) { \
|
||||
inp->getInput()->setDelegate(nullptr); \
|
||||
inp->setString(value); \
|
||||
inp->getInput()->setDelegate(this); \
|
||||
#define IF_NOT_EXCEPT(inp, value) \
|
||||
if (inp->getInputNode() != except) { \
|
||||
inp->setString(value, false); \
|
||||
}
|
||||
|
||||
IF_NOT_EXCEPT(m_rInput, numToString<int>(m_color.r));
|
||||
|
@ -253,7 +416,7 @@ void ColorPickPopup::setColorTarget(cocos2d::CCSprite* spr) {
|
|||
|
||||
ColorPickPopup* ColorPickPopup::create(ccColor4B const& color, bool isRGBA) {
|
||||
auto ret = new ColorPickPopup();
|
||||
if (ret && ret->init(400.f, (isRGBA ? 290.f : 240.f), color, isRGBA)) {
|
||||
if (ret && ret->initAnchored(400.f, (isRGBA ? 290.f : 240.f), color, isRGBA)) {
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -12,42 +12,37 @@ bool MDPopup::setup(
|
|||
|
||||
m_onClick = onClick;
|
||||
|
||||
auto winSize = CCDirector::sharedDirector()->getWinSize();
|
||||
|
||||
auto contentSize = CCSize {
|
||||
m_size.width - 70.f,
|
||||
m_size.height - 120.f,
|
||||
};
|
||||
auto content = MDTextArea::create(info, contentSize);
|
||||
content->setPosition(winSize / 2);
|
||||
m_mainLayer->addChild(content);
|
||||
m_mainLayer->addChildAtPosition(content, Anchor::Center, ccp(0, 0));
|
||||
|
||||
auto btnSpr = ButtonSprite::create(btn1Text);
|
||||
|
||||
auto btn = CCMenuItemSpriteExtra::create(btnSpr, this, menu_selector(MDPopup::onBtn));
|
||||
btn->setTag(0);
|
||||
m_buttonMenu->addChild(btn);
|
||||
|
||||
auto menu = CCMenu::create();
|
||||
menu->setLayout(
|
||||
RowLayout::create()
|
||||
->setAxisAlignment(AxisAlignment::Center)
|
||||
->setGap(10.f)
|
||||
);
|
||||
menu->addChild(btn);
|
||||
|
||||
if (btn2Text) {
|
||||
auto btn2Spr = ButtonSprite::create(btn2Text);
|
||||
|
||||
auto btn2 = CCMenuItemSpriteExtra::create(btn2Spr, this, menu_selector(MDPopup::onBtn));
|
||||
btn2->setTag(1);
|
||||
m_buttonMenu->addChild(btn2);
|
||||
|
||||
auto fullBtnWidth = btnSpr->getContentSize().width + 10.f + btn2Spr->getContentSize().width;
|
||||
menu->addChild(btn2);
|
||||
}
|
||||
|
||||
btn->setPosition(
|
||||
-fullBtnWidth / 2 + btnSpr->getContentSize().width / 2, -m_size.height / 2 + 35.f
|
||||
);
|
||||
btn2->setPosition(
|
||||
fullBtnWidth / 2 - btn2Spr->getContentSize().width / 2, -m_size.height / 2 + 35.f
|
||||
);
|
||||
}
|
||||
// position button in the middle
|
||||
else {
|
||||
btn->setPosition(.0f, -m_size.height / 2 + 35.f);
|
||||
}
|
||||
m_buttonMenu->addChildAtPosition(menu, Anchor::Bottom, ccp(0, 30));
|
||||
menu->updateLayout();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -69,7 +64,7 @@ MDPopup* MDPopup::create(
|
|||
) {
|
||||
auto ret = new MDPopup();
|
||||
if (ret &&
|
||||
ret->init(
|
||||
ret->initAnchored(
|
||||
320.f, MDPopup::estimateHeight(content), title, content, btn1, btn2, onClick,
|
||||
"square01_001.png", { 0, 0, 94, 94 }
|
||||
)) {
|
||||
|
|
|
@ -9,6 +9,6 @@ void geode::utils::detail::logTerminationError(const char* reason, Mod* mod) {
|
|||
log::logImpl(
|
||||
Severity::Error, mod,
|
||||
"The mod '{}' by {} has deliberately asked the game to crash.\nReason: {}",
|
||||
mod->getID(), mod->getDeveloper(), reason
|
||||
mod->getID(), fmt::format("{}", fmt::join(mod->getDevelopers(), ", ")), reason
|
||||
);
|
||||
}
|
||||
|
|
|
@ -75,12 +75,12 @@ protected:
|
|||
float x = -75.f;
|
||||
|
||||
for (auto& [spr, icon] : {
|
||||
std::pair { "player_01_001.png", Icon::Steve, },
|
||||
std::pair { "player_02_001.png", Icon::Mike, },
|
||||
std::pair { "player_03_001.png", Icon::LazarithTheDestroyerOfForsakenSouls, },
|
||||
std::pair { "player_04_001.png", Icon::Geoff, },
|
||||
std::pair { "GJ_square01.png", Icon::Steve, },
|
||||
std::pair { "GJ_square02.png", Icon::Mike, },
|
||||
std::pair { "GJ_square03.png", Icon::LazarithTheDestroyerOfForsakenSouls, },
|
||||
std::pair { "GJ_square04.png", Icon::Geoff, },
|
||||
}) {
|
||||
auto btnSpr = CCSprite::createWithSpriteFrameName(spr);
|
||||
auto btnSpr = CCSprite::create(spr);
|
||||
btnSpr->setScale(.7f);
|
||||
m_sprites.push_back(btnSpr);
|
||||
if (icon == m_currentIcon) {
|
||||
|
|
Loading…
Reference in a new issue