r/godot • Godot Senior • May 02 '22

Discussion I created my first pull request for the engine, print_rich() for printing messages in color (BBCode)

Post image
378 Upvotes

29 comments sorted by

89

u/Voylinslife Godot Senior May 02 '22 edited May 02 '22

This took me 3 days with a lot of headaches and a lot of figuring out how the code of the engine actually works. I have contributed to the Godot demo projects, but this is my first time to the actual engine. At this moment it is not improved yet (I guess some things may need a little tweaking).

But I just wanted to share this as I am so proud of myself that I was able to accomplish this. This is a a feature I've been wanting for some time now, and the fact that my c++ programming skills are finally becoming enough that I can program things like this made me very happy. ^^

But also kind of wondering how many people would find this helpful to be implemented into the engine.

Edit:
Link to the pull request: https://github.com/godotengine/godot/pull/60675

6

u/belzecue May 02 '22

This is a a feature I've been wanting for some time now

Thanks for working to make Godot better! Approval forthcoming or not, the effort is what counts, and I hope you find more opportunities to contribute.

Can you describe how *you* use the feature in Godot? I can easily think of use cases for myself, but I'm interested in what problems this solved for you.

4

u/Voylinslife Godot Senior May 02 '22

For me this feature basically makes the debug console a lot more readable. I like to have my own way of making errors, debug messages. I made my own logger to have a better structure. Compared to everything in white, having this option for bold and colors is soooo much more helpful.

3

u/belzecue May 02 '22

I like the idea of colorising categories of messages/errors, to see with a glance at the console how things are going just from color frequency.

This is 4.0 only, I'm guessing? No backport?

4

u/Voylinslife Godot Senior May 02 '22

4.0 only I guess I could try implementing the same thing inside of the 3.x branch if it gets accepted in the master branch(4.0) and if people would like to have this feature in 3.x as well.

1

u/threepenisbeer May 02 '22

I could see it being useful when printing a lot of info and wanting an important part to standout. Or maybe printing a color being used so you can see what is going on easier than looking at RGB values. Still kind of fringe useful, but not useless so I would enjoy having the option.

-17

u/AfshanGulAhmed May 02 '22

I know it is a very simple thing to do.

0

u/[deleted] May 02 '22

[deleted] — view deleted comment

31

u/Voylinslife Godot Senior May 02 '22

Basically, don't give up hahaha.
My tips:
- Use an IDE or other program which you know how to handle and setup. (I use VS Code which is not advised as debugging with breakpoints is not possible as far as I found out.)
- Look for the tags that say Good first issue (This pull request was not labelled like this, but it seemed simple enough, spoiler: It was not as simple as I thought.)
- Get a grasp on how the basics of c++ and programming in general work. (Been programming in other languages for some years, but only recently decided to learn C++ (Learned most of the basics through Sololearn))
- Make draft pull requests if you are stuck but mostly done. This way people can give comments on how to do it better. (You don't always get advice, so don't expect people to go out of their way to help)
- Make sure nobody else is working on the issue, sure you may get experience, but it feels much more rewarding if you solved that issue.

But my biggest advice is probably, just try. Fork the Godot repo, try solving issues, even if it doesn't work out, you will have learned more about a part of the engine. It really is quite interesting and fun to go through all the code. Have fun ;~)

4

u/Konsti219 May 02 '22

You can debug and set breakpoints in vscode for c++ with the right extension. But maybe there is something Godot specific. But visual studio is free too.

4

u/Voylinslife Godot Senior May 02 '22

Visual studio is free, but not available on Linux sadly enough. This has caused me some issues in finding a good IDE but I settled on VS Code as with the right extensions, you can accomplish a lot. Sadly c++ so far has not been great, but Java was even more terrible, for Java I use Intellij IDEA. That is the only IDE that I use nowadays, as VS Code can't really be considered to be an IDE.

1

u/SpeakThunder May 03 '22

Eclipse?

1

u/Voylinslife Godot Senior May 03 '22

Tried it but not a fan, the UI is all messed up. Probably because I use i3 so Eclipse doesn't know how to apply the theming correctly I guess. But I finally found out how to debug in vs code so yeay 🤗😁

1

u/SpeakThunder May 03 '22

Haha. Awesome. Yeah, the UI is marginal at best.

5

u/KoBeWi Foundation May 02 '22

- Use an IDE or other program which you know how to handle and setup. (I use VS Code which is not advised as debugging with breakpoints is not possible as far as I found out.)

It is possible when you use cppvsdbg (the debugger that comes with Visual Studio). I didn't have any luck with other debuggers.

As for prerequisites, you forgot the most important one - use Godot. If you are a user, the codebase will make more sense to you and contributing code will be easier. If you are not an actual Godot user, it will be more difficult to start contributing.

1

u/Voylinslife Godot Senior May 02 '22

hahaha yeah, I guess that's very true. If you don't use godot, you won't get far in figuring out how everything works. I always heard people say that it is a good thing that the engine is build with the nodes of Godot, never knew how good that was until I started working on this feature.

I just tried out cppvsdbg, but I only get a warning that it's not accepted in this environment. I'm using linux so probably another thing which is not supported on the linux version. ^^"

1

u/KoBeWi Foundation May 02 '22

Ah, I'm using Windows, and the debugger just works automatically; I only needed to configure it once. Not sure how it is on Linux, but it should be possible to configure it too.

There's also a chance that your debugger is working, but you don't use it properly. See, there's a catch on debugging Godot - you need to skip Project Manager, as running the editor from manager will disconnect the debugger. You need to open the project directly, by using --path argument.

2

u/Voylinslife Godot Senior May 02 '22

Skipping the project manager with path helped! I'm using cppdbg and I also had to put the option for externalConsole on false.

Thanks for the help! 😁

2

u/Voylinslife Godot Senior May 02 '22

Just a quick other piece of advice for if you aren't very familiar with Git and Github, first try to help out in smaller repo's. or create your own repo's to learn how to do rebase, squash, pull requests, branching, merging, cherry-picking, stashing, popping and so on ...

I messed up a lot in the beginning and it's only recently that I'm getting the hang of all the commands and how Git actually works. ;)

18

u/TabiJapan May 02 '22

thanks for making hope it will be added

3

u/Voylinslife Godot Senior May 02 '22

Had to change some values, but the workflow checks succeeded one time, so the moment those are run again and thenn it will be hoping that someone of the code maintainers approves it. ^o^

I'm so looking forward to this feature becoming a part of the main engine.

7

u/Voylinslife Godot Senior May 02 '22

All checks are running now, I have been improving this feature since this morning and fixing all the workflow bugs as well. Been a busy day but I hope it will finally go well :D
Edit: in total I compiled the engine 86 times since I started doing this. I don't want to pass 100 ^^"

10

u/EkoeJean Godot Junior May 02 '22

Thank all people who take their time and endure headaches to give some of their genius on open source projects.

4

u/Dizzy_Caterpillar777 May 02 '22

Nice! May I suggest writing some more documentation? Currently the RichTextLabel supports bbcode and its documentation contains a list of supported commands (https://docs.godotengine.org/en/stable/tutorials/ui/bbcode_in_richtextlabel.html?highlight=bbcode#reference). This new print_rich() function supports a slightly different set of bbcode, so it would be nice to have a similar documentation about the supported commands and colors.

3

u/Calinou Foundation May 02 '22

The subset of BBCode tags supported by print_rich() is subset to change, so I'd wait until modifying the documentation.

Also, it'd be better to list the supported tags within the print_rich() class reference (although the BBCode in RichTextLabel manual page could link to it too).

1

u/[deleted] May 02 '22

This is such a neat idea! Thank you for sharing!

1

u/Voylinslife Godot Senior May 02 '22

Let's hope that the code maintainers approve it as well 🙂

1

u/fractalCha0s May 02 '22

Amazing work! Now I won't have to copy paste output to and editor and search for what I'm looking for.

1

u/Auralinkk May 02 '22

I never thought about this, but now it is here I must find a way to use it. Way to go, mate!

1

u/osdd_alt_123 May 03 '22

Very nice, we're so very proud of you. Keep it up, dearie! 🥰🤗😊😁👍🎉🎈