diff options
author | Robert C. Helling <helling@atdotde.de> | 2016-11-23 11:48:41 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-11-24 09:59:32 +0900 |
commit | d1a0655613ba11a32dc7558c27ea733e9a447276 (patch) | |
tree | 8020f14c4dd56c61d46b1e642fad3a78480b077c /core/planner.c | |
parent | 6aa01372fddfa82533bceceb3275a73172644f77 (diff) | |
download | subsurface-d1a0655613ba11a32dc7558c27ea733e9a447276.tar.gz |
Show runtime on top of diveplan
This is central information when planning a dive but often
scrolled out of the window for longer plans. So print it on
the top.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/planner.c')
-rw-r--r-- | core/planner.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/core/planner.c b/core/planner.c index 93aa94dbd..3e67b4674 100644 --- a/core/planner.c +++ b/core/planner.c @@ -509,6 +509,18 @@ static int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops, int gnr) return stoplevels; } +int diveplan_duration(struct diveplan *diveplan) +{ + struct divedatapoint *dp = diveplan->dp; + int duration = 0; + while(dp) { + if (dp->time > duration) + duration = dp->time; + dp = dp->next; + } + return duration / 60; +} + static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_disclaimer, int error) { const unsigned int sz_buffer = 2000000; @@ -573,8 +585,10 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool snprintf(temp, sz_temp, translate("gettextFromC", "recreational mode based on Bühlmann ZHL-16B with GFlow = %d and GFhigh = %d"), diveplan->gflow, diveplan->gfhigh); } - len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s</b><br>%s</div><br>", + len += snprintf(buffer + len, sz_buffer - len, "<div><b>%s</b><br>%s</div>", translate("gettextFromC", "Subsurface dive plan"), temp); + len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "<div>Runtime: %dmin</div><br>"), + diveplan_duration(diveplan)); if (!plan_verbatim) { len += snprintf(buffer + len, sz_buffer - len, "<div><table><thead><tr><th></th><th>%s</th>", |