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

Codechange: Rearrange (code) of AI/GS debug window. #11483

Merged
merged 1 commit into from Dec 3, 2023

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented Nov 21, 2023

Motivation / Problem

The AI/GS debug window updated its state as it was drawn, and would redraw again if some state had changed.

Many widgets were drawn in OnPaint() instead of DrawWidget(), and the company icon was drawn incorrect based on unscaled hardcoded pixel dimensions.

image

Description

Instead, update state either during OnInvalidateData or before any drawing commences, and draw everything through DrawWidget() handler, via smaller class methods to break it up.

Additionally the "Game Script" button is moved next to the Company/AI selector which makes it more obvious that it is part of the same exclusive toggle.

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')

Copy link
Member

@2TallTyler 2TallTyler left a comment

Choose a reason for hiding this comment

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

The padding around the company and script buttons looks strange to me -- it's all very busy and crammed up against the bar below containing the script name, the settings button, and the reload button. I wonder if increasing (or maybe eliminating) said padding would help with the visual confusion.

I know that's out of scope, but since you're there anyway... (Feel free to say "another PR" or "do it yourself" 😛)

src/script/script_gui.cpp Outdated Show resolved Hide resolved
src/script/script_gui.cpp Outdated Show resolved Hide resolved
src/script/script_gui.cpp Outdated Show resolved Hide resolved
@PeterN
Copy link
Member Author

PeterN commented Nov 22, 2023

The padding around the company and script buttons looks strange to me -- it's all very busy and crammed up against the bar below containing the script name, the settings button, and the reload button. I wonder if increasing (or maybe eliminating) said padding would help with the visual confusion.

I know that's out of scope, but since you're there anyway... (Feel free to say "another PR" or "do it yourself" 😛)

I did adjust it from uneven padding where it overlaps or touches borders, so the style used on the Detailed Performance Rating window.

The only other place with this style of list is the Cargo Flow Legend window, which still has touching borders (because I've not touched it yet) so... dunno.

Maybe the button row below could go above the company buttons, or at the bottom with the other buttons. Hmm.

@glx22
Copy link
Contributor

glx22 commented Nov 22, 2023

Main issue in this window is the number of "tabs"

Maybe the 2 rows of 8 companies (with the empty space because there are only 15) could be replaced with 3 rows of 5.
At least it could allow to pack company buttons and game script button, giving some space on their right which could be filled with a frame for script name and and the 2 buttons.

Another option to keep the tab style is to put tabs in a single column on the left.

It's very hard for this window to look "nice".

@PeterN PeterN changed the title Change: Rearrange (code) and reposition (one widget) of AI/GS debug window. Change: Rearrange (code) of AI/GS debug window. Dec 3, 2023
…te/draw pattern.

The AI/GS window updated its state as it was drawn, and would redraw again if some state had changed.

Instead, update state either during OnInvalidateData or before any drawing commences.
@PeterN
Copy link
Member Author

PeterN commented Dec 3, 2023

All layout changes have been undone, as it seems people would rather have a full redesign than a minor tweak.

Copy link
Member

@2TallTyler 2TallTyler 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 wasn't trying to argue that your layout change wasn't an improvement. 😦

This might need a new commit title when merging, because it's now a codechange rather than a change. Maybe Codechange: Refactor AI/GS debug window.

@PeterN PeterN changed the title Change: Rearrange (code) of AI/GS debug window. Codechange: Rearrange (code) of AI/GS debug window. Dec 3, 2023
@PeterN PeterN merged commit aae6e04 into OpenTTD:master Dec 3, 2023
20 checks passed
@PeterN PeterN deleted the ai-gs-debug-window branch December 3, 2023 18:53
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