Skip to content

Commit

Permalink
Bump to 1.2.0.2 - Add option to hide empty silos, add number formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsage committed Jan 28, 2023
1 parent ab6362c commit 1a7d02d
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 10 deletions.
Binary file modified FS22_ProductionInspector.zip
Binary file not shown.
Binary file modified FS22_ProductionInspector_update.zip
Binary file not shown.
14 changes: 9 additions & 5 deletions src/ProductionInspector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function ProductionInspector:new(mission, modDirectory, modName, logger)
isEnabledAnimMax = { 0, "int" },

isEnabledSiloMax = { 0, "int" },
isEnabledSiloShowEmpty = true,

setValueTextMarginX = { 15, "int" },
setValueTextMarginY = { 10, "int" },
Expand Down Expand Up @@ -204,11 +205,13 @@ function ProductionInspector:updateSilos()
end
end

table.insert(new_data_table, {
name = thisSilo:getName(),
percent = MathUtil.getFlooredPercent(totalFill, capacity),
fillLevels = cleanFillLevels
})
if self.settings:getValue("isEnabledSiloShowEmpty") or totalFill > 1 then
table.insert(new_data_table, {
name = thisSilo:getName(),
percent = MathUtil.getFlooredPercent(totalFill, capacity),
fillLevels = cleanFillLevels
})
end
end

self.logger:printVariable(new_data_table, FS22Log.LOG_LEVEL.VERBOSE, "display_data_silo", 4)
Expand Down Expand Up @@ -1396,6 +1399,7 @@ function ProductionInspector.initGui(self)
{ "ForceAnimJustify", "just"},
{ "DisplayModeSilo", "disp"},
{ "SiloVisible", "bool"},
{ "SiloShowEmpty", "bool"},
{ "SiloMax", "max"},
{ "ForceSiloJustify", "just"},
{ "TextBold", "bool"},
Expand Down
12 changes: 11 additions & 1 deletion src/lib/fs22FSGUnitConvert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ function FS22FSGUnits:getUnitType(fillTypeIdx)
return self.unit_types.SOLID
end

function FS22FSGUnits:scaleFillTypeLevel(fillTypeIdx, fillLevel, unitIdxSolid, unitIdxLiquid, showUnit)
function FS22FSGUnits:scaleFillTypeLevel(fillTypeIdx, fillLevel, unitIdxSolid, unitIdxLiquid, showUnit, showFormat)
-- Args :
-- - fillTypeIdx : fillType index. Same as to g_fillTypeManager:getFillTypeByIndex()
-- - fillLevel : Numeric fill level
-- - unitIdxSolid : Unit to use for solids, from FS22FSGUnits.unit_select[<unit type>]
-- - unitIdxLiquid : Unit to use for liquids, from FS22FSGUnits.unit_select[<unit type>]
-- - showUnit : append unit to returned value, default true
-- - showFormat: format the number (l10n)
local numberFormat = Utils.getNoNil(showFormat, true)
local showTheUnit = Utils.getNoNil(showUnit, true)
local fillType = g_fillTypeManager:getFillTypeByIndex(fillTypeIdx)
local massPerLiter = Utils.getNoNil(fillType.massPerLiter, 1)
Expand All @@ -180,6 +182,14 @@ function FS22FSGUnits:scaleFillTypeLevel(fillTypeIdx, fillLevel, unitIdxSolid, u

local convertedFillLevel = MathUtil.round(returnFillLevel * unitData.factor, unitData.precision)

if numberFormat then
if showTheUnit then
return g_i18n:formatVolume(convertedFillLevel, unitData.precision, g_i18n:getText(unitData.text))
else
return g_i18n:formatVolume(convertedFillLevel, unitData.precision, '')
end
end

if showTheUnit then
return tostring(convertedFillLevel) .. " " .. g_i18n:getText(unitData.text)
else
Expand Down
2 changes: 1 addition & 1 deletion src/loader.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

local debug = true
local debug = false
local modDirectory = g_currentModDirectory or ""
local modName = g_currentModName or "unknown"
local modEnvironment
Expand Down
10 changes: 7 additions & 3 deletions src/modDesc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Left Alt + Num Pad 6 : Toggle silo display on and off
Changelog:
v1.2.0.1
v1.2.0.2
- Format numbers with localization
- Add option to hide empty silos
- Fix top-left display to play nice with Precision Farming
- Add option to convert units for display
Expand Down Expand Up @@ -71,7 +73,9 @@ Left Alt + Num Pad 6 : Siloanzeige ein- und ausschalten
Changelog:
v1.2.0.1
v1.2.0.2
- Zahlen mit Lokalisierung formatieren
- Option zum Ausblenden leerer Silos hinzufügen
- Reparieren Sie die Anzeige oben links, damit sie mit Precision Farming kompatibel ist.
- Option zum Umrechnen von Einheiten für die Anzeige hinzufügen
Expand All @@ -95,7 +99,7 @@ v1.1.0.0
]]></de>
</description>
<author>JTSage</author>
<version>1.2.0.1</version>
<version>1.2.0.2</version>
<iconFilename>modIcon.dds</iconFilename>
<multiplayer supported="true"/>
<extraSourceFiles>
Expand Down
2 changes: 2 additions & 0 deletions src/translations/translation_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@
<text name="unit_fsgUnitConvert_imperialTon" text="tn" />
<text name="unit_fsgUnitConvert_fluidOunce" text="fl.oz" />
<text name="unit_fsgUnitConvert_fluidGallon" text="gal" />
<text name="setting_productionInspector_SiloShowEmpty" text="Leere Silos anzeigen" />
<text name="toolTip_productionInspector_SiloShowEmpty" text="Wenn aktiviert, Silos anzeigen, wenn sie leer sind" />
</texts>
</l10n>
3 changes: 3 additions & 0 deletions src/translations/translation_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<text name="setting_productionInspector_SiloVisible" text="Silos HUD Visible" />
<text name="toolTip_productionInspector_SiloVisible" text="When enabled, the silo overlay is shown" />

<text name="setting_productionInspector_SiloShowEmpty" text="Show Empty Silos" />
<text name="toolTip_productionInspector_SiloShowEmpty" text="When enabled, show silos when they are empty" />

<text name="setting_productionInspector_ForceProdJustify" text="Force Productions Text Justification" />
<text name="toolTip_productionInspector_ForceProdJustify" text="Force rendering of text left or right justified, default is based on placement" />
<text name="setting_productionInspector_ForceAnimJustify" text="Force Animals Text Justification" />
Expand Down
2 changes: 2 additions & 0 deletions src/translations/translation_ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@
<text name="unit_fsgUnitConvert_imperialTon" text="tn" />
<text name="unit_fsgUnitConvert_fluidOunce" text="fl.oz" />
<text name="unit_fsgUnitConvert_fluidGallon" text="gal" />
<text name="setting_productionInspector_SiloShowEmpty" text="Показать пустые силосы" />
<text name="toolTip_productionInspector_SiloShowEmpty" text="Когда включено, показывать бункеры, когда они пусты" />
</texts>
</l10n>

0 comments on commit 1a7d02d

Please sign in to comment.