@@ -24,7 +24,7 @@ public class PolyTechMain : PolyTechMod
24
24
public new const string
25
25
PluginGuid = "polytech.polytechframework" ,
26
26
PluginName = "PolyTech Framework" ,
27
- PluginVersion = "0.9.5 " ;
27
+ PluginVersion = "0.9.6 " ;
28
28
private static BindingList < PolyTechMod >
29
29
noncheatMods = new BindingList < PolyTechMod > { } ,
30
30
cheatMods = new BindingList < PolyTechMod > { } ;
@@ -78,6 +78,8 @@ public enum watermarks
78
78
polybridge
79
79
}
80
80
81
+ Harmony harmony ;
82
+
81
83
public void Awake ( )
82
84
{
83
85
moddedWatermark = Config . Bind ( moddedWatermarkDef , watermarks . polytech , new ConfigDescription ( "Selected Watermark" ) ) ;
@@ -107,7 +109,9 @@ public void Awake()
107
109
this . modCheated = false ;
108
110
this . repositoryUrl = "https://github.com/PolyTech-Modding/PolyTechFramework/" ;
109
111
110
- Harmony . CreateAndPatchAll ( typeof ( PolyTechMain ) ) ;
112
+ harmony = new Harmony ( PluginGuid ) ;
113
+ harmony . PatchAll ( typeof ( PolyTechMain ) ) ;
114
+ harmony . PatchAll ( typeof ( PolyTechMain ) . Assembly ) ;
111
115
112
116
PolyTechUtils . setModdedSimSpeeds ( ) ;
113
117
PolyTechUtils . setReplaysModded ( ) ;
@@ -701,13 +705,17 @@ private static void PatchGalleryUploadBody(ref GalleryUploadBody __result)
701
705
}
702
706
}
703
707
708
+ public static bool isSavingAnyModData ( ) {
709
+ return noncheatMods . Where ( x => x . isEnabled && x . shouldSaveData ) . Count ( ) + cheatMods . Where ( x => x . isEnabled ) . Count ( ) > 0 ;
710
+ }
711
+
704
712
[ HarmonyPatch ( typeof ( SandboxLayoutData ) , "SerializePreBridgeBinary" ) ]
705
713
[ HarmonyPrefix ]
706
714
static void patchSerializerOne ( SandboxLayoutData __instance , List < byte > bytes )
707
715
{
708
716
ptfInstance . ptfLogger . LogMessage ( $ "Layout pre version: { __instance . m_Version } ") ;
709
717
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 ;
711
719
__instance . m_Version *= - 1 ;
712
720
//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);
713
721
ptfInstance . ptfLogger . LogMessage ( $ "Version after cheat question: { __instance . m_Version . ToString ( ) } ") ;
@@ -1009,6 +1017,52 @@ Queue<LeaderboardUploadScore> ___m_ScoresToUpload
1009
1017
}
1010
1018
return true ;
1011
1019
}
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
+
1012
1066
}
1013
1067
1014
1068
0 commit comments