public Game1() { //display displaymode = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode; graphics = new GraphicsDeviceManager(this); height = displaymode.Height; width = displaymode.Width; graphics.PreferredBackBufferHeight = height; graphics.PreferredBackBufferWidth = width; graphics.ApplyChanges(); graphics.IsFullScreen = fullScreen ; //Content Content.RootDirectory = "Content"; audio = new Audio(Content); //state _currentState = gameState.Initialisateur; StateManager = new Dictionary<gameState, GameState>(); StateManager.Add(gameState.PlayingState, new PlayingState(this,graphics,Content)); StateManager.Add(gameState.MainMenuState, new MainMenuState(this, graphics, Content)); StateManager.Add(gameState.Level_select_state, new Level_select_state(this, graphics, Content)); StateManager.Add(gameState.Level2, new Level2(this, graphics, Content)); StateManager.Add(gameState.SEU, new Shoot_Em_Up(this, graphics, Content)); StateManager.Add(gameState.Pause, new Pause(this, graphics, Content)); StateManager.Add(gameState.Initialisateur, new Initialisateur(this, graphics, Content)); StateManager.Add(gameState.Editeur_mapVV, new Editeur_MapVV(this, graphics, Content)); StateManager.Add(gameState.leveleditor, new leveleditor(this, graphics, Content)); StateManager.Add(gameState.level_Pselect, new Leveleditorselect (this,graphics ,Content )); StateManager.Add(gameState.win ,new GameWin(this,graphics,Content )); }
public void EqualsTest() { DisplayMode mode = new DisplayMode(); Assert.AreNotEqual(mode, null, "#1"); Assert.IsTrue(mode == mode, "#2"); Assert.IsFalse(mode != mode, "#3"); }
public Options() { hasChanged = false; isMouseVisible = false; isFullscreen = false; resNumber = 0; virtualWidth = 1366; virtualHeight = 768; CurrentResolution = Resolution.Instance.DisplayModesSixteenNine[resNumber]; WorldWidth = 256; WorldHeight = WorldWidth * 2; }
//Contructor public ScreenManager() { DisplayMode = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode; Screensize = new Vector2(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height); //Screen Centered Dimensions = new Vector2(506, 84); Position = new Point((int)(Screensize.X - Dimensions.X) / 2, (int)(Screensize.Y - Dimensions.Y) / 2); //FullScreen, zorg dat screen op borderless staat //Dimensions = new Vector2(Screensize.X, Screensize.Y-40); //Position = new Point(0, 0); currentscreen = new SplashScreen(); IsTransitioning = false; }
private void positionLettersBounceBack() { // v is the delta value: 1 = fully the straight line, 0 = fully the old position before grabbing float v = bounceBackRange.Value; for (int i = 0; i < letters.Count; i++) letterPositions[i] = bounceBackInterpolate.interpolate(i, v); lineDirection = InterpolatePosition.interpolate(lineDirectionOnRelease, oldLineDirection, v); lineAngle = InterpolatePosition.interpolate(lineAngleOnRelease, oldLineAngle, v); //if (letters.Count > 0) //{ // Vector2 end = new Vector2(letterPositions[0].X, letterPositions[0].Y); // lineDirection = end - lineStart; // lineDirection.Normalize(); // lineAngle = (float)Math.Acos(lineDirection.X) * Math.Sign(lineDirection.Y); //} circle.Position = bounceBackInterpolate.interpolate(-1, v); // needed to do one more call of this function to prevent a weird bug // but once the letters get positioned one last time, can return to normal just fine if (mode == DisplayMode.BounceBackFinished) mode = DisplayMode.Normal; }
void options_DisplayModeChanged(Options options, DisplayMode mode) { graphicsDeviceManager.IsFullScreen = options.IsFullScreen; graphicsDeviceManager.ApplyChanges(); }
// this is the event handler for bouncing back public void bounceBackFinished() { bounceBackCount++; // the number of times (not counting initial value of 1) we will be stop on the negative and positive sides of 0 int numPositiveBounce = numTimesToBounceBack / 2; int numNegativeBounce = (numTimesToBounceBack - 1) / 2; // we need to adjust the min range the first time it bounces back // this way it doesn't swing wildly back to the straight line, but rather closer to 0 // basically we don't want to divide the space between [1, 0], but rather [some small value, 0] if (bounceBackCount == 1) bounceBackRange.Min = -(bounceBackStart + bounceBackEnd); if (bounceBackCount >= numTimesToBounceBack + 1) { // we're done; it bounced back all the times specified, and the math worked out so the extra time bounces it to 0 // (ie, 0 = the final resting place, the curve in its wavy form before it was dragged) // then we can return to normal operation and everything lines up bounceBackCount = 0; mode = DisplayMode.BounceBackFinished; } else { // else, we need to let it keep bouncing, but cut the min/max so it won't bounce back as far as last time // since min and max are absolute (not relative) values (basically, how far should we move from where we currently are) // we need to simply subtract some movement "percentage" value, rather than set a hard value float v; // divide the space between start or end into num + 1 pieces if (bounceBackRange.MovementDirection > 0) v = bounceBackStart / (numPositiveBounce + 1); else v = bounceBackEnd / (numNegativeBounce + 1); // then it will move this much LESS the next time it bounces bounceBackRange.Max -= v; bounceBackRange.Min += v; } bounceBackRange.InitialValue = bounceBackRange.Value; bounceBackRange.initialize(); }
public void growOutwardFinished() { mode = DisplayMode.Normal; }
private void AddDevices(GraphicsAdapter adapter, DeviceType deviceType, DisplayMode mode, GraphicsDeviceInformation baseDeviceInfo, List<GraphicsDeviceInformation> foundDevices) { for (int i = 0; i < ValidBackBufferFormats.Length; i++) { SurfaceFormat backBufferFormat = ValidBackBufferFormats[i]; if (adapter.CheckDeviceType(deviceType, mode.Format, backBufferFormat, this.IsFullScreen)) { GraphicsDeviceInformation item = baseDeviceInfo.Clone(); if (this.IsFullScreen) { item.PresentationParameters.BackBufferWidth = mode.Width; item.PresentationParameters.BackBufferHeight = mode.Height; item.PresentationParameters.FullScreenRefreshRateInHz = mode.RefreshRate; } else if (this.useResizedBackBuffer) { item.PresentationParameters.BackBufferWidth = this.resizedBackBufferWidth; item.PresentationParameters.BackBufferHeight = this.resizedBackBufferHeight; } else { item.PresentationParameters.BackBufferWidth = this.PreferredBackBufferWidth; item.PresentationParameters.BackBufferHeight = this.PreferredBackBufferHeight; } item.PresentationParameters.BackBufferFormat = backBufferFormat; item.PresentationParameters.AutoDepthStencilFormat = this.ChooseDepthStencilFormat(adapter, deviceType, mode.Format); if (this.PreferMultiSampling) { for (int j = 0; j < multiSampleTypes.Length; j++) { int qualityLevels = 0; MultiSampleType sampleType = multiSampleTypes[j]; if (adapter.CheckDeviceMultiSampleType(deviceType, backBufferFormat, this.IsFullScreen, sampleType, out qualityLevels)) { GraphicsDeviceInformation information2 = item.Clone(); information2.PresentationParameters.MultiSampleType = sampleType; if (!foundDevices.Contains(information2)) { foundDevices.Add(information2); } break; } } } else if (!foundDevices.Contains(item)) { foundDevices.Add(item); } } } }
/// <summary> /// Accepts a existing Direct3D.DisplayMode object. /// </summary> public VideoMode( XFG.DisplayMode videoMode ) { modeNum = ++modeCount; displayMode = videoMode; }
private void CheckDisplayMode() { if (displayMode == null) { this.displayMode = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode; } }
private static GraphicsAdapter CreateAdapter(SharpDX.DXGI.Adapter1 device, SharpDX.DXGI.Output monitor) { var adapter = new GraphicsAdapter(); adapter._adapter = device; adapter.DeviceName = monitor.Description.DeviceName.TrimEnd(new char[] { '\0' }); adapter.Description = device.Description1.Description.TrimEnd(new char[] { '\0' }); adapter.DeviceId = device.Description1.DeviceId; adapter.Revision = device.Description1.Revision; adapter.VendorId = device.Description1.VendorId; adapter.SubSystemId = device.Description1.SubsystemId; adapter.MonitorHandle = monitor.Description.MonitorHandle; var desktopWidth = monitor.Description.DesktopBounds.Right - monitor.Description.DesktopBounds.Left; var desktopHeight = monitor.Description.DesktopBounds.Bottom - monitor.Description.DesktopBounds.Top; var modes = new List <DisplayMode>(); foreach (var formatTranslation in FormatTranslations) { SharpDX.DXGI.ModeDescription[] displayModes; // This can fail on headless machines, so just assume the desktop size // is a valid mode and return that... so at least our unit tests work. try { displayModes = monitor.GetDisplayModeList(formatTranslation.Key, 0); } catch (SharpDX.SharpDXException) { var mode = new DisplayMode(desktopWidth, desktopHeight, SurfaceFormat.Color); modes.Add(mode); adapter._currentDisplayMode = mode; break; } foreach (var displayMode in displayModes) { var mode = new DisplayMode(displayMode.Width, displayMode.Height, formatTranslation.Value); // Skip duplicate modes with the same width/height/formats. if (modes.Contains(mode)) { continue; } modes.Add(mode); if (adapter._currentDisplayMode == null) { if (mode.Width == desktopWidth && mode.Height == desktopHeight && mode.Format == SurfaceFormat.Color) { adapter._currentDisplayMode = mode; } } } } adapter._supportedDisplayModes = new DisplayModeCollection(modes); if (adapter._currentDisplayMode == null) //(i.e. desktop mode wasn't found in the available modes) { adapter._currentDisplayMode = new DisplayMode(desktopWidth, desktopHeight, SurfaceFormat.Color); } return(adapter); }
internal GraphicsAdapter() { _displayMode = new DisplayMode(OpenTK.DisplayDevice.Default); }
/// <summary> /// Constructor of WindowDisplayModeChangedEventArgs class /// </summary> /// <param name="mode">New display mode</param> /// <param name="win">Window</param> public WindowDisplayModeChangedEventArgs(DisplayMode mode, Window win) { _mode = mode; _window = win; }
public void ChangeResolution(int i) { switch (ResolutionAspect) { case resAspect.FourThree: { CurrentResolution = Resolution.Instance.DisplayModesFourThree[i]; break; } case resAspect.SixteenNine: { CurrentResolution = Resolution.Instance.DisplayModesSixteenNine[i]; break; } case resAspect.SixteenTen: { CurrentResolution = Resolution.Instance.DisplayModesSixteenTen[i]; break; } } managers.screenManager.GameScreenManager.Instance.Dimensions = new Vector2(virtualWidth, virtualHeight); Resolution.Instance.SetVirtualResolution(virtualWidth, virtualHeight); Resolution.Instance.SetResolution(CurrentResolution.Width, CurrentResolution.Height, isFullscreen); Resolution.Instance.ScaleMouse(); managers.CursorManager.Instance.ResetState(); Camera.Instance.Position = new Vector2((int)Resolution.Instance.VirtualResolution.X / 2, (int)Resolution.Instance.VirtualResolution.Y / 2); Camera.Instance.isViewTransformationDirty = true; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { Shorewood.fonts.Add(FontTypes.DebugFont, Content.Load<SpriteFont>("Fonts\\Courier New")); Shorewood.fonts.Add(FontTypes.MenuFont, Content.Load<SpriteFont>("Fonts\\Arial")); Shorewood.fonts.Add(FontTypes.FloatingPointsFont, Content.Load<SpriteFont>("Fonts\\Nonstop.font")); Shorewood.fonts.Add(FontTypes.GoalFont, Content.Load<SpriteFont>("Fonts\\Arial.Smaller")); Shorewood.fonts.Add(FontTypes.MenuButtonFont, Content.Load<SpriteFont>("Fonts\\Arial.Large.Glyphs")); Shorewood.fonts.Add(FontTypes.ScoreFont, Content.Load<SpriteFont>("Fonts\\Arial.Smaller")); Shorewood.fonts.Add(FontTypes.Font1337, Content.Load<SpriteFont>("Fonts\\elite")); displayMode = GraphicsDevice.DisplayMode; Shorewood.localization.Add(UsEnglishLocalization.Language, UsEnglishLocalization.StringTable); ConstructAlphabet(); titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea; #if !XBOX titleSafeArea = new Rectangle(128, 72, 1024, 576); #endif dialogManager = new DialogManager(this); popUpManager = new PopUpManager(this); menu = new MainMenu(this, dialogManager); menu.Enabled = false; menu.Visible = false; scale = titleSafeArea.Height / 1000.0f; base.Initialize(); }
public override void Initialize() { base.Initialize(); ScreenResolutions = new List<RadioButton>(); var top = 50; var exit = new Button(ControlManager.Manager) {Text = "Back to previous screen", Left = 50, Top = top, Width = 200, Height = 50}; exit.Init(); ControlManager.Add(exit); exit.Click += (sender, args) => ScreenManager.SwapScreens(this, Constants.ScreenNames.MainMenu); var panel = new Panel(ControlManager.Manager) {Width = 856, Height = 467, Left = 300, Top = 50 }; panel.Init(); ControlManager.Add(panel); var resLabel = new Label(ControlManager.Manager) {Text = "Screen Resolution:", Top = top, Left = 20, Width = 250}; resLabel.Init(); panel.Add(resLabel); top += 50; resolutionPanel = new Panel(ControlManager.Manager) {Color = Color.Gray, Width = 300, Height = 150, Top = 70, Left = 50, Parent = panel, AutoScroll = true}; resolutionPanel.Init(); var resTop = 10; DisplayMode current = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode; foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes.Where(i => i.Format == SurfaceFormat.Color && i.Width >= 1224)) { if (mode.Width > current.Width) FullScreenResolution = mode; var option = new RadioButton(ControlManager.Manager) { Text = String.Format("{0}x{1}", mode.Width, mode.Height), Width = 200, Left = 50, Top = resTop, Parent = resolutionPanel}; option.Checked = mode.Width == GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width && mode.Height == GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; int x = mode.Width; int y = mode.Height; option.Click += (sender, args) => ApplyResolution(x, y); resTop += 30; option.Init(); current = mode; ScreenResolutions.Add(option); } top += resolutionPanel.Height; var fullScreenModeLabel = new Label(ControlManager.Manager) { Text = "Full Screen Mode:", Top = top, Left = resLabel.Left, Parent = panel, Width = 200 }; fullScreenModeLabel.Init(); top += fullScreenModeLabel.Height; var fullScreenPanel = new Panel(ControlManager.Manager) { Color = Color.Gray, Width = resolutionPanel.Width, Height = 50, Top = top, Left = resolutionPanel.Left, Parent = panel }; fullScreenPanel.Init(); top += fullScreenModeLabel.Height; String OnOff = Application.Graphics.IsFullScreen ? "On" : "Off"; var fullScreenIndicator = new RadioButton(ControlManager.Manager) { Top = top, Left = 100, Width = 200, Parent = panel, Text = "Full Screen: " + OnOff, Checked = Application.Graphics.IsFullScreen }; fullScreenIndicator.Click += (sender, args) => FullScreenMode(fullScreenIndicator); fullScreenIndicator.Init(); top += fullScreenPanel.Height; var backgroundSoundLabel = new Label(ControlManager.Manager) { Text = "Background Volume:", Top = top, Left = 20, Width = 250 }; backgroundSoundLabel.Init(); panel.Add(backgroundSoundLabel); top += backgroundSoundLabel.Height; var backgroundVolumePercentage = new Label(ControlManager.Manager) { Text = "50%", Top = top, Left = 480, Width = 250 }; backgroundVolumePercentage.Init(); panel.Add(backgroundVolumePercentage); var backgroundVolume = new TrackBar(ControlManager.Manager) {Width = 400, Top = top, Left = 50}; backgroundVolume.Init(); panel.Add(backgroundVolume); backgroundVolume.Value = 50; backgroundVolume.ValueChanged += (sender, args) => ChangeBackgroundVolume(backgroundVolumePercentage, backgroundVolume.Value); top += 20; var soundEffectsLabel = new Label(ControlManager.Manager) { Text = "Effects Volume:", Top = top, Left = 20, Width = 250 }; soundEffectsLabel.Init(); panel.Add(soundEffectsLabel); top += 20; var effectsVolumePercentage = new Label(ControlManager.Manager) { Text = "50%", Top = top, Left = 480, Width = 250 }; backgroundVolumePercentage.Init(); panel.Add(effectsVolumePercentage); var effectsVolume = new TrackBar(ControlManager.Manager) {Width = 400, Top = top, Left = 50 }; effectsVolume.Init(); panel.Add(effectsVolume); effectsVolume.Value = 50; effectsVolume.ValueChanged += (sender, args) => ChangeEffectsVolume(effectsVolumePercentage, effectsVolume.Value); }
internal GraphicsAdapter( DisplayMode currentMode, DisplayModeCollection modes, string description ) { CurrentDisplayMode = currentMode; SupportedDisplayModes = modes; Description = description; UseNullDevice = false; UseReferenceDevice = false; }
public ResolutionData(DisplayMode displayMode) { width = displayMode.Width; height = displayMode.Height; }
public Item(string name, DisplayMode value) { Name = name; Value = value; }
private GraphicsAdapter() { IntPtr infoPtr = Sdl.SDL_GetVideoInfo (); Sdl.SDL_VideoInfo info = (Sdl.SDL_VideoInfo) Marshal.PtrToStructure (infoPtr, typeof (Sdl.SDL_VideoInfo)); currentDisplayMode = new DisplayMode(info.current_w, info.current_h, -1, SurfaceFormat.Bgr32); hardwareCapabilities = new GraphicsDeviceCapabilities(); findGLCapabilities(); }
public Main(int monitor, bool vr) { this.monitor = monitor; this.VR = vr; this.nativeDisplayMode = GraphicsAdapter.Adapters[this.monitor].CurrentDisplayMode;
public void ToStringTest() { DisplayMode mode = new DisplayMode(); Assert.AreEqual(mode.ToString(), "{Width:" + mode.Width + " Height:" + mode.Height + " Format:" + mode.Format + " RefreshRate" + mode.RefreshRate + "}"); }
/// <summary> /// FetchResolutions() /// Internally defaults to native resolution if fullscreen set to true. /// Not quite sure how this is going to work yet. /// </summary> private static void FetchAndSetResolution() { foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) { #if DEBUG Gears.Cloud._Debug.Debug.Out(mode.ToString()); #endif _mode = mode; } if (ContentButler.GetGame().GraphicsDevice.PresentationParameters.IsFullScreen) { #if DEBUG Gears.Cloud._Debug.Debug.Out("Setting resolution to native resolution: " + _mode.Width + "," + _mode.Height); #endif SetScreen(_mode.Width, _mode.Height); } else { Gears.Cloud._Debug.Debug.Out("Detected supported resolutions: " + _mode); } }
/// <summary> /// Compares two display mode by their resolutions /// </summary> /// <param name="first">First display mode</param> /// <param name="second">Second display mode</param> /// <returns>Returns -1 if the first resolution is lower, 1 if higher and 0 if both are equals</returns> private static int CompareDisplayModeByResolution(DisplayMode first, DisplayMode second) { int result; if (first.Width < second.Width) result = -1; else if (first.Width > second.Width) result = 1; else { if (first.Height < second.Height) result = -1; else if (first.Height > second.Height) result = 1; else result = 0; } return result; }