Opened 9 years ago

Last modified 5 years ago

#3078 new defect

[PATCH] Improve tooltip management in gui code

Reported by: mimo Owned by:
Priority: Should Have Milestone: Backlog
Component: UI – In-game Keywords: patch
Cc: Patch:

Description

Presently in the gui code, there are tons of tooltip strings which are created every turns, sometimes requiring some additionnal call to GuiInterfaceCall to gather the necessary informations and then translated, and most of the time for nothing. In the attached patch, we use the Engine GetGUIObjectUnderMouse to know which tooltip is displayed if any and creates only its string. In addition this patch caches some formation info which was retrieved every turn as soon as a unit is selected, and which never changes. And finally a small inconsistency is fixed: when asking the list of available formations, the list from the player was retrieved while it should be the list of the owner of the selected units.

I've done some tests with the patch: the cpu time from "gui sim update" is decreased by about 30% when a single unit is selected (from about 20 ms/turn to 14 ms/turn on my (slow) PC), while the gain is about 10% with 200 units selected (from about 44 to 40 ms).

Attachments (1)

tooltip.diff (23.3 KB ) - added by mimo 9 years ago.

Download all attachments as: .zip

Change History (7)

by mimo, 9 years ago

Attachment: tooltip.diff added

comment:1 by mimo, 9 years ago

Keywords: patch review added
Summary: Improve tooltip management in gui code[PATCH] Improve tooltip management in gui code

in reply to:  1 comment:2 by fcxSanya, 9 years ago

Replying to mimo: A couple of minor notes:

  1. GuiInterface.js
     	438	            if (type != "Ranged") 
     	439	                ret.attack[type].elevationBonus = 0; 
     	440	            else 
     	441	                ret.attack[type].elevationBonus = 0; 
    

Apparently the else-part should contain ret.attack[type].elevationBonus = range.elevationBonus;

  1. in the same file below: why cmpObstruction part is commented out? If it's not needed it probably should be removed entirely.

comment:3 by mimo, 9 years ago

Thanks for the comments (here and on irc). I've included them on my wip version, but while testing the patch, i noticed two flaws:

1) with this approach, tooltips are not created when we pause the game. An easy solution is to add a call to onSimulationUpdate without tooltip restrictions just before pausing the game. 2) tooltip refreshing is too slow when we run with a small simRate (< 0.3). I've to think a bit more to find a good solution.

comment:4 by mimo, 9 years ago

In 16460:

cache some formation info in gui + some cleanings, see #3078

comment:5 by mimo, 9 years ago

Keywords: review removed
Milestone: Alpha 19Backlog

I had no time to dedicate to this ticket lately, so I've commited the part of the patch dealing with formation (caching the info in the gui) in r16460 and put the remaining ticket in backlog for the time being.

comment:6 by Imarok, 5 years ago

Component: UI & SimulationIn-game UI

Move tickets to In-game UI as UI & Simulation got some sub components.

Note: See TracTickets for help on using tickets.