public override void OnAwake()
        {
            base.OnAwake();

            GetLocalizedLabels();

            var usiTools = USI_AddonServiceManager.Instance;

            if (usiTools != null)
            {
                _serviceManager = usiTools.ServiceManager;

                try
                {
                    var windowManager = _serviceManager.GetService <WindowManager>();
                    _window = windowManager.GetWindow <ResourceTransferWindow>();
                    _window.Initialize(this, windowManager, () =>
                    {
                        if (_toolbarButton != null)
                        {
                            // The app launcher button behaves like a toggle and will
                            //  remain in the 'on' state if the window closes itself
                            //  so we need to reset the button when that happens
                            _toolbarButton.SetFalse(false);
                        }
                    });

                    // Do an initial update before the Update method takes over
                    LazyUpdate(0f);
                    _nextLazyUpdate = Planetarium.GetUniversalTime() + 1d;
                }
                catch (Exception ex)
                {
                    Debug.LogError($"[Konstruction] {ClassName}: {ex.Message}");
                    enabled = false;
                    return;
                }
            }

            // Create toolbar button
            var textureService = _serviceManager.GetService <TextureService>();
            var toolbarIcon    = textureService.GetTexture(
                "GameData/UmbraSpaceIndustries/Konstruction/Assets/UI/Logistics_36x36.png", 36, 36);
            var showInScenes = ApplicationLauncher.AppScenes.FLIGHT;

            _toolbarButton = ApplicationLauncher.Instance.AddModApplication(
                ShowWindow,
                CloseWindow,
                null,
                null,
                null,
                null,
                showInScenes,
                toolbarIcon);
        }
示例#2
0
 public override void OnAwake()
 {
     base.OnAwake();
     resources_window = gameObject.AddComponent <ResourceTransferWindow>();
     crew_window      = gameObject.AddComponent <CrewTransferWindow>();
 }