Exemplo n.º 1
0
        protected override void Open()
        {
            base.Open();
            IoCManager.InjectDependencies(this);

            if (!Owner.Owner.TryGetComponent(out MaterialStorageComponent storage) ||
                !Owner.Owner.TryGetComponent(out SharedLatheComponent lathe) ||
                !Owner.Owner.TryGetComponent(out LatheDatabaseComponent database))
            {
                return;
            }

            Storage  = storage;
            Lathe    = lathe;
            Database = database;

            menu = new LatheMenu {
                Owner = this
            };
            queueMenu = new LatheQueueMenu {
                Owner = this
            };

            menu.OnClose += Close;

            menu.Populate();
            menu.PopulateMaterials();

            menu.QueueButton.OnPressed += (args) => { queueMenu.OpenCentered(); };

            storage.OnMaterialStorageChanged += menu.PopulateDisabled;
            storage.OnMaterialStorageChanged += menu.PopulateMaterials;

            menu.OpenCentered();
        }
        protected override void Open()
        {
            base.Open();

            if (!Owner.Owner.TryGetComponent(out MaterialStorageComponent storage) ||
                !Owner.Owner.TryGetComponent(out SharedLatheComponent lathe) ||
                !Owner.Owner.TryGetComponent(out SharedLatheDatabaseComponent database))
            {
                return;
            }



            Storage  = storage;
            Lathe    = lathe;
            Database = database;

            _menu      = new LatheMenu(this);
            _queueMenu = new LatheQueueMenu {
                Owner = this
            };

            _menu.OnClose += Close;

            _menu.Populate();
            _menu.PopulateMaterials();

            _menu.QueueButton.OnPressed += (args) => { _queueMenu.OpenCentered(); };

            _menu.ServerConnectButton.OnPressed += (args) =>
            {
                SendMessage(new SharedLatheComponent.LatheServerSelectionMessage());
            };

            _menu.ServerSyncButton.OnPressed += (args) =>
            {
                SendMessage(new SharedLatheComponent.LatheServerSyncMessage());
            };

            storage.OnMaterialStorageChanged += _menu.PopulateDisabled;
            storage.OnMaterialStorageChanged += _menu.PopulateMaterials;

            _menu.OpenCentered();
        }