From a5920f643153b8e927496f59ad602aa238c45bcf Mon Sep 17 00:00:00 2001 From: Mmtrx Date: Thu, 3 Aug 2023 17:50:59 +0200 Subject: [PATCH] v1.2.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Sort per NPC and contract value. - Allow Göweil mission bales (#144) - Allow mowers/ swathers on harvest missions. Tweak plow reward (#137) --- betterContracts.lua | 30 ++++++++++++++-- gui/SCGui.xml | 16 +++++---- gui/guiProfiles.xml | 22 ++++++++---- l10n/l10n_br.xml | 2 ++ l10n/l10n_cs.xml | 2 ++ l10n/l10n_cz.xml | 2 ++ l10n/l10n_da.xml | 2 ++ l10n/l10n_de.xml | 4 ++- l10n/l10n_en.xml | 4 ++- l10n/l10n_fr.xml | 2 ++ l10n/l10n_it.xml | 2 ++ l10n/l10n_jp.xml | 2 ++ l10n/l10n_pl.xml | 2 ++ l10n/l10n_ru.xml | 2 ++ modDesc.xml | 11 ++++-- scripts/gui.lua | 85 +++++++++++++++++++++++++++++---------------- scripts/userint.lua | 32 ++++++++++------- 17 files changed, 157 insertions(+), 65 deletions(-) diff --git a/betterContracts.lua b/betterContracts.lua index 1fa5034..0ddd3d8 100644 --- a/betterContracts.lua +++ b/betterContracts.lua @@ -58,6 +58,8 @@ -- let player instant-ferment wrapped bales -- v1.2.7.9 21.04.2023 Allow 240er PackedBales as mission bales, i.e. insta ferment. -- Add 240er bales to Kuhn sw4014 wrapper +-- v1.2.8.0 03.08.2023 Sort per NPC and contract value. Allow Göweil mission bales. +-- Allow mowers/ swathers on harvest missions. Tweak plow reward (#137) --======================================================================================================= SC = { FERTILIZER = 1, -- prices index @@ -103,7 +105,7 @@ SC = { valu6 = "valu6", valu7 = "valu7", sort = "sort", - sortcat = "sortcat", + sortcat = "sortcat", "sortrev", "sortnpc", sortprof = "sortprof", sortpmin = "sortpmin", helpsort = "helpsort", @@ -391,7 +393,7 @@ function initGui(self) self.my[name] = self.frCon.contractBox:getDescendantById(name) end -- set callbacks for our 3 sort buttons - for _, name in ipairs({"sortcat", "sortprof", "sortpmin"}) do + for _, name in ipairs({"sortcat", "sortrev", "sortnpc", "sortprof", "sortpmin"}) do self.my[name].onClickCallback = onClickSortButton self.my[name].onHighlightCallback = onHighSortButton self.my[name].onHighlightRemoveCallback = onRemoveSortButton @@ -473,6 +475,8 @@ function BetterContracts:initialize() self.lastSort = 0 -- last sorted status self.buttons = { {"sortcat", g_i18n:getText("SC_sortCat")}, -- {button id, help text} + {"sortrev", g_i18n:getText("SC_sortRev")}, + {"sortnpc", g_i18n:getText("SC_sortNpc")}, {"sortprof", g_i18n:getText("SC_sortProf")}, {"sortpmin", g_i18n:getText("SC_sortpMin")} } @@ -490,11 +494,21 @@ function BetterContracts:initialize() -- to show our ingame menu settings page when admin logs in: Utility.appendedFunction(InGameMenuMultiplayerUsersFrame,"onAdminLoginSuccess",adminMP) + -- to allow forage wagon on bale missions: Utility.overwrittenFunction(BaleMission, "new", baleMissionNew) + -- to allow MOWER / SWATHER on harvest missions: + Utility.overwrittenFunction(HarvestMission, "new", harvestMissionNew) + -- to set missionBale for packed 240cm bales: Utility.overwrittenFunction(Bale, "loadBaleAttributesFromXML", loadBaleAttributes) + -- allow stationary baler to produce mission bales: + local pType = g_vehicleTypeManager:getTypeByName("pdlc_goeweilPack.balerStationary") + if pType ~= nil then + SpecializationUtil.registerOverwrittenFunction(pType, "createBale", self.createBale) + end + -- to count and save/load # of jobs per farm per NPC Utility.appendedFunction(AbstractFieldMission,"finish",finish) Utility.appendedFunction(FarmStats,"saveToXMLFile",saveToXML) @@ -574,6 +588,9 @@ function BetterContracts:onMissionInitialize(baseDirectory, missionCollaborators end function BetterContracts:onSetMissionInfo(missionInfo, missionDynamicInfo) + PlowMission.REWARD_PER_HA = 2800 -- tweak plow reward (#137) + + -- setup new / clear buttons for contracts page: Utility.overwrittenFunction(g_currentMission.inGameMenu, "onClickMenuExtra1", onClickMenuExtra1) Utility.overwrittenFunction(g_currentMission.inGameMenu, "onClickMenuExtra2", onClickMenuExtra2) end @@ -962,9 +979,16 @@ function adminMP(self) BetterContracts.gameMenu:updatePages() end function baleMissionNew(isServer, superf, isClient, customMt ) + -- allow forage wagons to collect grass/ hay, for baling/wrapping at stationary baler local self = superf(isServer, isClient, customMt) self.workAreaTypes[WorkAreaType.FORAGEWAGON] = true self.workAreaTypes[WorkAreaType.CUTTER] = true - -- allow forage wagons to collect grass/ hay, for baling/wrapping at stationary baler + return self +end +function harvestMissionNew(isServer, superf, isClient, customMt ) + -- allow mower/ swather to harvest swaths + local self = superf(isServer, isClient, customMt) + self.workAreaTypes[WorkAreaType.MOWER] = true + self.workAreaTypes[WorkAreaType.FORAGEWAGON] = true return self end diff --git a/gui/SCGui.xml b/gui/SCGui.xml index b05db72..d01857c 100644 --- a/gui/SCGui.xml +++ b/gui/SCGui.xml @@ -32,14 +32,16 @@ - - - - - + + + + + + + - - + + diff --git a/gui/guiProfiles.xml b/gui/guiProfiles.xml index 0927f4b..11fe100 100644 --- a/gui/guiProfiles.xml +++ b/gui/guiProfiles.xml @@ -59,14 +59,14 @@ - + - + @@ -80,16 +80,24 @@ - + + + + + + + - + - - - + + + + + diff --git a/l10n/l10n_br.xml b/l10n/l10n_br.xml index 66de9fa..92e86a7 100644 --- a/l10n/l10n_br.xml +++ b/l10n/l10n_br.xml @@ -48,6 +48,8 @@ + + diff --git a/l10n/l10n_cs.xml b/l10n/l10n_cs.xml index 9a50cc3..8de211e 100644 --- a/l10n/l10n_cs.xml +++ b/l10n/l10n_cs.xml @@ -57,6 +57,8 @@ + + diff --git a/l10n/l10n_cz.xml b/l10n/l10n_cz.xml index 9396563..50af560 100644 --- a/l10n/l10n_cz.xml +++ b/l10n/l10n_cz.xml @@ -49,6 +49,8 @@ + + diff --git a/l10n/l10n_da.xml b/l10n/l10n_da.xml index 0cedb75..74a6130 100644 --- a/l10n/l10n_da.xml +++ b/l10n/l10n_da.xml @@ -57,6 +57,8 @@ + + diff --git a/l10n/l10n_de.xml b/l10n/l10n_de.xml index a6aa253..72da433 100644 --- a/l10n/l10n_de.xml +++ b/l10n/l10n_de.xml @@ -53,8 +53,10 @@ + + - + diff --git a/l10n/l10n_en.xml b/l10n/l10n_en.xml index 768b2f5..f3d1b26 100644 --- a/l10n/l10n_en.xml +++ b/l10n/l10n_en.xml @@ -57,8 +57,10 @@ + + - + diff --git a/l10n/l10n_fr.xml b/l10n/l10n_fr.xml index 3bb3d6a..d5716bf 100644 --- a/l10n/l10n_fr.xml +++ b/l10n/l10n_fr.xml @@ -49,6 +49,8 @@ + + diff --git a/l10n/l10n_it.xml b/l10n/l10n_it.xml index 8e9a93b..916550e 100644 --- a/l10n/l10n_it.xml +++ b/l10n/l10n_it.xml @@ -49,6 +49,8 @@ + + diff --git a/l10n/l10n_jp.xml b/l10n/l10n_jp.xml index 88de68c..f9c9047 100644 --- a/l10n/l10n_jp.xml +++ b/l10n/l10n_jp.xml @@ -49,6 +49,8 @@ + + diff --git a/l10n/l10n_pl.xml b/l10n/l10n_pl.xml index 9efdc09..5bf20e4 100644 --- a/l10n/l10n_pl.xml +++ b/l10n/l10n_pl.xml @@ -49,6 +49,8 @@ + + diff --git a/l10n/l10n_ru.xml b/l10n/l10n_ru.xml index f0e5085..24da0e4 100644 --- a/l10n/l10n_ru.xml +++ b/l10n/l10n_ru.xml @@ -48,6 +48,8 @@ + + diff --git a/modDesc.xml b/modDesc.xml index 00c32d3..1ba3d7e 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,7 +1,7 @@  Mmtrx - 1.2.7.9 + 1.2.8.0 <en>Better Contracts</en> @@ -24,7 +24,12 @@ 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.9 +Changelog v1.2.8.0 +- Tweak plow reward. Sort per NPC and contract value (#137) +- Allow mowers/ swathers on harvest missions (#137) +- Allow Göweil mission bales (#144) + +Changelog v1.2.7.9 - Allow 240er PackedBales as mission bales, i.e. insta ferment (needs mod arcusin Multipack D14) (#131) - Add 240er bales to Kuhn sw4014 wrapper @@ -107,7 +112,7 @@ Warnung: Alle in der Detailanzeige angegebenen Werte sind GESCHÄTZT. Sie sollte Die Mod merkt sich die Anzahl Verträge, die Sie für jeden der NPC Farmer abgeschlossen haben (die Zahl wird unter dem Bild des Farmers angezeigt, wenn "Details" an ist). Wenn der optionale Discount Modus oder der Hard Modus aktiviert wird, beeinflusst die Anzahl abgeschlossener Jobs das Spielgeschehen. -Changelog v1.2.7.9 +Changelog v1.2.7.9 - Gepackte 240er Ballen können mit dem im Mod enthaltenen arcusin Multipack D14 nun auch bei Gras-Missionen verwendet werden (#131) - Kuhn sw4014 Ballenwickler (im Mod) verarbeitet auch gepackte 240er Ballen diff --git a/scripts/gui.lua b/scripts/gui.lua index 76c04cc..896f472 100644 --- a/scripts/gui.lua +++ b/scripts/gui.lua @@ -26,6 +26,7 @@ -- v1.2.7.3 20.02.2023 double progress bar active contracts. Fix PnH BGA/ Maize+ -- v1.2.7.5 26.02.2023 display other farms active contracts (MP only) -- v1.2.7.6 21.03.2023 format rewd values > 100.000 (issue #113) +-- v1.2.8.0 03.08.2023 Sort per NPC and contract value --======================================================================================================= --- Adds a new page to the in game menu. @@ -458,7 +459,13 @@ function populateCell(frCon, list, sect, index, cell) end end function sortList(frCon, superfunc) - -- sort frCon.contracts according to sort button clicked + --[[ sort frCon.contracts according to sort button clicked: + 1 "sortcat", mission category / field (defaut) + 2 "sortrev", Revenue / contract value + 3 "sortnpc", NPC farmer offering mission + 4 "sortprof", net profit + 5 "sortpmin", net profit per minute + ]] local self = BetterContracts if not self.isOn or self.sort < 2 then superfunc(frCon) @@ -468,24 +475,29 @@ function sortList(frCon, superfunc) local av, bv = 1000000.0 * (a.active and 1 or 0) + 500000.0 * (a.finished and 1 or 0), 1000000.0 * (b.active and 1 or 0) + 500000.0 * (b.finished and 1 or 0) local am, bm = a.mission, b.mission - if self.sort == 3 then -- sort profit per Minute + if self.sort == 5 then -- sort profit per Minute -- if permin == 0 for both am, bm, then sort on profit av = av + 50.0 * self.IdToCont[am.id][2].permin + 0.0001 * self.IdToCont[am.id][2].profit bv = bv + 50.0 * self.IdToCont[bm.id][2].permin + 0.0001 * self.IdToCont[bm.id][2].profit - elseif self.sort == 2 then -- sort profit + + elseif self.sort == 4 then -- sort profit av = av + self.IdToCont[am.id][2].profit bv = bv + self.IdToCont[bm.id][2].profit - --[[ - elseif self.sort == 1 then -- sort mission category / field # - av = av - 10000 * self.IdToCont[am.id][1] - 100 * am.type.typeId - if am.field ~= nil then - av = av - am.field.fieldId - end - bv = bv - 10000 * self.IdToCont[bm.id][1] - 100 * bm.type.typeId - if bm.field ~= nil then - bv = bv - bm.field.fieldId - end - ]] + + elseif self.sort == 3 then -- sort NPC + local anpc, bnpc = am:getNPC().title, bm:getNPC().title + local afield = am.field ~= nil and am.field.fieldId or 0 + local bfield = bm.field ~= nil and bm.field.fieldId or 0 + local z = anpc < bnpc and 1000 or -1000 + + if anpc == bnpc then z = 0 end + av = av + z - afield + bv = bv - z - bfield + + elseif self.sort == 2 then -- sort revenue + av = av + self.IdToCont[am.id][2].reward + bv = bv + self.IdToCont[bm.id][2].reward + else -- should not happen av, bv = am.generationTime, bm.generationTime end @@ -501,21 +513,38 @@ function sortList(frCon, superfunc) { title = g_i18n:getText("fieldJob_finished"), contracts = {} }, - { title = g_i18n:getText("SC_sortpMin"):upper(), + { title = g_i18n:getText("SC_sortpMin"):upper(), -- assume self.sort == 5 contracts = {} } } - if self.sort == 2 then + if self.sort == 3 then -- npc sort, needs multiple sections + table.remove(frCon.sectionContracts, 3) + elseif self.sort == 4 then frCon.sectionContracts[3].title = g_i18n:getText("SC_sortProf"):upper() + elseif self.sort == 2 then + frCon.sectionContracts[3].title = g_i18n:getText("SC_sortRev"):upper() end - local lastType = nil + local lastNpc, npc = nil for _, contract in ipairs(frCon.contracts) do if contract.active then table.insert(frCon.sectionContracts[1].contracts, contract) elseif contract.finished then table.insert(frCon.sectionContracts[2].contracts, contract) else - table.insert(frCon.sectionContracts[3].contracts, contract) + if self.sort ~= 3 then + table.insert(frCon.sectionContracts[3].contracts, contract) + else + -- if new npc, make a section, else insert contract in current sect + npc = contract.mission:getNPC() + if lastNpc ~= npc then + table.insert(frCon.sectionContracts, { + title = npc.title, + contracts = {} + }) + lastNpc = npc + end + table.insert(frCon.sectionContracts[#frCon.sectionContracts].contracts, contract) + end end end if #frCon.sectionContracts[2].contracts == 0 then @@ -726,11 +755,10 @@ function updateButtonsPanel(menu, page) end function BetterContracts:radioButton(st) -- implement radiobutton behaviour: max. one sort button can be active - self.lastSort = self.sort self.sort = st local prof = { - active = {"SeeContactiveCat", "SeeContactiveProf", "SeeContactivepMin"}, - std = {"SeeContsortCat", "SeeContsortProf", "SeeContsortpMin"} + active = {"BCactiveCat", "BCactiveRev", "BCactiveNpc", "BCactiveProf", "BCactivepMin"}, + std = {"BCsortCat", "BCsortRev", "BCsortNpc", "BCsortProf", "BCsortpMin"} } local bname if st == 0 then -- called from buttonCallback() when switching to off @@ -743,16 +771,13 @@ function BetterContracts:radioButton(st) end return end - local a, b = math.fmod(st + 1, 3), math.fmod(st + 2, 3) - if a == 0 then - a = 3 - end - if b == 0 then - b = 3 - end self.my[self.buttons[st][1]]:applyProfile(prof.active[st]) -- set this Button Active - self.my[self.buttons[a][1]]:applyProfile(prof.std[a]) -- reset the other 2 - self.my[self.buttons[b][1]]:applyProfile(prof.std[b]) + + local last = self.lastSort + if last > 0 then + self.my[self.buttons[last][1]]:applyProfile(prof.std[last]) -- reset the last active button + end + self.lastSort = self.sort end function onClickFilterButton(frCon, button) local self = BetterContracts diff --git a/scripts/userint.lua b/scripts/userint.lua index 60c06c7..d5c003a 100644 --- a/scripts/userint.lua +++ b/scripts/userint.lua @@ -295,18 +295,6 @@ function BetterContracts:estWorktime(wid, hei, wwid, speed) return netT, netT + nlanes * self.turnTime -- assume 5 sec per u-turn end --------------------- allow mission bales in bale/pallet store ------------------------------------ -AbstractBaleObject = PlaceableObjectStorage.ABSTRACT_OBJECTS_BY_CLASS_NAME["Bale"] -function AbstractBaleObject.isObjectSupported(storage, object) - if not storage.spec_objectStorage.supportsBales then - return false - end - if not storage:getObjectStorageSupportsFillType(object:getFillType()) then - return false - end - return true -end - -------------------- bale fermenting functions --------------------------------------------------- BC_Action = { BC_CUT = 1, @@ -375,7 +363,7 @@ function BaleFermentEvent:run(connection) end end --------------------- allow packed bale as mision bale -------------------------------------------- +-------------------- allow packed bale as mission bale -------------------------------------------- function loadBaleAttributes(self, superf, xmlFile) -- overwrites Bale:loadBaleAttributesFromXML(xmlFile) if self:isa(PackedBale) then @@ -387,3 +375,21 @@ function loadBaleAttributes(self, superf, xmlFile) end return superf(self, xmlFile) end + +-------------------- let Göweil create mission bale ----------------------------------------------- +function BetterContracts:createBale(superFunc, baleFillType, fillLevel, ...) + -- overwrites createBale() in "balerStationary" spec + local ret = superFunc(self, baleFillType, fillLevel, ...) + if ret then + local spec = self.spec_baler + local bale = spec.bales[#spec.bales] + if bale.baleObject ~= nil then + local x,_,z = getWorldTranslation(self.rootNode) + local m = g_missionManager:getMissionAtWorldPosition(x,z) + if m ~= nil and m.type.name == "mow_bale" then + bale.baleObject:setIsMissionBale(true) + end + end + end + return ret +end