Skip to content

Commit

Permalink
0.16.1
Browse files Browse the repository at this point in the history
Fixed subassembly loading.
  • Loading branch information
sirkut committed Jun 20, 2014
1 parent 1026fba commit 2b4c931
Show file tree
Hide file tree
Showing 2 changed files with 1,201 additions and 1,019 deletions.
40 changes: 27 additions & 13 deletions InfernalRobotics/InfernalRobotics/GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,25 @@ void onVesselChange(Vessel v)
}
}

int partCounter = 0;
void onPartAttach(GameEvents.HostTargetAction<Part, Part> host_target)
{
//Part p = host_target.host;
//foreach (var servo in p.Modules.OfType<MuMechToggle>()) {
// add_servo(servo);
//}
Part part = host_target.host;
Part parent = host_target.target;
foreach (var p in part.GetComponentsInChildren<MuMechToggle>())
//EditorLogic.fetch.ship.Parts.Count
if ((EditorLogic.fetch.ship.parts.Count >= partCounter) && (EditorLogic.fetch.ship.parts.Count != partCounter) )
{
add_servo(p);
Part part = host_target.host;
if ((partCounter != 1) && (EditorLogic.fetch.ship.parts.Count != 1))
{
foreach (var p in part.GetComponentsInChildren<MuMechToggle>())
{
add_servo(p);
}
partCounter = EditorLogic.fetch.ship.parts.Count;
}
}
}

Expand All @@ -215,6 +223,10 @@ void onPartRemove(GameEvents.HostTargetAction<Part, Part> host_target)
{
remove_servo(p);
}
if (EditorLogic.fetch.ship.parts.Count == 1)
partCounter = 0;
else
partCounter = EditorLogic.fetch.ship.parts.Count;
}

bool update14to15 = false;
Expand All @@ -223,6 +235,7 @@ void onPartRemove(GameEvents.HostTargetAction<Part, Part> host_target)
bool groupEditorEnabled = false;
void Awake()
{

loadConfigXML();
Debug.Log("[IR GUI] awake");
//enabled = false;
Expand All @@ -237,6 +250,8 @@ void Awake()
}
else if (scene == GameScenes.EDITOR || scene == GameScenes.SPH)
{
//partCounter = EditorLogic.fetch.ship.parts.Count;
//onEditorAttach
GameEvents.onPartAttach.Add(onPartAttach);
GameEvents.onPartRemove.Add(onPartRemove);
gui_controller = this;
Expand All @@ -259,7 +274,7 @@ void Awake()
IRMinimizeButton.ToolTip = "Infernal Robotics";
IRMinimizeButton.Visibility = new GameScenesVisibility(GameScenes.EDITOR, GameScenes.SPH, GameScenes.FLIGHT);
IRMinimizeButton.OnClick += (e) => guiEnabled = !guiEnabled;

IRMinimizeGroupButton = ToolbarManager.Instance.add("sirkut2", "IREditorGroupButton");
IRMinimizeGroupButton.TexturePath = "MagicSmokeIndustries/Textures/icon_buttonGROUP";
IRMinimizeGroupButton.ToolTip = "Infernal Robotics Group Editor";
Expand Down Expand Up @@ -310,14 +325,14 @@ private void ControlWindow(int windowID)
{
GUILayout.BeginHorizontal();
GUILayout.Label(g.name, GUILayout.ExpandWidth(true));

int forceFlags = 0;
var width20 = GUILayout.Width(20);
var width40 = GUILayout.Width(40);
forceFlags |= GUILayout.RepeatButton("<", width20) ? 1 : 0;
forceFlags |= GUILayout.RepeatButton("O", width20) ? 4 : 0;
forceFlags |= GUILayout.RepeatButton(">", width20) ? 2 : 0;

g.speed = GUILayout.TextField(g.speed, width40);
float speed;
bool speed_ok = float.TryParse(g.speed, out speed);
Expand Down Expand Up @@ -608,7 +623,7 @@ void GroupEditorWindow(int windowID)

GUILayout.BeginHorizontal();
GUILayout.Label("Servo Name", expand);
if(update14to15)
if (update14to15)
GUILayout.Label("Rotation", expand);

if (servo_groups.Count > 1)
Expand Down Expand Up @@ -770,7 +785,7 @@ void tweakWindow(int windowID)


void refreshKeysFromGUI()
{
{
foreach (Group g in servo_groups)
{
if (g.servos.Count() > 0)
Expand All @@ -783,7 +798,7 @@ void refreshKeysFromGUI()
}
}
}

}


Expand Down Expand Up @@ -848,7 +863,7 @@ void OnGUI()
"Servo Group Editor",
GUILayout.Width(250),
height);
if(guiTweakEnabled)
if (guiTweakEnabled)
tweakWinPos = GUILayout.Window(959, tweakWinPos,
tweakWindow,
servoTweak.servoName,
Expand Down Expand Up @@ -886,7 +901,7 @@ public void loadConfigXML()
tweakWinPos = config.GetValue<Rect>("tweakWinPos");
controlWinPos = config.GetValue<Rect>("controlWinPos");
groupEditorWinPos = config.GetValue<Rect>("groupEditorWinPos");

}

public void saveConfigXML()
Expand All @@ -900,4 +915,3 @@ public void saveConfigXML()
}
}
}

Loading

0 comments on commit 2b4c931

Please sign in to comment.