Пример #1
0
        void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Rename launchpad: ");
            newName = GUILayout.TextField(newName);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("OK"))
            {
                padInstance.Name = newName;
                gui_enabled      = false;
                ExBuildWindow.updateCurrentPads();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel"))
            {
                gui_enabled = false;
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUI.DragWindow(new Rect(0, 0, 10000, 20));
        }
 void OnDestroy()
 {
     instance = null;
     GameEvents.onVesselChange.Remove(onVesselChange);
     GameEvents.onVesselWasModified.Remove(onVesselWasModified);
     GameEvents.onHideUI.Remove(onHideUI);
     GameEvents.onShowUI.Remove(onShowUI);
 }
 void ParseBuildWindow(ConfigNode settings)
 {
     if (settings.HasNode("BuildWindow"))
     {
         var node = settings.GetNode("BuildWindow");
         ExBuildWindow.LoadSettings(node);
     }
 }
 void Awake()
 {
     instance = this;
     GameEvents.onVesselChange.Add(onVesselChange);
     GameEvents.onVesselWasModified.Add(onVesselWasModified);
     GameEvents.onHideUI.Add(onHideUI);
     GameEvents.onShowUI.Add(onShowUI);
     enabled = false;
 }
Пример #5
0
 public void Awake()
 {
     if (ToolbarManager.Instance == null)
     {
         return;
     }
     ExBuildWindowButton             = ToolbarManager.Instance.add("ExtraplanetaryLaunchpads", "ExBuildWindowButton");
     ExBuildWindowButton.TexturePath = "ExtraplanetaryLaunchpads/Textures/icon_button";
     ExBuildWindowButton.ToolTip     = "EL Build Window";
     ExBuildWindowButton.OnClick    += (e) => ExBuildWindow.ToggleGUI();
 }
Пример #6
0
        public void Awake()
        {
            ExAppButton.Toggle += ExBuildWindow.ToggleGUI;

            if (ToolbarManager.Instance == null)
            {
                return;
            }
            ExBuildWindowButton             = ToolbarManager.Instance.add("ExtraplanetaryLaunchpads", "ExBuildWindowButton");
            ExBuildWindowButton.Visible     = ExSettings.PreferBlizzy;
            ExBuildWindowButton.TexturePath = "ExtraplanetaryLaunchpads/Textures/icon_button";
            ExBuildWindowButton.ToolTip     = "EL Build Window";
            ExBuildWindowButton.OnClick    += (e) => ExBuildWindow.ToggleGUI();
        }
Пример #7
0
 void Awake()
 {
     if (CompatibilityChecker.IsWin64())
     {
         enabled = false;
         return;
     }
     instance = this;
     GameEvents.onVesselChange.Add(onVesselChange);
     GameEvents.onVesselWasModified.Add(onVesselWasModified);
     GameEvents.onHideUI.Add(onHideUI);
     GameEvents.onShowUI.Add(onShowUI);
     enabled = false;
 }
        public override void OnSave(ConfigNode config)
        {
            //Debug.Log (String.Format ("[EL] Settings save: {0}", config));
            var settings = new ConfigNode("Settings");

            config.AddNode(settings);

            settings.AddValue("UseKAC", use_KAC);
            settings.AddValue("KACAction", KACAction.ToString());
            settings.AddValue("PreferBlizzy", PreferBlizzy);

            ExShipInfo.SaveSettings(settings.AddNode("ShipInfo"));
            ExBuildWindow.SaveSettings(settings.AddNode("BuildWindow"));
        }
        void SetPadMass()
        {
            double mass = 0;

            if (builtStuff != null && buildCost != null)
            {
                var built = builtStuff.required;
                var cost  = buildCost.required;

                foreach (var bres in built)
                {
                    var cres = ExBuildWindow.FindResource(cost, bres.name);
                    mass += (cres.amount - bres.amount) * bres.density;
                }
            }
            builder.SetCraftMass(mass);
        }
        public override void OnSave(ConfigNode config)
        {
            //Debug.Log (String.Format ("[EL] Settings save: {0}", config));
            var settings = new ConfigNode("Settings");

            bool uk = use_KAC;

            settings.AddValue("UseKAC", uk);

            string ka = KACAction.ToString();

            settings.AddValue("KACAction", ka);

            config.AddNode(settings);

            ExShipInfo.SaveSettings(settings.AddNode("ShipInfo"));
            ExBuildWindow.SaveSettings(settings.AddNode("BuildWindow"));
        }
 void OnDestroy()
 {
     instance = null;
     GameEvents.onVesselChange.Remove (onVesselChange);
     GameEvents.onVesselWasModified.Remove (onVesselWasModified);
     GameEvents.onHideUI.Remove (onHideUI);
     GameEvents.onShowUI.Remove (onShowUI);
 }
 void Awake()
 {
     instance = this;
     GameEvents.onVesselChange.Add (onVesselChange);
     GameEvents.onVesselWasModified.Add (onVesselWasModified);
     GameEvents.onHideUI.Add (onHideUI);
     GameEvents.onShowUI.Add (onShowUI);
     enabled = false;
 }
Пример #13
0
 public void ShowUI()
 {
     ExBuildWindow.ShowGUI();
     ExBuildWindow.SelectPad(control);
 }
Пример #14
0
 public void HideUI()
 {
     ExBuildWindow.HideGUI();
 }
 void Awake()
 {
     if (CompatibilityChecker.IsWin64 ()) {
         enabled = false;
         return;
     }
     instance = this;
     GameEvents.onVesselChange.Add (onVesselChange);
     GameEvents.onVesselWasModified.Add (onVesselWasModified);
     GameEvents.onHideUI.Add (onHideUI);
     GameEvents.onShowUI.Add (onShowUI);
     enabled = false;
 }
        public override void OnLoad(ConfigNode config)
        {
            //Debug.Log (String.Format ("[EL] Settings load"));
            var settings = config.GetNode("Settings");

            if (settings == null)
            {
                settings    = new ConfigNode("Settings");
                gui_enabled = true;                 // Show settings window on first startup
            }
            if (!settings.HasValue("UseKAC"))
            {
                var val = use_KAC;
                settings.AddValue("UseKAC", val);
            }
            if (!settings.HasValue("KACAction"))
            {
                var val = KACAction.ToString();
                settings.AddValue("KACAction", val);
            }

            var  uks = settings.GetValue("UseKAC");
            bool uk  = true;

            bool.TryParse(uks, out uk);
            use_KAC = uk;

            string str = settings.GetValue("KACAction");

            switch (str)
            {
            case ("KillWarp"):
                KACAction = KACWrapper.KACAPI.AlarmActionEnum.KillWarp;
                break;

            case ("KillWarpOnly"):
                KACAction = KACWrapper.KACAPI.AlarmActionEnum.KillWarpOnly;
                break;

            case ("MessageOnly"):
                KACAction = KACWrapper.KACAPI.AlarmActionEnum.MessageOnly;
                break;

            case ("PauseGame"):
                KACAction = KACWrapper.KACAPI.AlarmActionEnum.PauseGame;
                break;

            default:
                KACAction = KACWrapper.KACAPI.AlarmActionEnum.KillWarp;
                break;
            }
            ;

            if (settings.HasNode("ShipInfo"))
            {
                var node = settings.GetNode("ShipInfo");
                ExShipInfo.LoadSettings(node);
            }

            if (settings.HasNode("BuildWindow"))
            {
                var node = settings.GetNode("BuildWindow");
                ExBuildWindow.LoadSettings(node);
            }

            if (CompatibilityChecker.IsWin64())
            {
                enabled = false;
            }
            else
            {
                if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
                {
                    enabled = true;
                }
            }
        }
        private void DoWork_Cancel(double kerbalHours)
        {
            var built            = builtStuff.required;
            var cost             = buildCost.required;
            var base_kerbalHours = Math.Abs(kerbalHours);

            bool did_work;
            int  count;

            do
            {
                count = 0;
                foreach (var bres in built)
                {
                    var cres = ExBuildWindow.FindResource(cost, bres.name);
                    if (cres.amount - bres.amount > 0)
                    {
                        count++;
                    }
                }
                if (count == 0)
                {
                    break;
                }

                double work = kerbalHours / count;
                did_work = false;
                count    = 0;
                foreach (var bres in built)
                {
                    var    cres      = ExBuildWindow.FindResource(cost, bres.name);
                    double remaining = cres.amount - bres.amount;
                    if (remaining < 0)
                    {
                        continue;
                    }
                    double amount      = work / bres.kerbalHours;
                    double base_amount = Math.Abs(amount);

                    if (amount > remaining)
                    {
                        amount = remaining;
                    }
                    count++;
                    did_work = true;
                    // do only the work required to process the actual amount
                    // of returned or disposed resource
                    kerbalHours -= work * amount / base_amount;
                    bres.amount += amount;
                    //Debug.Log("remove delta: "+amount);
                    bres.deltaAmount = amount;

                    double capacity = padResources.ResourceCapacity(bres.name)
                                      - padResources.ResourceAmount(bres.name);
                    if (amount > capacity)
                    {
                        amount = capacity;
                    }
                    if (amount / base_amount <= 1e-10)
                    {
                        continue;
                    }
                    padResources.TransferResource(bres.name, amount);
                }
            } while (did_work && kerbalHours / base_kerbalHours > 1e-10);

            SetPadMass();

            if (count == 0)
            {
                state      = State.Planning;
                KACalarmID = "";
            }
        }