private void SetLocalVariables()
 {
     windowSettings = mbARP.windowSettings;
     settings = KSPAlternateResourcePanel.settings;
     lstResources = mbARP.lstResourcesVessel;
     lstResourcesLastStage = mbARP.lstResourcesLastStage;
     SelectedResources = mbARP.SelectedResources;
 }
Beispiel #2
0
        internal override void Awake()
        {
            LogFormatted("Awakening the AlternateResourcePanel (ARP)");

            LogFormatted("Loading Settings");
            settings = new Settings("settings.cfg");
            if (!settings.Load())
                LogFormatted("Settings Load Failed");

            //If the window is in the pre0.24 default then move it down so its not over the app launcher
            if (new Rect(Screen.width - 310, 0, 310, 40).Contains(settings.vectButtonPos))
            {
                settings.vectButtonPos = new Vector3(Screen.width - 405, 0,0 );
                settings.ButtonPosUpdatedv24 = true;
                settings.Save();
            }
            if (!settings.WindowPosUpdatedv24 && settings.WindowPosition == new Rect(new Rect(Screen.width - 298, 19, 299, 20)))
            {
                MonoBehaviourExtended.LogFormatted("Moving window for 0.24");
                settings.WindowPosUpdatedv24 = true;
                settings.Save();
                blnResetWindow = true;
            }

            //Ensure settings.resources contains all the resources in the loaded game
            VerifyResources();

            //get the sounds and set things up
            Resources.LoadSounds();
            InitAudio();

            //Get whether the toolbar is there
            settings.BlizzyToolbarIsAvailable = ToolbarManager.ToolbarAvailable;

            //convert blizzy bool to display enum
            if (settings.UseBlizzyToolbarIfAvailable) {
                settings.UseBlizzyToolbarIfAvailable = false;
                settings.ButtonStyleChosen = ARPWindowSettings.ButtonStyleEnum.Toolbar;
            }

            //setup the Toolbar button if necessary
            if (settings.ButtonStyleToDisplay==ARPWindowSettings.ButtonStyleEnum.Toolbar)
            {
                    btnToolbar = InitToolbarButton();
            }
            ////if requested use that button
            //if (settings.BlizzyToolbarIsAvailable && settings.UseBlizzyToolbarIfAvailable)
            //    btnToolbar = InitToolbarButton();

            //init the global variables
            lstPartWindows = new ARPPartWindowList();
            lstResourcesVessel = new ARPResourceList(ARPResourceList.ResourceUpdate.AddValues, settings.Resources);
            lstResourcesLastStage = new ARPResourceList(ARPResourceList.ResourceUpdate.AddValues, settings.Resources);

            lstResourcesVesselPerStage = new Dictionary<Int32, ARPResourceList>();

            lstPartsLastStageEngines = new ARPPartList();

            lstResourcesToDisplay = new List<Int32>();
            SelectedResources = new PartResourceVisibleList();

            lstTransfers = new ARPTransferList();

            SelectedResources.ResourceRemoved += SelectedResources_ResourceRemoved;

            lstResourcesVessel.OnMonitorStateChanged += lstResourcesVessel_OnMonitorStateChanged;
            lstResourcesVessel.OnAlarmStateChanged += lstResourcesVessel_OnAlarmStateChanged;

            //init the windows
            InitMainWindow();
            InitSettingsWindow();
            InitResourceConfigWindow();
            InitDebugWindow();

            //plug us in to the draw queue and start the worker
            RenderingManager.AddToPostDrawQueue(1, DrawGUI);
            StartRepeatingWorker(10);

            //register for stage separation events - so we can cancel the noise on a sep
            GameEvents.onStageActivate.Add(OnStageActivate);
            GameEvents.onFlightReady.Add(OnFlightReady);

            //Hook the App Launcher
            OnGUIAppLauncherReady();
            //GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
            GameEvents.onGUIApplicationLauncherUnreadifying.Add(OnGUIAppLauncherUnreadifying);

            //do the daily version check if required
            if (settings.DailyVersionCheck)
                settings.VersionCheck(false);

            APIAwake();
        }