Skip to content

Commit

Permalink
2.0 release
Browse files Browse the repository at this point in the history
- Switched to BepInEx
- Simplified code following vanilla changes
- Added translations
  • Loading branch information
DingoDjango committed Jan 13, 2023
1 parent 15ecddd commit 46121e7
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 308 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"ContainerEmpty": "empty",
"ContainerOneItem": "1 item (not full)",
"ContainerFull": "full",
"ContainerNonempty": "{0} items (not full)"
}
5 changes: 5 additions & 0 deletions BepInEx/plugins/StorageInfo/Languages/French.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ContainerEmpty": "vide",
"ContainerFull": "plein",
"ContainerNonempty": "{0} objets (pas plein)"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"ContainerEmpty": "Leer",
"ContainerOneItem": "1 Gegenstand",
"ContainerFull": "Voll",
"ContainerNonempty": "{0} Gegenstände"
}
5 changes: 5 additions & 0 deletions BepInEx/plugins/StorageInfo/Languages/Polish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ContainerEmpty": "puste",
"ContainerFull": "pełne",
"ContainerNonempty": "{0} przedmioty/ów (nie pełne)"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"ContainerEmpty": "Пусто",
"ContainerOneItem": "Заполнено 1 предметом",
"ContainerFull": "Полностью заполнено",
"ContainerNonempty": "Заполнено {0} предметами"
}
Binary file added BepInEx/plugins/StorageInfo/StorageInfo.dll
Binary file not shown.
65 changes: 65 additions & 0 deletions HarmonyPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using HarmonyLib;
using SMLHelper.V2.Utility;

namespace StorageInfo
{
public class HarmonyPatches
{
private static void Patch_OnHandHover_Postfix(StorageContainer __instance)
{
ItemsContainer itemStorage = __instance.container;

if (itemStorage != null)
{
SetCustomInteractText(itemStorage);
}
}

private static void Patch_SetCurrentLanguage_Postfix()
{
Translation.ReloadLanguage();
}

internal static void InitializeHarmony()
{
Harmony harmony = new Harmony("Dingo.Harmony.StorageInfo");

/* Remove original SetInteractText and inject SetCustomInteractText */
// Patch: StorageContainer.OnHandHover
harmony.Patch(
original: AccessTools.Method(typeof(StorageContainer), nameof(StorageContainer.OnHandHover)),
postfix: new HarmonyMethod(typeof(HarmonyPatches), nameof(HarmonyPatches.Patch_OnHandHover_Postfix)));

/* Reset language cache on game language change */
// Patch: Language.SetCurrentLanguage
harmony.Patch(
original: AccessTools.Method(typeof(Language), nameof(Language.SetCurrentLanguage)),
postfix: new HarmonyMethod(typeof(HarmonyPatches), nameof(HarmonyPatches.Patch_SetCurrentLanguage_Postfix)));
}

public static void SetCustomInteractText(ItemsContainer itemStorage)
{
string customSubscriptText = string.Empty;

if (itemStorage != null)
{
if (itemStorage.IsEmpty())
{
customSubscriptText = "ContainerEmpty".Translate();
}

else if (itemStorage.IsFull())
{
customSubscriptText = "ContainerFull".Translate();
}

else
{
customSubscriptText = "ContainerNonempty".FormatTranslate(itemStorage.count.ToString());
}
}

HandReticle.main.SetText(HandReticle.TextType.HandSubscript, customSubscriptText, false);
}
}
}
23 changes: 23 additions & 0 deletions ModPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using BepInEx;
using UnityEngine;

namespace StorageInfo
{
[BepInPlugin(modGUID, modName, modVersion)]
public class ModPlugin : BaseUnityPlugin
{
private const string modGUID = "Dingo.SN.StorageInfo";
internal const string modName = "Storage Info";
private const string modVersion = "2.0.0";

internal static void LogMessage(string message)
{
Debug.Log($"{modName} :: " + message);
}

public void Start()
{
HarmonyPatches.InitializeHarmony();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StorageInfo")]
[assembly: AssemblyCopyright("Copyright © Dingo 2019")]
[assembly: AssemblyCopyright("Copyright © Dingo 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,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.0.4.0")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
6 changes: 0 additions & 6 deletions QMods/StorageInfo/Languages/Russian.json

This file was deleted.

Binary file removed QMods/StorageInfo/StorageInfo.dll
Binary file not shown.
10 changes: 0 additions & 10 deletions QMods/StorageInfo/mod.json

This file was deleted.

73 changes: 29 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,39 @@
## **Storage Info by Dingo**
# **Storage Info for Subnautica**

#### **Description:**
In Subnautica, only empty containers relay their status to the player. With this mod containers will always show if they are:
* Empty
* Full
* Have a certain amount of items, but aren't full
### **Description:**

#### **Installation:**
1) Install [QMods](https://www.nexusmods.com/subnautica/mods/201) if you haven't already
2) Install [SMLHelper (Modding Helper)](https://www.nexusmods.com/subnautica/mods/113)
3) Download the zip file from the [Files tab](https://www.nexusmods.com/subnautica/mods/229/?tab=files)
4) Unzip the contents of the zip to the game's main directory (where Subnautica.exe can be found)
In Subnautica, only empty containers relay their status to the player. With this mod containers will always show if they are:
- Empty
- Full
- Have a certain amount of items, but aren't full

#### **(Optional) Translation:**
If you want to contribute a translation for this mod, please follow these steps:
1) Look at the file *"English.json"* in *QMods\StorageInfo\Languages*
2) Copy that file and change the file name to your language. It needs to match the file name in *Subnautica\SNUnmanagedData\LanguageFiles*
3) Translate the file. Do not touch the keys ("ContainerFull"), only the translated values ("completely full")
4) Share the file with me, preferrably over GitHub, a Nexus private message or (if you must) a comment
### **Installation:**

#### **FAQ:**
1. Install [BepInEx for Subnautica](https://www.nexusmods.com/subnautica/mods/1108)
2. Install [SMLHelper (Modding Helper)](https://www.nexusmods.com/subnautica/mods/113)
3. Download the latest zip file from the [Files tab](https://www.nexusmods.com/subnautica/mods/229/?tab=files)
4. Unzip the contents of the zip to the game's main directory (where Subnautica.exe can be found)

* **Q. Is this mod safe to add or remove from an existing save file?**
* A. Perfectly safe.
* **Q. Does this mod have any known conflicts?**
* A. No, unless some other mod patches *StorageContainer.OnHandHover* and doesn't play nice.
### **(Optional) Translation:**

[Source code can be found here.](https://github.com/DingoDjango/snStorageInfo)
1. Navigate to *...\Subnautica\BepInEx\plugins\StorageInfo\Languages*
2. Copy *English.json* and change the file name to match your language
> Valid language names are found in *...\Subnautica\Subnautica_Data\StreamingAssets\SNUnmanagedData\LanguageFiles*
3. Translate the file. Do not touch the keys ("ContainerFull"), only the values ("full")
4. Share the file with me on GitHub or in a Nexus private message

#### **Credits:**
- Powered by [Harmony](https://github.com/pardeike/Harmony)
- Made for the [QMods Subnautica Mod System](https://www.nexusmods.com/subnautica/mods/201)
- Using [SMLHelper](https://www.nexusmods.com/subnautica/mods/113)
- German translation by [acidscorch](https://github.com/acidscorch)
- Russian translation by [mstislavovich](https://forums.nexusmods.com/index.php?/user/23416669-mstislavovich/)
### **FAQ:**

- **Q. Does this mod support the latest Subnautica update?**
- A. Tested on Subnautica version Dec-2022 71137 (Living Large update)
- **Q. Is this mod safe to add or remove from an existing save?**
- A. Yes
- **Q. Does this mod have any known conflicts?**
- A. No, unless some other mod patches *StorageContainer.OnHandHover* and doesn't play nice

2019-03-17 - v1.0.4
- Added Russian translation by mstislavovich
[Source code can be found here.](https://github.com/DingoDjango/snStorageInfo)

2019-03-16 - v1.0.3
- Small refactor to language loading

2019-03-16 - v1.0.2
- Added German translation by acidscorch
- Some refactoring to load languages properly
- Internal mod structure changes

2019-03-15 - v1.0.1
- Bug fixes

2019-03-15 - v1.0.0
- Initial mod release
### **Credits:**
- Powered by [Harmony](https://github.com/pardeike/Harmony)
- Using [SMLHelper](https://www.nexusmods.com/subnautica/mods/113)
- Translations by [acidscorch](https://github.com/acidscorch), [mstislavovich](https://forums.nexusmods.com/index.php?/user/23416669-mstislavovich/), [Yanuut](https://github.com/Yanuut), [Zemogiter](https://github.com/Zemogiter)
65 changes: 45 additions & 20 deletions StorageInfo/StorageInfo.csproj → StorageInfo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,62 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StorageInfo</RootNamespace>
<AssemblyName>StorageInfo</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\QMods\$(AssemblyName)\</OutputPath>
<OutputPath>BepInEx\plugins\StorageInfo\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<LangVersion>7.1</LangVersion>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\QMods\$(AssemblyName)\</OutputPath>
<OutputPath>BepInEx\plugins\StorageInfo\</OutputPath>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<LangVersion>7.1</LangVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony-1.2.0.1">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed\0Harmony-1.2.0.1.dll</HintPath>
<Reference Include="0Harmony">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\BepInEx\core\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\BepInEx\core\BepInEx.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="LitJson">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed\LitJson.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="SMLHelper">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\BepInEx\plugins\Modding Helper\SMLHelper.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -58,28 +75,36 @@
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\Subnautica\Subnautica_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Entry.cs" />
<Compile Include="ModPlugin.cs" />
<Compile Include="HarmonyPatches.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Translation.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Languages\English.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Languages\German.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Languages\Russian.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="mod.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>SET MODDIR=C:\Program Files (x86)\Steam\steamapps\common\Subnautica\BepInEx\
SET ZIPFILE=D:\Downloads\$(ProjectName).zip

xcopy "$(ProjectDir)BepInEx\*" "%25MODDIR%25" /i /e /r /y

7z a -mx9 "%25ZIPFILE%25" "$(ProjectDir)BepInEx"

cd $(ProjectDir)
del /f /s /q bin
del /f /s /q obj
rmdir /s /q bin
rmdir /s /q obj</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
22 changes: 0 additions & 22 deletions StorageInfo/Entry.cs

This file was deleted.

Loading

0 comments on commit 46121e7

Please sign in to comment.