Skip to content

Commit

Permalink
Updated to Harmony 1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Mar 17, 2017
1 parent 053f09b commit 06846fe
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 33 deletions.
Binary file modified Assemblies/0Harmony.dll
Binary file not shown.
Binary file modified Assemblies/CameraPlus.dll
Binary file not shown.
Binary file modified Harmony/0Harmony.dll
Binary file not shown.
46 changes: 15 additions & 31 deletions Source/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,65 +31,49 @@ static GameFont GetAdaptedGameFont()
return GameFont.Tiny;
}

class AdaptedGameFontReplacer : CodeProcessor
// we replace the first "GameFont.Tiny" with our "GetAdaptedGameFont()"
//
[HarmonyTranspiler]
static IEnumerable<CodeInstruction> AdaptedGameFontReplacerPatch(IEnumerable<CodeInstruction> instructions)
{
bool firstInstruction = true;

// we replace the first "GameFont.Tiny" with our "GetAdaptedGameFont()"
//
public override List<CodeInstruction> Process(CodeInstruction instruction)
foreach (var instruction in instructions)
{
var result = new List<CodeInstruction>();
if (firstInstruction && instruction.opcode == OpCodes.Ldc_I4_0)
{
var method = AccessTools.Method(typeof(GenMapUI_DrawThingLabel_Patch), "GetAdaptedGameFont");
var call = new CodeInstruction(OpCodes.Call, method);
result.Add(call);
yield return new CodeInstruction(OpCodes.Call, method);
}
else
result.Add(instruction);
yield return instruction;

firstInstruction = false;
return result;
}
}

[HarmonyProcessorFactory]
static HarmonyProcessor AdaptedGameFontReplacerPatch(MethodBase original)
{
var processor = new HarmonyProcessor();
processor.Add(new AdaptedGameFontReplacer());
return processor;
}
}

[HarmonyPatch(typeof(CameraDriver))]
[HarmonyPatch("get_CurrentZoom")]
static class CameraDriver_get_CurrentZoom_Patch
{
class ZoomLerper : CodeProcessor
// Normal values: 12, 13.8, 42, 57
//
[HarmonyTranspiler]
static IEnumerable<CodeInstruction> LerpCurrentZoom(IEnumerable<CodeInstruction> instructions)
{
// Normal values: 12, 13.8, 42, 57
//
public override List<CodeInstruction> Process(CodeInstruction instruction)
foreach (var instruction in instructions)
{
if (instruction.opcode == OpCodes.Ldc_R4)
{
var f = (float)instruction.operand;
f = GenMath.LerpDouble(12, 57, 30, 60, f);
instruction.operand = f;
yield return instruction;
}
return new List<CodeInstruction>() { instruction };
else
yield return instruction;
}
}

[HarmonyProcessorFactory]
static HarmonyProcessor LerpCurrentZoom(MethodBase original)
{
var processor = new HarmonyProcessor();
processor.Add(new ZoomLerper());
return processor;
}
}

[HarmonyPatch(typeof(CameraDriver))]
Expand Down
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyVersion("1.0.2.0")]
[assembly: AssemblyFileVersion("1.0.2.0")]

0 comments on commit 06846fe

Please # to comment.