Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework of the color code with & and standard codes #5416

Merged
merged 16 commits into from
Oct 25, 2022

Conversation

tonitch
Copy link
Contributor

@tonitch tonitch commented Apr 28, 2022

This is a draft for the rework of the chat, as explain in #5287 (no response so I assume this should be fine)

I want to make it as close as common server as possible so I want to follow this image color code and so using the & symbol

@tonitch tonitch changed the title adding build* to gitignore and tags for ctags rework of the color code with & and standard codes Apr 28, 2022
@tonitch tonitch marked this pull request as ready for review May 2, 2022 23:09
@tonitch
Copy link
Contributor Author

tonitch commented May 2, 2022

I think I'm ready for review,
I hope that you will understand my changes. I think it is quite important that we follow standard of minecraft, even community's one, so people are not disturbed by it

I tried to replace every bit that uses style in the code with this new guideline there is only one part I'm not sure...

cuberite/src/ClientHandle.cpp

Lines 1563 to 1568 in 3c75377

cCompositeChat Msg;
AString Color = m_Player->GetColor();
if (Color.length() == 3)
{
Color = AString("@") + Color[2];
}

I'm not sure if ranks color are implemented and so how should I change that... I haven't seens any way of setting the color of a rank....

@tonitch
Copy link
Contributor Author

tonitch commented May 23, 2022

Is there any update on the review ?

Copy link
Member

@madmaxoft madmaxoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Server/Plugins/APIDump/APIDesc.lua also needs to be updated - there's a cCompositeChat description there. What about plugin compatibility, did you test any plugins actually using chat colors?

Also, what about cChatColor, do we want to keep it? Is it up to date?

src/CompositeChat.cpp Outdated Show resolved Hide resolved
src/CompositeChat.cpp Outdated Show resolved Hide resolved
@tonitch
Copy link
Contributor Author

tonitch commented May 31, 2022

The Server/Plugins/APIDump/APIDesc.lua also needs to be updated - there's a cCompositeChat description there.

I did my best, english is a foreign language for me so I might not be clear in my way of explaining it... sorry :)

What about plugin compatibility, did you test any plugins actually using chat colors?

I didn't, I honestly didn't even tried plugin once since I'm in the cuberite project... So I don't really know which would break except for Core for whom I submitted a patch
I can maybe do a deprecated backward compatibility for colors as it uses @ and can be detected but for other style effect I don't think it's worth the effort...

Also, what about cChatColor, do we want to keep it? Is it up to date?

I didn't even knew it was a thing, by the look of things this is used by Cuberite/Core... I think it's not a bad thing that both exist as this make an altenative way of coding plugins. either typing the color or going for the standardized minecraft color code
and I also think that if plugin compatibility is a concern, then making cChatColor deprecated at the same time would break every single plugin that uses chat color

@12xx12
Copy link
Member

12xx12 commented May 31, 2022

I think we should check the plugins released with the cuberite github profile (check the Lua-Repos that are not archived)

@12xx12
Copy link
Member

12xx12 commented Jun 28, 2022

Just bumping @tonitch to check if the other plugins were checked.
These changes are good.

@tonitch
Copy link
Contributor Author

tonitch commented Jun 28, 2022

Just bumping @tonitch to check if the other plugins were checked.
These changes are good.

Sorry I didn't had much time, and will not have for the next two weeks... I will do that as soon as I can!
Thanks for the bump 😊

@tonitch
Copy link
Contributor Author

tonitch commented Jul 16, 2022

I'm back! Here is a list of what I checked and what I did!

checked

@tonitch
Copy link
Contributor Author

tonitch commented Jul 26, 2022

All seems good to me ^^
Tell if I need to do anything else ?!

@tonitch tonitch requested a review from madmaxoft July 26, 2022 17:51
@tonitch
Copy link
Contributor Author

tonitch commented Oct 7, 2022

i'm sorry if i'm rude but will this be pulled someday ? ^^

@12xx12
Copy link
Member

12xx12 commented Oct 7, 2022

I'm handing in my bachelor thesis on Wednesday. Then your time has come

@tonitch
Copy link
Contributor Author

tonitch commented Oct 7, 2022

Super! I can wait more, I was just a bit in the dark here ^^
Have fun and best of luck to you!

tests/CompositeChat/CompositeChatTest.cpp Show resolved Hide resolved
src/CompositeChat.h Show resolved Hide resolved
src/CompositeChat.cpp Outdated Show resolved Hide resolved
src/CompositeChat.cpp Show resolved Hide resolved
@12xx12
Copy link
Member

12xx12 commented Oct 14, 2022

So in total, the changes look great. I have some minor comments.

tonitch and others added 2 commits October 14, 2022 13:59
Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com>
Copy link
Member

@12xx12 12xx12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to go except we need to update the plugin submodules. So the plugin updates need to be merged first. Maybe @tigerw @bearbin or @NiLSPACE can merge those

@mathiascode
Copy link
Member

I can't review this PR right now, but I can merge some of the plugin PRs once this PR is merged.

A few questions:

  • I assume plugins using the old formatting/color codes keep working without any fatal errors?
  • Existing motd messages that use the old color codes will break once the Core PR is merged. Do we care about this?

@12xx12
Copy link
Member

12xx12 commented Oct 17, 2022

Nothing will break (in the sense of the application crashing). Using the old color Codes will just result in a weird & character in messages.

Since we provide a proper API to methods in cCompositeChat this might have been dodged.

Since I am writing this on mobile, so I can't check if those methods will stop working (no formatting) because some indicators were changed

Edit: since the codes for the bold, strike, italic,... are changed to other Charakters, this might break. @tonitch did you check this?

@tonitch
Copy link
Contributor Author

tonitch commented Oct 17, 2022

All plugins using the API are fine ... The only thing that would break is if plugin writer have implemented color code in the form of "@x"... These character will just be untouched and might be weird but as asked, I checked every plugin in the cuberite's GitHub and I found really little amount of dev using @ char in their code... They almost all use api and so are fine
Except those i made a PR ofc

@12xx12
Copy link
Member

12xx12 commented Oct 17, 2022

I meant if a plugin uses 'AddChatPartStyle' but uses the old keys. Then there would be no formatting without a warning.

@12xx12
Copy link
Member

12xx12 commented Oct 17, 2022

Maybe we should add a switch/case case that triggers on the old formatting codes informing the admin that the cold is outdated

@tonitch
Copy link
Contributor Author

tonitch commented Oct 17, 2022

Maybe we should add a switch/case case that triggers on the old formatting codes informing the admin that the cold is outdated

If I remember correctly, I though about that but I'm pretty sure there is conflict... Maybe I can do that only for those that are no more. Should i do anything else for the conflict ?

@12xx12
Copy link
Member

12xx12 commented Oct 17, 2022

I don't think so. The new character should be noticed fast :D

@tonitch
Copy link
Contributor Author

tonitch commented Oct 17, 2022

I'll do warnings then, but there should be a way of handling deprecation in cuberite... Like when a function is deprecated after x commit/version/month, this warning can be left out. I think this would avoid long portion of code that would literally do nothing 🙂

src/CompositeChat.cpp Outdated Show resolved Hide resolved
Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com>
@12xx12
Copy link
Member

12xx12 commented Oct 18, 2022

Yeah the deprecation handling is quite inconsistent and since we don't do releases, no dates are set.

@12xx12 12xx12 dismissed madmaxoft’s stale review October 18, 2022 07:39

The requested changes were applied

Copy link
Member

@12xx12 12xx12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last one. Then I'll approve

src/CompositeChat.cpp Outdated Show resolved Hide resolved
src/CompositeChat.cpp Outdated Show resolved Hide resolved
Copy link
Member

@12xx12 12xx12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting a day for any vetos

Copy link
Member

@bearbin bearbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine generally, I will not veto. I'm not totally confident with your refactor to the chat parsing logic, you seem to have made more changes than strictly necessary here and it's some complicated spaghettti with intrinsically unsafe data structures.

In an ideal world that whole mess would be refactored with modern C++ and use some safe primitives. But that's a bigger job, this is fine to get finally merged in.

@12xx12 12xx12 merged commit 16f3355 into cuberite:master Oct 25, 2022
@tonitch tonitch deleted the Chat_Color_improvement branch October 25, 2022 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants