Skip to content

Commit

Permalink
Merge pull request #212 from edbmods/fix-scenario-replacement
Browse files Browse the repository at this point in the history
Fix for scenario replacement workaround
  • Loading branch information
edbmods authored Jun 30, 2018
2 parents bcbeb40 + d92f414 commit cba3d36
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 49 deletions.
1 change: 0 additions & 1 deletion EdBPrepareCarefully.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
<Compile Include="Source\ExtensionsThing.cs" />
<Compile Include="Source\GenStep_CustomScatterThings.cs" />
<Compile Include="Source\CustomHeadType.cs" />
<Compile Include="Source\GenStep_RemovePrepareCarefullyScenario.cs" />
<Compile Include="Source\IRelationshipWorker.cs" />
<Compile Include="Source\OptionsApparel.cs" />
<Compile Include="Source\OptionsHealth.cs" />
Expand Down
7 changes: 7 additions & 0 deletions Resources/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
_____________________________________________________________________________

Version 1.0.1
_____________________________________________________________________________

- Added minimum support for 1.0

_____________________________________________________________________________

Version 0.18.2
Expand Down
10 changes: 3 additions & 7 deletions Resources/Defs/MapGeneratorDefs/MapGenerators.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<Defs>

<GenStepDef>
<defName>RemovePrepareCarefullyScenParts</defName>
<order>2147483647</order>
<genStep Class="EdB.PrepareCarefully.GenStep_RemovePrepareCarefullyScenario"/>
</GenStepDef>

<!-- This file is no longer used, but since the workshop doesn't seem to consistently
delete files on mod updates, we're leaving it here to avoid mod corruption errors.
-->
</Defs>

4 changes: 0 additions & 4 deletions Resources/Defs/Scenarios/ScenParts_Fixed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
<Defs>
<!-- This file is no longer used, but since the workshop doesn't seem to consistently
delete files on mod updates, we're leaving it here to avoid mod corruption errors.
We leave a placeholder pawn relation def since that should leave no side-effects.
-->
<EdB.PrepareCarefully.CarefullyPawnRelationDef>
<defName>ScenParts_FixedDummyDefinition</defName>
</EdB.PrepareCarefully.CarefullyPawnRelationDef>
</Defs>
4 changes: 0 additions & 4 deletions Resources/Defs/ThingDefs/EdBPrepareCarefully.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
<Defs>
<!-- This file is no longer used, but since the workshop doesn't seem to consistently
delete files on mod updates, we're leaving it here to avoid mod corruption errors.
We leave a placeholder pawn relation def since that should leave no side-effects.
-->
<EdB.PrepareCarefully.CarefullyPawnRelationDef>
<defName>EdBPrepareCarefullyDummyDefinition</defName>
</EdB.PrepareCarefully.CarefullyPawnRelationDef>
</Defs>
33 changes: 0 additions & 33 deletions Source/GenStep_RemovePrepareCarefullyScenario.cs

This file was deleted.

14 changes: 14 additions & 0 deletions Source/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ static HarmonyPatches() {
harmony.Patch(typeof(Page_ConfigureStartingPawns).GetMethod("DoWindowContents"),
new HarmonyMethod(null),
new HarmonyMethod(typeof(HarmonyPatches).GetMethod("DoWindowContentsPostfix")));
harmony.Patch(typeof(Game).GetMethod("InitNewGame"),
new HarmonyMethod(null),
new HarmonyMethod(typeof(HarmonyPatches).GetMethod("InitNewGamePostfix")));
}

// Clear the original scenario when opening the Configure Starting Pawns page. This makes
Expand All @@ -30,6 +33,17 @@ public static void PreOpenPostfix() {
PrepareCarefully.ClearOriginalScenario();
}

// Removes the customized scenario (with PrepareCarefully-specific scenario parts) and replaces
// it with a vanilla-friendly version that was prepared earlier. This is a workaround to avoid
// creating a dependency between a saved game and the mod. See Controller.PrepareGame() for
// more details.
public static void InitNewGamePostfix() {
if (PrepareCarefully.OriginalScenario != null) {
Current.Game.Scenario = PrepareCarefully.OriginalScenario;
PrepareCarefully.ClearOriginalScenario();
}
}

// Draw the "Prepare Carefully" button at the bottom of the Configure Starting Pawns page.
public static void DoWindowContentsPostfix(Rect rect, Page_ConfigureStartingPawns __instance) {
Vector2 BottomButSize = new Vector2(150f, 38f);
Expand Down

0 comments on commit cba3d36

Please sign in to comment.