Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#3939 closed defect (fixed)

[PATCH]Structure Tree research highlighting too long

Reported by: Stephen Imhoff Owned by: usey11
Priority: Nice to Have Milestone: Alpha 21
Component: UI & Simulation Keywords: simple patch
Cc: Patch:

Description

The "next phase" technology highlighting used in the Structure Tree of the Learn to Play menu is too long; it stops just outside the horizontal area for all structures instead of just after the last structure.

This is really only an issue when the structures available for a particular phase don't fill up the entire horizontal width. IOW, it looks almost okay for the Mauryans 1st phase because almost the entire area is covered (because their trainer unit decreases the space required). It looks a little off for most civilizations' 2nd phase structures, because the structures available are only half as wide as the highlighting.

So, I'm seeing this:

But expecting something like this:

(...note that in this expected the width of the entire overlay has also changed. Less sure about that.)

Attachments (5)

actual.png (760.6 KB ) - added by Stephen Imhoff 8 years ago.
expected.png (759.2 KB ) - added by Stephen Imhoff 8 years ago.
draw.js.patch (3.2 KB ) - added by usey11 8 years ago.
drawCleanUp.patch (3.6 KB ) - added by usey11 8 years ago.
draw_2.patch (4.1 KB ) - added by usey11 8 years ago.

Download all attachments as: .zip

Change History (15)

by Stephen Imhoff, 8 years ago

Attachment: actual.png added

by Stephen Imhoff, 8 years ago

Attachment: expected.png added

comment:1 by elexis, 8 years ago

Keywords: simple added

comment:2 by usey11, 8 years ago

Owner: set to usey11
Status: newassigned

by usey11, 8 years ago

Attachment: draw.js.patch added

comment:3 by usey11, 8 years ago

Keywords: rfc patch added
Milestone: BacklogAlpha 21
Summary: Structure Tree research highlighting too long[PATCH]Structure Tree research highlighting too long

comment:4 by bb, 8 years ago

L36 one newline is enough

L148 and L149 can be merged

The phaseCount variable isn't really needed as it is used only ones in that function so that can be nuked.

(One side note, try to keep the patches as small as possible, so keep the cleanup separated from the logic changes. Do not change it back for this patch though)

comment:5 by elexis, 8 years ago

And don't forget the programmers.json entry.

What I don't like about the patch are the hardcoded numbers.

Take a look at resizeMoreOptionsWindow of gamesetup.js to see how those magic numbers can be avoided.

Last edited 8 years ago by elexis (previous) (diff)

comment:6 by Niek, 8 years ago

Could we center the tech tree box in the middle of the screen on the fly (not the technologies / buildings itself but the larger box around it)?

by usey11, 8 years ago

Attachment: drawCleanUp.patch added

comment:7 by Imarok, 8 years ago

L148: one ; too much I think you should substitute the phaseCount in L148 with phaseList.length instead of the one in L291. L141 should use +=

comment:8 by elexis, 8 years ago

Still has these hardcoded offsets. It would be great if it would retrieve those numbers from the GUI objects themselves.

For example the code doesn't need to pass the 40 in prodBar, since it doens't change it.

You can use:

let foo = Engine.GetGUIObjectByName("foo");
let fooSize = foo.size;
fooSize.left = newLeft;
foo.size = fooSize;

thus avoid the hardcoded numbers, making it compatible to changing the XML without having to change the JS code.

by usey11, 8 years ago

Attachment: draw_2.patch added

comment:9 by elexis, 8 years ago

Resolution: fixed
Status: assignedclosed

In 18746:

Resize the gray phase bar background in the structure tree to end after the last template of that phase. Patch by usey11, fixes #3939.

comment:10 by elexis, 8 years ago

Keywords: rfc removed

Thanks for the patch! This issue had been annoying me for a long time.

What I changed before the commit:

  • The whitespace was removed some time ago already
  • Using Engine.GetGUIObjectByName("TreeDisplay").size.left instead of 76. Magic numbers should be avoided.
  • Made these neighbors const too.
  • // Make prod bar -> // Set initial prod bar size and icon
Note: See TracTickets for help on using tickets.