Skip to content

Commit 8b618df

Browse files
committed
[Breaking] Fixed r2modman update removing all content of the mod folder
Fixed fallback image beeing used when using ingame resources path
1 parent 83345d4 commit 8b618df

File tree

8 files changed

+26
-27
lines changed

8 files changed

+26
-27
lines changed

DSPTranslationPlugin/GameHarmony/Localizer_Refresh_Harmony.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static bool Prefix(Localizer __instance)
2626
}
2727
else if (graphic is Image image)
2828
{
29-
if (Uri.IsWellFormedUriString(__instance.translation, UriKind.RelativeOrAbsolute))
29+
if (IsUri(__instance.translation))
3030
{
3131
__instance.StartCoroutine(GetRequest(__instance.translation, image));
3232
}
@@ -37,7 +37,7 @@ public static bool Prefix(Localizer __instance)
3737
}
3838
else if (graphic is RawImage rawImage)
3939
{
40-
if (Uri.IsWellFormedUriString(__instance.translation, UriKind.RelativeOrAbsolute))
40+
if (IsUri(__instance.translation))
4141
{
4242
__instance.StartCoroutine(GetRequest(__instance.translation, rawImage));
4343
}
@@ -51,6 +51,11 @@ public static bool Prefix(Localizer __instance)
5151
return false;
5252
}
5353

54+
private static bool IsUri(string translation)
55+
{
56+
return translation.StartsWith("http") || translation.StartsWith("file");
57+
}
58+
5459
/// <summary>
5560
/// Expand in game credits box
5661
/// </summary>

DSPTranslationPlugin/GameHarmony/TranslationFix/UIReplicatorWindow_OnUpdate_Harmony.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
using HarmonyLib;
1+
using System.Collections.Generic;
2+
using System.Reflection;
3+
using System.Reflection.Emit;
4+
using HarmonyLib;
5+
using UnityEngine.UI;
26

37
namespace DSPTranslationPlugin.GameHarmony.TranslationFix
48
{

DSPTranslationPlugin/GameHarmony/VFPreload_PreloadThread_Harmony.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private static void ProtoJsonDump()
5252
var type = value.GetType();
5353
var result = JSON.ToJson(value, true);
5454
var instanceGenericName = type.FullName;
55-
TextWriter writer = new StreamWriter($"{Utils.PluginPath}/JsonDump/{instanceGenericName}.json");
55+
TextWriter writer = new StreamWriter($"{Utils.ConfigPath}/JsonDump/{instanceGenericName}.json");
5656
writer.Write(result);
5757
writer.Flush();
5858
writer.Close();

DSPTranslationPlugin/TranslationPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace DSPTranslationPlugin
1414
{
15-
[BepInPlugin("com.muchaszewski.dsp_translationPlugin", "DSP Community Translation", "0.2.2")]
15+
[BepInPlugin("com.muchaszewski.dsp_translationPlugin", "DSP Community Translation", "0.3.0")]
1616
public class TranslationPlugin : BaseUnityPlugin
1717
{
1818
public static MonoBehaviour StaticMonoBehaviour { get; private set; }

README.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33

44
[Licence: Project is under CC Attribution 4.0](https://raw.githubusercontent.com/Muchaszewski/DSP_TranslationMod/main/LICENSE)
55

6-
### Features
7-
- Adds possibility to add custom languages (text only)
6+
# BREAKING CHANGE
7+
New translation folder location for translation: `{Game Directory}\DSPGAME_Data\Translation\{LanguageName}\...`
8+
9+
# Features
10+
- Adds possibility to add custom languages
811
- Adds (currently hidden) French language
912
- Adds the possibility to change Font in game (WORK IN PROGRESS)
1013
- Use custom logo for custom translation
@@ -19,7 +22,7 @@
1922

2023
1. Press Install with Mod Manager at https://dsp.thunderstore.io/package/Muchaszewski/DSPTranslationPlugin/
2124
2. Add translations to
22-
`{Mods Directory}\Muchaszewski-DSPTranslationPlugin\Translation\{LanguageName}\translation_DysonSphereProgram.json`.
25+
`{Game Directory}\DSPGAME_Data\Translation\{LanguageName}\translation_DysonSphereProgram.json`.
2326
You can find [translations at Crowdin](https://crowdin.com/translate/dyson-sphere-program)
2427
6. Select new translation in Menu of the Game
2528
7. Enjoy
@@ -31,7 +34,7 @@
3134
3. Extract zip file
3235
4. Paste DLLs under `Dyson Sphere Program\BepInEx\plugins\DSPTranslationPlugin`
3336
5. Add translations to
34-
`Dyson Sphere Program\BepInEx\plugins\DSPTranslationPlugin\Translation\{LanguageName}\translation_DysonSphereProgram.json`.
37+
`{Game Directory}\DSPGAME_Data\Translation\{LanguageName}\translation_DysonSphereProgram.json`.
3538
You can find [translations at Crowdin](https://crowdin.com/translate/dyson-sphere-program)
3639

3740
6. Select new translation in Menu of the Game
@@ -97,22 +100,6 @@ URL needs to be a direct png file. Eg:
97100

98101
- `ImageLogo0` and `ImageLogo1` needs to have aspect ratio that corresponds to 800x300 pixels, otherwise they will be stretched
99102

100-
101-
### Dump file:
102-
Simpler file structure where only Translation value is provided.
103-
Each new translation is separated by 5 dashes `-----` this can speed up the translation process.
104-
Can cause error if ever game decide to change IDs or will add new ones, with JSON format there should be no such issue.
105-
#### IMPORTANT! Disable dump file import when sending for production!
106-
```
107-
Kliknij, aby zbudować
108-
-----
109-
Nie można tutaj budować
110-
-----
111-
Brak przedmiotu
112-
-----
113-
(...)
114-
```
115-
116103
# Special Thanks to
117104
[BepInEx](https://github.com/BepInEx/BepInEx/releases) - for mod support
118105

TranslationCommon/Translation/TranslationManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public static void LoadCurrentLanguage()
120120
/// <summary>
121121
/// Root translation folder
122122
/// </summary>
123-
public static string TranslationDirectory => $"{Utils.PluginPath}/Translation";
123+
public static string TranslationDirectory => $"{Utils.ConfigPath}/Translation";
124124

125125

126126
/// <summary>

TranslationCommon/Utils.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.IO;
22
using System.Reflection;
3+
using UnityEngine;
34

45
namespace TranslationCommon
56
{
@@ -12,5 +13,7 @@ public static class Utils
1213
/// Plugin path
1314
/// </summary>
1415
public static string PluginPath = Path.GetDirectoryName(AssemblyLocation);
16+
17+
public static string ConfigPath = Application.dataPath;
1518
}
1619
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "DSPTranslationPlugin",
3-
"version_number": "0.2.4",
3+
"version_number": "0.3.0",
44
"website_url": "https://github.com/Muchaszewski/DSP_TranslationMod",
55
"description": "Dyson sphere translation plugin! Translations download form crowdin https://crowdin.com/translate/dyson-sphere-program/14#",
66
"dependencies": [

0 commit comments

Comments
 (0)