From a8a3a53a5c3fe0b647060bf682ea05bbe679fd9e Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Wed, 23 Nov 2016 11:48:41 +0100 Subject: [PATCH 1/2] Show runtime on top of diveplan To: subsurface@subsurface-divelog.org 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 --- core/planner.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core/planner.c b/core/planner.c index 93aa94d..3e67b46 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, "
%s
%s

", + len += snprintf(buffer + len, sz_buffer - len, "
%s
%s
", translate("gettextFromC", "Subsurface dive plan"), temp); + len += snprintf(buffer + len, sz_buffer - len, translate("gettextFromC", "
Runtime: %dmin

"), + diveplan_duration(diveplan)); if (!plan_verbatim) { len += snprintf(buffer + len, sz_buffer - len, "
", -- 2.8.4 (Apple Git-73)
%s