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 2d3af14: Don't draw script log over panel borders #11621

Merged
merged 1 commit into from Dec 25, 2023

Conversation

glx22
Copy link
Contributor

@glx22 glx22 commented Dec 23, 2023

Motivation / Problem

Since the addition of horizontal scrollbar to script debug window, log lines are drawn on the panel border.
image

Description

Restore the original offset. This is done using a temporary clipping region and forced me to slightly adjust left and right border for highlighting.
image

Limitations

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

Comment on lines 904 to 912
if (!FillDrawPixelInfo(&tmp_dpi, fr)) return;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);

/* Draw content (now coordinates given to DrawString* are local to the new clipping region). */
fr = fr.Translate(-fr.left, -fr.top);
fr.left -= this->hscroll->GetPosition();
Copy link
Member

@PeterN PeterN Dec 23, 2023

Choose a reason for hiding this comment

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

You can keep the clipping region coordinates with

tmp_dpi.left += fr.left;
tmp_dpi.top += fr.top;

after FillDrawPixelInfo, which might avoid coordinate confusion. (This is how NWidgetLeaf::Draw() does it.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used code from TextfileWindow::DrawWidget() but I see IndustryDirectoryWindow::DrawWidget() uses your suggestion, and it indeed looks cleaner.

@glx22 glx22 merged commit 6c5a4aa into OpenTTD:master Dec 25, 2023
20 checks passed
@glx22 glx22 deleted the script_log branch December 25, 2023 17:42
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.

None yet

3 participants