Skip to content

Commit

Permalink
v1.2.7.4
Browse files Browse the repository at this point in the history
- increase range for "toDeliver". Add setting "toDeliverBale"
- streamlined gui loading
  • Loading branch information
Mmtrx committed Feb 22, 2023
1 parent 24ff474 commit 6c20803
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 62 deletions.
10 changes: 7 additions & 3 deletions betterContracts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
-- 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+
-- v1.2.7.4 22.02.2023 increase range for "toDeliver". Add setting "toDeliverBale"
--=======================================================================================================
SC = {
FERTILIZER = 1, -- prices index
Expand Down Expand Up @@ -223,7 +224,8 @@ function readconfig(self)
self.config.maxActive = xmlFile:getValue(key.."#maxActive", 3)
self.config.multReward= xmlFile:getValue(key.."#reward", 1.)
self.config.multLease = xmlFile:getValue(key.."#lease", 1.)
self.config.toDeliver = xmlFile:getValue(key.."#deliver", 0.93)
self.config.toDeliver = xmlFile:getValue(key.."#deliver", 0.94)
self.config.toDeliverBale = xmlFile:getValue(key.."#deliver", 0.90)
self.config.refreshMP = xmlFile:getValue(key.."#refreshMP", 2)
self.config.lazyNPC = xmlFile:getValue(key.."#lazyNPC", false)
self.config.hardMode = xmlFile:getValue(key.."#hard", false)
Expand Down Expand Up @@ -407,7 +409,8 @@ function BetterContracts:initialize()
maxActive = 3, -- max active contracts
multReward = 1., -- general reward multiplier
multLease = 1., -- general lease cost multiplier
toDeliver = 0.93, -- HarvestMission.SUCCESS_FACTOR
toDeliver = 0.94, -- HarvestMission.SUCCESS_FACTOR
toDeliverBale = 0.90, -- BaleMission.SUCCESS_FACTOR
generationInterval = 1, -- MissionManager.MISSION_GENERATION_INTERVAL
missionGenPercentage = 0.2, -- percent of missions to be generated (default: 20%)
refreshMP = SC.ADMIN, -- necessary permission to refresh contract list (MP)
Expand Down Expand Up @@ -583,7 +586,7 @@ function BetterContracts:onPostLoadMap(mapNode, mapFile)
end
-- init Harvest SUCCESS_FACTORs (std is harv = .93, bale = .9)
HarvestMission.SUCCESS_FACTOR = self.config.toDeliver
BaleMission.FILL_SUCCESS_FACTOR = self.config.toDeliver - 0.03
BaleMission.FILL_SUCCESS_FACTOR = self.config.toDeliverBale

BetterContracts:updateGenerationSettings()

Expand Down Expand Up @@ -649,6 +652,7 @@ function BetterContracts:onPostSaveSavegame(saveDir, savegameIndex)
xmlFile:setFloat( key.."#reward", conf.multReward)
xmlFile:setFloat( key.."#lease", conf.multLease)
xmlFile:setFloat( key.."#deliver", conf.toDeliver)
xmlFile:setFloat( key.."#deliverBale", conf.toDeliverBale)
xmlFile:setInt ( key.."#refreshMP", conf.refreshMP)
xmlFile:setBool ( key.."#lazyNPC", conf.lazyNPC)
xmlFile:setBool ( key.."#discount", conf.discountMode)
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_br.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<text name="bc_discMaxJobs_tooltip" text="Pode reduzir o desconto máximo, por ex. desconto por contrato = 11%, número de trabalhos = 3 -> desconto máximo = 33%. Cuidado: o número atual de trabalhos concluídos diminuirá neste valor na compra de terras agrícolas." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliverBale" text="Delivery for baling contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />

<text name="bc_missionGeneration" text="Contract generation" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_cs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<text name="bc_discMaxJobs_tooltip" text="将会减少最大的折扣,例如:每个合同的折扣为11%,任务的数量为3,则最大折扣为33%。注意:在购买农田时,当前完成的工作数量将被这个值减少。" />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliverBale" text="Delivery for baling contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />

<text name="bc_missionGeneration" text="Contract generation" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_cz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<text name="bc_discMaxJobs_tooltip" text="Může snížit maximální slevu, např. sleva na smlouvu = 11 %, počet smluv = 3 -> max. sleva = 33 %. Upozornění: Aktuální počet dokončených úloh se při nákupu zemědělské půdy sníží o tuto hodnotu." />

<text name="bc_toDeliver" text="Procenta doručení ze sklizně" />
<text name="bc_toDeliverBale" text="Delivery for baling contracts" />
<text name="bc_toDeliver_tooltip" text="Procento odhadovaného celkového výnosu, které musíte dodat, abyste dokončili smlouvu o sklizni." />

<text name="bc_missionGeneration" text="Contract generation" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<text name="bc_maxActive" text="Gleichzeitig aktive Verträge" />
<text name="bc_maxActive_tooltip" text="Maximalzahl der gleichzeitig erlaubten aktiven Verträge" />
<text name="bc_toDeliver" text="Lieferanteil Ernteverträge" />
<text name="bc_toDeliverBale" text="Lieferanteil Ballenverträge" />
<text name="bc_toDeliver_tooltip" text="Pozentsatz des theoretisch möglichen Ertrags, der zur Erfüllung eines Erntevertrags abgeliefert werden muss." />
<text name="bc_refreshMP" text="Berechtigung Vertragsliste" />
<text name="bc_refreshMP_tooltip" text="Wer in einem MP-Spiel Verträge löschen/ erzeugen darf" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<text name="bc_maxActive" text="Concurrently active contracts" />
<text name="bc_maxActive_tooltip" text="Max number of concurrently active contracts." />
<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliverBale" text="Delivery for baling contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
<text name="bc_refreshMP" text="Permission contracts list" />
<text name="bc_refreshMP_tooltip" text="Who can delete / refresh contracts in an MP game." />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<text name="bc_discMaxJobs_tooltip" text="Can reduce the max discount, e.g. discount per contract = 11%, number of jobs = 3 -> max discount = 33%. Caution: Current number of jobs complete will decrease by this value on a farmland purchase." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliverBale" text="Delivery for baling contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />

<text name="bc_missionGeneration" text="Contract generation" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_it.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<text name="bc_discMaxJobs_tooltip" text="Can reduce the max discount, e.g. discount per contract = 11%, number of jobs = 3 -> max discount = 33%. Caution: Current number of jobs complete will decrease by this value on a farmland purchase." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliverBale" text="Delivery for baling contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />

<text name="bc_missionGeneration" text="Contract generation" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_jp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<text name="bc_discMaxJobs_tooltip" text="Can reduce the max discount, e.g. discount per contract = 11%, number of jobs = 3 -> max discount = 33%. Caution: Current number of jobs complete will decrease by this value on a farmland purchase." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliverBale" text="Delivery for baling contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />

<text name="bc_missionGeneration" text="Contract generation" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_pl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<text name="bc_discMaxJobs_tooltip" text="Can reduce the max discount, e.g. discount per contract = 11%, number of jobs = 3 -> max discount = 33%. Caution: Current number of jobs complete will decrease by this value on a farmland purchase." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliverBale" text="Delivery for baling contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />

<text name="bc_missionGeneration" text="Contract generation" />
Expand Down
1 change: 1 addition & 0 deletions l10n/l10n_ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<text name="bc_discMaxJobs_tooltip" text="Можно изменить максимальную скидку: скидка за контракт = 11%, количество заданий = 3 -> максимальная скидка = 33%. Внимание: Текущее количество выполненных работ уменьшится на это значение при покупке участков." />

<text name="bc_toDeliver" text="Доставка по контрактам на сбор урожая" />
<text name="bc_toDeliverBale" text="Delivery for baling contracts" />
<text name="bc_toDeliver_tooltip" text="Процент от расчётного общего урожая, который вы должны доставить, чтобы выполнить контракт на сбор урожая." />

<text name="bc_missionGeneration" text="Contract generation" />
Expand Down
5 changes: 3 additions & 2 deletions modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="72">
<author>Mmtrx</author>
<version>1.2.7.3</version>
<version>1.2.7.4</version>
<title>
<en>Better Contracts</en>
</title>
Expand All @@ -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.3:
Changelog v1.2.7.4:
- 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
- add setting to change time interval between contract generation runs
Expand Down
90 changes: 39 additions & 51 deletions scripts/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,74 +105,62 @@ function loadIcons(self)
self.missionIcons[type] = icon
end
end
function BetterContracts:loadGUI(guiPath)
local canLoad = true
local fname
-- load my gui profiles
fname = guiPath .. "guiProfiles.xml"
if fileExists(fname) then
g_gui:loadProfiles(fname)
else
Logging.error("[GuiLoader %s] Required file '%s' could not be found!", self.name, fname)
return false
end
local xmlFile, layout
local cont = self.frCon.contractsContainer

-- load "SCGui.xml"
fname = guiPath .. "SCGui.xml"
function loadGuiFile(self, fname, parent, initial)
-- load gui from file, attach to parent, call initial func
if fileExists(fname) then
xmlFile = loadXMLFile("Temp", fname)
local fbox = self.frCon.farmerBox
-- load our "npcbox" as child of farmerBox:
g_gui:loadGuiRec(xmlFile, "GUI", fbox, self.frCon)
local npcbox = fbox:getDescendantById("npcbox")
npcbox:applyScreenAlignment()
npcbox:updateAbsolutePosition()
layout = fbox:getDescendantById("layout")
layout:invalidateLayout(true) -- adjust sort buttons
g_gui:loadGuiRec(xmlFile, "GUI", parent, self.frCon)
initial(parent)
delete(xmlFile)
else
Logging.error("[GuiLoader %s] Required file '%s' could not be found!", self.name, fname)
return false
end
-- load "filterGui.xml"
fname = guiPath .. "filterGui.xml"
return true
end
function BetterContracts:loadGUI(guiPath)
-- load my gui profiles
local fname = guiPath .. "guiProfiles.xml"
if fileExists(fname) then
xmlFile = loadXMLFile("Temp", fname)
g_gui:loadGuiRec(xmlFile, "GUI", cont, self.frCon)
layout = cont:getDescendantById("filterlayout")
layout:applyScreenAlignment()
layout:updateAbsolutePosition()
layout:invalidateLayout(true) -- adjust filter buttons
local hidden = cont:getDescendantById("hidden")
hidden:applyScreenAlignment()
hidden:updateAbsolutePosition()
delete(xmlFile)
g_gui:loadProfiles(fname)
else
Logging.error("[GuiLoader %s] Required file '%s' could not be found!", self.name, fname)
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)
-- 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()
parent:getDescendantById("layout"):invalidateLayout(true) -- adjust sort buttons
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 text fields
end
delete(xmlFile)
else
Logging.error("[GuiLoader %s] Required file '%s' could not be found!", self.name, fname)
return false
layout:invalidateLayout(true) -- adjust filter buttons
local hidden = parent:getDescendantById("hidden")
hidden:applyScreenAlignment()
hidden:updateAbsolutePosition()
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
end
end)
end

if not canLoad then return false end

-- load "BCsettingsPage.lua"
if g_gui ~= nil and g_gui.guis.BCSettingsFrame == nil then
local luaPath = guiPath .. "BCsettingsPage.lua"
Expand Down
21 changes: 15 additions & 6 deletions scripts/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-- Changelog:
-- v1.2.6.0 30.11.2022 UI for all settings
-- v1.2.6.5 18.01.2023 add setting "toDeliver": harvest contract success factor
-- v1.2.7.4 22.02.2023 increase range for "toDeliver". Add setting "toDeliverBale"
--=======================================================================================================
local function lazyNPCDisabled()
return not BetterContracts.config.lazyNPC
Expand Down Expand Up @@ -49,18 +50,27 @@ BCSettingsBySubtitle = {
noTranslate = true
},
{name = "toDeliver",
values = {.85,.87,.89,.91,.93},
texts = {"85 %","87 %","89 %","91 %","standard"},
default = 5,
min = .7, max = .941, increment = .03, unit = true,
default = 9,
title = "bc_toDeliver",
tooltip = "bc_toDeliver_tooltip",
actionFunc = function(self,ix)
HarvestMission.SUCCESS_FACTOR = self.values[ix]
BaleMission.FILL_SUCCESS_FACTOR = self.values[ix] - 0.03
BetterContracts:refresh() -- to recalc deliver/keep for harvest contr
end,
noTranslate = true
},
{name = "toDeliverBale",
min = .7, max = .91, increment = .04, unit = true,
default = 6,
title = "bc_toDeliverBale",
tooltip = "bc_toDeliver_tooltip",
actionFunc = function(self,ix)
BaleMission.FILL_SUCCESS_FACTOR = self.values[ix]
BetterContracts:refresh() -- to recalc deliver/keep for baling contr
end,
noTranslate = true
},
{name = "refreshMP",
values = {SC.ADMIN, SC.FARMMANAGER, SC.PLAYER},
texts = {"ui_admin","ui_farmManager","ui_players"},
Expand Down Expand Up @@ -239,7 +249,6 @@ function BCsetting.new(data, customMt)
self.values = table.copy(data.values)
self.texts = table.copy(data.texts)
elseif data.min ~= nil and data.max ~=nil then
-- maybe future use --
self.data.values = {}
self.data.texts = {}
BCsetting.generateValues(self, self.data.values, self.data.texts, data.min, data.max, data.increment, data.unit)
Expand Down Expand Up @@ -279,7 +288,7 @@ function BCsetting:generateValues(values, texts, min, max, inc, percent)
for i=min, max, inc do
table.insert(values, i)
local value = MathUtil.round(i, 2)
local text = percent and string.format("%+d %%",value*100) or tostring(value)
local text = percent and string.format("%d %%",value*100) or tostring(value)
table.insert(texts, text)
end
end
Expand Down

0 comments on commit 6c20803

Please sign in to comment.