Skip to content

Commit 6e8da2d

Browse files
committed
Merge
2 parents b9675a3 + d70bc94 commit 6e8da2d

File tree

5 files changed

+37
-40
lines changed

5 files changed

+37
-40
lines changed

PolyMod.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</RestoreAdditionalProjectSources>
1212
<Configurations>IL2CPP</Configurations>
1313
<Version>1.2.0-pre</Version>
14-
<PolytopiaVersion>2.12.3.14031</PolytopiaVersion>
14+
<PolytopiaVersion>2.13.0.14200</PolytopiaVersion>
1515
<Authors>PolyModdingTeam</Authors>
1616
<Description>The Battle of Polytopia's mod loader.</Description>
1717
<NoWarn>IDE0130</NoWarn>

installer/main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import zipfile
66
import requests
77
import threading
8+
import subprocess
89
import customtkinter
910
import CTkMessagebox as messagebox
1011

@@ -74,7 +75,7 @@ def install(path):
7475
)
7576
progress_bar.step()
7677

77-
customtkinter.CTkButton(app, text="Launch", command=launch).grid(
78+
customtkinter.CTkButton(app, text="Launch", command=lambda: launch(path)).grid(
7879
column=0, row=2, columnspan=2, padx=5, pady=5
7980
)
8081

@@ -107,8 +108,13 @@ def uninstall(path):
107108
)
108109

109110

110-
def launch():
111-
os.startfile("steam://rungameid/874390")
111+
def launch(path):
112+
if sys.platform != "win32":
113+
subprocess.check_call(f"chmod +x {path}/run_bepinex.sh", shell=True)
114+
subprocess.check_call(f"{path}/run_bepinex.sh {path}/Polytopia.*", shell=True)
115+
subprocess.check_call(f"xdg-open https://docs.bepinex.dev/articles/advanced/steam_interop.html", shell=True)
116+
else:
117+
subprocess.check_call(f"start steam://rungameid/874390", shell=True)
112118
quit()
113119

114120

src/Managers/Visual.cs

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ private static void StartScreen_Start()
5252
}
5353

5454
[HarmonyPrefix]
55-
[HarmonyPatch(typeof(SpriteAtlasManager), nameof(SpriteAtlasManager.LoadSprite), typeof(string), typeof(string), typeof(SpriteCallback))] // temporary fix
56-
private static bool SpriteAtlasManager_LoadSprite_Postfix(SpriteAtlasManager __instance, string atlas, string sprite, SpriteCallback completion)
55+
[HarmonyPatch(typeof(SpriteAtlasManager), nameof(SpriteAtlasManager.LoadSprite), typeof(string), typeof(string), typeof(SpriteCallback))]
56+
private static bool SpriteAtlasManager_LoadSprite(SpriteAtlasManager __instance, string atlas, string sprite, SpriteCallback completion)
5757
{
5858
bool found = false;
5959
__instance.LoadSpriteAtlas(atlas, (Il2CppSystem.Action<UnityEngine.U2D.SpriteAtlas>)GetAtlas);
@@ -64,47 +64,36 @@ void GetAtlas(SpriteAtlas spriteAtlas)
6464
{
6565
if (spriteAtlas != null)
6666
{
67-
Sprite foundSprite = __instance.GetSpriteFromAtlas(spriteAtlas, sprite);
68-
if (foundSprite != null)
67+
List<string> names = sprite.Split('_').ToList();
68+
List<string> filteredNames = new List<string>(names);
69+
string style = "";
70+
foreach (string item in names)
6971
{
70-
completion?.Invoke(atlas, sprite, __instance.GetSpriteFromAtlas(spriteAtlas, sprite));
72+
string upperitem = char.ToUpper(item[0]) + item.Substring(1);
73+
if (EnumCache<TribeData.Type>.TryGetType(item, out TribeData.Type tribe) || EnumCache<SkinType>.TryGetType(item, out SkinType skin)
74+
|| EnumCache<TribeData.Type>.TryGetType(upperitem, out TribeData.Type tribeUpper) || EnumCache<SkinType>.TryGetType(upperitem, out SkinType skinUpper))
75+
{
76+
filteredNames.Remove(item);
77+
style = item;
78+
continue;
79+
}
80+
}
81+
string name = string.Join("_", filteredNames);
82+
Sprite? newSprite = Registry.GetSprite(name, style);
83+
if (newSprite != null)
84+
{
85+
completion?.Invoke(atlas, sprite, newSprite);
7186
found = true;
7287
}
7388
}
7489
}
7590
}
7691

77-
[HarmonyPostfix]
78-
[HarmonyPatch(typeof(SpriteAtlasManager), nameof(SpriteAtlasManager.GetSpriteFromAtlas), typeof(SpriteAtlas), typeof(string))]
79-
private static void SpriteAtlasManager_GetSpriteFromAtlas(ref Sprite __result, SpriteAtlas spriteAtlas, string sprite)
80-
{
81-
List<string> names = sprite.Split('_').ToList();
82-
List<string> filteredNames = new List<string>(names);
83-
string style = "";
84-
foreach (string item in names)
85-
{
86-
string upperitem = char.ToUpper(item[0]) + item.Substring(1);
87-
if (EnumCache<TribeData.Type>.TryGetType(item, out TribeData.Type tribe) || EnumCache<SkinType>.TryGetType(item, out SkinType skin)
88-
|| EnumCache<TribeData.Type>.TryGetType(upperitem, out TribeData.Type tribeUpper) || EnumCache<SkinType>.TryGetType(upperitem, out SkinType skinUpper))
89-
{
90-
filteredNames.Remove(item);
91-
style = item;
92-
continue;
93-
}
94-
}
95-
string name = string.Join("_", filteredNames);
96-
Sprite? newSprite = Registry.GetSprite(name, style);
97-
if (newSprite != null)
98-
{
99-
__result = newSprite;
100-
}
101-
}
102-
10392
[HarmonyPostfix]
10493
[HarmonyPatch(typeof(SpriteAtlasManager), nameof(SpriteAtlasManager.DoSpriteLookup))]
10594
private static void SpriteAtlasManager_DoSpriteLookup(ref SpriteAtlasManager.SpriteLookupResult __result, SpriteAtlasManager __instance, string baseName, TribeData.Type tribe, SkinType skin, bool checkForOutline, int level)
10695
{
107-
baseName = Util.ReverseSpriteData(baseName);
96+
baseName = Util.FormatSpriteName(baseName);
10897

10998
Sprite? sprite = Registry.GetSprite(baseName, Util.GetStyle(tribe, skin), level);
11099
if (sprite != null)

src/NullableFix.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
namespace System.Runtime.CompilerServices
44
{
55
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple = true)]
6-
internal sealed class NullableAttribute : System.Attribute
6+
public sealed class NullableAttribute : System.Attribute
77
{
88
public NullableAttribute(byte b) { }
99
public NullableAttribute(byte[] b) { }
1010
}
1111

1212
[System.AttributeUsage(System.AttributeTargets.All, AllowMultiple = false)]
13-
internal sealed class NullableContextAttribute : System.Attribute
13+
public sealed class NullableContextAttribute : System.Attribute
1414
{
1515
public NullableContextAttribute(byte b) { }
1616
}
1717

1818
[System.AttributeUsage(System.AttributeTargets.Module)]
19-
internal sealed class NullablePublicOnlyAttribute : System.Attribute
19+
public sealed class NullablePublicOnlyAttribute : System.Attribute
2020
{
2121
public NullablePublicOnlyAttribute(bool b) { }
2222
}

src/Util.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal static string GetStyle(TribeData.Type tribe, SkinType skin)
4040
return skin != SkinType.Default ? EnumCache<SkinType>.GetName(skin) : EnumCache<TribeData.Type>.GetName(tribe);
4141
}
4242

43-
internal static string ReverseSpriteData(string baseName) // I cant believe i had to do this shit #MIDJIWANFIXYOURSHITCODE
43+
internal static string FormatSpriteName(string baseName) // I cant believe i had to do this shit #MIDJIWANFIXYOURSHITCODE
4444
{
4545
baseName = baseName.Replace(SpriteData.IMPROVEMENT_AQUA_FARM, EnumCache<ImprovementData.Type>.GetName(ImprovementData.Type.Aquafarm));
4646
baseName = baseName.Replace(SpriteData.IMPROVEMENT_ATOLL, EnumCache<ImprovementData.Type>.GetName(ImprovementData.Type.Atoll));
@@ -85,6 +85,8 @@ internal static string GetStyle(TribeData.Type tribe, SkinType skin)
8585
baseName = baseName.Replace(SpriteData.TILE_UNKNOWN, EnumCache<TerrainData.Type>.GetName(TerrainData.Type.Field));
8686
baseName = baseName.Replace(SpriteData.TILE_WATER, EnumCache<TerrainData.Type>.GetName(TerrainData.Type.Water));
8787
baseName = baseName.Replace(SpriteData.TILE_WETLAND, EnumCache<TerrainData.Type>.GetName(TerrainData.Type.Field) + "_flooded");
88+
89+
baseName = baseName.Replace("UI_", "");
8890
return baseName;
8991
}
9092
}

0 commit comments

Comments
 (0)