/// <summary>
        /// Called when the game is loaded. Used to set up all persistent objects and properties.
        /// </summary>
        public void Start()
        {
            fetch = this;
            "WalkAboutAddUtility.Start".Debug();
            activeEVA = false;
            if (!(FlightGlobals.ActiveVessel?.isEVA ?? false))
            {
                "Add Location utility deactivated: not an EVA".Debug();
            }
            else
            {
                var crew = FlightGlobals.ActiveVessel.GetVesselCrew();
                if ((crew?.Count ?? 0) != 1)
                {
                    "Add Location utility deactivated: invalid crew count".Debug();
                }
                else
                {
                    activeEVA = true;
                }
            }
            GameEvents.onVesselChange.Add(onVesselChange);

            _config = GetModConfig(); "Add Location utility obtained config".Debug();
            if (_config == null)
            {
                return;
            }
            if (!HighLogic.CurrentGame.Parameters.CustomParams <WA>().UtilityMode)
            {
                "Add Location utility deactivated: not in utility mode".Debug();
                return;
            }
            if (activeEVA)
            {
                $"Add Location utility activated on EVA for {FlightGlobals.ActiveVessel.GetVesselCrew()[0].name}".Debug();
            }

            _map           = GetLocationMap(); "Add Location utility obtained map object".Debug();
            _addUtilityGui = new AddUtilityGui();


            if (toolbarControl == null)
            {
                toolbarControl = gameObject.AddComponent <ToolbarControl>();
                toolbarControl.AddToAllToolbars(GuiOn, GuiOff,
                                                ApplicationLauncher.AppScenes.FLIGHT,
                                                WalkAbout.MODID,
                                                "walkaboutButton_Flight",
                                                "WalkAbout/PluginData/WalkAbout-38",
                                                "WalkAbout/PluginData/WalkAbout-24",
                                                WalkAbout.MODNAME
                                                );
            }
        }
Exemplo n.º 2
0
        //static AddUtilityGui() { }

        /// <summary>
        /// Initializes a new instance of the GUI with a collection of locations.
        /// </summary>
        internal AddUtilityGui()
        {
            _facilitySelectorScrollPosition = Vector2.zero;
            _unenteredText = "Location Name";

            _enteredLocationName = _unenteredText;
            _selectedFacility    = string.Empty;

            _map           = GetLocationMap();
            GuiCoordinates = new Rect();
            IsActive       = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when the game is loaded. Used to set up all persistent objects and properties.
        /// </summary>
        public void Start()
        {
            $"Started [Version={Constants.Version}, Debug={DebugExtensions.DebugIsOn}]".Log();
            fetch   = this;
            _config = GetModConfig(); "obtained config".Debug();
            if (_config == null)
            {
                return;
            }

            _map = GetLocationMap(); "obtained map object".Debug();
            _map.RefreshLocations(); // needed to avoid holding on to other games' data
            _items = GetAllItems(); "obtained items object".Debug();

            _mainGui = PlaceKerbalGui.Instance;
            _mainGui.GuiCoordinates = _config.GetScreenPosition();
            //_mainGui.TopFew = _config.TopFew;
            _mainGui.MaxItems  = HighLogic.CurrentGame.Parameters.CustomParams <WA>().MaxInventoryItems;
            _mainGui.MaxVolume = HighLogic.CurrentGame.Parameters.CustomParams <WA>().MaxInventoryVolume;
            $"created MainGui object".Debug();

            GetCentrum(); // Initialize the centrum to avoid errors if AddUtility is opened before WalkAbout.

            GameEvents.OnTechnologyResearched.Remove(ItemRefresh);
            GameEvents.OnKSCFacilityUpgraded.Remove(MapRefresh);
            GameEvents.OnTechnologyResearched.Add(ItemRefresh);
            GameEvents.OnKSCFacilityUpgraded.Add(MapRefresh);

            if (toolbarControl == null)
            {
                toolbarControl = gameObject.AddComponent <ToolbarControl>();
                toolbarControl.AddToAllToolbars(GuiOn, GuiOff,
                                                ApplicationLauncher.AppScenes.SPACECENTER,
                                                MODID,
                                                "walkaboutButton_spacecenter",
                                                "WalkAbout/PluginData/WalkAbout-38",
                                                "WalkAbout/PluginData/WalkAbout-24",
                                                MODNAME
                                                );
            }
        }
 public void getCurrentMapInfo()
 {
    currentMapInfo = KnownPlaces.GetMapInfo(currentPosX, currentPosY);
 }