示例#1
0
		private void VirtualPadControl_Load(object sender, EventArgs e)
		{
			Size = UIHelper.Scale(_schema.DefaultSize);
			MaximumSize = UIHelper.Scale(_schema.MaxSize ?? _schema.DefaultSize);
			PadBox.Text = _schema.DisplayName;
			foreach (var button in _schema.Buttons)
			{
				switch (button.Type)
				{
					case PadSchema.PadInputType.Boolean:
						var buttonControl = new VirtualPadButton
						{
							Name = button.Name,
							Text = button.DisplayName,
							Location = UIHelper.Scale(button.Location),
							Image = button.Icon,
						};
						if (button.Icon != null && UIHelper.AutoScaleFactorX > 1F && UIHelper.AutoScaleFactorY > 1F)
						{
							// When scaling up, unfortunately the icon will look too small, but at least we can make the rest of the button bigger
							buttonControl.AutoSize = false;
							buttonControl.Size = UIHelper.Scale(button.Icon.Size) + new Size(6, 6);
						}
						PadBox.Controls.Add(buttonControl);
						break;
					case PadSchema.PadInputType.AnalogStick:
						PadBox.Controls.Add(new VirtualPadAnalogStick
						{
							Name = button.Name,
							Location = UIHelper.Scale(button.Location),
							Size = UIHelper.Scale(new Size(180 + 79, 200 + 9)),
							RangeX = new float[] { button.MinValue, button.MidValue, button.MaxValue },
							RangeY = new float[] { button.MinValueSec, button.MidValueSec, button.MaxValueSec }, 
						});
						break;
					case PadSchema.PadInputType.TargetedPair:
						PadBox.Controls.Add(new VirtualPadTargetScreen
						{
							Name = button.Name,
							Location = UIHelper.Scale(button.Location),
							TargetSize = button.TargetSize,
							XName = button.Name,
							YName = button.SecondaryNames[0],
							RangeX = button.MaxValue,
							RangeY = button.MaxValue // TODO: ability to have a different Y than X
						});
						break;
					case PadSchema.PadInputType.FloatSingle:
						PadBox.Controls.Add(new VirtualPadAnalogButton
						{
							Name = button.Name,
							DisplayName = button.DisplayName,
							Location = UIHelper.Scale(button.Location),
							Size = UIHelper.Scale(button.TargetSize),
							MinValue = button.MinValue,
							MaxValue = button.MaxValue
						});
						break;
					case PadSchema.PadInputType.DiscManager:
						PadBox.Controls.Add(new VirtualPadDiscManager(button.SecondaryNames)
						{
							Name = button.Name,
							//DisplayName = button.DisplayName,
							Location = UIHelper.Scale(button.Location),
							Size = UIHelper.Scale(button.TargetSize),
							OwnerEmulator = button.OwnerEmulator
						});
						break;
				}
			}
		}
示例#2
0
        private void VirtualPadControl_Load(object sender, EventArgs e)
        {
            Size        = UIHelper.Scale(_schema.DefaultSize);
            MaximumSize = UIHelper.Scale(_schema.MaxSize ?? _schema.DefaultSize);
            PadBox.Text = _schema.DisplayName;
            foreach (var button in _schema.Buttons)
            {
                switch (button.Type)
                {
                case PadSchema.PadInputType.Boolean:
                    var buttonControl = new VirtualPadButton
                    {
                        Name     = button.Name,
                        Text     = button.DisplayName,
                        Location = UIHelper.Scale(button.Location),
                        Image    = button.Icon,
                    };
                    if (button.Icon != null && UIHelper.AutoScaleFactorX > 1F && UIHelper.AutoScaleFactorY > 1F)
                    {
                        // When scaling up, unfortunately the icon will look too small, but at least we can make the rest of the button bigger
                        buttonControl.AutoSize = false;
                        buttonControl.Size     = UIHelper.Scale(button.Icon.Size) + new Size(6, 6);
                    }
                    PadBox.Controls.Add(buttonControl);
                    break;

                case PadSchema.PadInputType.AnalogStick:
                    PadBox.Controls.Add(new VirtualPadAnalogStick
                    {
                        Name     = button.Name,
                        Location = UIHelper.Scale(button.Location),
                        Size     = UIHelper.Scale(new Size(button.MaxValue + 79, button.MaxValue + 9)), // TODO: don't use hardcoded values here, at least make them defaults in the AnalogStick object itself
                        RangeX   = button.MaxValue,
                        RangeY   = button.MaxValue                                                      // TODO ability to pass in a different Y max
                    });
                    break;

                case PadSchema.PadInputType.TargetedPair:
                    PadBox.Controls.Add(new VirtualPadTargetScreen
                    {
                        Name       = button.Name,
                        Location   = UIHelper.Scale(button.Location),
                        TargetSize = button.TargetSize,
                        XName      = button.Name,
                        YName      = button.SecondaryNames[0],
                        RangeX     = button.MaxValue,
                        RangeY     = button.MaxValue                             // TODO: ability to have a different Y than X
                    });
                    break;

                case PadSchema.PadInputType.FloatSingle:
                    PadBox.Controls.Add(new VirtualPadAnalogButton
                    {
                        Name        = button.Name,
                        DisplayName = button.DisplayName,
                        Location    = UIHelper.Scale(button.Location),
                        Size        = UIHelper.Scale(button.TargetSize),
                        MinValue    = button.MinValue,
                        MaxValue    = button.MaxValue
                    });
                    break;

                case PadSchema.PadInputType.DiscManager:
                    PadBox.Controls.Add(new VirtualPadDiscManager(button.SecondaryNames)
                    {
                        Name = button.Name,
                        //DisplayName = button.DisplayName,
                        Location      = UIHelper.Scale(button.Location),
                        Size          = UIHelper.Scale(button.TargetSize),
                        OwnerEmulator = button.OwnerEmulator
                    });
                    break;
                }
            }
        }