public GamePage(GameProgramInfoViewItem gameProgramInfoViewItem, bool startFresh = false) { _gameProgramInfoViewItem = gameProgramInfoViewItem ?? throw new ArgumentNullException(nameof(gameProgramInfoViewItem)); _startFreshReq = startFresh; _settings = DatastoreService.GetSettings(); _gameControl = new GameControl(); _buttonBack = new BackButton { Location = new(5, 5) }; _buttonSettings = new SettingsButton { Location = _buttonBack.ToRightOf(25, 0) }; _labelInfoText = new LabelControl { TextFontFamilyName = Styles.ExtraLargeFontFamily, TextFontSize = Styles.ExtraLargeFontSize, TextAlignment = DWriteTextAlignment.Center, Text = string.Empty, IsVisible = false }; _hud_buttonPower = new ButtonToggle { Text = "Power", Size = new(HudButtonWidth, HudButtonHeight), IsChecked = true }; _hud_buttonColor = new Button { Text = "Color", Size = new(HudButtonWidth, HudButtonHeight) }; _hud_buttonLD = new ButtonToggle { Text = "A/b", Size = new(HudButtonWidth, HudButtonHeight) }; _hud_buttonRD = new ButtonToggle { Text = "A/b", Size = new(HudButtonWidth, HudButtonHeight) }; _hud_buttonSelect = new Button { Text = "Select", Size = new(HudButtonWidth, HudButtonHeight) }; _hud_buttonReset = new Button { Text = "Reset", Size = new(HudButtonWidth, HudButtonHeight) }; _hud_buttonSound = new ButtonToggle { Text = "Sound", Size = new(HudButtonWidth, HudButtonHeight) }; _hud_buttonPaused = new ButtonToggle { Text = "Paused", Size = new(HudButtonWidth, HudButtonHeight) }; _hud_buttonAntiAliasMode = new ButtonToggle { Text = "Fuzzy", Size = new(HudButtonWidth, HudButtonHeight) }; _hud_buttonClose = new CheckButton(); _hud_numbercontrolFPS = new() { TextFontFamilyName = Styles.ExtraLargeFontFamily, TextFontSize = Styles.ExtraLargeFontSize }; _hud_labelFPS = new() { TextFontFamilyName = Styles.ExtraLargeFontFamily, TextFontSize = Styles.ExtraLargeFontSize, Text = "FPS", Size = new(100, 50) }; _hud_controllers = new() { TextFontFamilyName = Styles.SmallFontFamily, TextFontSize = Styles.SmallFontSize, TextAlignment = DWriteTextAlignment.Center, Text = string.Empty, }; _hud_buttonFpsMinus = new MinusButton(); _hud_buttonFpsPlus = new PlusButton(); _hud_buttonInput = new Button { Text = "Input", Size = new(HudButtonWidth, HudButtonHeight) }; _hud_buttonShowTouchControls = new ButtonToggle { Text = "Touch Controllers", Size = new(2 * HudButtonWidth + HudGapX, HudButtonHeight) }; _hud_controlCollection = new ControlCollection(); _hud_controlCollection.Add(_hud_buttonPower, _hud_buttonColor, _hud_buttonLD, _hud_buttonRD, _hud_buttonSelect, _hud_buttonReset, _hud_buttonClose, _hud_buttonSound, _hud_buttonPaused, _hud_numbercontrolFPS, _hud_labelFPS, _hud_controllers, _hud_buttonAntiAliasMode, _hud_buttonFpsMinus, _hud_buttonFpsPlus, _hud_buttonShowTouchControls, _hud_buttonInput); _hud_controlCollection.IsVisible = false; _touchbuttonLeft = new LeftButton { ExpandBoundingRectangleVertically = true }; _touchbuttonRight = new RightButton { ExpandBoundingRectangleVertically = true }; _touchbuttonUp = new UpButton { ExpandBoundingRectangleHorizontally = true }; _touchbuttonDown = new DownButton { ExpandBoundingRectangleHorizontally = true }; _touchbuttonFire = new FireButton(); _touchbuttonFire2 = new FireButton(); _touchbuttonCollection = new ControlCollection(); _touchbuttonCollection.Add(_touchbuttonLeft, _touchbuttonRight, _touchbuttonUp, _touchbuttonDown, _touchbuttonFire, _touchbuttonFire2); _gameControl.IsInTouchMode = _touchbuttonCollection.IsVisible = _settings.ShowTouchControls; Controls.Add(_gameControl, _labelInfoText, _hud_controlCollection, _touchbuttonCollection); if (!_startFreshReq) { Controls.Add(_buttonBack, _buttonSettings); } ResetBackAndSettingsButtonVisibilityCounter(); #if PROFILE _numbercontrolRefreshRate = new NumberControl { Radix = 1, UseComma = false }; Controls.Add(_numbercontrolRefreshRate); #endif _buttonBack.Clicked += ButtonBack_Clicked; _buttonSettings.Clicked += ButtonSettings_Clicked; _hud_buttonClose.Clicked += (s, e) => HideHud(); _hud_buttonSound.Checked += (s, e) => _gameControl.IsSoundOn = true; _hud_buttonSound.Unchecked += (s, e) => _gameControl.IsSoundOn = false; _hud_buttonPaused.Checked += (s, e) => _gameControl.IsPaused = true; _hud_buttonPaused.Unchecked += (s, e) => _gameControl.IsPaused = false; _hud_buttonAntiAliasMode.Checked += (s, e) => _gameControl.IsAntiAliasOn = true; _hud_buttonAntiAliasMode.Unchecked += (s, e) => _gameControl.IsAntiAliasOn = false; _hud_buttonShowTouchControls.Checked += (s, e) => HandleShowTouchControlsCheckedChanged(true); _hud_buttonShowTouchControls.Unchecked += (s, e) => HandleShowTouchControlsCheckedChanged(false); _hud_buttonInput.Clicked += Hud_buttonInput_Clicked; _hud_buttonPower.Checked += Hud_buttonPower_Checked; _hud_buttonPower.Unchecked += Hud_buttonPower_Unchecked; _hud_buttonColor.Pressed += (s, e) => RaiseMachineInputFromHud(MachineInput.Color, true); _hud_buttonColor.Released += (s, e) => RaiseMachineInputFromHud(MachineInput.Color, false); _hud_buttonLD.Pressed += (s, e) => RaiseMachineInputFromHud(MachineInput.LeftDifficulty, true); _hud_buttonLD.Released += (s, e) => RaiseMachineInputFromHud(MachineInput.LeftDifficulty, false); _hud_buttonRD.Pressed += (s, e) => RaiseMachineInputFromHud(MachineInput.RightDifficulty, true); _hud_buttonRD.Released += (s, e) => RaiseMachineInputFromHud(MachineInput.RightDifficulty, false); _hud_buttonSelect.Pressed += (s, e) => RaiseMachineInputFromHud(MachineInput.Select, true); _hud_buttonSelect.Released += (s, e) => RaiseMachineInputFromHud(MachineInput.Select, false); _hud_buttonReset.Pressed += (s, e) => RaiseMachineInputFromHud(MachineInput.Reset, true); _hud_buttonReset.Released += (s, e) => RaiseMachineInputFromHud(MachineInput.Reset, false); _touchbuttonLeft.Pressed += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Left, true); _touchbuttonLeft.Released += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Left, false); _touchbuttonRight.Pressed += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Right, true); _touchbuttonRight.Released += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Right, false); _touchbuttonUp.Pressed += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Up, true); _touchbuttonUp.Released += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Up, false); _touchbuttonDown.Pressed += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Down, true); _touchbuttonDown.Released += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Down, false); _touchbuttonFire.Pressed += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Z, true); _touchbuttonFire.Released += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.Z, false); _touchbuttonFire2.Pressed += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.X, true); _touchbuttonFire2.Released += (s, e) => RaiseKeyboardKeyPressed(KeyboardKey.X, false); }
public GameProgramSelectedEventArgs(GameProgramInfoViewItem gpivi) => GameProgramInfoViewItem = gpivi;