Skip to content

Commit

Permalink
Version 1.2.4.0
Browse files Browse the repository at this point in the history
- allow for other (future) mission types,
- fix distorted menu page for different screen aspect ratios,
- show fruit type to harvest in contracts list
  • Loading branch information
Mmtrx committed Aug 17, 2022
1 parent 735aff4 commit a10b81c
Show file tree
Hide file tree
Showing 12 changed files with 626 additions and 62 deletions.
91 changes: 40 additions & 51 deletions betterContracts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
-- v1.2.3.0 04.04.2022 filter contracts per jobtype
-- 04.05.2022 moved restartGame() to DebugCommands. MaxMissions 80
-- v1.2.3.1 26.07.2022 add NPCHarvest to fix harvest contracts
-- v1.2.4.0 26.08.2022 allow for other (future) mission types,
-- fix distorted menu page for different screen aspect ratios,
-- show fruit type to harvest in contracts list
--=======================================================================================================
InitRoyalUtility(Utils.getFilename("lib/utility/", g_currentModDirectory))
InitRoyalMod(Utils.getFilename("lib/rmod/", g_currentModDirectory))
Expand All @@ -32,6 +35,7 @@ SC = {
BALING = 4,
TRANSP = 5,
SUPPLY = 6,
OTHER = 7,
-- Gui controls:
CONTROLS = {
npcbox = "npcbox",
Expand Down Expand Up @@ -100,13 +104,32 @@ function BetterContracts:initialize()
10 supplyTransport (Mod)
]]
-- 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 = {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("deadwood", SC.OTHER)
addMapping("treeTransport", SC.OTHER)
self.harvest = {} -- harvest missions 1
self.spread = {} -- sow, spray, fertilize 2
self.simple = {} -- plow, cultivate, weed 3
self.mow_bale = {} -- mow/ bale 4
self.transp = {} -- transport 5
self.supply = {} -- supplyTransport mod 6
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"
Expand Down Expand Up @@ -241,7 +264,7 @@ function BetterContracts:onPostLoadMap(mapNode, mapFile)
local rewd = self.frCon.contractsList.cellDatabase.autoCell1:getDescendantByName("reward")
local profit = rewd:clone(self.frCon.contractsList.cellDatabase.autoCell1)
profit.name = "profit"
profit:setPosition(-110 / 1920, -12/1080)
profit:setPosition(-110/1920, -12/1080 *g_aspectScaleY) --
--profit:setTextColor(1, 1, 1, 1)
profit.textBold = false
profit:setVisible(false)
Expand Down Expand Up @@ -320,55 +343,10 @@ function BetterContracts:onUpdate(dt)
end
end

function BetterContracts:loadGUI(canLoad, guiPath)
if canLoad then
local fname
-- load my gui profiles
fname = guiPath .. "guiProfiles.xml"
if fileExists(fname) then
g_gui:loadProfiles(fname)
else
canLoad = false
end
local xmlFile, layout
-- load "SCGui.xml"
fname = guiPath .. "SCGui.xml"
if canLoad and fileExists(fname) then
xmlFile = loadXMLFile("Temp", fname)
local fbox = self.frCon.farmerBox
g_gui:loadGuiRec(xmlFile, "GUI", fbox, self.frCon)
layout = fbox:getDescendantById("layout")
layout:invalidateLayout(true) -- adjust sort buttons
fbox:applyScreenAlignment()
fbox:updateAbsolutePosition()
fbox:onGuiSetupFinished() -- connect the tooltip elements
delete(xmlFile)
else
canLoad = false
Logging.error("[GuiLoader %s] Required file '%s' could not be found!", self.name, fname)
end
-- load "filterGui.xml"
fname = guiPath .. "filterGui.xml"
if canLoad and fileExists(fname) then
xmlFile = loadXMLFile("Temp", fname)
local cont = self.frCon.contractsContainer
g_gui:loadGuiRec(xmlFile, "GUI", cont, self.frCon)
layout = cont:getDescendantById("filterlayout")
cont:applyScreenAlignment()
cont:updateAbsolutePosition()
layout:invalidateLayout(true) -- adjust filter buttons
delete(xmlFile)
else
canLoad = false
Logging.error("[GuiLoader %s] Required file '%s' could not be found!", self.name, fname)
end
end
return canLoad
end
function BetterContracts:refresh()
-- refresh our contract tables. Called by onFrameOpen/updateList, and every 15 sec by self:onUpdate
self.harvest, self.spread, self.simple, self.mow_bale, self.transp, self.supply =
{}, {}, {}, {}, {}, {}
self.harvest, self.spread, self.simple, self.mow_bale, self.transp, self.supply, self.other =
{}, {}, {}, {}, {}, {}, {}
self.IdToCont, self.fieldToMission = {}, {}
local list = g_missionManager:getMissionsList(g_currentMission:getFarmId())
local res = {}
Expand Down Expand Up @@ -492,7 +470,7 @@ function BetterContracts:addMission(m)
reward = rew
}
table.insert(self.supply, cont)
else -- cat == SC.TRANSP
elseif cat == SC.TRANSP then
cont = {
miss = m,
worktime = 0,
Expand All @@ -503,7 +481,18 @@ function BetterContracts:addMission(m)
reward = rew
}
table.insert(self.transp, cont)
end
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
return {cat, cont}
end
function getPalletType(m)
Expand Down
2 changes: 2 additions & 0 deletions l10n/l10n_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<text name="bc_detailsOn" text="Details an" />

<!-- Display texts -->
<text name="bc_harvest" text="Ernte " />

<text name="SC_widhei" text="Max Breite/ Länge:" />
<text name="SC_worktim" text="Zeitschätzung:" />
<text name="SC_price" text="Preis:" />
Expand Down
2 changes: 2 additions & 0 deletions l10n/l10n_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<text name="bc_detailsOn" text="Details on" />

<!-- Display texts -->
<text name="bc_harvest" text="Harv. " />

<text name="SC_widhei" text="Max width/ height:" />
<text name="SC_worktim" text="Estimated time:" />
<text name="SC_price" text="Price:" />
Expand Down
2 changes: 2 additions & 0 deletions l10n/l10n_fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<text name="bc_detailsOn" text="Avec détails" />

<!-- Display texts -->
<text name="bc_harvest" text="Réco. " />

<text name="SC_widhei" text="Largeur,Longueur (max):" />
<text name="SC_worktim" text="Temps estimé:" />
<text name="SC_price" text="Prix:" />
Expand Down
2 changes: 2 additions & 0 deletions l10n/l10n_it.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<text name="bc_detailsOn" text="Details on" />

<!-- Display texts -->
<text name="bc_harvest" text="Harv. " />

<text name="SC_widhei" text="Max width/ height:" />
<text name="SC_worktim" text="Estimated time:" />
<text name="SC_price" text="Price:" />
Expand Down
2 changes: 2 additions & 0 deletions l10n/l10n_jp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<text name="bc_detailsOn" text="詳細表示" />

<!-- Display texts -->
<text name="bc_harvest" text="Harv. " />

<text name="SC_widhei" text="ほ場 横幅 / 縦幅:" />
<text name="SC_worktim" text="作業時間:" />
<text name="SC_price" text="価格:" />
Expand Down
2 changes: 2 additions & 0 deletions l10n/l10n_pl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<text name="bc_detailsOff" text="Szczegóły wył." />
<text name="bc_detailsOn" text="Szczegóły wł." />

<text name="bc_harvest" text="Harv. " />

<!-- Display texts -->
<text name="SC_widhei" text="Max. szerokość/wysokość:" />
<text name="SC_worktim" text="Szacowany czas:" />
Expand Down
2 changes: 2 additions & 0 deletions l10n/l10n_ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<text name="bc_detailsOn" text="Детали вкл." />

<!-- Display texts -->
<text name="bc_harvest" text="Harv. " />

<text name="SC_widhei" text="Макс. ширина/длина:" />
<text name="SC_worktim" text="Предполагаемое время:" />
<text name="SC_price" text="Цена/1000л:" />
Expand Down
18 changes: 9 additions & 9 deletions missionVehicles/baseGame.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
Changelog:
v1.2.0.1 29.03.2022 initial beta
v1.2.3.1 01.08.2022 adapt vehicle configs for FS22
v1.2.4.0 17.08.2022 correct tractor/ weight for sow-small-grain and weed-small
======================================================================================================-->
<missionVehicles overwrite="false">

Expand Down Expand Up @@ -291,17 +293,15 @@
<mission type="sow">
<!-- grainMission -->
<group fieldSize="small" variant="GRAIN">
<vehicle filename="$data/vehicles/masseyFerguson/series3700AL/series3700AL.xml">
<vehicle filename="$data/vehicles/newHolland/t6/t6.xml">
<!-- tractor -->
<configuration name="motor" id="2" />
<configuration name="wheel" id="3" />
<configuration name="fillUnit" id="2" />
<configuration name="frontloader" id="1" />
<configuration name="motor" id="3" />
<configuration name="wheel" id="20" />
</vehicle>
<vehicle filename="$data/vehicles/amazone/centaya3000Super/centaya3000Super.xml">
<vehicle filename="$data/vehicles/amazone/centaya3000Super/centaya3000Super.xml" >
<!-- seeder -->
</vehicle>
<vehicle filename="$data/vehicles/agco/weight650/weight650.xml">
<vehicle filename="$data/vehicles/tenwinkel/weight1000/weight1000.xml">
<configuration name="baseMaterial" id="7" />
</vehicle>
</group>
Expand Down Expand Up @@ -391,9 +391,9 @@

<mission type="weed">
<group fieldSize="small" rewardScale="0.7">
<vehicle filename="$data/vehicles/masseyFerguson/series3700AL/series3700AL.xml">
<vehicle filename="$data/vehicles/zetor/majorCL80/majorCL80.xml">
<!-- tractor -->
<configuration name="wheel" id="5" />
<configuration name="wheel" id="7" />
</vehicle>
<vehicle filename="$data/vehicles/einboeck/pneumaticstar900/pneumaticstar900.xml" /> <!-- weeder -->
<vehicle filename="$data/vehicles/agco/weight650/weight650.xml">
Expand Down
Loading

0 comments on commit a10b81c

Please sign in to comment.