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

Fix some bad logic for AbstractCard.initializeDescriptionCN() #427

Merged
merged 5 commits into from
Jan 17, 2025

Conversation

Mwallx
Copy link

@Mwallx Mwallx commented Apr 22, 2024

This PR solves 3 issues:

  1. The vanilla code for AbstractCard.initializeDescriptionCN() (used by zhs, kor and jpn etc) uses a flawed logic which would result card strings with double space to be rendered incorrectly. This is because double space when processed by the Java's String.split(" "), will create another empty string "" between each consecutive occurence of spaces.(For example "I[double space]like[double space]it" will be split into "I","","like","","it") The vanilla function then, uses a flawed logic so that whenever it encounters any empty string "", it will set the width of the current line to be processed to 0, no matter it is a new line or not, resulting in some lines having shorter measured width than how long the real text is.
  2. The existing patch CNCardTextColors.java actually doesn't function at all. It's because this insertor patch is located within an if else branch, where a pervious branch's condition completely covers the patch's condition. So whenever the patch's condition could be met, it will met that one earlier so the patch actually doesn't work at all. I have optimized the logic and repositioned where it happens. It's now inserted before that other branch and will function normally.
  3. In the modified patch above, I added another logic to make colored text ignore punctuation's width, just like what vanilla did, if it's located at the ending of a line.
    Previews of these changes:
    For 1:
    before1
    after1

For 2:
(the forth line is aligned with the third because each colored block of text is incorrectly recognised by vanilla code to be energy orbs)
before2
after2

For 3:
(notice in the first image the 2 sentences are exactly the same text, but the second one is forced to be split between 2 lines because the period's width isn't ignored like the normal one, resulted in longer width even though there's enough space for it to be shown in one line.)
image
)9 B)RQ{Q{QAN%EN4~G78$V

@kiooeht kiooeht changed the base branch from master to develop January 17, 2025 01:38
@kiooeht kiooeht merged commit 5380e0e into daviscook477:develop Jan 17, 2025
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.

2 participants