From ed373f76096f6873fe5bdd84a8184f2897c43e03 Mon Sep 17 00:00:00 2001 From: Alberth Date: Tue, 30 Dec 2014 11:49:16 +0100 Subject: [PATCH] Add: Progress reporting. --- company.nut | 16 +++++++++++++++- lang/english.txt | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/company.nut b/company.nut index 818df48..36b3b04 100644 --- a/company.nut +++ b/company.nut @@ -59,7 +59,21 @@ function CompanyGoal::UpdateDelivered(mon) delivered = mon[this.cargo_id].town[this.accept.town]; } - this.delivered_amount += delivered; + if (delivered > 0) { + this.delivered_amount += delivered; + if (this.goal_id != null) { + local perc; + if (this.delivered_amount >= this.wanted_amount) { + perc = 100; + GSGoal.SetCompleted(this.goal_id, true); + } else { + perc = 100 * this.delivered_amount / this.wanted_amount; + if (perc > 100) perc = 100; + } + local progress_text = GSText(GSText.STR_PROGRESS, perc); + GSGoal.SetProgress(this.goal_id, progress_text); + } + } } // Test whether the goal can be considered 'done'. diff --git a/lang/english.txt b/lang/english.txt index 38231d0..d0c1ed5 100644 --- a/lang/english.txt +++ b/lang/english.txt @@ -1,4 +1,5 @@ STR_LAKE_NEWS :There are {NUM} {}fish here STR_COMPANY_GOAL :Deliver {CARGO_LONG} to {STRING} +STR_PROGRESS :{NUM}% done STR_TOWN_NAME :{TOWN} STR_INDUSTRY_NAME :{INDUSTRY}