diff --git a/FoodTooltip/FoodTooltip.csproj b/FoodTooltip/FoodTooltip.csproj index b18ab3c5..616a7079 100644 --- a/FoodTooltip/FoodTooltip.csproj +++ b/FoodTooltip/FoodTooltip.csproj @@ -2,7 +2,7 @@ Food Supply Tooltip - 3.7.0.0 + 3.8.0.0 PeterHan.FoodTooltip Shows tooltips on plants and critters for how much food they can supply per cycle in their current states. 3.2.0.0 diff --git a/FoodTooltip/FoodTooltipPatches.cs b/FoodTooltip/FoodTooltipPatches.cs index 9e7d88a0..b5daec78 100644 --- a/FoodTooltip/FoodTooltipPatches.cs +++ b/FoodTooltip/FoodTooltipPatches.cs @@ -70,7 +70,7 @@ public static class CreatureCalorieMonitor_Def_GetDescriptors_Patch { /// Applied after GetDescriptors runs. /// internal static void Postfix(GameObject obj, List __result) { - if (__result != null && obj != null) + if (__result != null) FoodTooltipUtils.AddCritterDescriptors(obj, __result); } } @@ -140,7 +140,7 @@ public static class SimpleInfoScreen_OnDeselectTarget_Patch { /// /// Applied after OnDeselectTarget runs. /// - internal static void Postfix(SimpleInfoScreen __instance, GameObject target) { + internal static void Prefix(SimpleInfoScreen __instance, GameObject target) { if (__instance != null && __instance.TryGetComponent( out InfoScreenRefresher rf)) rf.OnDeselectTarget(target); diff --git a/FoodTooltip/FoodTooltipUtils.cs b/FoodTooltip/FoodTooltipUtils.cs index 672d1351..d1e26cd8 100644 --- a/FoodTooltip/FoodTooltipUtils.cs +++ b/FoodTooltip/FoodTooltipUtils.cs @@ -40,15 +40,18 @@ internal static class FoodTooltipUtils { /// The plant to query. /// The location where the descriptors should be placed. internal static void AddCropDescriptors(Crop crop, IList descriptors) { + var db = Db.Get(); var cropVal = crop.cropVal; - GameObject go = crop.gameObject; - Klei.AI.Attribute yieldAmount = Db.Get().PlantAttributes.YieldAmount; - float preModifiedAttributeValue = go.GetComponent().GetPreModifiedAttributeValue(yieldAmount); - var maturity = Db.Get().Amounts.Maturity.Lookup(crop.gameObject); - if (maturity != null) - CreateDescriptors(TagManager.Create(cropVal.cropId), descriptors, - maturity.GetDelta() * Constants.SECONDS_PER_CYCLE * cropVal.numProduced - * preModifiedAttributeValue / maturity.GetMax(), FoodDescriptorTexts.PLANTS); + if (crop != null && crop.TryGetComponent(out Modifiers modifiers)) { + float preModifiedAttributeValue = modifiers.GetPreModifiedAttributeValue( + db.PlantAttributes.YieldAmount); + var maturity = Db.Get().Amounts.Maturity.Lookup(crop); + if (maturity != null) + CreateDescriptors(TagManager.Create(cropVal.cropId), descriptors, + maturity.GetDelta() * Constants.SECONDS_PER_CYCLE * cropVal. + numProduced * preModifiedAttributeValue / maturity.GetMax(), + FoodDescriptorTexts.PLANTS); + } } /// @@ -86,8 +89,10 @@ internal static void AddCritterDescriptors(GameObject critter, /// The tag IDs of the dropped items. /// The location where the dropped items will be stored. private static void CollectDrops(string[] drops, IDictionary result) { + int n = drops.Length; result.Clear(); - foreach (string drop in drops) { + for (int i = 0; i < n; i++) { + string drop = drops[i]; if (!result.TryGetValue(drop, out int qty)) qty = 0; result[drop] = qty + 1; diff --git a/FoodTooltip/InfoScreenRefresher.cs b/FoodTooltip/InfoScreenRefresher.cs index 136b555b..d51ba4a8 100644 --- a/FoodTooltip/InfoScreenRefresher.cs +++ b/FoodTooltip/InfoScreenRefresher.cs @@ -44,8 +44,10 @@ internal sealed class InfoScreenRefresher : KMonoBehaviour { /// /// The effect that was added or removed. private void EffectRefresh(object data) { + var di = DetailsScreen.Instance; // Effect IDs are hard coded in HappinessMonitor and Tinkerable - if (data is Effect effect && EFFECTS.Contains(effect.Id) && infoScreen != null) + if (data is Effect effect && EFFECTS.Contains(effect.Id) && infoScreen != null && + di != null && di.isActiveAndEnabled && di.target != null) infoScreen.RefreshInfoScreen(true); } @@ -84,7 +86,8 @@ internal void OnSelectTarget(GameObject target) { /// Refreshes the information panel. The argument is always null when reached. /// private void RefreshInfoPanel(object _) { - if (infoScreen != null) + var di = DetailsScreen.Instance; + if (infoScreen != null && di != null && di.isActiveAndEnabled && di.target != null) infoScreen.RefreshInfoScreen(true); } } diff --git a/PipPlantOverlay/translations/fr.po b/PipPlantOverlay/translations/fr.po index d7b42fc4..a7a3eb55 100644 --- a/PipPlantOverlay/translations/fr.po +++ b/PipPlantOverlay/translations/fr.po @@ -3,14 +3,14 @@ msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: \n" "PO-Revision-Date: \n" -"Last-Translator: \n" +"Last-Translator: Pholith\n" "Language-Team: \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Application: Oxygen Not IncludedPOT Version: 2.0\n" -"X-Generator: Poedit 3.4.1\n" +"X-Generator: Poedit 3.5\n" #. PeterHan.PipPlantOverlay.PipPlantOverlayStrings.INPUT_BINDINGS.ROOT.PIPPLANT msgctxt "" @@ -30,7 +30,7 @@ msgctxt "" "PeterHan.PipPlantOverlay.PipPlantOverlayStrings.UI.OVERLAYS.PIPPLANTING." "CANPLANT" msgid "Can plant here" -msgstr "Ne peut pas planter ici" +msgstr "Peut planter ici" #. PeterHan.PipPlantOverlay.PipPlantOverlayStrings.UI.OVERLAYS.PIPPLANTING.DESCRIPTION msgctxt "" @@ -119,7 +119,7 @@ msgctxt "" "PeterHan.PipPlantOverlay.PipPlantOverlayStrings.UI.OVERLAYS.PIPPLANTING." "TOOLTIPS.HARDNESS" msgid "Natural tile hardness is above {0:D}!" -msgstr "La dureté naturelle des carreaux est supérieure à {0:D} !" +msgstr "La dureté naturelle des dalles est supérieure à {0:D} !" #. PeterHan.PipPlantOverlay.PipPlantOverlayStrings.UI.OVERLAYS.PIPPLANTING.TOOLTIPS.PLANTCOUNT msgctxt ""