public static void Postfix(ThingPartDialog __instance, string contextName) { if (contextName.Equals("redo")) { ThingPart tp = __instance.thingPart(); var tuple = Main.GetThingPartStateTuple(tp); if (Main.thingPartStateHistory.RedoCount(tuple) > 0) { ThingPartStateHistoryEntry saved = Main.thingPartStateHistory.Redo(tuple, new ThingPartStateHistoryEntry(tp.states[tp.currentState])); DebugLog.Log("Redoing to {0}", saved); tp.transform.localPosition = saved.position; tp.transform.localEulerAngles = saved.rotation; tp.transform.localScale = saved.scale; tp.material.color = saved.color; RewriteThingPartMemorizeForUndo.disableMemorize = true; tp.SetStatePropertiesByTransform(false); RewriteThingPartMemorizeForUndo.disableMemorize = false; if (tp.materialType == MaterialTypes.Transparent) { tp.UpdateMaterial(); } DebugLog.Log(String.Format("[R] UndoCount={0} RedoCount={1}", Main.thingPartStateHistory.UndoCount(tuple), Main.thingPartStateHistory.RedoCount(tuple))); } else { Managers.soundManager.Play("no", __instance.transform, 0.5f, false, false); } __instance.UpdateUndoButton(); } }
public static void Postfix(ThingPartDialog __instance) { ThingPart tp = __instance.thingPart(); var tuple = Main.GetThingPartStateTuple(tp); if (redoButton != null) { UnityEngine.Object.Destroy(redoButton); redoButton = null; } if (Main.thingPartStateHistory.RedoCount(tuple) > 0) { int xOnFundament = (!tp.isText && !__instance.showSubThings()) ? 500 : 290; redoButton = __instance.AddButton("redo", null, null, "ButtonVerySmall", xOnFundament, 420, "undo"); // Flip the icon horizontally Transform iconQuad = redoButton.transform.Find("IconQuad"); Vector3 scale = iconQuad.localScale; iconQuad.localScale = new Vector3(-scale.x, scale.y, scale.z); } DebugLog.Log(String.Format("UUB UndoCount={0} RedoCount={1}", Main.thingPartStateHistory.UndoCount(tuple), Main.thingPartStateHistory.RedoCount(tuple))); }
public static bool showSubThings(this ThingPartDialog dialog) { return((bool)typeof(ThingPartDialog).GetField("showSubThings", InstanceNonPub).GetValue(dialog)); }
// ThingPartDialog public static ThingPart thingPart(this ThingPartDialog dialog) { return((ThingPart)typeof(ThingPartDialog).GetField("thingPart", InstanceNonPub).GetValue(dialog)); }