BUG Charts

ruff_hi

Live 4ever! Or die trying
Joined
Oct 24, 2005
Messages
9,134
Location
an Aussie in Boston
I had the following idea ...
Suggested improvement for Info Screen
  • there are currently 7 charts controlled by a drop down
  • change the drop down to a list of 7 text items (similar to the tab text) so that swapping between the charts is quicker
  • create a montage option that shows all 7 charts at the same time
  • make the smaller charts clickable - click on it and you jump to the full size version

This is what I have so far - no where near ready but it shouldn't take that long to come together.



Things that will change:
  • I want to have the default chart view show all 7 charts. I don't know if it will be 2 across and 4 deep or 3 across and 3 deep.
  • Each chart will have the title of the chart above it.
  • Click on the chart title and that chart gets blown up to full size
  • Click again, and you return to the 7 chart view
  • Legend will be in the current position when in 7 chart view
  • Legend will be in top left of chart when in 1 chart view (need to test this)

Still very much a work in progress.
 
Sweet! How about this placement:

Code:
L X X
L X X
X X X

Don't forget to hide the Espionage graph when the No Espionage option is enabled.

Also, it looks like you might need to hide the axis labels (can you) when they're that small. :(
 
Perfect. Glad I posted such an imcomplete screenshot. I'll be using your layout ... or maybe

Code:
x x x
L x x
L x x

The python file in question was full of '....' instead of tabs so I will be replacing those first and committing a tab rich version before I commit my changes. Under instructions from my lawyers, I'll test it in-game first.
 
update ...





The little graph titles are active, click on one and it gets blown up to full screen size (pic 2). Click on the title again and you return to the 7 little graphs (pic 1).

Things I still want to add:
  • move the titles around a pixel or two
  • put a panel behind the title so it stands out a bit more (similar to the legend panel)
  • expand the legend in the 7 graph version to take up the remaining spaces
  • allow player to remove / add leader lines
    • not sure if this is possible but going to try and make the legend names clickable - click on them will show / hide that leader on the graph
    • add a little '+' for shown / '-' for not shown after the leader name
    • put on '+' and '-' for show all / none
 
Good stuff ruff. :goodjob: If you can get the display of individual leaders to work, dead guys should be an option too. Although maybe that could be somewhat spoilery; CyPlayer.canDoEspionage() will definitely always return false on a dead guy so I don't know if we can tell whether you used to have enough EP against them... I'm also assuming CyTeam.isHasMet() works on dead guys to differentiate those you met before they died from those you didn't...
 
update ...





Notes:
  • Hannibal has been excluded. Little '-' after his name. Click on his name again and he comes back.
  • Click on a graph title when in 7 graph mode and it shows that item in big graph mode
  • click on the graph title when in big graph mode and it returns to little graph mode
  • click on one of the titles across the top when in big graph mode and it shows the big graph for that item

Things I still want to add:
  • make legend big when all 7 charts displayed
  • test no espionage option
  • speed up load times
  • add 'select / deselect all' text to legend
 
Wicked cool, man. I'm glad you added all the graph titles across the top when in big-mode. :)

I have one suggestion: from the screenshot it's very hard to see that Hannibal is deselected. I don't know how much control you have over the legend (is it a specific UI object in the engine or is it created using normal UI elements?), but if you have a lot could you put deselected leaders at the bottom after a horizontal line or gray them out?

I'm not sure that moving them around in the legend is a great idea, but I'd like some easier way to see that they are not in the graph than that tiny "-".
 
W(hy)TF are you using a german interface :D ? other than that, great stuff as always...
 
because I was testing the spacing on some labels and german typically has the longest words.

Bug graphs now committed to SVN. Still some small layout issues and 1 XML key to be added but the python stuff should work. Also need to work on the load speed.
 
The initial load of the graphs takes just over 3 seconds on my PC with a test game. I've used EF's timer utility to find that nearly all of the time is taken actually plotting the players lines.

Code:
08:34:52 Timer - InfoScreen [drawGraph - player plots, inner loop] took 13 ms
08:34:52 Timer - InfoScreen [drawGraph - player plots, inner loop] took 14 ms
08:34:52 Timer - InfoScreen [drawGraph - player plots, inner loop] took 24 ms
08:34:52 Timer - InfoScreen [drawGraph - player plots, inner loop] took 37 ms
08:34:52 Timer - InfoScreen [drawGraph - player plots, inner loop] took 44 ms
08:34:52 Timer - InfoScreen [drawGraph - player plots, inner loop] took 54 ms
08:34:52 Timer - InfoScreen [drawGraph - player plots, inner loop] took 62 ms
08:34:52 Timer - InfoScreen [drawGraph - player plots, inner loop] took 74 ms
08:34:52 Timer - InfoScreen [drawGraph - player plots, inner loop] took 78 ms
08:34:52 Timer - InfoScreen [total - all players] took 431 ms

That is just for 1 graph. No idea why each player takes more time but that action is consistent for each of the 7 graphs. Sometimes (3 times out of 56 attempts) it was quicker.

The 'offending' bit of code is ...
Code:
def drawLine (self, screen, canvas, x0, y0, x1, y1, color):
#	if abs(x0 - x1) <= 1 and abs(y0 - y1) <= 1: return
	screen.addLineGFC(canvas, self.getNextLineName(), x0, y0 + 1, x1, y1 + 1, color)
	screen.addLineGFC(canvas, self.getNextLineName(), x0 + 1, y0, x1 + 1, y1, color)
	screen.addLineGFC(canvas, self.getNextLineName(), x0, y0, x1, y1, color)

Yes - each one of those graph lines is actually 3 lines.
 
Note that I have started to look at ways of improving the performance. If I uncomment that if blah: return statement, I get these sort of results ...

Code:
08:41:37 Timer - InfoScreen [drawGraph - player plots, inner loop] took 2 ms
08:41:37 Timer - InfoScreen [drawGraph - player plots, inner loop] took 2 ms
08:41:37 Timer - InfoScreen [drawGraph - player plots, inner loop] took 2 ms
08:41:37 Timer - InfoScreen [drawGraph - player plots, inner loop] took 2 ms
08:41:37 Timer - InfoScreen [drawGraph - player plots, inner loop] took 2 ms
08:41:37 Timer - InfoScreen [drawGraph - player plots, inner loop] took 2 ms
08:41:37 Timer - InfoScreen [drawGraph - player plots, inner loop] took 3 ms
08:41:37 Timer - InfoScreen [drawGraph - player plots, inner loop] took 4 ms
08:41:37 Timer - InfoScreen [drawGraph - player plots, inner loop] took 2 ms
08:41:37 Timer - InfoScreen [total - all players] took 59 ms

However, ...
 
If I use the following code ...

Code:
def drawLine (self, screen, canvas, x0, y0, x1, y1, color):
#	if abs(x0 - x1) <= 1 and abs(y0 - y1) <= 1: return
#	screen.addLineGFC(canvas, self.getNextLineName(), x0, y0 + 1, x1, y1 + 1, color)
#	screen.addLineGFC(canvas, self.getNextLineName(), x0 + 1, y0, x1 + 1, y1, color)
	screen.addLineGFC(canvas, self.getNextLineName(), x0, y0, x1, y1, color)

Code:
08:46:35 Timer - InfoScreen [drawGraph - player plots, inner loop] took 5 ms
08:46:35 Timer - InfoScreen [drawGraph - player plots, inner loop] took 6 ms
08:46:35 Timer - InfoScreen [drawGraph - player plots, inner loop] took 7 ms
08:46:35 Timer - InfoScreen [drawGraph - player plots, inner loop] took 5 ms
08:46:35 Timer - InfoScreen [drawGraph - player plots, inner loop] took 5 ms
08:46:35 Timer - InfoScreen [drawGraph - player plots, inner loop] took 12 ms
08:46:35 Timer - InfoScreen [drawGraph - player plots, inner loop] took 8 ms
08:46:35 Timer - InfoScreen [drawGraph - player plots, inner loop] took 9 ms
08:46:35 Timer - InfoScreen [drawGraph - player plots, inner loop] took 12 ms
08:46:35 Timer - InfoScreen [total - all players] took 103 ms

... and the graphs look like this ...
 
So - options ...
  • leave it as and the loading of graphs just takes what it takes
  • put in the line to 'skip' if the start and end of the lines are close together - gives spotty graphs
  • reduce the thickness of the lines

I am thinking that we will only do this for the 7-in-1 screen. The big graph will run through unchanged and take approximately 700ms (0.7 seconds) for each draw. Note that clicking around the various graph options or selecting / deselecting players forces a complete redraw. The delay is noticeable during the late game.
 
Oh - just been thinking about those spotty graphs. Those occur because the actual line is made up of very small line segments and when you get a lot of little lines that don't go anyway (ie within 1 pixel of each other) no line is drawn and whole segments of missing little lines occur - thus causing the gaps.

I can change that so that the starting position (x0, y0) is held constant until the end position (x1, y1) is at least 1 pixel away and then draw the line. This will result in no gaps and a smoother line. So, we can go with that option, resulting in smoother lines but there will be more line draws - hence more time.

Edit: Did that and now get solid lines ...
Code:
09:05:53 Timer - InfoScreen [drawGraph - player plots, inner loop] took 3 ms
09:05:53 Timer - InfoScreen [drawGraph - player plots, inner loop] took 2 ms
09:05:53 Timer - InfoScreen [drawGraph - player plots, inner loop] took 2 ms
09:05:53 Timer - InfoScreen [drawGraph - player plots, inner loop] took 3 ms
09:05:53 Timer - InfoScreen [drawGraph - player plots, inner loop] took 3 ms
09:05:53 Timer - InfoScreen [drawGraph - player plots, inner loop] took 4 ms
09:05:53 Timer - InfoScreen [drawGraph - player plots, inner loop] took 3 ms
09:05:53 Timer - InfoScreen [drawGraph - player plots, inner loop] took 3 ms
09:05:53 Timer - InfoScreen [drawGraph - player plots, inner loop] took 3 ms
09:05:53 Timer - InfoScreen [total - all players] took 53 ms
 
Well - everyone is too late with their input, not that I gave you much time. I'm going to put in the smoothing code (skip stupid little lines that don't go anywhere) and run with that. It will apply to all charts, big, 7-in-1 and the default Civ4 versions too.
 
I've uploaded to SVN the final (to me) version. I'm not going to be playing with it (sans bug fixes) so feel free to hammer it and point out if you think I have screwed up somewhere.

BTW: I changed the default behaviour a little bit - the graph screen now remembers how you left the screen and represents that instead of defaulting to the score. This is also true for when you turn off the BUG graphs - so a slight change to BtS Vanilla behaviour.
 
Holy crap! :goodjob:

Random suggestions after playing with it for 2 minutes:

  • Remember all settings: add selected leaders and time frame selection.
  • Show all graph names across top in single-graph view. Best to avoid disappearing/moving elements in UI. Bold/yellow the one being viewed. Could drop title from corner of graph if done this way but not necessary.
  • Center the graph titles across top instead of left-align.
  • Selecting leaders results in drawing the lines in different orders, so lines shift in front/behind each other. Not a big deal, but I'm a perfectionist. Why is the draw order be changed?
  • Horizontally size legend so leader names fit inside the box. You can use CyInterface.determineWidth(string) for this.
  • Allow click on the graph itself (or just the background) to switch to single-graph view.
I'm still floored. Great work!
 
  1. Remember all settings: add selected leaders and time frame selection.
  2. Show all graph names across top in single-graph view. Best to avoid disappearing/moving elements in UI. Bold/yellow the one being viewed. Could drop title from corner of graph if done this way but not necessary.
  3. Center the graph titles across top instead of left-align.
  4. Selecting leaders results in drawing the lines in different orders, so lines shift in front/behind each other. Not a big deal, but I'm a perfectionist. Why is the draw order be changed?
  5. Horizontally size legend so leader names fit inside the box. You can use CyInterface.determineWidth(string) for this.
  6. Allow click on the graph itself (or just the background) to switch to single-graph view.
I'm still floored. Great work!
Thanks EF. Re your comments ...

  1. what? the graphs should remember how you left it
  2. good point - more consistent - F9 info screen was coded by someone different from other screens so the method of yellow is slightly different - but I can worth with their method
  3. nawww - I like top left - and less chance of actually covering a graph line that way
  4. that shouldn't happen - lines use leader colors - will look at it. The order is based on the player ID - just loops thru them and draws the lines in that order
  5. good point - will look at it
  6. IFAIK, panels aren't not clickable - I did try it.
 
Top Bottom