// Draw the main control area private void DrawMainControls() { Rect controlRect = GUILayoutUtility.GetRect(184f, 64f); Rect iconRect = new Rect(0f, 0f, 64f, 64f); Rect titleRect = new Rect(64f, 0f, 116f, 32f); Rect toggleRect = new Rect(64f, 32f, 32f, 32f); Rect settingsButtonRect = new Rect(133f, 36f, 20f, 20f); GUI.BeginGroup(controlRect); // STATIC: Icon GUI.DrawTextureWithTexCoords(iconRect, host.GUIResources.GetReactorIcon(reactor.UIIcon).iconAtlas, host.GUIResources.GetReactorIcon(reactor.UIIcon).iconRect); // STATIC: UI Name GUI.Label(titleRect, reactor.UIName, host.GUIResources.GetStyle("header_basic")); // BUTTON: Toggle bool current = reactor.ModuleIsActive(); bool toggled = GUI.Toggle(toggleRect, reactor.ModuleIsActive(), "ON", host.GUIResources.GetStyle("button_toggle")); if (current != toggled) { reactor.ToggleResourceConverterAction(new KSPActionParam(0, KSPActionType.Activate)); } // BUTTON: Settings if (GUI.Button(settingsButtonRect, "", host.GUIResources.GetStyle("button_overlaid"))) { ReactorUI.ShowFocusedReactorSettings(reactor); } GUI.DrawTextureWithTexCoords(settingsButtonRect, host.GUIResources.GetIcon("gear").iconAtlas, host.GUIResources.GetIcon("gear").iconRect); GUI.EndGroup(); }
// Draw the main control area private void DrawMainControls() { GUILayout.BeginHorizontal(); // STATIC: Icon Rect iconRect = GUILayoutUtility.GetRect(32f, 32f); GUI.DrawTextureWithTexCoords(iconRect, host.GUIResources.GetReactorIcon(reactor.UIIcon).iconAtlas, host.GUIResources.GetReactorIcon(reactor.UIIcon).iconRect); // STATIC: UI Name GUILayout.BeginVertical(); GUILayout.Label(reactor.UIName, host.GUIResources.GetStyle("header_basic"), GUILayout.MaxHeight(32f), GUILayout.MinHeight(32f), GUILayout.MaxWidth(150f), GUILayout.MinWidth(150f)); GUILayout.Space(10f); GUILayout.BeginHorizontal(); // BUTTON: Toggle bool current = reactor.ModuleIsActive(); bool toggled = GUILayout.Toggle(reactor.ModuleIsActive(),"Active",host.GUIResources.GetStyle("button_toggle")); if (current != toggled) { reactor.ToggleResourceConverterAction( new KSPActionParam(0,KSPActionType.Activate) ); } // BUTTON: Settings iconRect = GUILayoutUtility.GetRect(32f, 32f); if (GUI.Button(iconRect, "", host.GUIResources.GetStyle("button_overlaid"))) { ReactorUI.ShowFocusedReactorSettings(reactor); } GUI.DrawTextureWithTexCoords(iconRect, host.GUIResources.GetIcon("gear").iconAtlas, host.GUIResources.GetIcon("gear").iconRect); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
// Constructor public ReactorUIEntry(FissionReactor toDraw, ReactorUI uihost) { host = uihost; reactor = toDraw; generator = reactor.GetComponent <FissionGenerator>(); }