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

Label Improvements #15256

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Jade-Harleyy
Copy link

This PR allows submakers and modders to:

  • Change the padding of ItemLabels
  • Change the alignment of ItemLabels
  • Change the font of ItemLabels

@zhu-rengong
Copy link

zhu-rengong commented Nov 27, 2024

There is a very marginal problem that writing changes mid-game via code modding may cause the client to asynchronize with the server and disconnect. This is mainly due to #12772 #10203 ; so here it needs to do the same thing in the server source, make Padding and Alignment editable, and add the Font property in the server project. There is a command listeditableproperties used to check for this.

Copy link
Collaborator

@Regalis11 Regalis11 left a comment

Choose a reason for hiding this comment

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

Spotted one oddity in the changes. I also believe there's an issue with syncing the new values in multiplayer as zhu-rengong commented: since they only exist client-side, trying to sync properties of the label will now cause errors in multiplayer due to the mismatching number of editable properties between the server and the clients.

};
if (!Fields.ContainsKey(property.Name)) { Fields.Add(property.Name.ToIdentifier(), new GUIComponent[] { propertyTickBox }); }
return propertyTickBox;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unclear why this method was modified (seems unrelated to the rest of the changes in the PR) or what was actually modified about it.

Copy link
Author

@Jade-Harleyy Jade-Harleyy Nov 27, 2024

Choose a reason for hiding this comment

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

Seems like the new commit has made it show the changes.
From the looks of it, it seems autoformatting has struck again, fixing broken spacing.
Most likely not a problem, but can be reverted if necessary.

@Regalis11 Regalis11 added Feature request Request a new feature to be added Code Programming task Waiting Cannot be worked on/reviewed/tested at the moment for some reason labels Nov 27, 2024
Copy link
Collaborator

@Regalis11 Regalis11 left a comment

Choose a reason for hiding this comment

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

I feel there are still some issues with the way the new properties have been implemented. I also don't fully understand the GUIBridge class. I would recommend syncing the font in some other way: it doesn't seem ideal to me to add this sort of a "mock" class that doesn't actually fully work outside this specific context.

{
public readonly Identifier Identifier;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The purpose of this class is not at all clear without diving into the code and seeing how it's used (and even then it's not that clear unless you happen to know what issue it was intended to address). At the very least I think it needs some comments explaining what it's for.

I'm also not sure this works correctly. I don't see any place where the server would add values to the Fonts dictionary.

Copy link
Author

Choose a reason for hiding this comment

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

I changed to defining them as partial classes in the shared source, and included the addition of fonts as well.

public Alignment TextAlignment { get; set; }

[Editable, Serialize("UnscaledSmallFont", IsPropertySaveable.Yes, "The label's font.")]
public GUIFont Font { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems potentially error-prone to me that we'd maintain two sets of these properties. It would be very easy for someone to do the mistake of editing these in the client project without realizing the changes need to be done to the server project as well (because surely UI stuff like this is client-only, so there's no need to touch the server code?). This also introduces some unnecessary code duplication.

I think it'd be preferable to define these in the shared project.

Copy link
Author

Choose a reason for hiding this comment

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

Done, all duplicated properties are now defined in the shared source.

Copy link
Collaborator

@Regalis11 Regalis11 left a comment

Choose a reason for hiding this comment

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

Sorry, I think I should've been clearer in my previous review: by suggesting that we shouldn't implement this sort of a mock font and style classes, I didn't mean that we should implement "full" support for GUIStyles and Fonts server-side or move the classes to shared code. In my opinion this latest commit vastly increases the scope of the PR: it includes hundreds of lines of new changes by introducing entirely new kind-of-content-types server-side, and it's unclear at least to me to what extent they actually work or are used server-side (I would suspect they don't really, and a lot of it is essentially dead code).

As far as I can see, the only thing we need is a way for the server to communicate the identifier of the selected font to the clients. I don't think we need to go this far to do that, I believe something like a server-side property of the type Identifier that corresponds to the client-side Font property would suffice. Or maybe it could just be a shared property of the type Identifier, and the setter would just find the appropriate font based on the identifier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Programming task Feature request Request a new feature to be added Waiting Cannot be worked on/reviewed/tested at the moment for some reason
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants