private void Start()
        {
            Logger.Info($"Starting {ModName} v{Version}...");

            var resourceProvider = new ResourceProvider(ModName);

            Logger.Debug("Loading configuration");
            m_configuration = ConfigurationParser.LoadFromFile(ConfigurationFile);
            m_configuration.PropertyChanged += OnConfigurationChanged;
            m_toggleButton = m_configuration.ToggleKey;

            Logger.Debug("Setting up OrbitVisibilityController");
            m_visibilityController = new OrbitVisibilityController(m_configuration);
            m_visibilityController.OnVisibilityChanged += OnOrbitVisibilityChanged;

            // setup window
            Logger.Debug("Creating window");
            m_window = new ConfigurationWindow(ModName, m_configuration, m_visibilityController, resourceProvider);

            // setup toolbar button
            Logger.Debug("Creating toolbar button");
            m_toolbarButton            = new ToolbarButton(resourceProvider);
            m_toolbarButton.OnEnable  += m_window.Show;
            m_toolbarButton.OnDisable += m_window.Hide;

            // get notifcations when player changes to map view
            MapView.OnEnterMapView += OnEnterMapView;
            MapView.OnExitMapView  += OnExitMapView;

            // disable script until woken up by entering map view
            enabled = false;
        }
Пример #2
0
 public ConfigurationWindow(string title, Configuration configuration, IVisibilityController visibilityController, ResourceProvider resources)
 {
     m_title                = title;
     m_configuration        = configuration;
     m_visibilityController = visibilityController;
     m_pencilTexture        = resources.PencilIcon;
     m_toolbarTexture       = resources.ToolbarIcon;
     m_greenToolbarTexture  = resources.GreenToolbarIcon;
     m_moveTexture          = resources.MoveIcon;
     m_expandTexture        = resources.ExpandIcon;
     m_retractTexture       = resources.RetractIcon;
     RestoreConfiguration();
 }
        internal void Start()
        {
            Log.Info("TooManyOrbitsCoreModule.Start");
            Instance = this;

            resourceProvider = new ResourceProvider(ModName);

            m_configuration = ConfigurationParser.LoadFromFile(ConfigurationFile);
            m_configuration.PropertyChanged += OnConfigurationChanged;
            m_toggleButton = m_configuration.ToggleKey;

            m_visibilityController = new OrbitVisibilityController(m_configuration);
            m_visibilityController.OnVisibilityChanged += OnOrbitVisibilityChanged;

            // setup window
            Log.Debug("Creating window");
            m_window = new ConfigurationWindow(ModName, m_configuration, m_visibilityController, resourceProvider);

            // setup toolbar button
            Log.Debug("Creating toolbar button");
            if (toolbarControl == null)
            {
                BuildButton();
            }

#if false
            if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                OnEnterMapView();
            }
            else
#endif
            {
                // get notifcations when player changes to map view
                MapView.OnEnterMapView += OnEnterMapView;
                MapView.OnExitMapView  += OnExitMapView;
            }

            // disable script until woken up by entering map view
            //enabled = false;
            DontDestroyOnLoad(this);
        }
        internal void Update()
        {
            if (m_skipUpdate)
            {
                m_skipUpdate = false;
                return;
            }

            if (Input.GetKeyDown(m_toggleButton))
            {
#if false
                if (m_visibilityController == null)
                {
                    m_visibilityController = new OrbitVisibilityController(m_configuration);
                    m_visibilityController.OnVisibilityChanged += OnOrbitVisibilityChanged;
                }
#endif
                m_visibilityController.Toggle();
            }
        }