From 05108a6fc47bb5ff57b5822f0e322a1550f2cdf6 Mon Sep 17 00:00:00 2001 From: Mmtrx Date: Thu, 2 Mar 2023 09:01:30 +0100 Subject: [PATCH] v1.2.7.5 - display other farms active contracts (MP only) - read userDefined missions from "BCuserDefined.xml" in modSettings dir - update l10n: br, cz, ru --- betterContracts.lua | 138 +++++++++--------- gui/SCGui.xml | 32 +++- gui/guiProfiles.xml | 68 ++++++++- l10n/l10n_br.xml | 23 +-- l10n/l10n_cs.xml | 1 + l10n/l10n_cz.xml | 1 + l10n/l10n_de.xml | 3 +- l10n/l10n_en.xml | 1 + l10n/l10n_fr.xml | 1 + l10n/l10n_it.xml | 1 + l10n/l10n_jp.xml | 1 + l10n/l10n_pl.xml | 1 + l10n/l10n_ru.xml | 1 + ...mple_userDefined.xml => BCuserDefined.xml} | 3 +- modDesc.xml | 9 +- scripts/debug.lua | 88 ++++++++++- scripts/gui.lua | 52 ++++--- scripts/missionVehicles.lua | 26 ++-- 18 files changed, 325 insertions(+), 125 deletions(-) rename missionVehicles/{sample_userDefined.xml => BCuserDefined.xml} (98%) diff --git a/betterContracts.lua b/betterContracts.lua index 84f4eea..7f6bf16 100644 --- a/betterContracts.lua +++ b/betterContracts.lua @@ -48,6 +48,8 @@ -- 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+ -- v1.2.7.4 22.02.2023 increase range for "toDeliver". Add setting "toDeliverBale" +-- v1.2.7.5 26.02.2023 display other farms active contracts (MP only). +-- Read userDefined missions from "BCuserDefined.xml" in modSettings dir --======================================================================================================= SC = { FERTILIZER = 1, -- prices index @@ -62,15 +64,15 @@ SC = { BALING = 4, TRANSP = 5, SUPPLY = 6, - OTHER = 7, - -- refresh MP: - ADMIN = 1, - FARMMANAGER = 2, - PLAYER = 3, - -- hardMode expire: - DAY = 1, - MONTH = 2, - -- Gui controls: + OTHER = 7, + -- refresh MP: + ADMIN = 1, + FARMMANAGER = 2, + PLAYER = 3, + -- hardMode expire: + DAY = 1, + MONTH = 2, + -- Gui farmerBox controls: CONTROLS = { npcbox = "npcbox", sortbox = "sortbox", @@ -95,7 +97,10 @@ SC = { sortcat = "sortcat", sortprof = "sortprof", sortpmin = "sortpmin", - helpsort = "helpsort" + helpsort = "helpsort", + container = "container", + mTable = "mTable", + mToggle = "mToggle", }, -- Gui contractBox controls: CONTBOX = { @@ -128,28 +133,30 @@ function catMissionTypes(self) mission.type to BC category: harvest, spread, simple, mow, transp, supply self.typeToCat = {4, 3, 3, 2, 1, 3, 2, 2, 5, 6} ]] - self.typeToCat = {} - local function addMapping(name, category) - local missionType = g_missionManager:getMissionType(name) - if missionType ~= nil then - self.typeToCat[missionType.typeId] = category - end - end - addMapping("mow_bale", SC.BALING) - addMapping("plow", SC.SIMPLE) - addMapping("cultivate", SC.SIMPLE) - addMapping("sow", SC.SPREAD) - addMapping("harvest", SC.HARVEST) - addMapping("weed", SC.SIMPLE) - addMapping("spray", SC.SPREAD) - addMapping("fertilize", SC.SPREAD) - addMapping("transport", SC.TRANSP) - addMapping("supplyTransport", SC.SUPPLY) -- mod by GtX - addMapping("deadwood", SC.OTHER) -- Platinum DLC mission by Giants - addMapping("treeTransport", SC.OTHER) -- Platinum DLC mission by Giants - addMapping("destructibleRocks", SC.OTHER) -- Platinum DLC mission by Giants - addMapping("roll", SC.SIMPLE) -- roller mission by tn4799 - addMapping("lime", SC.SPREAD) -- lime mission by Mmtrx + self.typeToCat = {} + self.jobText = {} + local function addMapping(name, title, category) + local missionType = g_missionManager:getMissionType(name) + if missionType ~= nil then + self.typeToCat[missionType.typeId] = category + self.jobText[name] = g_i18n:getText(title) + end + end + addMapping("mow_bale", "fieldJob_jobType_baling", SC.BALING) + addMapping("plow","fieldJob_jobType_plowing", SC.SIMPLE) + addMapping("cultivate","fieldJob_jobType_cultivating", SC.SIMPLE) + addMapping("sow","fieldJob_jobType_sowing", SC.SPREAD) + addMapping("harvest","fieldJob_jobType_harvesting", SC.HARVEST) + addMapping("weed","fieldJob_jobType_weeding", SC.SIMPLE) + addMapping("spray","fieldJob_jobType_spraying", SC.SPREAD) + addMapping("fertilize","fieldJob_jobType_fertilizing", SC.SPREAD) + addMapping("transport","helpLine_Misc_Transport", SC.TRANSP) + addMapping("supplyTransport","ai_jobTitleDeliver", SC.SUPPLY) -- mod by GtX + addMapping("deadwood","deadwoodMission_title", SC.OTHER) -- Platinum DLC mission by Giants + addMapping("treeTransport","treeTransportMission_title", SC.OTHER) -- Platinum DLC mission by Giants + addMapping("destructibleRocks","destructibleRockMission_title", SC.OTHER) -- Platinum DLC mission by Giants + addMapping("roll","helpLine_ImproveYield_Rolling", SC.SIMPLE) -- roller mission by tn4799 + addMapping("lime","helpLine_ImproveYield_Liming", SC.SPREAD) -- lime mission by Mmtrx for _, missionType in pairs(g_missionManager.missionTypes) do if self.typeToCat[missionType.typeId] == nil then addMapping(missionType.name, SC.OTHER) -- default category for not registered mission types @@ -281,36 +288,25 @@ function loadPrices(self) return prices end function setupMissionFilter(self) - -- setup fieldjob types: - self.jobText = { - mow_bale = g_i18n:getText("fieldJob_jobType_baling"), - cultivate = g_i18n:getText("fieldJob_jobType_cultivating"), - fertilize = g_i18n:getText("fieldJob_jobType_fertilizing"), - harvest = g_i18n:getText("fieldJob_jobType_harvesting" ), - plow = g_i18n:getText("fieldJob_jobType_plowing"), - sow = g_i18n:getText("fieldJob_jobType_sowing"), - spray = g_i18n:getText("fieldJob_jobType_spraying"), - weed = g_i18n:getText("fieldJob_jobType_weeding"), - -- lime is g_missionManager.missionTypes[2] ! - } - self.fieldjobs = {} + self.buttonNames = {} self.otherTypes = {} self.filterState = {} for _, type in ipairs(g_missionManager.missionTypes) do -- initial state: show all types self.filterState[type.name] = true + -- setup button names local name = self.jobText[type.name] - if name ~= nil then - table.insert(self.fieldjobs, {type.typeId, type.name, name}) + if string.find("mow_balecultivatefertilizeharvestplowsowsprayweed",type.name) then + table.insert(self.buttonNames, {type.typeId, type.name, name}) else - table.insert(self.otherTypes,{type.typeId, type.name}) + table.insert(self.otherTypes,{type.typeId, type.name, name}) end end - table.sort(self.fieldjobs, function(a,b) + table.sort(self.buttonNames, function(a,b) return a[3] < b[3] end) -- this is for all other mission types: - table.insert(self.fieldjobs, + table.insert(self.buttonNames, {nil,"other", g_i18n:getText("bc_other")}) -- set controls for filterbox: @@ -323,7 +319,7 @@ function setupMissionFilter(self) button.onClickCallback = onClickFilterButton button.pressed = true -- set button text - button.elements[1]:setText(self.fieldjobs[i][3]) + button.elements[1]:setText(self.buttonNames[i][3]) end end function initGui(self) @@ -378,7 +374,7 @@ function initGui(self) -- set controls for npcbox, sortbox and their elements: for _, name in pairs(SC.CONTROLS) do - self.my[name] = self.frCon.farmerBox:getDescendantById(name) + self.my[name] = self.frCon.detailsBox:getDescendantById(name) end -- set controls for contractBox: for _, name in pairs(SC.CONTBOX) do @@ -394,12 +390,18 @@ function initGui(self) end setupMissionFilter(self) + -- init other farms mission table + self.my.mTable:initialize() + self.my.container:setVisible(false) + self.mapTableOn = false -- visibility of other farms mission table + self.my.mToggle.onClickCallback = onClickToggle + self.my.mToggle:setVisible(self.isMultiplayer) + self.my.filterlayout:setVisible(true) self.my.hidden:setVisible(false) self.my.npcbox:setVisible(false) self.my.sortbox:setVisible(false) end - function BetterContracts:initialize() debugPrint("[%s] initialize(): %s", self.name,self.initialized) if self.initialized ~= nil then return end -- run only once @@ -447,7 +449,7 @@ function BetterContracts:initialize() self.mow_bale = {} -- mow/ bale 4 self.transp = {} -- transport 5 self.supply = {} -- supplyTransport mod 6 - self.other = {} -- deadwood, treeTrans 7 + self.other = {} -- deadwood, treeTrans 7 self.IdToCont = {} -- to find a contract from its mission id self.fieldToMission = {} -- to find a contract from its field number self.catHarvest = "BEETHARVESTING BEETVEHICLES CORNHEADERS COTTONVEHICLES CUTTERS POTATOHARVESTING POTATOVEHICLES SUGARCANEHARVESTING SUGARCANEVEHICLES" @@ -516,8 +518,8 @@ function BetterContracts:initialize() Utility.appendedFunction(AbstractFieldMission, "onVehicleReset", onVehicleReset) -- rename mission vehicle: - for name, typeDef in pairs(g_vehicleTypeManager.types) do - if typeDef ~= nil and not TableUtility.contains({"horse","pallet","locomotive"}, name) then + for name, typeDef in pairs(g_vehicleTypeManager.types) do + if typeDef ~= nil and not TableUtility.contains({"horse","pallet","locomotive"}, name) then SpecializationUtil.registerOverwrittenFunction(typeDef, "getName", vehicleGetName) end end @@ -577,8 +579,9 @@ function BetterContracts:onPostLoadMap(mapNode, mapFile) if self.config.discountMode then txt = txt..", discountMode" end debugPrint(txt) end + addConsoleCommand("bcprint","Print detail stats for all available missions.","consoleCommandPrint",self) + addConsoleCommand("bcMissions","Print stats for other clients active missions.","bcMissions",self) if self.config.debug then - addConsoleCommand("bcprint", "Print detail stats for all available missions.", "consoleCommandPrint", self) addConsoleCommand("bcFieldGenerateMission", "Force generating a new mission for given field", "consoleGenerateFieldMission", g_missionManager) addConsoleCommand("gsMissionLoadAllVehicles", "Loading and unloading all field mission vehicles", "consoleLoadAllFieldMissionVehicles", g_missionManager) addConsoleCommand("gsMissionHarvestField", "Harvest a field and print the liters", "consoleHarvestField", g_missionManager) @@ -591,6 +594,7 @@ function BetterContracts:onPostLoadMap(mapNode, mapFile) BetterContracts:updateGenerationSettings() -- initialize constants depending on game manager instances + self.isMultiplayer = g_currentMission.missionDynamicInfo.isMultiplayer self.ft = g_fillTypeManager.fillTypes self.prices = loadPrices() self.sprUse = { @@ -859,18 +863,18 @@ function BetterContracts:addMission(m) reward = rew } table.insert(self.transp, cont) - elseif cat == SC.OTHER then - cont = { - miss = m, - worktime = 0, - profit = rew, - permin = 0, - reward = rew - } - table.insert(self.other, cont) + elseif cat == SC.OTHER then + cont = { + miss = m, + worktime = 0, + profit = rew, + permin = 0, + reward = rew + } + table.insert(self.other, cont) else Logging.warning("[%s]: Unknown cat %s in addMission(m)", self.name, cat) - end + end return {cat, cont} end function getPalletType(m) diff --git a/gui/SCGui.xml b/gui/SCGui.xml index 454ed81..b05db72 100644 --- a/gui/SCGui.xml +++ b/gui/SCGui.xml @@ -8,8 +8,8 @@ v1.0.0 20.04.2021 submit for release v1.1.0.4 07.07.2021 (Mmtrx) add user-defined missionVehicles.xml, allow missions with no vehicles v1.2.0.0 18.01.2022 (Mmtrx) adapt for FS22 + v1.2.7.5 26.02.2023 display other farms active contracts (general table) ======================================================================================================--> - @@ -42,4 +42,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gui/guiProfiles.xml b/gui/guiProfiles.xml index c502c9b..0927f4b 100644 --- a/gui/guiProfiles.xml +++ b/gui/guiProfiles.xml @@ -8,11 +8,11 @@ v1.0.0 20.04.2021 submit for release v1.1.0.4 07.07.2021 (Mmtrx) add user-defined missionVehicles.xml, allow missions with no vehicles v1.2.0.0 18.01.2022 (Mmtrx) adapt for FS22 + v1.2.7.5 26.02.2023 display other farms active contracts (general table) =======================================================================================================--> - - + @@ -21,6 +21,16 @@ + + + + + + + + + + @@ -133,4 +143,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/l10n/l10n_br.xml b/l10n/l10n_br.xml index fa8ab6a..fc8d686 100644 --- a/l10n/l10n_br.xml +++ b/l10n/l10n_br.xml @@ -3,6 +3,7 @@ + @@ -50,8 +51,8 @@ - - + + @@ -69,7 +70,7 @@ - + @@ -99,14 +100,14 @@ - - - + + + - - - - - + + + + + diff --git a/l10n/l10n_cs.xml b/l10n/l10n_cs.xml index 94af9fa..7ca8bb4 100644 --- a/l10n/l10n_cs.xml +++ b/l10n/l10n_cs.xml @@ -3,6 +3,7 @@ + diff --git a/l10n/l10n_cz.xml b/l10n/l10n_cz.xml index 274a4a3..64c7cf4 100644 --- a/l10n/l10n_cz.xml +++ b/l10n/l10n_cz.xml @@ -3,6 +3,7 @@ + diff --git a/l10n/l10n_de.xml b/l10n/l10n_de.xml index 8e7eeea..78ab033 100644 --- a/l10n/l10n_de.xml +++ b/l10n/l10n_de.xml @@ -2,7 +2,8 @@ - + + diff --git a/l10n/l10n_en.xml b/l10n/l10n_en.xml index 7d62325..016ce2e 100644 --- a/l10n/l10n_en.xml +++ b/l10n/l10n_en.xml @@ -3,6 +3,7 @@ + diff --git a/l10n/l10n_fr.xml b/l10n/l10n_fr.xml index 4af608d..dd7ff6d 100644 --- a/l10n/l10n_fr.xml +++ b/l10n/l10n_fr.xml @@ -3,6 +3,7 @@ + diff --git a/l10n/l10n_it.xml b/l10n/l10n_it.xml index bf23186..d1dfde3 100644 --- a/l10n/l10n_it.xml +++ b/l10n/l10n_it.xml @@ -3,6 +3,7 @@ + diff --git a/l10n/l10n_jp.xml b/l10n/l10n_jp.xml index bca154a..209efa1 100644 --- a/l10n/l10n_jp.xml +++ b/l10n/l10n_jp.xml @@ -3,6 +3,7 @@ + diff --git a/l10n/l10n_pl.xml b/l10n/l10n_pl.xml index 9390845..594a52f 100644 --- a/l10n/l10n_pl.xml +++ b/l10n/l10n_pl.xml @@ -3,6 +3,7 @@ + diff --git a/l10n/l10n_ru.xml b/l10n/l10n_ru.xml index 7111354..17002bc 100644 --- a/l10n/l10n_ru.xml +++ b/l10n/l10n_ru.xml @@ -3,6 +3,7 @@ + diff --git a/missionVehicles/sample_userDefined.xml b/missionVehicles/BCuserDefined.xml similarity index 98% rename from missionVehicles/sample_userDefined.xml rename to missionVehicles/BCuserDefined.xml index 89f0808..ec3eb48 100644 --- a/missionVehicles/sample_userDefined.xml +++ b/missionVehicles/BCuserDefined.xml @@ -7,7 +7,7 @@ You can define mod vehicles/ tools, see requiredMod="FS22_vaderstadSpiritR300S" below. Your user-defined vehicles are added to the mission vehicles from base game (and possibly from the map definition), to choose from when a new mission is created. - To make the mod read in your vehicle definitions, rename this file to userDefined.xml. + To make the mod read in your vehicle definitions, copy this file to your modSettings/ directory . You can delete any base game or map-defined mission vehicles (and thus use only those that you defined) by setting overwrite="true" in the tag. If you want to try this, use extreme @@ -20,6 +20,7 @@ v1.1.0.4 07.07.2021 (Mmtrx) add user-defined missionVehicles.xml, allow missions with no vehicles v1.2.0.0 18.01.2022 adapt for FS22 v1.2.6.3 18.01.2023 add seed / fertilizer / herbicide + v1.2.7.5 28.02.2023 Read userDefined missions from "BCuserDefined.xml" in modSettings/ dir =======================================================================================================--> diff --git a/modDesc.xml b/modDesc.xml index 9a4b7f9..06a0d22 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,7 +1,7 @@  Mmtrx - 1.2.7.4 + 1.2.7.5 <en>Better Contracts</en> @@ -24,7 +24,8 @@ 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.4: +Changelog v1.2.7.5: +- add all farms active missions display (MP only) - increase settings range for harvest success, separate setting for baling - add 2nd progress bar for active harvest contracts - fix Maize+ issue with Pumps'n Hoses BGA @@ -251,10 +252,14 @@ Registro de alterações v1.2.2.0: + + + + diff --git a/scripts/debug.lua b/scripts/debug.lua index a9486f4..c69db92 100644 --- a/scripts/debug.lua +++ b/scripts/debug.lua @@ -1,4 +1,3 @@ ----@diagnostic disable: lowercase-global --======================================================================================================= -- BetterContracts SCRIPT -- @@ -11,9 +10,90 @@ -- v1.1.0.4 07.07.2021 (Mmtrx) add user-defined missionVehicles.xml, allow missions with no vehicles -- v1.2.0.0 18.01.2022 (Mmtrx) adapt for FS22 -- 13.04.2022 moved restartGame() to DebugCommands +-- v1.2.7.5 26.02.2023 display other farms active contracts (MP only) --======================================================================================================= --------------------- development helper functions --------------------------------------------------- +-------------------- v1.2.7.5 functions for mTable -------------------------------------------------- +function BetterContracts:bcMissions() + -- print all active missions (only in debug mode) + print(string.format("%10s %10s %5s %10s %5s", "Farm","Contract","Field","Fruit","Compl")) + local data = self:getMData() + for _,row in ipairs(data) do + print(string.format("%10s %10s %5s %10s %5s", + row.c1, row.c2, row.c3, row.c4, row.c5)) + end +end +function BetterContracts:getMData(notMy) + -- return data rows for other farms mission table + -- {c1="MyFarm",c2="Düngen",c3=14,c4="Gerste", c5="22%"} + local fmissions, data = {}, {} + local myId = g_currentMission.player.farmId or 0 + for _, farm in ipairs(g_farmManager:getFarms()) do + if not (notMy and farm.farmId == myId) then + fmissions = table.ifilter(g_missionManager:getMissionsList(farm.farmId), function(m) + return m.status == AbstractMission.STATUS_RUNNING or + m.status == AbstractMission.STATUS_FINISHED + end) + for _, m in ipairs(fmissions) do + local jobName = self.jobText[m.type.name] + if jobName==nil then jobName = g_i18n:getText("bc_other") end + local progress = string.format("%d%%", MathUtil.round(m:getCompletion()*100)) + local fruitName = "n/a" + local fieldId = "n/a" + if m.field then fieldId = m.field.fieldId end + if table.hasElement({"harvest","mow_bale","supplyTransport"}, m.type.name) then + fruitName = self.ft[m.fillType].title + elseif m.field and m.field.fruitType then + local ft = g_fruitTypeManager:getFillTypeIndexByFruitTypeIndex(m.field.fruitType) + fruitName = self.ft[ft].title + end + local row = { + c1 = farm.name, + c2 = jobName, + c3 = fieldId, + c4 = fruitName, + c5 = progress, + } + table.insert(data, row) + end + end + end + return data +end +function testData(self) + return { + {c1="MyFarm",c2="Düngen",c4="Gerste", c3=14, c5=22}, + {c1="MyFarm",c2="Ernten",c4="Weizen", c3=18, c5=11}, + {c1="Hof-2", c2="Düngen",c4="Bohnen", c3=5, c5=100}, + {c1="Hof 3", c2="Düngen",c4="Kartoffeln",c3=37, c5=80}, + {c1="Hof 3", c2="Kalken",c4="n/a", c3=114,c5=0}, + {c1="Hof-2", c2="Düngen",c4="Bohnen", c3=5, c5=100}, + {c1="Hof 3", c2="Düngen",c4="Kartoffeln",c3=37, c5=80}, + {c1="Hof 3", c2="Kalken",c4="n/a", c3=114,c5=0}, + } +end +function updateMTable(self) + -- update missions table + local bt = self.my.mTable + bt:clearData() + local mData = self:getMData(true) + for i=1, #mData do + self:buildRow(bt, bt.columnNames, mData[i]) + end + bt:updateView(true) +end +function BetterContracts:buildRow(bt, cols, values) + -- adds a row to table bt, inits col cells to values + -- bt.columnnames = {"c1","c2","c3","c4","c5"} + -- local id = string.combine(values.c1:split(" "),"") -- id only optional for new row + local row = TableElement.DataRow.new(nil, cols ) + bt:addRow(row) -- this makes bt.data[bt.numActiveRows] = row + local ixRow = bt.numActiveRows + for c, value in pairs(values) do + bt:setCellText(ixRow, cols[c], tostring(value)) + end +end +------------------------------------------------------------------------------------------ function BetterContracts:consoleCommandPrint() -- print table of current missions local sep = string.rep("-", 45) @@ -45,9 +125,9 @@ function BetterContracts:consoleCommandPrint() ) end -- mow/bale missions: - if #self.baling > 0 then + if #self.mow_bale > 0 then print(sep .. "Baling Miss" .. sep) - for i, c in ipairs(self.baling) do + for i, c in ipairs(self.mow_bale) do m = c.miss print( string.format( diff --git a/scripts/gui.lua b/scripts/gui.lua index 99801f4..50008c2 100644 --- a/scripts/gui.lua +++ b/scripts/gui.lua @@ -24,6 +24,7 @@ -- 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+ +-- v1.2.7.5 26.02.2023 display other farms active contracts (MP only) --======================================================================================================= --- Adds a new page to the in game menu. @@ -120,6 +121,13 @@ function loadGuiFile(self, fname, parent, initial) end return true end +function fixPosition(element, invLayout) + element:applyScreenAlignment() + element:updateAbsolutePosition() + if invLayout then + element:invalidateLayout(true) + end +end function BetterContracts:loadGUI(guiPath) -- load my gui profiles local fname = guiPath .. "guiProfiles.xml" @@ -129,33 +137,24 @@ function BetterContracts:loadGUI(guiPath) Logging.error("[GuiLoader %s] Required file '%s' could not be found!", self.name, fname) return false end - -- load our "npcbox" as child of farmerBox: - local canLoad = loadGuiFile(self, guiPath.."SCGui.xml", self.frCon.farmerBox, function(parent) - local npcbox = parent:getDescendantById("npcbox") - npcbox:applyScreenAlignment() - npcbox:updateAbsolutePosition() + -- load our npcbox and mission table as child of detailsBox: + local canLoad = loadGuiFile(self, guiPath.."SCGui.xml", self.frCon.detailsBox, function(parent) + fixPosition(parent:getDescendantById("npcbox")) parent:getDescendantById("layout"):invalidateLayout(true) -- adjust sort buttons + fixPosition(parent:getDescendantById("container")) end) -- load filter buttons if canLoad then canLoad = loadGuiFile(self, guiPath.."filterGui.xml", self.frCon.contractsContainer, function(parent) - layout = parent:getDescendantById("filterlayout") - layout:applyScreenAlignment() - layout:updateAbsolutePosition() - layout:invalidateLayout(true) -- adjust filter buttons - local hidden = parent:getDescendantById("hidden") - hidden:applyScreenAlignment() - hidden:updateAbsolutePosition() + fixPosition(parent:getDescendantById("filterlayout"), true) + fixPosition(parent:getDescendantById("hidden")) end) end -- load progress bars if canLoad then canLoad = loadGuiFile(self, guiPath.."progressGui.xml", self.frCon.contractBox, function(parent) for _,id in ipairs({"box1","box2"}) do - layout = parent:getDescendantById(id) - layout:applyScreenAlignment() - layout:updateAbsolutePosition() - layout:invalidateLayout(true) -- adjust text fields + fixPosition(parent:getDescendantById(id), true) end end) end @@ -519,8 +518,11 @@ function sortList(frCon, superfunc) end end function updateFarmersBox(frCon, field, npc) - -- set the text values in our npcbox local self = BetterContracts + -- hide farmerBox when our mapTable is shown: + frCon.farmerBox:setVisible(not self.mapTableOn) + + -- set the text values in our npcbox if not self.isOn then return end -- find the current contract @@ -761,8 +763,8 @@ function onClickFilterButton(frCon, button) filterList(other[1], button.pressed) end else - local typeId = self.fieldjobs[index][1] - local typeName = self.fieldjobs[index][2] + local typeId = self.buttonNames[index][1] + local typeName = self.buttonNames[index][2] self.filterState[typeName] = button.pressed filterList(typeId, button.pressed) end @@ -812,3 +814,15 @@ function showContextBox(contextBox, hotspot, description, imageFilename, uvs, fa text:applyProfile("ingameMenuMapContextText") end end +-------------------------------------------- v1.2.7.5 ------------------------------- +function onClickToggle(frCon) + -- toggles display of other farms mission table, can only be called in MP game + self = BetterContracts + local stat = not self.mapTableOn + self.mapTableOn = stat + if stat then + updateMTable(self) + end + self.my.container:setVisible(stat) + frCon.farmerBox:setVisible(not stat) +end diff --git a/scripts/missionVehicles.lua b/scripts/missionVehicles.lua index aad0ba0..55ded66 100644 --- a/scripts/missionVehicles.lua +++ b/scripts/missionVehicles.lua @@ -14,6 +14,7 @@ -- v1.2.6.5 19.01.2023 handle zombie (pallet, bigbag) vehicles when dismissing contracts -- v1.2.7.0 29.01.2023 visual tags for mission fields and vehicles. -- show leased vehicles for active contracts +-- v1.2.7.5 28.02.2023 Read userDefined missions from "BCuserDefined.xml" in savegame dir --======================================================================================================= ---------------------- mission vehicle loading functions -------------------------------------------- @@ -25,27 +26,19 @@ function BetterContracts.loadMissionVehicles(missionManager, superFunc, xmlFilen if self.overwrittenVehicles then return true end -- do not add further vecs to a userdefined setup if superFunc(missionManager, xmlFilename, baseDirectory) then - --[[ - if g_modIsLoaded["FS19_ThueringerHoehe_BG_Edition"] then - debugPrint("[%s] %s map detected, loading mission vehicles created by %s", self.name, "FS19_ThueringerHoehe", "Lahmi") - missionManager.missionVehicles = {} - self:loadExtraMissionVehicles(self.directory .. "missionVehicles/FS19_ThueringerHoehe/baseGame.xml") - else - ]] if self.loadedVehicles then return true end - if self.debug then - self:checkExtraMissionVehicles(self.directory .. "missionVehicles/baseGame.xml") - end - self:loadExtraMissionVehicles(self.directory .. "missionVehicles/baseGame.xml") - -- self:loadExtraMissionVehicles(self.directory .. "missionVehicles/claasPack.xml") - self.loadedVehicles = true - --end - local userdef = self.directory .. "missionVehicles/userDefined.xml" + if self.debug then + self:checkExtraMissionVehicles(self.directory .. "missionVehicles/baseGame.xml") + end + self:loadExtraMissionVehicles(self.directory .. "missionVehicles/baseGame.xml") + self.loadedVehicles = true + + local userdef = g_modSettingsDirectory .. "BCuserDefined.xml" if fileExists(userdef) and self:checkExtraMissionVehicles(userdef) then -- check for other mod: if g_modIsLoaded.FS22_DynamicMissionVehicles then - Logging.warning("[%s] userDefined.xml not loaded. Incompatible with FS22_DynamicMissionVehicles", + Logging.warning("[%s] BCuserDefined.xml not loaded. Incompatible with FS22_DynamicMissionVehicles", self.name) else self.overwrittenVehicles = self:loadExtraMissionVehicles(userdef) @@ -268,7 +261,6 @@ function BetterContracts:vehicleTag(m, vehicle) local txt = string.format(" (%.6s %s)", self.jobText[m.type.name], m.field.fieldId) self.missionVecs[vehicle] = txt end - function loadNextVehicle(self, super, vehicle, vehicleLoadState, arguments) -- overwritten AbstractFieldMission:loadNextVehicleCallback() to allow spawning pallets if vehicle == nil then return end