Add "text color" condition/expression for text objects
Description
Both main text objects / object types "Text" and "BBText" have actions to set the text color (or base color for BBText) but are missing getter expressions and conditions to check the current text instance color.
Solution suggested
Add a condition and expression each for regular text object, BBText and Bitmap Font that return the current text instance color. Therefore:
- Color of text (text object) Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â [condition] and [expression]
- Color of text (BBText object) Â Â Â Â Â Â Â Â Â Â Â Â [condition] and [expression]
- Color of text (Bitmap Font object) Â Â Â Â [condition] and [expression]
Â
Â

Maybe even have only one condition/expression and the engine then hands the instance to the method that needs that object type. Not needed because this would apply to other methods as well and should be put focus on separately in my opinion.
Quick sketch in case I explained it too poorly (simplified java syntax):
//main public method
public String color(Object object) {
  if (object is Text) { return color(Text object); }
 if (object is BBText) { return color(BBText object); }
 if (object is BitmapFont) { return color(BitmapFont object); }
 return ""; } //return error or empty string
//helper methods
private String color(Text object) { return object.textColor(); }
private String color(BBText object) { return object.bbtextColor(); }
private String color(BitmapFont object) { return object.bitmapColor(); }
I always support exposing more object/system parameters for objects as expressions. Hopefully we'll eventually have all objects/setting parameters exposed.
I am new to opensource and contributions but I would love to try it out!
It would also be helpful if you could tell me which file I would need to make these changes in (It's a pretty huge codebase and I am a little lost)
Thanks :)
Thank you @Shreyansh-Rai! In lack of other comments, I can try my best to hint at a direction or files but without any guarantee that what I say is correct since I don't have any experience with the code nor GitHub, really. It seems like BBText and Bitmap Text are all based on the regular text object since I can only find actions and conditions being added for the regular Text object while the other two text object types include the .h file of the regular text object - if that make sense.
https://github.com/4ian/GDevelop/blob/d980400c2b2f1b553e7960393977183f7980669b/Extensions/TextObject/Extension.cpp
From what I can tell, you'd need to add something like this:
obj.AddCondition("Color",
_("Color of text"),
_("Get the color of the text object"),
//...
.SetFunctionName("GetColor")
.SetIncludeFile("TextObject/TextObject.h");
That's a quick sketch, I think you get the idea. There are many other conditions and actions in that file that you can take a look at and compare with to get the right result (compare with the strings in the editor https://editor.gdevelop-app.com/, if needed or unsure)
That's about all guidance I can provide :)
If this issue is still open , I also want to contribute on this issue
Yes, it is still open and you are welcome to contribute to it :)
Since there haven't been any new notes (and since it hasn't been implemented in the latest version), I'll give it another go and block this thing for myself. I'll keep you updated.
Cool :) Note that we often don't provide a color condition because you can't really compare a color. I would be in favor of only doing a text expression (and if you really want to compare it, you can always use a For Each event + the condition to compare two texts).