@@ -24,7 +24,7 @@ public class PolyTechMain : PolyTechMod
2424 public new const string
2525 PluginGuid = "polytech.polytechframework" ,
2626 PluginName = "PolyTech Framework" ,
27- PluginVersion = "0.9.5 " ;
27+ PluginVersion = "0.9.6 " ;
2828 private static BindingList < PolyTechMod >
2929 noncheatMods = new BindingList < PolyTechMod > { } ,
3030 cheatMods = new BindingList < PolyTechMod > { } ;
@@ -78,6 +78,8 @@ public enum watermarks
7878 polybridge
7979 }
8080
81+ Harmony harmony ;
82+
8183 public void Awake ( )
8284 {
8385 moddedWatermark = Config . Bind ( moddedWatermarkDef , watermarks . polytech , new ConfigDescription ( "Selected Watermark" ) ) ;
@@ -107,7 +109,9 @@ public void Awake()
107109 this . modCheated = false ;
108110 this . repositoryUrl = "https://github.com/PolyTech-Modding/PolyTechFramework/" ;
109111
110- Harmony . CreateAndPatchAll ( typeof ( PolyTechMain ) ) ;
112+ harmony = new Harmony ( PluginGuid ) ;
113+ harmony . PatchAll ( typeof ( PolyTechMain ) ) ;
114+ harmony . PatchAll ( typeof ( PolyTechMain ) . Assembly ) ;
111115
112116 PolyTechUtils . setModdedSimSpeeds ( ) ;
113117 PolyTechUtils . setReplaysModded ( ) ;
@@ -701,13 +705,17 @@ private static void PatchGalleryUploadBody(ref GalleryUploadBody __result)
701705 }
702706 }
703707
708+ public static bool isSavingAnyModData ( ) {
709+ return noncheatMods . Where ( x => x . isEnabled && x . shouldSaveData ) . Count ( ) + cheatMods . Where ( x => x . isEnabled ) . Count ( ) > 0 ;
710+ }
711+
704712 [ HarmonyPatch ( typeof ( SandboxLayoutData ) , "SerializePreBridgeBinary" ) ]
705713 [ HarmonyPrefix ]
706714 static void patchSerializerOne ( SandboxLayoutData __instance , List < byte > bytes )
707715 {
708716 ptfInstance . ptfLogger . LogMessage ( $ "Layout pre version: { __instance . m_Version } ") ;
709717 if ( GameStateManager . GetState ( ) != GameState . BUILD && GameStateManager . GetState ( ) != GameState . SANDBOX ) return ;
710- if ( noncheatMods . Where ( x => x . shouldSaveData ) . Count ( ) + cheatMods . Where ( x => x . isEnabled ) . Count ( ) == 0 ) return ;
718+ if ( ! isSavingAnyModData ( ) ) return ;
711719 __instance . m_Version *= - 1 ;
712720 //PopUpMessage.Display("You have cheat mods enabled, do you want to store them?\n(This will make the layout incompatible with vanilla PB2)", yes, no);
713721 ptfInstance . ptfLogger . LogMessage ( $ "Version after cheat question: { __instance . m_Version . ToString ( ) } ") ;
@@ -1009,6 +1017,52 @@ Queue<LeaderboardUploadScore> ___m_ScoresToUpload
10091017 }
10101018 return true ;
10111019 }
1020+
1021+ [ HarmonyPatch ]
1022+ static class areModsInstalledPatch
1023+ {
1024+ static bool Prepare ( )
1025+ {
1026+ return TargetMethod ( ) != null ;
1027+ }
1028+
1029+ static MethodInfo TargetMethod ( )
1030+ {
1031+ return AccessTools . Method ( typeof ( GameManager ) , "AreModsInstalled" ) ;
1032+ }
1033+
1034+ static void Postfix ( bool __result ) {
1035+ __result = true ;
1036+ }
1037+ }
1038+
1039+ [ HarmonyPatch ( typeof ( Panel_WorkshopSubmit ) , "Submit" ) ]
1040+ static class submitPatch {
1041+ static bool state = false ;
1042+ static bool Prefix ( ) {
1043+ if ( state ) {
1044+ state = false ;
1045+ return true ;
1046+ }
1047+
1048+ if ( isSavingAnyModData ( ) ) {
1049+ PopUpMessage . Display (
1050+ "This level contains modded data, are you sure you would like to upload it to the workshop?" ,
1051+ ( ) => {
1052+ state = true ;
1053+ GameUI . m_Instance . m_WorkshopSubmit . Submit ( ) ;
1054+ } ,
1055+ ( ) => { }
1056+ ) ;
1057+ }
1058+ else {
1059+ return true ;
1060+ }
1061+
1062+ return false ;
1063+ }
1064+ }
1065+
10121066 }
10131067
10141068
0 commit comments