File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ func set_data(entities:Array[PandoraEntity]) -> void:
5151 option_button .get_popup ().clear ()
5252 for entity in _entities :
5353 option_button .get_popup ().add_icon_item (load (entity .get_icon_path ()), entity .get_entity_name (), id_counter )
54+ # Godot 4.1+
55+ if option_button .get_popup ().has_method ("set_item_icon_modulate" ):
56+ option_button .get_popup ().set_item_icon_modulate (id_counter , entity .get_icon_color ())
5457 _ids_to_entities [id_counter ] = entity
5558 _entity_ids_to_ids [entity .get_entity_id ()] = id_counter
5659 id_counter += 1
@@ -59,6 +62,7 @@ func set_data(entities:Array[PandoraEntity]) -> void:
5962func select (entity :PandoraEntity ) -> void :
6063 var id = _entity_ids_to_ids [entity .get_entity_id ()]
6164 option_button .select (id )
65+ option_button .modulate = entity .get_icon_color ()
6266
6367
6468func _on_id_selected (id :int ) -> void :
Original file line number Diff line number Diff line change @@ -17,15 +17,17 @@ func _init(class_data:Dictionary) -> void:
1717
1818 for entity in all_entities :
1919 property_control .get_popup ().add_icon_item (load (entity .get_icon_path ()), entity .get_entity_name (), id_counter )
20- property_control .get_popup ().set_item_icon_modulate (id_counter , entity .get_icon_color ())
20+ # Godot 4.1+
21+ if property_control .get_popup ().has_method ("set_item_icon_modulate" ):
22+ property_control .get_popup ().set_item_icon_modulate (id_counter , entity .get_icon_color ())
2123 ids_to_entities [id_counter ] = entity
2224 id_counter += 1
2325
2426
2527func _on_id_selected (id :int ) -> void :
2628 var entity = ids_to_entities [id ] as PandoraEntity
2729 var current_entity = get_edited_object ()[get_edited_property ()] as PandoraEntity
28-
30+ property_control . modulate = current_entity . get_icon_color () if current_entity != null else Color . WHITE
2931 if current_entity != null and entity .get_entity_id () == current_entity .get_entity_id ():
3032 # skip current entities
3133 return
@@ -44,6 +46,7 @@ func _update_deferred() -> void:
4446 for id in ids_to_entities .keys ():
4547 if ids_to_entities [id ].get_entity_id () == current_entity .get_entity_id ():
4648 property_control .select (id )
49+ property_control .modulate = current_entity .get_icon_color ()
4750 break
4851
4952
You can’t perform that action at this time.
0 commit comments