public GasThermomachineWindow()
    {
        RobustXamlLoader.Load(this);

        SpinboxHBox.AddChild(
            TemperatureSpinbox = new FloatSpinBox(.1f, 2)
        {
            MaxWidth = 150, HorizontalExpand = true
        }
            );
    }
示例#2
0
    public DecalPlacerWindow(IPrototypeManager prototypeManager)
    {
        RobustXamlLoader.Load(this);

        _prototypeManager     = prototypeManager;
        _decalPlacementSystem = EntitySystem.Get <DecalPlacementSystem>();

        // This needs to be done in C# so we can have custom stuff passed in the constructor
        // and thus have a proper step size
        RotationSpinBox = new FloatSpinBox(90.0f, 0)
        {
            HorizontalExpand = true
        };
        SpinBoxContainer.AddChild(RotationSpinBox);

        Search.OnTextChanged      += _ => RefreshList();
        ColorPicker.OnColorPicked += color =>
        {
            _color = color;
            UpdateDecalPlacementInfo();
            RefreshList();
        };
        RotationSpinBox.OnValueChanged += args =>
        {
            _rotation = args.Value;
            UpdateDecalPlacementInfo();
        };
        EnableColor.OnToggled += args =>
        {
            _useColor = args.Pressed;
            UpdateDecalPlacementInfo();
            RefreshList();
        };
        EnableSnap.OnToggled += args =>
        {
            _snap = args.Pressed;
            UpdateDecalPlacementInfo();
        };
        EnableCleanable.OnToggled += args =>
        {
            _cleanable = args.Pressed;
            UpdateDecalPlacementInfo();
        };
        // i have to make this a member method for some reason and i have no idea why its only for spinboxes
        ZIndexSpinBox.ValueChanged += ZIndexSpinboxChanged;

        Populate();
    }
        /// <summary>
        ///     Add a single reagent entry to the list
        /// </summary>
        private void AddReagentEntry(Solution.ReagentQuantity reagent)
        {
            var box  = new BoxContainer();
            var spin = new FloatSpinBox(1, 2);

            spin.Value            = reagent.Quantity.Float();
            spin.OnValueChanged  += (args) => SetReagent(args, reagent.ReagentId);
            spin.HorizontalExpand = true;

            box.AddChild(new Label()
            {
                Text = reagent.ReagentId, HorizontalExpand = true
            });
            box.AddChild(spin);

            ReagentList.AddChild(box);
        }
        /// <summary>
        ///     Updates the entry displaying the current and maximum volume of the selected solution.
        /// </summary>
        /// <param name="solution">The selected solution.</param>
        private void UpdateVolumeBox(Solution solution)
        {
            VolumeBox.DisposeAllChildren();

            var volumeLabel = new Label();

            volumeLabel.HorizontalExpand = true;
            volumeLabel.Margin           = new Thickness(0, 4);
            volumeLabel.Text             = Loc.GetString("admin-solutions-window-volume-label",
                                                         ("currentVolume", solution.CurrentVolume),
                                                         ("maxVolume", solution.MaxVolume));

            var capacityBox = new BoxContainer();

            capacityBox.Orientation      = BoxContainer.LayoutOrientation.Horizontal;
            capacityBox.HorizontalExpand = true;
            capacityBox.Margin           = new Thickness(0, 4);

            var capacityLabel = new Label();

            capacityLabel.HorizontalExpand = true;
            capacityLabel.Margin           = new Thickness(0, 1);
            capacityLabel.Text             = Loc.GetString("admin-solutions-window-capacity-label");

            var capacitySpin = new FloatSpinBox(1, 2);

            capacitySpin.HorizontalExpand = true;
            capacitySpin.Margin           = new Thickness(0, 1);
            capacitySpin.Value            = (float)solution.MaxVolume;
            capacitySpin.OnValueChanged  += SetCapacity;

            capacityBox.AddChild(capacityLabel);
            capacityBox.AddChild(capacitySpin);

            VolumeBox.AddChild(volumeLabel);
            VolumeBox.AddChild(capacityBox);
        }
    public DecalPlacerWindow(IPrototypeManager prototypeManager)
    {
        RobustXamlLoader.Load(this);

        _prototypeManager     = prototypeManager;
        _decalPlacementSystem = EntitySystem.Get <DecalPlacementSystem>();

        // This needs to be done in C# so we can have custom stuff passed in the constructor
        // and thus have a proper step size
        RotationSpinBox = new FloatSpinBox(90.0f, 0)
        {
            HorizontalExpand = true
        };
        SpinBoxContainer.AddChild(RotationSpinBox);

        Search.OnTextChanged       += _ => RefreshList();
        ColorPicker.OnColorChanged += OnColorPicked;

        PickerOpen.OnPressed += _ =>
        {
            if (_picker is null)
            {
                _picker = new PaletteColorPicker();
                _picker.OpenToLeft();
                _picker.PaletteList.OnItemSelected += args =>
                {
                    var color = (args.ItemList.GetSelected().First().Metadata as Color?) !.Value;
                    ColorPicker.Color = color;
                    OnColorPicked(color);
                };
            }
            else
            {
                if (_picker.IsOpen)
                {
                    _picker.Close();
                }
                else
                {
                    _picker.Open();
                }
            }
        };

        RotationSpinBox.OnValueChanged += args =>
        {
            _rotation = args.Value;
            UpdateDecalPlacementInfo();
        };
        EnableColor.OnToggled += args =>
        {
            _useColor = args.Pressed;
            UpdateDecalPlacementInfo();
            RefreshList();
        };
        EnableSnap.OnToggled += args =>
        {
            _snap = args.Pressed;
            UpdateDecalPlacementInfo();
        };
        EnableCleanable.OnToggled += args =>
        {
            _cleanable = args.Pressed;
            UpdateDecalPlacementInfo();
        };
        // i have to make this a member method for some reason and i have no idea why its only for spinboxes
        ZIndexSpinBox.ValueChanged += ZIndexSpinboxChanged;

        Populate();
    }
        /// <summary>
        ///     Updates the entry displaying the current specific heat, heat capacity, temperature, and thermal energy
        ///     of the selected solution.
        /// </summary>
        /// <param name="solution">The selected solution.</param>
        private void UpdateThermalBox(Solution solution)
        {
            ThermalBox.DisposeAllChildren();

            var specificHeatLabel = new Label();

            specificHeatLabel.HorizontalExpand = true;
            specificHeatLabel.Margin           = new Thickness(0, 1);
            specificHeatLabel.Text             = Loc.GetString("admin-solutions-window-specific-heat-label", ("specificHeat", solution.SpecificHeat));

            var heatCapacityLabel = new Label();

            heatCapacityLabel.HorizontalExpand = true;
            heatCapacityLabel.Margin           = new Thickness(0, 1);
            heatCapacityLabel.Text             = Loc.GetString("admin-solutions-window-heat-capacity-label", ("heatCapacity", solution.HeatCapacity));

            // Temperature entry:
            var temperatureBox = new BoxContainer();

            temperatureBox.Orientation      = BoxContainer.LayoutOrientation.Horizontal;
            temperatureBox.HorizontalExpand = true;
            temperatureBox.Margin           = new Thickness(0, 1);

            var temperatureLabel = new Label();

            temperatureLabel.HorizontalExpand = true;
            temperatureLabel.Margin           = new Thickness(0, 1);
            temperatureLabel.Text             = Loc.GetString("admin-solutions-window-temperature-label");

            var temperatureSpin = new FloatSpinBox(1, 2);

            temperatureSpin.HorizontalExpand = true;
            temperatureSpin.Margin           = new Thickness(0, 1);
            temperatureSpin.Value            = solution.Temperature;
            temperatureSpin.OnValueChanged  += SetTemperature;

            temperatureBox.AddChild(temperatureLabel);
            temperatureBox.AddChild(temperatureSpin);

            // Thermal energy entry:
            var thermalEnergyBox = new BoxContainer();

            thermalEnergyBox.Orientation      = BoxContainer.LayoutOrientation.Horizontal;
            thermalEnergyBox.HorizontalExpand = true;
            thermalEnergyBox.Margin           = new Thickness(0, 1);

            var thermalEnergyLabel = new Label();

            thermalEnergyLabel.HorizontalExpand = true;
            thermalEnergyLabel.Margin           = new Thickness(0, 1);
            thermalEnergyLabel.Text             = Loc.GetString("admin-solutions-window-thermal-energy-label");

            var thermalEnergySpin = new FloatSpinBox(1, 2);

            thermalEnergySpin.HorizontalExpand = true;
            thermalEnergySpin.Margin           = new Thickness(0, 1);
            thermalEnergySpin.Value            = solution.ThermalEnergy;
            thermalEnergySpin.OnValueChanged  += SetThermalEnergy;

            thermalEnergyBox.AddChild(thermalEnergyLabel);
            thermalEnergyBox.AddChild(thermalEnergySpin);

            ThermalBox.AddChild(specificHeatLabel);
            ThermalBox.AddChild(heatCapacityLabel);
            ThermalBox.AddChild(temperatureBox);
            ThermalBox.AddChild(thermalEnergyBox);
        }