Page 1 of 1
[nogo] Goal gui improvements
Posted: 07 Sep 2012 21:06
by Zuu
From creating and playing with NoCarGoal I have got some ideas on how the GUI facilities for Game Scripts could be improved. In this first patch I have added a progress counter (from 0 to 100 %) to the in-memory goals. Using a new API function GSGoal::Update it is now possible to update the text and progress information of a goal. The progress is shown in a separate column in the Goal GUI.
Further on I will probably try to add a company selector to the goal window with a first tab for viewing global goals. The goal list for each scope could then possible have sort by completion percentage rather than by goal ID.
API additions:
- GSGoal::Update(goal_id, text, progress)
- GSGoal::IsCompleted(goal_id) // Returns true if progress is 100, otherwise false
Thoughts about the patch/work
I'm thinking that if you haven't set any progress yet, it shouldn't show any value at all. Or that you can turn of progress display by setting progress to 255. As for NoCarGoal, showing percentage for global goals doesn't really make sense.
This patch includes changes to the savegame format and as I haven't done any such changes before, it is probably not complete in that matter. I have for example not changed the savegame format number yet.
Screenshots
(mind that I haven't updated the Goal strings in NoCarGoal to regard the fact that the goals are left visible after they have been completed)

- Clueless, 18th Apr 1950.png (93.59 KiB) Viewed 5399 times

- Clueless, 6th Jun 1950.png (36.34 KiB) Viewed 5399 times
Re: [nogo] Goal gui improvements
Posted: 08 Sep 2012 08:04
by Alberth
Perhaps display the percentage at the left?
Then I can make the window much smaller, once I know the goal to reach.
Re: [nogo] Goal gui improvements
Posted: 08 Sep 2012 09:12
by frosch
Maybe instead of a percentage, just allow to set a separate text for the progress.
I don't think a percentage is always the best choice for a progress. "2/7" feels a lot better than "29%". A percentage is useful if the progress can change in very small steps ("28%" is better than "15717/56134"), but it is not suitable for stuff like "2/7".
In the case of Silicon Valley I would use the "x/y" form for the number of industries goals, and the "xxx%" form for the cargo amount.
Using a general text for progress would allow a lot of different progress indicators:
- "" (no progress indication)
- "xxx %"
- "x/y"
- "1st", "2nd", "3rd", ...
- "5 months left"
- ...
Using a general text would not offer a IsComplete thingie. That would need a separate parameter.
Wrt. global goals: The progress should be set per company.
In total I propose these functions:
- GSGoal::SetText(goal_id, text)
- GSGoal::SetProgess(goal_id, company_id, text)
- GSGoal::SetComplete(goal_id, company_id, bool)
- GSGoal::GetComplete(goal_id, company_id)
The company_id is meant for global goals. Using COMPANY_INVALID would affect the company the goal belongs to, or all companies in case of global goals (for goals which are really shared between companies).
Edit:
Wrt. the window design. Progress on right looks more intuitive for me. But the resizing should clip the goal text and keep the progress text.
Re: [nogo] Goal gui improvements
Posted: 08 Sep 2012 12:27
by Zuu
frosch wrote:Wrt. global goals: The progress should be set per company.
So for the GUI design, global goals should still show up at the company tab of each company instead of having a separate tab for global goals? (as otherwise you can't see the progress of global goals for other companies)
Alberth wrote:Perhaps display the percentage at the left?
Then I can make the window much smaller, once I know the goal to reach.
In the current implementation it use 40 pixels at the right side for progress information. So you can resize the window and it will cut down on the goal text rather than on the progress text.
Re: [nogo] Goal gui improvements
Posted: 08 Sep 2012 12:49
by frosch
I thought about a separate button in the main toolbar, next to subsidies, not "under subsidies".
It would behave like most of those buttons, and offer a dropdown to select the "goal view" of another company.
Also that button might be hidden if no GS is present to not confuse users. (Similar to how the "build object" button is hidden when no objects are present)
I don't think tabs as in the script debug window or company score is the way to go. Those do not fit the GUI style of the rest imo

Re: [nogo] Goal gui improvements
Posted: 08 Sep 2012 14:55
by Zuu
frosch wrote:I thought about a separate button in the main toolbar, next to subsidies, not "under subsidies".
It would behave like most of those buttons, and offer a dropdown to select the "goal view" of another company.
Also that button might be hidden if no GS is present to not confuse users. (Similar to how the "build object" button is hidden when no objects are present)
I don't think tabs as in the script debug window or company score is the way to go. Those do not fit the GUI style of the rest imo

Isn't the main toolbar width limited to the current size? Eg. do I need to first remove something in order to get room for a new button there? Or can I just add a button there?
Also, even if we add a goal button to the main toolbar, if that is used to show a menu of all companies at top level, it will not allow more goal related windows to appear there. The only way for further windows is to add buttons in the goal window to show them from there.
Re: [nogo] Goal gui improvements
Posted: 08 Sep 2012 15:33
by Hyronymus
Percentages are clear cut and easy to rea, no need to worry about writing out 222 of 1.000 tonnes or 222 out of 1.000 passengers.
Allow me to say that I truly admire the entire Goal framework you and others have created, Zuu

.
Re: [nogo] Goal gui improvements
Posted: 08 Sep 2012 15:42
by frosch
Hyronymus:
Take a look at this:
http://www.tt-forums.net/download/file.php?id=163924
A percentage works nice for the third goal. It works somewhat for the first two, but 0/3 would be better. For the last one a percentage does not work at all.
Zuu:
More goal buttons? Ok, but maybe we should then move everything to the company league menu.
Re: [nogo] Goal gui improvements
Posted: 19 Sep 2012 13:30
by Honza_
It is nice, but why to code this. one can easily compute percentages in goal script already, and align hem to the left.
Re: [nogo] Goal gui improvements
Posted: 19 Sep 2012 18:24
by Zuu
Honza_ wrote:It is nice, but why to code this. one can easily compute percentages in goal script already, and align hem to the left.
- I was unaware that there is a posibility to create two columns with current OpenTTD. Please show me.
- With the original percentage-only implementation, adding AI friendly APIs is possible. With the newer complete-text implementation, that is not really true anymore
- The IsCompleted state can be read by AIs
- In future we can add APIs to allow town growth depend on an arbitrary goal by allowing it to depend on the completeness of a goal. (this is however not very AI friendly so that is a drawback with this path)
Re: [nogo] Goal gui improvements
Posted: 19 Sep 2012 21:14
by Honza_
Zuu wrote:
I was unaware that there is a posibility to create two columns with current OpenTTD. Please show me.
You do very well know, there is not.
I think it is nice, but computing percentages is simple (current goal / goal * 100%), and aling it left is pure [number percent]...few spaces..."some text"
Much better would be extended gui in town window.
But sure, this your patch is indeed a gui improvement

Re: [nogo] Goal gui improvements
Posted: 19 Dec 2012 23:05
by Zuu
I've updated the patch:
- Added a codechange patch that reduce code duplication before the actual changes
- Fixed resizeing of window.
- Changed the progress column to be aligned to the right. I think this makes more sense both with "k %" and "k out of n" type of progress displays. In both cases k will align up better for comparing small/large numbers if progress is aligned to the right.
If any user of a RTL language reads this, what is the preferred aliment for RTL languages? As far as I can see OpenTTD outputs numbers so that the most significant digit is still to the left. Thus perhaps also RTL languages should have the progress text aligned to the right so that digits of the same significance appear above each other just as what I was aiming to do for non-RTL languages.
Re: [nogo] Goal gui improvements
Posted: 19 Dec 2012 23:06
by Zuu
Screenshot with RTL language
Re: [nogo] Goal gui improvements
Posted: 20 Dec 2012 19:49
by Zuu
Updated patch (now that the code change patch is in trunk):
Re: [nogo] Goal gui improvements
Posted: 20 Dec 2012 22:02
by Zuu
Re: [nogo] Goal gui improvements
Posted: 26 May 2013 21:52
by Zuu
r25296 changes
r25296 wrote:-Feature: Goals can now have a progress text and/or be marked as completed.
You can now use these methods to update goals:
- GSGoal.SetProgress
- GSGoal.SetCompleted
- GSGoal.SetText
There is also a method to check if a given goal is marked as completed or not:
Note however, that until
FS#5561 is fixed, you need to create all goals after world gen has completed in order to get the goal ID. To force world gen to finish you can make sure GSController.Sleep(1) is called at least once in the game before you create any goal.