Skip to content

Commit

Permalink
Merge pull request #36 from Vapok/vapok/r1.5.7
Browse files Browse the repository at this point in the history
Fixes the Cultural Issue on the Drops for Configuration Manager for Non-English Clients
  • Loading branch information
Vapok authored Feb 2, 2023
2 parents a8bd62f + 5e9d749 commit dfbcb7c
Show file tree
Hide file tree
Showing 23 changed files with 166 additions and 101 deletions.
5 changes: 3 additions & 2 deletions AdventureBackpacks/AdventureBackpacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Vapok.Common.Abstractions;
using Vapok.Common.Managers;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Managers.LocalizationManager;
using Vapok.Common.Tools;

namespace AdventureBackpacks
Expand All @@ -32,7 +33,7 @@ public class AdventureBackpacks : BaseUnityPlugin, IPluginInfo
//Module Constants
private const string _pluginId = "vapok.mods.adventurebackpacks";
private const string _displayName = "AdventureBackpacks";
private const string _version = "1.5.6";
private const string _version = "1.5.7";

//Interface Properties
public string PluginId => _pluginId;
Expand Down Expand Up @@ -72,7 +73,7 @@ private void Awake()

PrefabManager.Initalized = true;

Waiter.StatusChanged += InitializeBackpacks;
Localizer.Waiter.StatusChanged += InitializeBackpacks;

//Patch Harmony
_harmony = new Harmony(Info.Metadata.GUID);
Expand Down
5 changes: 3 additions & 2 deletions AdventureBackpacks/Assets/Effects/ColdResistance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using HarmonyLib;
using JetBrains.Annotations;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Shared;

namespace AdventureBackpacks.Assets.Effects;

Expand All @@ -26,7 +27,7 @@ public static void RegisterEffectConfiguration()
EnabledEffect = ConfigSyncBase.SyncedConfig(_configSection, "Effect Enabled", true,
new ConfigDescription("Enables the effect.",
null, // range between 0f and 1f will make it display as a percentage slider
new ConfigAttributes { IsAdminOnly = true, Order = 1 }));
new ConfigurationManagerAttributes { Order = 1 }));

//Waiting For Startup
ConfigRegistry.Waiter.StatusChanged += FillBiomeSettings;
Expand All @@ -48,7 +49,7 @@ public static void RegisterEffectBiomeQuality(BackpackBiomes biome, int defaultQ
var qualityLevel = ConfigSyncBase.SyncedConfig(_configSection, $"Effective Quality Level: {biome.ToString()}", defaultQuality,
new ConfigDescription("Quality Level needed to apply effect to backpack. Zero disables effect for Biome.",
new AcceptableValueRange<int>(0, 5),
new ConfigAttributes { IsAdminOnly = true, Order = 2 }));
new ConfigurationManagerAttributes { Order = 2 }));

if (!BiomeQualityLevels.ContainsKey(biome))
{
Expand Down
5 changes: 3 additions & 2 deletions AdventureBackpacks/Assets/Effects/Demister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using HarmonyLib;
using JetBrains.Annotations;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Shared;

namespace AdventureBackpacks.Assets.Effects;

Expand All @@ -26,7 +27,7 @@ public static void RegisterEffectConfiguration()
EnabledEffect = ConfigSyncBase.SyncedConfig(_configSection, "Effect Enabled", true,
new ConfigDescription("Enables the effect.",
null, // range between 0f and 1f will make it display as a percentage slider
new ConfigAttributes { IsAdminOnly = true, Order = 1 }));
new ConfigurationManagerAttributes { Order = 1 }));

//Waiting For Startup
ConfigRegistry.Waiter.StatusChanged += FillBiomeSettings;
Expand All @@ -48,7 +49,7 @@ public static void RegisterEffectBiomeQuality(BackpackBiomes biome, int defaultQ
var qualityLevel = ConfigSyncBase.SyncedConfig(_configSection, $"Effective Quality Level: {biome.ToString()}", defaultQuality,
new ConfigDescription("Quality Level needed to apply effect to backpack. Zero disables effect for Biome.",
new AcceptableValueRange<int>(0, 5),
new ConfigAttributes { IsAdminOnly = true, Order = 2 }));
new ConfigurationManagerAttributes { Order = 2 }));

if (!BiomeQualityLevels.ContainsKey(biome))
{
Expand Down
5 changes: 3 additions & 2 deletions AdventureBackpacks/Assets/Effects/FeatherFall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using HarmonyLib;
using JetBrains.Annotations;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Shared;

namespace AdventureBackpacks.Assets.Effects;

Expand All @@ -26,7 +27,7 @@ public static void RegisterEffectConfiguration()
EnabledEffect = ConfigSyncBase.SyncedConfig(_configSection, "Effect Enabled", true,
new ConfigDescription("Enables the effect.",
null, // range between 0f and 1f will make it display as a percentage slider
new ConfigAttributes { IsAdminOnly = true, Order = 1 }));
new ConfigurationManagerAttributes { Order = 1 }));

//Waiting For Startup
ConfigRegistry.Waiter.StatusChanged += FillBiomeSettings;
Expand All @@ -47,7 +48,7 @@ public static void RegisterEffectBiomeQuality(BackpackBiomes biome, int defaultQ
var qualityLevel = ConfigSyncBase.SyncedConfig(_configSection, $"Effective Quality Level: {biome.ToString()}", defaultQuality,
new ConfigDescription("Quality Level needed to apply effect to backpack. Zero disables effect for Biome.",
new AcceptableValueRange<int>(0, 5),
new ConfigAttributes { IsAdminOnly = true, Order = 2 }));
new ConfigurationManagerAttributes { Order = 2 }));

if (!BiomeQualityLevels.ContainsKey(biome))
{
Expand Down
5 changes: 3 additions & 2 deletions AdventureBackpacks/Assets/Effects/Waterproof.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using HarmonyLib;
using JetBrains.Annotations;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Shared;

namespace AdventureBackpacks.Assets.Effects;

Expand All @@ -28,7 +29,7 @@ public static void RegisterEffectConfiguration()
EnabledEffect = ConfigSyncBase.SyncedConfig(_configSection, "Effect Enabled", true,
new ConfigDescription("Enables the effect.",
null, // range between 0f and 1f will make it display as a percentage slider
new ConfigAttributes { IsAdminOnly = true, Order = 1 }));
new ConfigurationManagerAttributes { Order = 1 }));

//Waiting For Startup
ConfigRegistry.Waiter.StatusChanged += FillBiomeSettings;
Expand All @@ -49,7 +50,7 @@ public static void RegisterEffectBiomeQuality(BackpackBiomes biome, int defaultQ
var qualityLevel = ConfigSyncBase.SyncedConfig(_configSection, $"Effective Quality Level: {biome.ToString()}", defaultQuality,
new ConfigDescription("Quality Level needed to apply effect to backpack. Zero disables effect for Biome.",
new AcceptableValueRange<int>(0,5),
new ConfigAttributes { IsAdminOnly = true, Order = 2 }));
new ConfigurationManagerAttributes { Order = 2 }));

if (!BiomeQualityLevels.ContainsKey(biome))
{
Expand Down
17 changes: 10 additions & 7 deletions AdventureBackpacks/Assets/Items/BackpackItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Vapok.Common.Abstractions;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Managers.StatusEffects;
using Vapok.Common.Shared;

namespace AdventureBackpacks.Assets.Items;

Expand All @@ -16,6 +17,7 @@ internal abstract class BackpackItem : AssetItem, IBackpackItem
private static ConfigSyncBase _config;
private static ILogIt _logger;
private string _configSection;
private string _localizedCategory;

//Config Settings
internal Dictionary<int,ConfigEntry<Vector2>> BackpackSize { get; private set;}
Expand All @@ -32,7 +34,8 @@ internal abstract class BackpackItem : AssetItem, IBackpackItem

protected BackpackItem(string prefabName, string itemName, string configSection = "") : base(prefabName,itemName)
{
_configSection = string.IsNullOrEmpty(configSection) ? $"Backpack: {Localization.instance.Localize(itemName)}" : configSection;
_configSection = string.IsNullOrEmpty(configSection) ? $"Backpack: {itemName}" : configSection;
_localizedCategory = Localization.instance.Localize(_configSection);
Item.SectionName = _configSection;
BackpackSize = new();
}
Expand Down Expand Up @@ -65,7 +68,7 @@ internal virtual void RegisterBackpackSize(int quality = 1, int x = 6, int y = 3
BackpackSize.Add(quality, ConfigSyncBase.SyncedConfig(_configSection, $"Backpack Size - Level {quality}", new Vector2(x, y),
new ConfigDescription("Backpack size (width, height).\nMax width is 8 unless you want to break things.",
null,
new ConfigAttributes { IsAdminOnly = true, Order = 1 })));
new ConfigurationManagerAttributes { Category = _localizedCategory, Order = 1 })));

BackpackSize[quality]!.SettingChanged += Backpacks.UpdateItemDataConfigValues;
}
Expand All @@ -75,7 +78,7 @@ internal virtual void RegisterWeightMultiplier(float defaultValue = 0.5f)
WeightMultiplier = ConfigSyncBase.SyncedConfig(_configSection, "Weight Multiplier", defaultValue,
new ConfigDescription("The weight of items stored in the backpack gets multiplied by this value.",
new AcceptableValueRange<float>(0f, 1f), // range between 0f and 1f will make it display as a percentage slider
new ConfigAttributes { IsAdminOnly = true, Order = 2 }));
new ConfigurationManagerAttributes { Category = _localizedCategory, Order = 2 }));

WeightMultiplier!.SettingChanged += Backpacks.UpdateItemDataConfigValues;
}
Expand All @@ -85,15 +88,15 @@ internal virtual void RegisterBackpackBiome(BackpackBiomes defaultValue = Backpa
BackpackBiome = ConfigSyncBase.SyncedConfig(_configSection, "Backpack Biome", defaultValue,
new ConfigDescription("The Biome this bag will draw it's effects from.",
null,
new ConfigAttributes { IsAdminOnly = true, Order = 6 }));
new ConfigurationManagerAttributes { Category = _localizedCategory, Order = 6 }));
}

internal virtual void RegisterCarryBonus(int defaultValue = 0)
{
CarryBonus = ConfigSyncBase.SyncedConfig(_configSection, "Carry Bonus", defaultValue,
new ConfigDescription("Increases your carry capacity by this much (multiplied by item level) while wearing the backpack.",
new AcceptableValueRange<int>(0, 300),
new ConfigAttributes { IsAdminOnly = true, Order = 3 }));
new ConfigurationManagerAttributes { Category = _localizedCategory, Order = 3 }));

CarryBonus!.SettingChanged += Backpacks.UpdateItemDataConfigValues;
}
Expand All @@ -103,7 +106,7 @@ internal virtual void RegisterSpeedMod(float defaultValue = -0.15f)
SpeedMod = ConfigSyncBase.SyncedConfig(_configSection, "Speed Modifier", defaultValue,
new ConfigDescription("Wearing the backpack slows you down by this much.",
new AcceptableValueRange<float>(-1f, -0f),
new ConfigAttributes { IsAdminOnly = true, Order = 4 }));
new ConfigurationManagerAttributes { Category = _localizedCategory, Order = 4 }));

SpeedMod!.SettingChanged += Backpacks.UpdateItemDataConfigValues;
}
Expand All @@ -113,7 +116,7 @@ internal virtual void RegisterEnableFreezing(bool defaultValue = true)
EnableFreezing = ConfigSyncBase.SyncedConfig(_configSection, "Prevent freezing/cold?", defaultValue,
new ConfigDescription("Wearing the backpack protects you against freezing/cold, just like capes.",
null,
new ConfigAttributes { IsAdminOnly = true, Order = 5 }));
new ConfigurationManagerAttributes { Category = _localizedCategory, Order = 5 }));

EnableFreezing!.SettingChanged += Backpacks.UpdateItemDataConfigValues;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ public BackpackBlackForest(string prefabName, string itemName) : base(prefabName
AddUpgradeIngredient("TrollHide", 3);
AddUpgradeIngredient("Bronze", 3);

Item.DropsFrom.Add("Greydwarf", 0.02f, 1);
Item.DropsFrom.Add("Greydwarf_Elite", 0.04f, 1);
Item.DropsFrom.Add("Greydwarf_Shaman", 0.04f, 1);
Item.DropsFrom.Add("Troll", 0.10f, 1);

RegisterShaderSwap();

Item.DropsFrom.Add("Greydwarf", 0.002f, 1);
Item.DropsFrom.Add("Greydwarf_Elite", 0.004f, 1);
Item.DropsFrom.Add("Greydwarf_Shaman", 0.004f, 1);
Item.DropsFrom.Add("Troll", 0.01f, 1);
}

internal sealed override void RegisterConfigSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ public BackpackMeadows(string prefabName, string itemName) : base(prefabName , i
AddUpgradeIngredient("LeatherScraps", 5);
AddUpgradeIngredient("DeerHide", 3);

Item.DropsFrom.Add("Greyling", 0.02f, 1);

RegisterShaderSwap();
Item.DropsFrom.Add("Greyling", 0.002f, 1);
}

internal sealed override void RegisterConfigSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@ public BackpackMistlands(string prefabName, string itemName) : base(prefabName,
AddUpgradeIngredient("Eitr", 2);
AddUpgradeIngredient("Softtissue", 5);

Item.DropsFrom.Add("Dverger", 0.02f, 1);
Item.DropsFrom.Add("DvergerMage", 0.02f, 1);
Item.DropsFrom.Add("DvergerMageFire", 0.02f, 1);
Item.DropsFrom.Add("DvergerMageIce", 0.02f, 1);
Item.DropsFrom.Add("DvergerMageSupport", 0.02f, 1);

//RegisterShaderSwap();

Item.DropsFrom.Add("Dverger", 0.002f, 1);
Item.DropsFrom.Add("DvergerMage", 0.002f, 1);
Item.DropsFrom.Add("DvergerMageFire", 0.002f, 1);
Item.DropsFrom.Add("DvergerMageIce", 0.002f, 1);
Item.DropsFrom.Add("DvergerMageSupport", 0.002f, 1);
}
internal sealed override void RegisterConfigSettings()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ public BackpackMountains(string prefabName, string itemName) : base(prefabName,
AddUpgradeIngredient("WolfPelt", 5);
AddUpgradeIngredient("Silver", 5);

Item.DropsFrom.Add("Fenring_Cultist", 0.02f, 1);
Item.DropsFrom.Add("Fenring", 0.08f, 1);

RegisterShaderSwap();

Item.DropsFrom.Add("Fenring_Cultist", 0.002f, 1);
Item.DropsFrom.Add("Fenring", 0.008f, 1);
}

internal sealed override void RegisterConfigSettings()
Expand Down
10 changes: 4 additions & 6 deletions AdventureBackpacks/Assets/Items/BackpackItems/BackpackPlains.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ public BackpackPlains(string prefabName, string itemName) : base(prefabName, ite
AddUpgradeIngredient("LoxPelt", 2);
AddUpgradeIngredient("BlackMetal", 5);

Item.DropsFrom.Add("Goblin", 0.02f, 1);
Item.DropsFrom.Add("GoblinArcher", 0.02f, 1);
Item.DropsFrom.Add("GoblinBrute", 0.02f, 1);
Item.DropsFrom.Add("GoblinShaman", 0.02f, 1);

RegisterShaderSwap();
Item.DropsFrom.Add("Goblin", 0.002f, 1);
Item.DropsFrom.Add("GoblinArcher", 0.002f, 1);
Item.DropsFrom.Add("GoblinBrute", 0.002f, 1);
Item.DropsFrom.Add("GoblinShaman", 0.002f, 1);
}

internal sealed override void RegisterConfigSettings()
Expand Down
11 changes: 4 additions & 7 deletions AdventureBackpacks/Assets/Items/BackpackItems/BackpackSwamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ public BackpackSwamp(string prefabName, string itemName) : base(prefabName, item
AddUpgradeIngredient("Bloodbag", 2);
AddUpgradeIngredient("Iron", 5);

Item.DropsFrom.Add("Draugr", 0.02f, 1);
Item.DropsFrom.Add("Draugr_Ranged", 0.04f, 1);
Item.DropsFrom.Add("Draugr_Elite", 0.04f, 1);
Item.DropsFrom.Add("Troll", 0.08f, 1);

RegisterShaderSwap();

Item.DropsFrom.Add("Draugr", 0.002f, 1);
Item.DropsFrom.Add("Draugr_Ranged", 0.004f, 1);
Item.DropsFrom.Add("Draugr_Elite", 0.004f, 1);
Item.DropsFrom.Add("Troll", 0.008f, 1);
}

internal sealed override void RegisterConfigSettings()
Expand Down
10 changes: 6 additions & 4 deletions AdventureBackpacks/Configuration/ConfigRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using UnityEngine;
using Vapok.Common.Abstractions;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Shared;

namespace AdventureBackpacks.Configuration
{
Expand All @@ -23,30 +24,31 @@ public ConfigRegistry(IPluginInfo mod): base(mod)

InitializeConfigurationSettings();
}

public sealed override void InitializeConfigurationSettings()
{
if (_config == null)
return;

//User Configs
HotKeyOpen = _config.Bind("Local Config", "Open Backpack", KeyCode.I,
new ConfigDescription("Hotkey to open backpack.", null, new ConfigAttributes{ Order = 3 }));
new ConfigDescription("Hotkey to open backpack.", null, new ConfigurationManagerAttributes{ Order = 3 }));

HotKeyDrop = _config.Bind(
"Local Config", "Quickdrop Backpack", KeyCode.Y,
new ConfigDescription("Hotkey to quickly drop backpack while on the run.",
null,
new ConfigAttributes { Order = 2 }));
new ConfigurationManagerAttributes { Order = 2 }));

CloseInventory = _config.Bind(
"Local Config", "Close Inventory", true,
new ConfigDescription("If set to true, both backpack and inventory will close with Open Backpack keybind is pressed while Inventory is open.",
null, new ConfigAttributes { Order = 1 }));
null, new ConfigurationManagerAttributes { Order = 1 }));

OutwardMode = _config.Bind(
"Local Config", "Outward Mode", false,
new ConfigDescription("You can use a hotkey to quickly drop your equipped backpack in order to run faster away from danger.",
null, new ConfigAttributes { Order = 1 }));
null, new ConfigurationManagerAttributes { Order = 1 }));

Assets.Effects.Demister.Configuration.RegisterEffectConfiguration();
Assets.Effects.FeatherFall.Configuration.RegisterEffectConfiguration();
Expand Down
4 changes: 2 additions & 2 deletions AdventureBackpacks/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.6.0")]
[assembly: AssemblyFileVersion("1.5.6.0")]
[assembly: AssemblyVersion("1.5.7.0")]
[assembly: AssemblyFileVersion("1.5.7.0")]
7 changes: 7 additions & 0 deletions PATCHNOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Adventure Backpacks Patchnotes

# 1.5.7.0
* We have finally identified the issue with the drop rates. The issue stemmed from Non-English OS based players (where decimals are represented as 0,00, not 0.00) were experiencing an issue with a Culture variation issue.
* I couldn't detect it because I only run in English mode, and so it worked for me Apologies to my non-English friends out there.
* **_NOTE: PLEASE DELETE YOUR CONFIGURATION ON BOTH SERVER AND CLIENT WHEN UPDATING TO 1.5.7_**
* Revamped the Configuration Section to use non-localized section names in the configuration file, while still showing localized labels in the Configuration Manager UI.
* Turned off materials shader replacer, which was causing a flicker.

# 1.5.6.0
* Adding in Korean Translation thanks to hanawa07!
* When using the Configuration Manager, there was a weird interaction dealing with the Drop Chance that was making it impossible to edit the drop chance.
Expand Down
Loading

0 comments on commit dfbcb7c

Please sign in to comment.