//
// ConfigureHSVWidget::init from 0x10042fdf0 to 0x10043074e (2398 bytes)
//
// 2 xrefs:
// > HSVWidgetPopup::init @ 0x10042f8d9
// > ConfigureHSVWidget::create @ 0x10042fac1
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// local variable allocation has failed, the output may be wrong!
bool __fastcall ConfigureHSVWidget::init(ConfigureHSVWidget *a1, cocos2d::ccHSVValue a2, bool a3, bool a4)
{
bool result; // al
cocos2d::CCDictionary *v8; // rax
cocos2d::extension::CCScale9Sprite *v9; // r14
cocos2d::CCLabelBMFont *v10; // rax
cocos2d::CCLabelBMFont *m_hueLabel; // r14
unsigned __int64 *v12; // r14
Slider *v13; // rax
Slider *m_hueSlider; // r14
unsigned __int64 *v15; // r15
SliderThumb *Thumb; // rax
cocos2d::CCLabelBMFont *v17; // rax
cocos2d::CCLabelBMFont *m_saturationLabel; // r14
__int64 v19; // rax
unsigned __int64 *v20; // r14
Slider *v21; // rax
Slider *m_saturationSlider; // r14
unsigned __int64 *v23; // r15
SliderThumb *v24; // rax
cocos2d::CCLabelBMFont *v25; // rax
cocos2d::CCLabelBMFont *m_brightnessLabel; // r14
__int64 v27; // rax
unsigned __int64 *v28; // r14
Slider *v29; // rax
Slider *m_brightnessSlider; // r14
unsigned __int64 *v31; // r12
SliderThumb *v32; // rax
cocos2d::CCMenu *v33; // r14
cocos2d::CCDirector *v34; // rax
cocos2d::CCTouchDispatcher *v35; // rax
cocos2d::CCDirector *v36; // rax
__int64 v37; // rax
bool absoluteSaturation; // r13
unsigned __int64 *v39; // rax
bool absoluteBrightness; // r13
unsigned __int64 *v41; // rax
cocos2d::ccHSVValue *p_m_hsv; // r15
double v43; // xmm0_8
HSVWidgetDelegate *m_delegate; // rdi
cocos2d::CCSprite *v45; // rax
CCMenuItemSpriteExtra *v46; // r15
Slider *v47; // r14
Slider *v48; // r14
float s; // xmm0_4
float v50; // xmm0_4
Slider *v51; // r14
float v; // xmm0_4
float v53; // xmm0_4
__int16 v54; // [rsp+50h] [rbp-80h] BYREF
char v55; // [rsp+52h] [rbp-7Eh]
void *__p; // [rsp+60h] [rbp-70h]
__int16 v57; // [rsp+68h] [rbp-68h] BYREF
char v58; // [rsp+6Ah] [rbp-66h]
void *v59; // [rsp+78h] [rbp-58h]
float v60[2]; // [rsp+84h] [rbp-4Ch] BYREF
unsigned __int64 v61[2]; // [rsp+8Ch] [rbp-44h] BYREF
unsigned __int64 v62; // [rsp+9Ch] [rbp-34h] BYREF
bool v63; // [rsp+A7h] [rbp-29h]
double v64; // 0:xmm0_8.8
cocos2d::CCRect v65; // 0:xmm0_8.8,8:xmm1_8.8
result = cocos2d::CCNode::init(a1);
if ( result )
{
v63 = result;
a1->m_updating = 1;
v8 = cocos2d::CCDictionary::create();
a1->m_inputs = v8;
cocos2d::CCObject::retain(v8);
_mm_storel_ps((double *)&a1->m_hsv.h, (__m128)a2);
*(_QWORD *)&a1->m_hsv.v = *(_QWORD *)&a2.v;
a1->m_addInputs = a4;
if ( !a3 )
{
v65.origin = 0;
v65.size = 0;
sub_10028CC00((__int64)v61, 0.0, 0.0, (__m128)0x42A00000u, (__m128)0x42A00000u);
v9 = cocos2d::extension::CCScale9Sprite::create_2("square02_001.png", v65);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, __int64))v9->setOpacity)(v9, 75);
sub_10028CBF0((float *)v61, 270.0, 160.0);
((void (__fastcall *)(cocos2d::extension::CCScale9Sprite *, unsigned __int64 *))v9->setContentSize)(v9, v61);
((void (__fastcall *)(ConfigureHSVWidget *, cocos2d::extension::CCScale9Sprite *, __int64))a1->addChild_0)(
a1,
v9,
0xFFFFFFFFLL);
}
v10 = cocos2d::CCLabelBMFont::create_3("Hue:", "bigFont.fnt");
a1->m_hueLabel = v10;
((void (__fastcall *)(ConfigureHSVWidget *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v10);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_hueLabel->setScale)(a1->m_hueLabel, 0.5);
m_hueLabel = a1->m_hueLabel;
sub_10028CBE0((float *)v61, 0.0, 66.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))m_hueLabel->setPosition)(m_hueLabel, v61);
if ( a1->m_addInputs )
{
v12 = (unsigned __int64 *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_hueLabel->getPosition)(a1->m_hueLabel);
sub_10028CBE0((float *)&v62, -10.0, 0.0);
sub_10028CCE0((double *)v61, v12, &v62);
ConfigureHSVWidget::createTextInputNode(a1, (cocos2d::CCPoint)3240099840LL, (int)v61);
}
v13 = Slider::create_2(a1, (cocos2d::SEL_MenuHandler)(unsigned __int64)ConfigureHSVWidget::sliderChanged);
a1->m_hueSlider = v13;
Slider::setBarVisibility(v13, 0);
((void (__fastcall *)(ConfigureHSVWidget *, Slider *))a1->addChild)(a1, a1->m_hueSlider);
m_hueSlider = a1->m_hueSlider;
v15 = (unsigned __int64 *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_hueLabel->getPosition)(a1->m_hueLabel);
sub_10028CBE0((float *)&v62, 0.0, -25.0);
sub_10028CCE0((double *)v61, v15, &v62);
((void (__fastcall *)(Slider *, unsigned __int64 *))m_hueSlider->setPosition)(m_hueSlider, v61);
Thumb = Slider::getThumb(a1->m_hueSlider);
((void (__fastcall *)(SliderThumb *, __int64))Thumb->setTag)(Thumb, 1);
v17 = cocos2d::CCLabelBMFont::create_3("Saturation:", "bigFont.fnt");
a1->m_saturationLabel = v17;
((void (__fastcall *)(ConfigureHSVWidget *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v17);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_saturationLabel->setScale)(a1->m_saturationLabel, 0.5);
m_saturationLabel = a1->m_saturationLabel;
v19 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_hueLabel->getPosition)(a1->m_hueLabel);
sub_10028CBE0((float *)v61, 0.0, *(float *)(v19 + 4) + -50.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))m_saturationLabel->setPosition)(
m_saturationLabel,
v61);
if ( a1->m_addInputs )
{
v20 = (unsigned __int64 *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_saturationLabel->getPosition)(a1->m_saturationLabel);
sub_10028CBE0((float *)&v62, 22.0, 0.0);
sub_10028CCE0((double *)v61, v20, &v62);
ConfigureHSVWidget::createTextInputNode(a1, (cocos2d::CCPoint)1102053376LL, (int)v61);
}
v21 = Slider::create_2(a1, (cocos2d::SEL_MenuHandler)(unsigned __int64)ConfigureHSVWidget::sliderChanged);
a1->m_saturationSlider = v21;
Slider::setBarVisibility(v21, 0);
((void (__fastcall *)(ConfigureHSVWidget *, Slider *))a1->addChild)(a1, a1->m_saturationSlider);
m_saturationSlider = a1->m_saturationSlider;
v23 = (unsigned __int64 *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_saturationLabel->getPosition)(a1->m_saturationLabel);
sub_10028CBE0((float *)&v62, 0.0, -25.0);
sub_10028CCE0((double *)v61, v23, &v62);
((void (__fastcall *)(Slider *, unsigned __int64 *))m_saturationSlider->setPosition)(m_saturationSlider, v61);
v24 = Slider::getThumb(a1->m_saturationSlider);
((void (__fastcall *)(SliderThumb *, __int64))v24->setTag)(v24, 2);
v25 = cocos2d::CCLabelBMFont::create_3("Brightness:", "bigFont.fnt");
a1->m_brightnessLabel = v25;
((void (__fastcall *)(ConfigureHSVWidget *, cocos2d::CCLabelBMFont *))a1->addChild)(a1, v25);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, float))a1->m_brightnessLabel->setScale)(a1->m_brightnessLabel, 0.5);
m_brightnessLabel = a1->m_brightnessLabel;
v27 = ((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_saturationLabel->getPosition)(a1->m_saturationLabel);
sub_10028CBE0((float *)v61, 0.0, *(float *)(v27 + 4) + -50.0);
((void (__fastcall *)(cocos2d::CCLabelBMFont *, unsigned __int64 *))m_brightnessLabel->setPosition)(
m_brightnessLabel,
v61);
if ( a1->m_addInputs )
{
v28 = (unsigned __int64 *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_brightnessLabel->getPosition)(a1->m_brightnessLabel);
sub_10028CBE0((float *)&v62, 22.0, 0.0);
sub_10028CCE0((double *)v61, v28, &v62);
ConfigureHSVWidget::createTextInputNode(a1, (cocos2d::CCPoint)1102053376LL, (int)v61);
}
v29 = Slider::create_2(a1, (cocos2d::SEL_MenuHandler)(unsigned __int64)ConfigureHSVWidget::sliderChanged);
a1->m_brightnessSlider = v29;
Slider::setBarVisibility(v29, 0);
((void (__fastcall *)(ConfigureHSVWidget *, Slider *))a1->addChild)(a1, a1->m_brightnessSlider);
m_brightnessSlider = a1->m_brightnessSlider;
v31 = (unsigned __int64 *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_brightnessLabel->getPosition)(a1->m_brightnessLabel);
sub_10028CBE0((float *)&v62, 0.0, -25.0);
sub_10028CCE0((double *)v61, v31, &v62);
((void (__fastcall *)(Slider *, unsigned __int64 *))m_brightnessSlider->setPosition)(m_brightnessSlider, v61);
v32 = Slider::getThumb(a1->m_brightnessSlider);
((void (__fastcall *)(SliderThumb *, __int64))v32->setTag)(v32, 3);
v33 = cocos2d::CCMenu::create();
((void (__fastcall *)(ConfigureHSVWidget *, cocos2d::CCMenu *))a1->addChild)(a1, v33);
v34 = cocos2d::CCDirector::sharedDirector();
v35 = (cocos2d::CCTouchDispatcher *)((__int64 (__fastcall *)(cocos2d::CCDirector *))v34->getTouchDispatcher)(v34);
if ( cocos2d::CCTouchDispatcher::isUsingForcePrio(v35) )
{
v36 = cocos2d::CCDirector::sharedDirector();
v37 = ((__int64 (__fastcall *)(cocos2d::CCDirector *))v36->getTouchDispatcher)(v36);
((void (__fastcall *)(cocos2d::CCMenu *, _QWORD))v33->setTouchPriority)(
v33,
(unsigned int)(*(_DWORD *)(v37 + 124) - 1));
}
sub_10028CBE0((float *)v61, -95.0, 0.0);
v54 = 8194;
v55 = 0;
absoluteSaturation = a1->m_hsv.absoluteSaturation;
v39 = (unsigned __int64 *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *))a1->m_saturationLabel->getPosition)(a1->m_saturationLabel);
sub_10028CCE0((double *)&v62, v39, v61);
sub_10028CBE0(v60, 0.0, 1.0);
GameToolbox::createToggleButton(
(unsigned int)&v54,
(unsigned int)ConfigureHSVWidget::onToggleSConst,
0,
absoluteSaturation,
(_DWORD)v33,
(unsigned int)&v62,
(__int64)a1,
(__int64)a1,
(__int64)v60,
(__int64)"bigFont.fnt",
1,
0,
0);
if ( (v54 & 1) != 0 )
operator delete(__p);
v57 = 8194;
v58 = 0;
absoluteBrightness = a1->m_hsv.absoluteBrightness;
v41 = (unsigned __int64 *)((__int64 (__fastcall *)(cocos2d::CCLabelBMFont *, double, double, double))a1->m_brightnessLabel->getPosition)(
a1->m_brightnessLabel,
COERCE_DOUBLE(1058642330),
COERCE_DOUBLE(1053609165),
COERCE_DOUBLE(1125515264));
sub_10028CCE0((double *)&v62, v41, v61);
sub_10028CBE0(v60, 0.0, 1.0);
GameToolbox::createToggleButton(
(unsigned int)&v57,
(unsigned int)ConfigureHSVWidget::onToggleVConst,
0,
absoluteBrightness,
(_DWORD)v33,
(unsigned int)&v62,
(__int64)a1,
(__int64)a1,
(__int64)v60,
(__int64)"bigFont.fnt",
1,
0,
0);
p_m_hsv = &a1->m_hsv;
if ( (v57 & 1) != 0 )
operator delete(v59);
*(_QWORD *)&v43 = LODWORD(p_m_hsv->h);
if ( *(float *)&v43 == -0.001 )
{
*p_m_hsv = (cocos2d::ccHSVValue)xmmword_1009A1698;
Slider::setValue(a1->m_hueSlider, 0.5);
Slider::setValue(a1->m_saturationSlider, 0.5);
*(_QWORD *)&v43 = 1056964608;
Slider::setValue(a1->m_brightnessSlider, 0.5);
ConfigureHSVWidget::updateLabels(a1);
m_delegate = a1->m_delegate;
if ( m_delegate )
((void (__fastcall *)(HSVWidgetDelegate *, ConfigureHSVWidget *, float, double, double))m_delegate->hsvChanged)(
m_delegate,
a1,
0.5,
COERCE_DOUBLE(1053609165),
COERCE_DOUBLE(1125515264));
if ( !a1->m_addInputs )
{
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const char *, double, double, double))a1->m_hueLabel->setString)(
a1->m_hueLabel,
"Hue: Mixed",
COERCE_DOUBLE(1056964608),
COERCE_DOUBLE(1053609165),
COERCE_DOUBLE(1125515264));
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const char *))a1->m_saturationLabel->setString)(
a1->m_saturationLabel,
"Saturation: Mixed");
((void (__fastcall *)(cocos2d::CCLabelBMFont *, const char *))a1->m_brightnessLabel->setString)(
a1->m_brightnessLabel,
"Brightness: Mixed");
}
a1->m_mixed = 1;
}
else
{
ConfigureHSVWidget::updateLabels(a1);
}
v45 = cocos2d::CCSprite::createWithSpriteFrameName("GJ_resetBtn_001.png");
v46 = CCMenuItemSpriteExtra::create(
v45,
nullptr,
a1,
(cocos2d::SEL_MenuHandler)(unsigned __int64)ConfigureHSVWidget::onResetHSV);
((void (__fastcall *)(cocos2d::CCMenu *, CCMenuItemSpriteExtra *, double, double, double))v33->addChild)(
v33,
v46,
v43,
COERCE_DOUBLE(1053609165),
COERCE_DOUBLE(1125515264));
sub_10028CBE0(v60, 119.0, 64.0);
*(cocos2d::CCPoint *)&v64 = cocos2d::CCNode::convertToNodeSpace(
(cocos2d::CCNode *)&v62,
(const cocos2d::CCPoint *)v33);
((void (__fastcall *)(CCMenuItemSpriteExtra *, unsigned __int64 *, double))v46->setPosition)(v46, &v62, v64);
v47 = a1->m_hueSlider;
*(float *)&v64 = cocos2d::clampf((float)(a1->m_hsv.h + 180.0) / 360.0, 0.0, 1.0);
Slider::setValue(v47, *(float *)&v64);
v48 = a1->m_saturationSlider;
s = a1->m_hsv.s;
if ( a1->m_hsv.absoluteSaturation )
s = s + 1.0;
v50 = cocos2d::clampf(s * 0.5, 0.0, 1.0);
Slider::setValue(v48, v50);
v51 = a1->m_brightnessSlider;
v = a1->m_hsv.v;
if ( a1->m_hsv.absoluteBrightness )
v = v + 1.0;
v53 = cocos2d::clampf(v * 0.5, 0.0, 1.0);
Slider::setValue(v51, v53);
a1->m_updating = 0;
return v63;
}
return result;
}