@@ -35,7 +35,7 @@ void DevTools::drawNodeAttributes(CCNode* node) {
3535 if (ImGui::Button (" Deselect" )) {
3636 return this ->selectNode (nullptr );
3737 }
38- ImGui::Text (" Address: 0x%p " , node);
38+ ImGui::Text (" Address: %s " , fmt::to_string ( fmt::ptr ( node)). c_str () );
3939 ImGui::SameLine ();
4040 if (ImGui::Button (U8STR (FEATHER_COPY " Copy" ))) {
4141 clipboard::write (
@@ -48,11 +48,16 @@ void DevTools::drawNodeAttributes(CCNode* node) {
4848
4949 if (auto menuItemNode = typeinfo_cast<CCMenuItem*>(node)) {
5050 const auto selector = menuItemNode->m_pfnSelector ;
51- const auto addr = formatAddressIntoOffset (addresser::getNonVirtual (selector));
52- ImGui::Text (" CCMenuItem selector: %s" , addr.c_str ());
53- ImGui::SameLine ();
54- if (ImGui::Button (U8STR (FEATHER_COPY " Copy##copymenuitem" ))) {
55- clipboard::write (addr);
51+ if (!selector) {
52+ std::string addr = " N/A" ;
53+ ImGui::Text (" CCMenuItem selector: %s" , addr.c_str ());
54+ } else {
55+ const auto addr = formatAddressIntoOffset (addresser::getNonVirtual (selector));
56+ ImGui::Text (" CCMenuItem selector: %s" , addr.c_str ());
57+ ImGui::SameLine ();
58+ if (ImGui::Button (U8STR (FEATHER_COPY " Copy##copymenuitem" ))) {
59+ clipboard::write (addr);
60+ }
5661 }
5762 }
5863
@@ -111,25 +116,51 @@ void DevTools::drawNodeAttributes(CCNode* node) {
111116 &CCNode::ignoreAnchorPointForPosition
112117 );
113118
114- if (auto rgbaNode = dynamic_cast <CCRGBAProtocol*>(node)) {
119+ if (auto rgbaNode = typeinfo_cast <CCRGBAProtocol*>(node)) {
115120 auto color = rgbaNode->getColor ();
116121 float _color[4 ] = { color.r / 255 .f , color.g / 255 .f , color.b / 255 .f , rgbaNode->getOpacity () / 255 .f };
117- ImGui::ColorEdit4 (" Color" , _color);
118- rgbaNode->setColor ({
119- static_cast <GLubyte>(_color[0 ] * 255 ),
120- static_cast <GLubyte>(_color[1 ] * 255 ),
121- static_cast <GLubyte>(_color[2 ] * 255 )
122- });
123- rgbaNode->setOpacity (static_cast <GLubyte>(_color[3 ] * 255 ));
122+ if (ImGui::ColorEdit4 (" Color" , _color)) {
123+ rgbaNode->setColor ({
124+ static_cast <GLubyte>(_color[0 ] * 255 ),
125+ static_cast <GLubyte>(_color[1 ] * 255 ),
126+ static_cast <GLubyte>(_color[2 ] * 255 )
127+ });
128+
129+ rgbaNode->setOpacity (static_cast <GLubyte>(_color[3 ] * 255 ));
130+ }
124131 }
125132
126- if (auto labelNode = dynamic_cast <CCLabelProtocol*>(node)) {
133+ if (auto labelNode = typeinfo_cast <CCLabelProtocol*>(node)) {
127134 std::string str = labelNode->getString ();
128135 if (ImGui::InputText (" Text" , &str, 256 )) {
129136 labelNode->setString (str.c_str ());
130137 }
131138 }
132139
140+ if (auto textureProtocol = typeinfo_cast<CCTextureProtocol*>(node)) {
141+ if (auto texture = textureProtocol->getTexture ()) {
142+ auto * cachedTextures = CCTextureCache::sharedTextureCache ()->m_pTextures ;
143+ for (auto [key, obj] : CCDictionaryExt<std::string, CCTexture2D*>(cachedTextures)) {
144+ if (obj == texture) {
145+ ImGui::TextWrapped (" Texture name: %s" , key.c_str ());
146+ break ;
147+ }
148+ }
149+
150+ if (auto spriteNode = typeinfo_cast<CCSprite*>(node)) {
151+ auto * cachedFrames = CCSpriteFrameCache::sharedSpriteFrameCache ()->m_pSpriteFrames ;
152+ const auto rect = spriteNode->getTextureRect ();
153+ for (auto [key, frame] : CCDictionaryExt<std::string, CCSpriteFrame*>(cachedFrames)) {
154+ if (frame->getTexture () == texture && frame->getRect () == rect) {
155+ ImGui::Text (" Frame name: %s" , key.c_str ());
156+ break ;
157+ }
158+ }
159+ }
160+
161+ }
162+ }
163+
133164 ImGui::NewLine ();
134165 ImGui::Separator ();
135166 ImGui::NewLine ();
0 commit comments