public void EnableReconstruction(bool enabled) { if (Reconstruct.Enabled != enabled) { Reconstruct.Enabled = enabled; if (enabled) { Reconstruct.Focus(); } else { Start.Focus(); } } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (HighLogic.LoadedScene == GameScenes.LOADING) { Debug.Log($"[KSP Secondary Motion - Hierarchy Reconstructor]OnLoad"); ConfigNode[] nodes = node.GetNodes("RECONSTRUCT"); if (nodes != null && nodes.Length > 0) { foreach (ConfigNode n in nodes) { Debug.Log($"[KSP Secondary Motion - Hierarchy Reconstructor] Part {part.name} has ModuleHierarchyReconstructor with a RECONSTRUCT named {n.GetValue("name")}"); Reconstruct reconstruct = new Reconstruct(n.GetValue("name"), bool.Parse(n.GetValue("reparent")), n.GetValue("asChildOf"), n.GetValue("asParentOf"), n.GetValue("whichIsAChildOf"), StringToVector3(n.GetValue("localPosition")), StringToVector3(n.GetValue("localRotationEuler")), StringToVector3(n.GetValue("localScale"))); Debug.Log($"[KSP Secondary Motion - Hierarchy Reconstructor] RECONSTRUCT Content:\n{reconstruct}"); GameObject obj = new GameObject(reconstruct.name); if (reconstruct.reparent) { //reparent mode Transform child = null; if (reconstruct.whichIsAChildOf == "__ISROOTTRANSFORM__") { child = part.FindModelTransform(reconstruct.asParentOf); } else { child = part.FindModelTransforms(reconstruct.asParentOf).First(candidate => candidate.parent.name == reconstruct.whichIsAChildOf); } obj.transform.parent = child.parent; obj.transform.localPosition = reconstruct.localPosition; obj.transform.localRotation = Quaternion.Euler(reconstruct.localRotationEuler); obj.transform.localScale = reconstruct.localScale; child.parent = obj.transform; } else { //add transform only mode Transform parent = null; if (reconstruct.whichIsAChildOf == "__ISROOTTRANSFORM__") { parent = part.FindModelTransform(reconstruct.asChildOf); } else { parent = part.FindModelTransforms(reconstruct.asChildOf).First(candidate => candidate.parent.name == reconstruct.whichIsAChildOf); } obj.transform.parent = parent; obj.transform.localPosition = reconstruct.localPosition; obj.transform.localRotation = Quaternion.Euler(reconstruct.localRotationEuler); obj.transform.localScale = reconstruct.localScale; } Debug.Log($"[KSP Secondary Motion - Hierarchy Reconstructor] Reconstruction complete"); } } } }
public void SetButtonState(ButtonState state) { Color RECORD_COLOR = Color.Red; // Consolidated logic to restore the color of the Reconstruct button after the scanning has ended. if (Reconstruct.BackColor == RECORD_COLOR) { Reconstruct.BackColor = OriginalReconstructBackColor; } buttonState = state; switch (buttonState) { case ButtonState.SCe_SSd: // Streaming stopped (Start Camera enabled, Start Scanning disabled) Start.Text = "Start Camera"; Start.Enabled = true; Start.Focus(); Reconstruct.Text = "Start Scanning"; Reconstruct.Enabled = false; break; case ButtonState.Cd_SSd: // Waiting for streaming start (Cancel disabled, Start Scanning disabled) Start.Text = "Cancel"; Start.Enabled = false; Reconstruct.Text = "Start Scanning"; Reconstruct.Enabled = false; break; case ButtonState.Ce_SSd: // Start Camera pressed (Cancel enabled, Start Scanning disabled) Start.Text = "Cancel"; Start.Enabled = true; Start.Focus(); Reconstruct.Text = "Start Scanning"; Reconstruct.Enabled = false; break; case ButtonState.Ce_SSd2: // Streaming started (Cancel enabled, Start Scanning disabled) Start.Text = "Cancel"; Start.Enabled = true; Start.Focus(); Reconstruct.Text = "Start Scanning"; Reconstruct.Enabled = false; break; case ButtonState.Ce_SSe: // Scanning preconditions met (Cancel enabled, Start Scanning enabled) Start.Text = "Cancel"; Start.Enabled = true; Reconstruct.Text = "Start Scanning"; Reconstruct.Enabled = true; Reconstruct.Focus(); break; case ButtonState.Ce_ESd: // Start Scanning pressed (Cancel enabled, End Scanning disabled) scan_requested = true; Start.Text = "Cancel"; Start.Enabled = true; Start.Focus(); Reconstruct.Text = "End Scanning"; Reconstruct.Enabled = false; break; case ButtonState.Ce_ESe: // Scanning started (Cancel enabled, End Scanning enabled) Start.Text = "Cancel"; Start.Enabled = true; Reconstruct.Text = "End Scanning"; Reconstruct.Enabled = true; Reconstruct.Focus(); OriginalReconstructBackColor = Reconstruct.BackColor; Reconstruct.BackColor = RECORD_COLOR; break; case ButtonState.Cd_ESd: // Scanning ended (Cancel disabled, End Scanning disabled) Start.Text = "Cancel"; Start.Enabled = false; Reconstruct.Text = "End Scanning"; Reconstruct.Enabled = false; break; } Panel_Paint(MainPanel, null); }