diff --git a/betterContracts.lua b/betterContracts.lua index 86e4a60..000f40f 100644 --- a/betterContracts.lua +++ b/betterContracts.lua @@ -46,6 +46,7 @@ -- v1.2.7.1 10.02.2023 fix mission visual tags for MP: renderIcon(). -- v1.2.7.2 15.02.2023 Add settings to adjust contract generation -- Icon for roller missions. Don't show negative togos +-- v1.2.7.3 20.02.2023 double progress bar active contracts. Fix PnH BGA/ Maize+ --======================================================================================================= SC = { FERTILIZER = 1, -- prices index @@ -68,7 +69,6 @@ SC = { -- hardMode expire: DAY = 1, MONTH = 2, - -- Gui controls: CONTROLS = { npcbox = "npcbox", @@ -95,6 +95,11 @@ SC = { sortprof = "sortprof", sortpmin = "sortpmin", helpsort = "helpsort" + }, + -- Gui contractBox controls: + CONTBOX = { + "box1", "box2", "prog1", "prog2", + "progressBarBg", "progressBar1", "progressBar2" } } function debugPrint(text, ...) @@ -373,6 +378,10 @@ function initGui(self) for _, name in pairs(SC.CONTROLS) do self.my[name] = self.frCon.farmerBox:getDescendantById(name) end + -- set controls for contractBox: + for _, name in pairs(SC.CONTBOX) do + self.my[name] = self.frCon.contractBox:getDescendantById(name) + end -- set callbacks for our 3 sort buttons for _, name in ipairs({"sortcat", "sortprof", "sortpmin"}) do self.my[name].onClickCallback = onClickSortButton @@ -722,7 +731,12 @@ function BetterContracts:getFilltypePrice(m) self.name, m.type.name, self.ft[m.fillType].title, m.field.fieldId) return 0 end - return m.sellPoint:getEffectiveFillTypePrice(m.fillType) + -- check for Maize+ filltype + local fillType = m.fillType + if m.sellPoint.fillTypePrices[fillType] == nil then + fillType = FillType.SILAGE + end + return m.sellPoint:getEffectiveFillTypePrice(fillType) end function BetterContracts:calcProfit(m, successFactor) -- calculate brutto income as reward + value of kept harvest diff --git a/gui/guiProfiles.xml b/gui/guiProfiles.xml index 4d55fdc..c502c9b 100644 --- a/gui/guiProfiles.xml +++ b/gui/guiProfiles.xml @@ -120,4 +120,17 @@ + + + + + + + + + + + + + diff --git a/gui/progressGui.xml b/gui/progressGui.xml new file mode 100644 index 0000000..5d53d24 --- /dev/null +++ b/gui/progressGui.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/l10n/l10n_br.xml b/l10n/l10n_br.xml index c485d6f..b25287c 100644 --- a/l10n/l10n_br.xml +++ b/l10n/l10n_br.xml @@ -49,6 +49,10 @@ + + + + diff --git a/l10n/l10n_cs.xml b/l10n/l10n_cs.xml index 55dac68..6a0c40a 100644 --- a/l10n/l10n_cs.xml +++ b/l10n/l10n_cs.xml @@ -49,6 +49,10 @@ + + + + diff --git a/l10n/l10n_cz.xml b/l10n/l10n_cz.xml index fd9eed3..b91215f 100644 --- a/l10n/l10n_cz.xml +++ b/l10n/l10n_cz.xml @@ -50,6 +50,10 @@ + + + + diff --git a/l10n/l10n_de.xml b/l10n/l10n_de.xml index c363f67..afa69b5 100644 --- a/l10n/l10n_de.xml +++ b/l10n/l10n_de.xml @@ -54,6 +54,10 @@ + + + + diff --git a/l10n/l10n_en.xml b/l10n/l10n_en.xml index 3e0da8b..ef768de 100644 --- a/l10n/l10n_en.xml +++ b/l10n/l10n_en.xml @@ -49,6 +49,10 @@ + + + + diff --git a/l10n/l10n_fr.xml b/l10n/l10n_fr.xml index 097a994..7e62580 100644 --- a/l10n/l10n_fr.xml +++ b/l10n/l10n_fr.xml @@ -50,6 +50,10 @@ + + + + diff --git a/l10n/l10n_it.xml b/l10n/l10n_it.xml index 11adefc..080830a 100644 --- a/l10n/l10n_it.xml +++ b/l10n/l10n_it.xml @@ -50,6 +50,10 @@ + + + + diff --git a/l10n/l10n_jp.xml b/l10n/l10n_jp.xml index fc1ab9f..46895b4 100644 --- a/l10n/l10n_jp.xml +++ b/l10n/l10n_jp.xml @@ -50,6 +50,10 @@ + + + + diff --git a/l10n/l10n_pl.xml b/l10n/l10n_pl.xml index d2c316d..3f3a770 100644 --- a/l10n/l10n_pl.xml +++ b/l10n/l10n_pl.xml @@ -50,6 +50,10 @@ + + + + diff --git a/l10n/l10n_ru.xml b/l10n/l10n_ru.xml index 299182a..b189aa4 100644 --- a/l10n/l10n_ru.xml +++ b/l10n/l10n_ru.xml @@ -49,6 +49,10 @@ + + + + diff --git a/modDesc.xml b/modDesc.xml index 032aab8..81c3784 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,7 +1,7 @@  Mmtrx - 1.2.7.2 + 1.2.7.3 <en>Better Contracts</en> @@ -24,7 +24,9 @@ Disclaimer: All values shown in details display are ESTIMATES. You should not ta The mod keeps track of the amount of contracts you completed for each of the NPC farmers (number of completed jobs is displayed below the farmers image, if "Details" on). If you enable the optional discount mode or hard mode options (on the mods settings page), the amount of completed jobs influence gameplay. -Changelog v1.2.7.2: +Changelog v1.2.7.3: +- add 2nd progress bar for active harvest contracts +- fix Maize+ issue with Pumps'n Hoses BGA - add setting to change time interval between contract generation runs - fix missing icon for roller missions, do not display negative "to go" values - fix mission visual tags for MP: renderIcon(). diff --git a/scripts/gui.lua b/scripts/gui.lua index 8e8a749..ea5d728 100644 --- a/scripts/gui.lua +++ b/scripts/gui.lua @@ -23,6 +23,7 @@ -- v1.2.7.0 29.01.2023 visual tags for mission fields and vehicles. -- show leased vehicles for active contracts -- v1.2.7.2 12.02.2023 don't show negative togos +-- v1.2.7.3 20.02.2023 double progress bar active contracts. Fix PnH BGA/ Maize+ --======================================================================================================= --- Adds a new page to the in game menu. @@ -116,6 +117,8 @@ function BetterContracts:loadGUI(guiPath) return false end local xmlFile, layout + local cont = self.frCon.contractsContainer + -- load "SCGui.xml" fname = guiPath .. "SCGui.xml" if fileExists(fname) then @@ -137,7 +140,6 @@ function BetterContracts:loadGUI(guiPath) fname = guiPath .. "filterGui.xml" if fileExists(fname) then xmlFile = loadXMLFile("Temp", fname) - local cont = self.frCon.contractsContainer g_gui:loadGuiRec(xmlFile, "GUI", cont, self.frCon) layout = cont:getDescendantById("filterlayout") layout:applyScreenAlignment() @@ -152,6 +154,25 @@ function BetterContracts:loadGUI(guiPath) return false end + -- load "progressGui.xml" + fname = guiPath .. "progressGui.xml" + if fileExists(fname) then + xmlFile = loadXMLFile("Temp", fname) + local contBox = self.frCon.contractBox + -- load our "progressbar" as child of contractBox: + g_gui:loadGuiRec(xmlFile, "GUI", contBox, self.frCon) + for _,id in ipairs({"box1","box2"}) do + layout = contBox:getDescendantById(id) + layout:applyScreenAlignment() + layout:updateAbsolutePosition() + layout:invalidateLayout(true) -- adjust text fields + end + delete(xmlFile) + else + Logging.error("[GuiLoader %s] Required file '%s' could not be found!", self.name, fname) + return false + end + -- load "BCsettingsPage.lua" if g_gui ~= nil and g_gui.guis.BCSettingsFrame == nil then local luaPath = guiPath .. "BCsettingsPage.lua" @@ -629,7 +650,7 @@ function updateFarmersBox(frCon, field, npc) local active = cont.active local text, text4a, text4b --get current price - local price = m.sellPoint:getEffectiveFillTypePrice(m.fillType) + local price = self:getFilltypePrice(m) self.my.filltype:setText(c.ftype) if active then @@ -656,6 +677,9 @@ function updateFarmersBox(frCon, field, npc) self.my.valu4a:setText(val4a) self.my.line4b:setText(text4b) self.my.valu4b:setText(val4b) + -- save values for progress bars: + self.fieldPercent = m.fieldPercentageDone + self.deliverPercent = depo/c.deliver else text4a = g_i18n:formatVolume(MathUtil.round(c.deliver / 100) * 100) text4b = g_i18n:formatVolume(MathUtil.round(c.keep / 100) * 100) diff --git a/scripts/options.lua b/scripts/options.lua index 6a9ba2c..b0db425 100644 --- a/scripts/options.lua +++ b/scripts/options.lua @@ -14,6 +14,7 @@ -- show leased vehicles for active contracts -- v1.2.7.1 10.02.2023 fix mission visual tags for MP: renderIcon(). -- v1.2.7.2 12.02.2023 icon for roller missions. Don't show negative togos +-- v1.2.7.3 20.02.2023 double progress bar active contracts. Fix PnH BGA/ Maize+ --======================================================================================================= --------------------- lazyNPC --------------------------------------------------------------------------- @@ -204,6 +205,7 @@ function harvestCalcStealing(self,superf) return steal + penal end function updateDetails(self, section, index) + -- appended to InGameMenuContractsFrame:updateDetailContents() local bc = BetterContracts local contract = nil local sectionContracts = self.sectionContracts[section] @@ -229,11 +231,20 @@ function updateDetails(self, section, index) self.tallyBox:getDescendantByName("stealing"):setText(g_i18n:formatMoney(penal, 0, true, true)) self.tallyBox:getDescendantByName("total"):setText(g_i18n:formatMoney(total, 0, true, true)) end + local noActive = not contract.active or not bc.isOn - -- show leased vecs for active contract - if contract.active and mission:hasLeasableVehicles() and mission.spawnedVehicles - and bc.isOn then + -- toggle standard / enhanced progress bars + bc:showProgressBars(contract, not noActive and + table.hasElement({"harvest","mow_bale"}, mission.type.name)) + if noActive then return end + + -- update display for active contracts + if mission:hasLeasableVehicles() and mission.spawnedVehicles then + -- show leased vecs for active contract local totalWidth = 0 + -- smaller vehiclesBox to not interfere with 2nd progress bar + self.vehicleTemplate:applyProfile("myVehiclesItem") + self.vehiclesBox:applyProfile("myVehiclesBox") for _, v in ipairs(mission.vehiclesToLoad) do local storeItem = g_storeManager:getItemByXMLFilename(v.filename) local element = self.vehicleTemplate:clone(self.vehiclesBox) @@ -248,7 +259,28 @@ function updateDetails(self, section, index) self.vehiclesBox:invalidateLayout() end end +function BetterContracts:showProgressBars(contract, on) + -- hide standard progress bar + local off = not on + local cbox = self.frCon + cbox.progressText:setVisible(off and contract.active) + cbox.progressTitleText:setVisible(off and contract.active) + cbox.extraProgressText:setVisible(off and contract.active) + cbox.progressBarBg:setVisible(off and contract.active) + + -- show my progress bars + self.my.box1:setVisible(on) + self.my.box2:setVisible(on) + if off then return end + local fullWidth = self.my.progressBarBg.size[1] - self.my.progressBar1.margin[1] * 2 + local fieldPercent = math.min(self.fieldPercent, 1) + local deliverPercent = math.min(self.deliverPercent, 1) + self.my.prog1:setText(string.format(" %.0f%%", fieldPercent * 100)) + self.my.progressBar1:setSize(fullWidth * fieldPercent, nil) + self.my.prog2:setText(string.format(" %.0f%%", deliverPercent * 100)) + self.my.progressBar2:setSize(fullWidth * deliverPercent, nil) +end function dismiss(self) -- appended to AbstractMission:dismiss() if not BetterContracts.config.hardMode or not self.isServer then return end