Ejemplo n.º 1
0
		public GraphicsDevice( Size size, WindowMode window )
		{
			Console.WriteLine("Using Cg renderer");
			windowSize = size;

			var extensions = new string[]
			{
				"GL_ARB_vertex_program",
				"GL_ARB_fragment_program",
				"GL_ARB_vertex_buffer_object",
			};

			surf = SdlGraphics.InitializeSdlGl(ref windowSize, window, extensions);

			cgContext = Tao.Cg.Cg.cgCreateContext();

			Tao.Cg.Cg.cgSetErrorCallback( CgErrorCallback );

			Tao.Cg.CgGl.cgGLRegisterStates( cgContext );
			Tao.Cg.CgGl.cgGLSetManageTextureParameters( cgContext, true );
			vertexProfile = CgGl.cgGLGetLatestProfile( CgGl.CG_GL_VERTEX );
			fragmentProfile = CgGl.cgGLGetLatestProfile( CgGl.CG_GL_FRAGMENT );

			Gl.glEnableClientState( Gl.GL_VERTEX_ARRAY );
			ErrorHandler.CheckGlError();
			Gl.glEnableClientState( Gl.GL_TEXTURE_COORD_ARRAY );
			ErrorHandler.CheckGlError();

			Sdl.SDL_SetModState( 0 );	// i have had enough.

			input = new SdlInput( surf );
		}
Ejemplo n.º 2
0
        void SetMode(WindowMode mode)
        {
            if (mode == WindowMode.Fullscreen)
            {
                Settings.DeviceMode = DeviceMode.Fullscreen;
                Settings.Resolution = new Resolution
                {
                    Width = 1440,
                    Height = 900
                };
            }
            else
                Settings.DeviceMode = DeviceMode.Windowed;

            if (mode == WindowMode.Windowed)
            {
                window.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable;
                window.WindowState = System.Windows.Forms.FormWindowState.Normal;
                //Settings.Resolution = new Resolution
                //{
                //    Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size.
                //};
            }
            else
            {
                window.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                window.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            }

            WindowMode = mode;

            GraphicsDevice.ApplySettings();
        }
Ejemplo n.º 3
0
        public GraphicsDevice( int width, int height, WindowMode window, bool vsync )
        {
            Console.WriteLine("Using Gl renderer");
            Sdl.SDL_Init( Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_DOUBLEBUFFER, 1 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_RED_SIZE, 8 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_GREEN_SIZE, 8 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_BLUE_SIZE, 8 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_ALPHA_SIZE, 0 );

            int windowFlags = 0;
            switch( window )
            {
            case WindowMode.Fullscreen:
                windowFlags |= Sdl.SDL_FULLSCREEN;
                break;
            case WindowMode.PseudoFullscreen:
                windowFlags |= Sdl.SDL_NOFRAME;
                Environment.SetEnvironmentVariable( "SDL_VIDEO_WINDOW_POS", "0,0" );
                break;
            default:
                break;
            }

            surf = Sdl.SDL_SetVideoMode( width, height, 0, Sdl.SDL_OPENGL | windowFlags );

            Sdl.SDL_WM_SetCaption( "OpenRA", "OpenRA" );
            Sdl.SDL_ShowCursor( 0 );
            Sdl.SDL_EnableUNICODE( 1 );
            Sdl.SDL_EnableKeyRepeat( Sdl.SDL_DEFAULT_REPEAT_DELAY, Sdl.SDL_DEFAULT_REPEAT_INTERVAL );

            CheckGlError();

            // Test for required extensions
            var required = new string[]
            {
                "GL_ARB_vertex_shader",
                "GL_ARB_fragment_shader",
                "GL_ARB_vertex_buffer_object",
            };

            var extensions = Gl.glGetString(Gl.GL_EXTENSIONS);
            if (required.Any(r => !extensions.Contains(r)))
            {
                Log.AddChannel("graphics", "graphics.log");
                Log.Write("graphics", "Unsupported GPU: Missing extensions.");
                Log.Write("graphics", "Available extensions:");
                Log.Write("graphics", extensions);
                throw new InvalidProgramException("Unsupported GPU. See graphics.log for details.");
            }

            windowSize = new Size( width, height );

            Gl.glEnableClientState( Gl.GL_VERTEX_ARRAY );
            CheckGlError();
            Gl.glEnableClientState( Gl.GL_TEXTURE_COORD_ARRAY );
            CheckGlError();

            Sdl.SDL_SetModState( 0 );
        }
Ejemplo n.º 4
0
        public Sdl2GraphicsDevice(Size windowSize, WindowMode windowMode)
        {
            size = windowSize;

            SDL.SDL_Init(SDL.SDL_INIT_NOPARACHUTE | SDL.SDL_INIT_VIDEO);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_RED_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_GREEN_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_BLUE_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_ALPHA_SIZE, 0);

            SDL.SDL_DisplayMode display;
            SDL.SDL_GetCurrentDisplayMode(0, out display);

            Console.WriteLine("Desktop resolution: {0}x{1}", display.w, display.h);
            if (size.Width == 0 && size.Height == 0)
            {
                Console.WriteLine("No custom resolution provided, using desktop resolution");
                size = new Size(display.w, display.h);
            }

            Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height);

            window = SDL.SDL_CreateWindow("OpenRA", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED, size.Width, size.Height, SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL);

            if (windowMode == WindowMode.Fullscreen)
                SDL.SDL_SetWindowFullscreen(window, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN);
            else if (windowMode == WindowMode.PseudoFullscreen)
            {
                // Work around a visual glitch in OSX: the window is offset
                // partially offscreen if the dock is at the left of the screen
                if (Platform.CurrentPlatform == PlatformType.OSX)
                    SDL.SDL_SetWindowPosition(window, 0, 0);

                SDL.SDL_SetWindowFullscreen(window, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP);
                SDL.SDL_SetHint(SDL.SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
            }

            SDL.SDL_ShowCursor(0);
            context = SDL.SDL_GL_CreateContext(window);
            SDL.SDL_GL_MakeCurrent(window, context);
            GL.LoadAll();
            ErrorHandler.CheckGlVersion();
            ErrorHandler.CheckGlError();

            if (SDL.SDL_GL_ExtensionSupported("GL_EXT_framebuffer_object") == SDL.SDL_bool.SDL_FALSE)
            {
                ErrorHandler.WriteGraphicsLog("OpenRA requires the OpenGL extension GL_EXT_framebuffer_object.\n"
                    +"Please try updating your GPU driver to the latest version provided by the manufacturer.");
                throw new InvalidProgramException("Missing OpenGL extension GL_EXT_framebuffer_object. See graphics.log for details.");
            }

            GL.EnableClientState(ArrayCap.VertexArray);
            ErrorHandler.CheckGlError();
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            ErrorHandler.CheckGlError();

            SDL.SDL_SetModState(0);
            input = new Sdl2Input();
        }
Ejemplo n.º 5
0
        public Sdl2GraphicsDevice(Size windowSize, WindowMode windowMode)
        {
            Console.WriteLine("Using SDL 2 with OpenGL renderer");
            WindowSize = windowSize;

            SDL.SDL_Init(SDL.SDL_INIT_NOPARACHUTE | SDL.SDL_INIT_VIDEO);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_RED_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_GREEN_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_BLUE_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_ALPHA_SIZE, 0);

            SDL.SDL_DisplayMode display;
            SDL.SDL_GetCurrentDisplayMode(0, out display);

            Console.WriteLine("Desktop resolution: {0}x{1}", display.w, display.h);
            if (WindowSize.Width == 0 && WindowSize.Height == 0)
            {
                Console.WriteLine("No custom resolution provided, using desktop resolution");
                WindowSize = new Size(display.w, display.h);
            }

            Console.WriteLine("Using resolution: {0}x{1}", WindowSize.Width, WindowSize.Height);

            window = SDL.SDL_CreateWindow("OpenRA", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED,
                WindowSize.Width, WindowSize.Height, SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL);

            if (Game.Settings.Game.LockMouseWindow)
                GrabWindowMouseFocus();
            else
                ReleaseWindowMouseFocus();

            if (windowMode == WindowMode.Fullscreen)
                SDL.SDL_SetWindowFullscreen(window, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN);
            else if (windowMode == WindowMode.PseudoFullscreen)
            {
                // Work around a visual glitch in OSX: the window is offset
                // partially offscreen if the dock is at the left of the screen
                if (Platform.CurrentPlatform == PlatformType.OSX)
                    SDL.SDL_SetWindowPosition(window, 0, 0);

                SDL.SDL_SetWindowFullscreen(window, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP);
                SDL.SDL_SetHint(SDL.SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
            }

            context = SDL.SDL_GL_CreateContext(window);
            if (context == IntPtr.Zero || SDL.SDL_GL_MakeCurrent(window, context) < 0)
                throw new InvalidOperationException("Can not create OpenGL context. (Error: {0})".F(SDL.SDL_GetError()));

            OpenGL.Initialize();

            OpenGL.glEnableVertexAttribArray(Shader.VertexPosAttributeIndex);
            OpenGL.CheckGLError();
            OpenGL.glEnableVertexAttribArray(Shader.TexCoordAttributeIndex);
            OpenGL.CheckGLError();

            SDL.SDL_SetModState(SDL.SDL_Keymod.KMOD_NONE);
            input = new Sdl2Input();
        }
Ejemplo n.º 6
0
        public GraphicsDevice( int width, int height, WindowMode window, bool vsync )
        {
            Console.WriteLine("Using Cg renderer");
            Sdl.SDL_Init( Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_DOUBLEBUFFER, 1 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_RED_SIZE, 8 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_GREEN_SIZE, 8 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_BLUE_SIZE, 8 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_ALPHA_SIZE, 0 );

            int windowFlags = 0;
            switch( window )
            {
            case WindowMode.Fullscreen:
                windowFlags |= Sdl.SDL_FULLSCREEN;
                break;
            case WindowMode.PseudoFullscreen:
                windowFlags |= Sdl.SDL_NOFRAME;
                Environment.SetEnvironmentVariable( "SDL_VIDEO_WINDOW_POS", "0,0" );
                break;
            case WindowMode.Windowed:
                Environment.SetEnvironmentVariable( "SDL_VIDEO_CENTERED", "1" );
                break;
            default:
                break;
            }

            surf = Sdl.SDL_SetVideoMode( width, height, 0, Sdl.SDL_OPENGL | windowFlags );

            Sdl.SDL_WM_SetCaption( "OpenRA", "OpenRA" );
            Sdl.SDL_ShowCursor( 0 );
            Sdl.SDL_EnableUNICODE( 1 );
            Sdl.SDL_EnableKeyRepeat( Sdl.SDL_DEFAULT_REPEAT_DELAY, Sdl.SDL_DEFAULT_REPEAT_INTERVAL );

            CheckGlError();

            windowSize = new Size( width, height );

            cgContext = Tao.Cg.Cg.cgCreateContext();

            Tao.Cg.Cg.cgSetErrorCallback( CgErrorCallback );

            Tao.Cg.CgGl.cgGLRegisterStates( cgContext );
            Tao.Cg.CgGl.cgGLSetManageTextureParameters( cgContext, true );
            vertexProfile = CgGl.cgGLGetLatestProfile( CgGl.CG_GL_VERTEX );
            fragmentProfile = CgGl.cgGLGetLatestProfile( CgGl.CG_GL_FRAGMENT );

            //Console.WriteLine("VP Profile: " + vertexProfile);
            //Console.WriteLine("FP Profile: " + fragmentProfile);

            Gl.glEnableClientState( Gl.GL_VERTEX_ARRAY );
            CheckGlError();
            Gl.glEnableClientState( Gl.GL_TEXTURE_COORD_ARRAY );
            CheckGlError();

            Sdl.SDL_SetModState( 0 );	// i have had enough.
        }
Ejemplo n.º 7
0
        public Sdl2GraphicsDevice(Size windowSize, WindowMode windowMode)
        {
            size = windowSize;

            SDL.SDL_Init(SDL.SDL_INIT_NOPARACHUTE | SDL.SDL_INIT_VIDEO);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_RED_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_GREEN_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_BLUE_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_ALPHA_SIZE, 0);

            var windowFlags = SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL;
            if (windowMode == WindowMode.Fullscreen)
                windowFlags |= SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN;
            else if (windowMode == WindowMode.PseudoFullscreen)
            {
                windowFlags |= SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP;
                Environment.SetEnvironmentVariable("SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS", "0");
            }

            SDL.SDL_DisplayMode display;
            SDL.SDL_GetCurrentDisplayMode(0, out display);

            Console.WriteLine("Desktop resolution: {0}x{1}", display.w, display.h);
            if (size.Width == 0 && size.Height == 0)
            {
                Console.WriteLine("No custom resolution provided, using desktop resolution");
                size = new Size(display.w, display.h);
            }

            Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height);

            window = SDL.SDL_CreateWindow("OpenRA", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED, size.Width, size.Height, windowFlags);

            SDL.SDL_ShowCursor(0);
            SDL.SDL_GL_CreateContext(window);
            ErrorHandler.CheckGlError();

            var extensions = Gl.glGetString(Gl.GL_EXTENSIONS);
            if (extensions == null)
                Console.WriteLine("Failed to fetch GL_EXTENSIONS, this is bad.");

            var missingExtensions = requiredExtensions.Where(r => !extensions.Contains(r)).ToArray();
            if (missingExtensions.Any())
            {
                ErrorHandler.WriteGraphicsLog("Unsupported GPU: Missing extensions: {0}".F(missingExtensions.JoinWith(",")));
                throw new InvalidProgramException("Unsupported GPU. See graphics.log for details.");
            }

            Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
            ErrorHandler.CheckGlError();
            Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
            ErrorHandler.CheckGlError();

            SDL.SDL_SetModState(0);
            input = new Sdl2Input();
        }
Ejemplo n.º 8
0
 static SettingsLogic()
 {
     var original = Game.Settings;
     OriginalSoundDevice = original.Sound.Device;
     OriginalGraphicsMode = original.Graphics.Mode;
     OriginalGraphicsWindowedSize = original.Graphics.WindowedSize;
     OriginalGraphicsFullscreenSize = original.Graphics.FullscreenSize;
     OriginalServerDiscoverNatDevices = original.Server.DiscoverNatDevices;
 }
Ejemplo n.º 9
0
 static SettingsLogic()
 {
     var original = Game.Settings;
     OriginalSoundDevice = original.Sound.Device;
     OriginalSoundEngine = original.Sound.Engine;
     OriginalGraphicsMode = original.Graphics.Mode;
     OriginalGraphicsRenderer = original.Graphics.Renderer;
     OriginalGraphicsWindowedSize = original.Graphics.WindowedSize;
     OriginalGraphicsFullscreenSize = original.Graphics.FullscreenSize;
 }
Ejemplo n.º 10
0
 public GLFWWindow(int width, int height, int rbits, int gbits, int bbits, int alpha, int depth, int stencil, WindowMode mode)
 {
     _width = width;
     _height = height;
     _rbits = rbits;
     _gbits = gbits;
     _bbits = bbits;
     _alpha = alpha;
     _depth = depth;
     _stencil = stencil;
     _mode = mode;
 }
Ejemplo n.º 11
0
		public GraphicsDevice(Size size, WindowMode window)
			: base(size, window, RequiredExtensions)
		{
			cgContext = Tao.Cg.Cg.cgCreateContext();

			Tao.Cg.Cg.cgSetErrorCallback(CgErrorCallback);

			Tao.Cg.CgGl.cgGLRegisterStates(cgContext);
			Tao.Cg.CgGl.cgGLSetManageTextureParameters(cgContext, true);
			vertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX);
			fragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT);
		}
Ejemplo n.º 12
0
 /// <summary>
 /// Creates a window.
 /// </summary>
 /// <param name="winname">Name of the window in the window caption that may be used as a window identifier.</param>
 /// <param name="flags">
 /// Flags of the window. Currently the only supported flag is CV WINDOW AUTOSIZE. If this is set, 
 /// the window size is automatically adjusted to fit the displayed image (see imshow ), and the user can not change the window size manually.
 /// </param>
 public static void NamedWindow(string winname, WindowMode flags)
 {
     if (string.IsNullOrEmpty(winname))
         throw new ArgumentNullException("winname");
     try
     {
         NativeMethods.highgui_namedWindow(winname, (int)flags);
     }
     catch (BadImageFormatException ex)
     {
         throw PInvokeHelper.CreateException(ex);
     }
 }
Ejemplo n.º 13
0
        public SdlGraphics(Size size, WindowMode window, string[] extensions)
        {
            windowSize = size;
            InitializeSdlGl(ref windowSize, window, extensions);

            Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
            ErrorHandler.CheckGlError();
            Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
            ErrorHandler.CheckGlError();

            Sdl.SDL_SetModState(0);

            input = new SdlInput();
        }
Ejemplo n.º 14
0
        public GraphicsDevice( int width, int height, WindowMode window, bool vsync )
        {
            Console.WriteLine("Using Gl renderer");
            Sdl.SDL_Init( Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_DOUBLEBUFFER, 1 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_RED_SIZE, 8 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_GREEN_SIZE, 8 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_BLUE_SIZE, 8 );
            Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_ALPHA_SIZE, 0 );

            int windowFlags = 0;
            switch( window )
            {
            case WindowMode.Fullscreen:
                windowFlags |= Sdl.SDL_FULLSCREEN;
                break;
            case WindowMode.PseudoFullscreen:
                // pseudo-fullscreen only reliably works on windows; fall back to fullscreen for everyone else
                windowFlags |= ( Environment.OSVersion.Platform == PlatformID.Win32NT ) ? Sdl.SDL_NOFRAME : Sdl.SDL_FULLSCREEN;
                Environment.SetEnvironmentVariable( "SDL_VIDEO_WINDOW_POS", "0,0" );
                break;
            default:
                break;
            }

            surf = Sdl.SDL_SetVideoMode( width, height, 0, Sdl.SDL_OPENGL | windowFlags );

            Sdl.SDL_WM_SetCaption( "OpenRA", "OpenRA" );
            Sdl.SDL_ShowCursor( 0 );
            Sdl.SDL_EnableUNICODE( 1 );
            Sdl.SDL_EnableKeyRepeat( Sdl.SDL_DEFAULT_REPEAT_DELAY, Sdl.SDL_DEFAULT_REPEAT_INTERVAL );

            CheckGlError();

            windowSize = new Size( width, height );

            Gl.glEnableClientState( Gl.GL_VERTEX_ARRAY );
            CheckGlError();
            Gl.glEnableClientState( Gl.GL_TEXTURE_COORD_ARRAY );
            CheckGlError();

            Sdl.SDL_SetModState( 0 );	// i have had enough.

            var extensions = Gl.glGetString(Gl.GL_EXTENSIONS);

            if (!extensions.Contains("GL_ARB_vertex_shader") || !extensions.Contains("GL_ARB_fragment_shader"))
                throw new InvalidProgramException("Unsupported GPU. OpenRA requires the GL_ARB_vertex_shader and GL_ARB_fragment_shader extensions.");
        }
Ejemplo n.º 15
0
        static Settings()
        {
            int screenWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            int screenHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Constants.APP_DATA_GAME_NAME);

            // General
            _windowMode = WindowMode.Fullscreen;
            _startingGameState = GameState.MainMenu;
            _X_resolution = screenWidth;
            _Y_resolution = screenHeight;
            _X_windowPos = 0;
            _Y_windowPos = 0;
            _mouseVisible = true;
            _fixedTimestep = false;
            _mouseScrolling = true;
            // Audio
            _masterVolume = 1.0f;
            _effectVolume = 1.0f;
            _musicVolume = 0.5f;
        }
Ejemplo n.º 16
0
        public GraphicsDevice( Size size, WindowMode window )
        {
            Console.WriteLine("Using Gl renderer");
            windowSize = size;

            var extensions = new string[]
            {
                "GL_ARB_vertex_shader",
                "GL_ARB_fragment_shader",
                "GL_ARB_vertex_buffer_object",
            };

            surf = SdlGraphics.InitializeSdlGl( ref windowSize, window, extensions );

            Gl.glEnableClientState( Gl.GL_VERTEX_ARRAY );
            ErrorHandler.CheckGlError();
            Gl.glEnableClientState( Gl.GL_TEXTURE_COORD_ARRAY );
            ErrorHandler.CheckGlError();

            Sdl.SDL_SetModState( 0 );

            input = new SdlInput( surf );
        }
 public IPlatformWindow CreateWindow(Size size, WindowMode windowMode, int batchSize)
 {
     return(new Sdl2PlatformWindow(size, windowMode, batchSize));
 }
Ejemplo n.º 18
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            if (input.KeyState.WasPress(Keys.Tab))
            {
                graphics.ToggleFullScreen();

            }

            if (input.KeyState.WasPress(Keys.V))
            {
                Win = WindowMode.Tiny;

            }
            if (input.KeyState.WasPress(Keys.B))
            {
                Win = WindowMode.Big;

            }
            if (input.KeyState.WasPress(Keys.C))
            {
                Window.AllowUserResizing = !Window.AllowUserResizing;

            }

                        switch( Win ){
                case WindowMode.Tiny:{

                    break;
                }

                case WindowMode.Big:{

                    break;
                }

            }

            //Entra y recarga toda la informacion si es que
            //Hay una cantidad diferente de archivos de la que habia antes
            //Algun archivo cambio de nombre
            if (Data_Loader.Loader.IsTheresomethingnew())
            {
                //reinicializo los contadores de cantidad de elemntos en FXY y FXYZ
                Data_Loader.Loader.Re_InitializeVariables();
                Data_Loader.Loader.Load_All_Data_from_Folder();

            }

            base.Update(gameTime);
        }
Ejemplo n.º 19
0
 public static void NamedWindow(string winname, WindowMode flags)
 {
     NativeBindings.Kernal.NamedWindow(winname, flags);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Provides derived classes an opportunity to handle changes to the WindowFrameMode property.
 /// </summary>
 /// <param name="oldWindowFrameMode">Old Value</param>
 /// <param name="newWindowFrameMode">New Value</param>
 protected void OnWindowFrameModeChanged(WindowMode oldWindowFrameMode, WindowMode newWindowFrameMode)
 {
     UpdateWindowFrame(newWindowFrameMode);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Creates a window.
 /// </summary>
 /// <param name="winname">Name of the window in the window caption that may be used as a window identifier.</param>
 /// <param name="flags">
 /// Flags of the window. Currently the only supported flag is CV WINDOW AUTOSIZE. If this is set, 
 /// the window size is automatically adjusted to fit the displayed image (see imshow ), and the user can not change the window size manually.
 /// </param>
 public static void NamedWindow(string winname, WindowMode flags = WindowMode.None)
 {
     if (string.IsNullOrEmpty(winname))
         throw new ArgumentNullException("winname");
     CppInvoke.cv_namedWindow(winname, flags);
 }
Ejemplo n.º 22
0
 public IGraphicsDevice Create(Size size, WindowMode windowMode)
 {
     Console.WriteLine("Using SDL 1.2 with Cg renderer");
     return(new GraphicsDevice(size, windowMode));
 }
Ejemplo n.º 23
0
        /// <summary>
        /// 適当なウィンドウ名で、画像の表示モードを指定して初期化
        /// </summary>
        /// <param name="flags">ウィンドウのフラグ</param>
        /// <param name="image">ウィンドウに表示する画像</param>
#else
        /// <summary>
        /// Creates a window with a specified image and flag
        /// </summary>
        /// <param name="flags">Flags of the window. Currently the only supported flag is WindowMode.AutoSize.
        /// If it is set, window size is automatically adjusted to fit the displayed image (see cvShowImage), while user can not change the window size manually. </param>
        /// <param name="image"></param>
#endif
        public CvWindow(WindowMode flags, CvArr image)
            : this(DefaultName(), flags, image)
        {
        }
Ejemplo n.º 24
0
 // Returns full view name including namespace and suffix 'View'
 private string GetFullViewName(WindowMode mode)
 {
     return("Nameless.NumberConverter.Views." + mode.ToString() + "View");
 }
Ejemplo n.º 25
0
        public void Load(string filePath)
        {
            XDocument doc = XMLExtensions.TryLoadXml(filePath);

            MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", "");

            AutoCheckUpdates = doc.Root.GetAttributeBool("autocheckupdates", true);
            WasGameUpdated   = doc.Root.GetAttributeBool("wasgameupdated", false);

            VerboseLogging       = doc.Root.GetAttributeBool("verboselogging", false);
            SaveDebugConsoleLogs = doc.Root.GetAttributeBool("savedebugconsolelogs", false);
            if (doc.Root.Attribute("senduserstatistics") == null)
            {
                ShowUserStatisticsPrompt = true;
            }
            else
            {
                sendUserStatistics = doc.Root.GetAttributeBool("senduserstatistics", true);
            }

            if (doc == null)
            {
                GraphicsWidth  = 1024;
                GraphicsHeight = 678;

                MasterServerUrl = "";

                SelectedContentPackage = ContentPackage.list.Any() ? ContentPackage.list[0] : new ContentPackage("");

                JobNamePreferences = new List <string>();
                foreach (JobPrefab job in JobPrefab.List)
                {
                    JobNamePreferences.Add(job.Name);
                }
                return;
            }

            XElement graphicsMode = doc.Root.Element("graphicsmode");

            GraphicsWidth  = graphicsMode.GetAttributeInt("width", 0);
            GraphicsHeight = graphicsMode.GetAttributeInt("height", 0);
            VSyncEnabled   = graphicsMode.GetAttributeBool("vsync", true);

#if CLIENT
            if (GraphicsWidth == 0 || GraphicsHeight == 0)
            {
                GraphicsWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                GraphicsHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            }
#endif

            //FullScreenEnabled = ToolBox.GetAttributeBool(graphicsMode, "fullscreen", true);

            var windowModeStr = graphicsMode.GetAttributeString("displaymode", "Fullscreen");
            if (!Enum.TryParse <WindowMode>(windowModeStr, out windowMode))
            {
                windowMode = WindowMode.Fullscreen;
            }

            SoundVolume = doc.Root.GetAttributeFloat("soundvolume", 1.0f);
            MusicVolume = doc.Root.GetAttributeFloat("musicvolume", 0.3f);

            EnableSplashScreen = doc.Root.GetAttributeBool("enablesplashscreen", true);

            keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
            keyMapping[(int)InputType.Up]    = new KeyOrMouse(Keys.W);
            keyMapping[(int)InputType.Down]  = new KeyOrMouse(Keys.S);
            keyMapping[(int)InputType.Left]  = new KeyOrMouse(Keys.A);
            keyMapping[(int)InputType.Right] = new KeyOrMouse(Keys.D);
            keyMapping[(int)InputType.Run]   = new KeyOrMouse(Keys.LeftShift);

            keyMapping[(int)InputType.Chat]       = new KeyOrMouse(Keys.Tab);
            keyMapping[(int)InputType.RadioChat]  = new KeyOrMouse(Keys.OemPipe);
            keyMapping[(int)InputType.CrewOrders] = new KeyOrMouse(Keys.C);

            keyMapping[(int)InputType.Select] = new KeyOrMouse(Keys.E);

            keyMapping[(int)InputType.Use] = new KeyOrMouse(0);
            keyMapping[(int)InputType.Aim] = new KeyOrMouse(1);

            keyMapping[(int)InputType.Ragdoll] = new KeyOrMouse(Keys.Space);

            foreach (XElement subElement in doc.Root.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "keymapping":
                    foreach (XAttribute attribute in subElement.Attributes())
                    {
                        if (Enum.TryParse(attribute.Name.ToString(), true, out InputType inputType))
                        {
                            if (int.TryParse(attribute.Value.ToString(), out int mouseButton))
                            {
                                keyMapping[(int)inputType] = new KeyOrMouse(mouseButton);
                            }
                            else
                            {
                                if (Enum.TryParse(attribute.Value.ToString(), true, out Keys key))
                                {
                                    keyMapping[(int)inputType] = new KeyOrMouse(key);
                                }
                            }
                        }
                    }
                    break;

                case "gameplay":
                    JobNamePreferences = new List <string>();
                    foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
                    {
                        JobNamePreferences.Add(ele.GetAttributeString("name", ""));
                    }
                    break;

                case "player":
                    defaultPlayerName  = subElement.GetAttributeString("name", "");
                    characterHeadIndex = subElement.GetAttributeInt("headindex", Rand.Int(10));
                    characterGender    = subElement.GetAttributeString("gender", Rand.Range(0.0f, 1.0f) < 0.5f ? "male" : "female")
                                         .ToLowerInvariant() == "male" ? Gender.Male : Gender.Female;
                    break;
                }
            }

            foreach (InputType inputType in Enum.GetValues(typeof(InputType)))
            {
                if (keyMapping[(int)inputType] == null)
                {
                    DebugConsole.ThrowError("Key binding for the input type \"" + inputType + " not set!");
                    keyMapping[(int)inputType] = new KeyOrMouse(Keys.D1);
                }
            }

            UnsavedSettings = false;

            foreach (XElement subElement in doc.Root.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "contentpackage":
                    string path = subElement.GetAttributeString("path", "");

                    SelectedContentPackage = ContentPackage.list.Find(cp => cp.Path == path);
                    if (SelectedContentPackage == null)
                    {
                        SelectedContentPackage = new ContentPackage(path);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 26
0
    public void DecreaseToggle(string DesiredMenu)
    {
        switch (DesiredMenu)
        {
        case "SelectionMenu":
            if (_MenuType > MenuType.RADIAL)
            {
                _MenuType--;
            }
            else
            {
                _MenuType = MenuType.WINDOW;;
            }
            UpdateTextAndApplySettings();
            PlayerPrefs.SetInt("MenuType", (int)_MenuType);
            PlayerPrefs.Save();
            break;

        case "WindowMode":
            if (_WindowMode > WindowMode.FULLSCREEN)
            {
                _WindowMode--;
            }
            else
            {
                _WindowMode = WindowMode.WINDOWED;
            }
            PlayerPrefs.SetInt("WindowMode", (int)_WindowMode);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;

        case "Resolution":
            if (_Resolution > Resolution.NINETEEN_TWENTY_BY_TEN_EIGHTY)
            {
                _Resolution--;
            }
            else
            {
                _Resolution = Resolution.THIRTY_EIGHT_FOURTY_BY_TWENTY_ONE_SIXTY;
            }
            PlayerPrefs.SetInt("Resolution", (int)_Resolution);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;

        case "Aspect Ratio":
            if (_AspectRatio > AspectRatio.SIXTEEN_NINE)
            {
                _AspectRatio--;
            }
            else
            {
                _AspectRatio = AspectRatio.FIVE_FOUR;
            }
            PlayerPrefs.SetInt("AspectRatio", (int)_AspectRatio);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;

        case "VSync":
            if (VSync == 0)
            {
                VSync = 1;
            }
            else if (VSync == 1)
            {
                VSync = 0;
            }
            PlayerPrefs.SetInt("VSync", VSync);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;

        case "TextureQ":
            if (_TextureQuality > TextureQuality.LOW)
            {
                _TextureQuality--;
            }
            else
            {
                _TextureQuality = TextureQuality.HIGH;
            }
            PlayerPrefs.SetInt("TextureQuality", (int)_TextureQuality);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;
        }
    }
Ejemplo n.º 27
0
 public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
 {
     ExternalThemeManager.Initialize();
 }
Ejemplo n.º 28
0
    public void IncreaseToggle(string DesiredMenu)
    {
        switch (DesiredMenu)
        {
        case "SelectionMenu":
            if (_MenuType < MenuType.WINDOW)
            {
                _MenuType++;
            }
            else
            {
                _MenuType = 0;
            }
            PlayerPrefs.SetInt("MenuType", (int)_MenuType);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;

        case "WindowMode":
            if (_WindowMode < WindowMode.WINDOWED)
            {
                _WindowMode++;
            }
            else
            {
                _WindowMode = 0;
            }
            PlayerPrefs.SetInt("WindowMode", (int)_WindowMode);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;

        case "Resolution":
            if (_Resolution < Resolution.THIRTY_EIGHT_FOURTY_BY_TWENTY_ONE_SIXTY)
            {
                _Resolution++;
            }
            else
            {
                _Resolution = 0;
            }
            PlayerPrefs.SetInt("Resolution", (int)_Resolution);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;

        case "Aspect Ratio":
            if (_AspectRatio < AspectRatio.FIVE_FOUR)
            {
                _AspectRatio++;
            }
            else
            {
                _AspectRatio = AspectRatio.SIXTEEN_NINE;
            }
            PlayerPrefs.SetInt("AspectRatio", (int)_AspectRatio);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;

        case "VSync":
            if (VSync == 0)
            {
                VSync = 1;
            }
            else if (VSync == 1)
            {
                VSync = 0;
            }
            PlayerPrefs.SetInt("VSync", VSync);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;

        case "TextureQ":
            if (_TextureQuality < TextureQuality.HIGH)
            {
                _TextureQuality++;
            }
            else
            {
                _TextureQuality = 0;
            }
            PlayerPrefs.SetInt("TextureQuality", (int)_TextureQuality);
            UpdateTextAndApplySettings();
            PlayerPrefs.Save();
            break;
        }
    }
Ejemplo n.º 29
0
    /// <summary>
    ///  Do actions based on current active scene.
    /// </summary>
    private void SwitchSettings()
    {
        switch (CurrentSelection)
        {
        case "MenuType":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButtonDown("RB"))
                {
                    if (_MenuType < MenuType.WINDOW)
                    {
                        _MenuType++;
                    }
                    else
                    {
                        _MenuType = 0;
                    }
                    PlayerPrefs.SetInt("MenuType", (int)_MenuType);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButtonDown("LB"))
                {
                    if (_MenuType > MenuType.RADIAL)
                    {
                        _MenuType--;
                    }
                    else
                    {
                        _MenuType = MenuType.WINDOW;;
                    }
                    UpdateTextAndApplySettings();
                    PlayerPrefs.SetInt("MenuType", (int)_MenuType);
                    PlayerPrefs.Save();
                }
            }
            break;

        case "WindowMode":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButtonDown("RB"))
                {
                    if (_WindowMode < WindowMode.WINDOWED)
                    {
                        _WindowMode++;
                    }
                    else
                    {
                        _WindowMode = 0;
                    }
                    PlayerPrefs.SetInt("WindowMode", (int)_WindowMode);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButtonDown("LB"))
                {
                    if (_WindowMode > WindowMode.FULLSCREEN)
                    {
                        _WindowMode--;
                    }
                    else
                    {
                        _WindowMode = WindowMode.WINDOWED;
                    }
                    PlayerPrefs.SetInt("WindowMode", (int)_WindowMode);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
            }
            break;

        case "Resolution":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButtonDown("RB"))
                {
                    if (_Resolution < Resolution.THIRTY_EIGHT_FOURTY_BY_TWENTY_ONE_SIXTY)
                    {
                        _Resolution++;
                    }
                    else
                    {
                        _Resolution = 0;
                    }
                    PlayerPrefs.SetInt("Resolution", (int)_Resolution);
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButtonDown("LB"))
                {
                    if (_Resolution > Resolution.NINETEEN_TWENTY_BY_TEN_EIGHTY)
                    {
                        _Resolution--;
                    }
                    else
                    {
                        _Resolution = Resolution.THIRTY_EIGHT_FOURTY_BY_TWENTY_ONE_SIXTY;
                    }
                    PlayerPrefs.SetInt("Resolution", (int)_Resolution);
                    PlayerPrefs.Save();
                }
            }
            break;

        case "AspectRatio":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButtonDown("RB"))
                {
                    if (_AspectRatio < AspectRatio.FIVE_FOUR)
                    {
                        _AspectRatio++;
                    }
                    else
                    {
                        _AspectRatio = AspectRatio.SIXTEEN_NINE;
                    }
                    PlayerPrefs.SetInt("AspectRatio", (int)_AspectRatio);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButtonDown("LB"))
                {
                    if (_AspectRatio > AspectRatio.SIXTEEN_NINE)
                    {
                        _AspectRatio--;
                    }
                    else
                    {
                        _AspectRatio = AspectRatio.FIVE_FOUR;
                    }
                    PlayerPrefs.SetInt("AspectRatio", (int)_AspectRatio);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
            }
            break;

        case "VSync":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButtonDown("RB"))
                {
                    if (VSync == 0)
                    {
                        VSync = 1;
                    }
                    else if (VSync == 1)
                    {
                        VSync = 0;
                    }
                    PlayerPrefs.SetInt("VSync", VSync);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButtonDown("LB"))
                {
                    if (VSync == 0)
                    {
                        VSync = 1;
                    }
                    else if (VSync == 1)
                    {
                        VSync = 0;
                    }
                    PlayerPrefs.SetInt("VSync", VSync);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
            }
            break;

        case "TextureQuality":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButtonDown("RB"))
                {
                    if (_TextureQuality < TextureQuality.HIGH)
                    {
                        _TextureQuality++;
                    }
                    else
                    {
                        _TextureQuality = 0;
                    }
                    PlayerPrefs.SetInt("TextureQuality", (int)_TextureQuality);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButtonDown("LB"))
                {
                    if (_TextureQuality > TextureQuality.LOW)
                    {
                        _TextureQuality--;
                    }
                    else
                    {
                        _TextureQuality = TextureQuality.HIGH;
                    }
                    PlayerPrefs.SetInt("TextureQuality", (int)_TextureQuality);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
            }
            break;

        case "MasterVolume":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButton("LB"))
                {
                    if (MasterVolume > 0)
                    {
                        MasterVolume--;
                    }
                    PlayerPrefs.SetFloat("MasterVolume", MasterVolume);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButton("RB"))
                {
                    if (MasterVolume < 100)
                    {
                        MasterVolume++;
                    }
                    PlayerPrefs.SetFloat("MasterVolume", MasterVolume);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
            }
            break;

        case "MusicVolume":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButton("LB"))
                {
                    if (MusicVolume > 0)
                    {
                        MusicVolume--;
                    }
                    PlayerPrefs.SetFloat("MusicVolume", MusicVolume);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButton("RB"))
                {
                    if (MusicVolume < 100)
                    {
                        MusicVolume++;
                    }
                    PlayerPrefs.SetFloat("MusicVolume", MusicVolume);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
            }

            break;

        case "SFXVolume":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButton("LB"))
                {
                    if (EffectsVolume > 0)
                    {
                        EffectsVolume--;
                    }

                    PlayerPrefs.SetFloat("SFXVolume", EffectsVolume);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButton("RB"))
                {
                    if (EffectsVolume < 100)
                    {
                        EffectsVolume++;
                    }

                    PlayerPrefs.SetFloat("SFXVolume", EffectsVolume);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
            }

            break;

        case "VoiceVolume":
            if (InputChecker.CurrentController == "Controller")
            {
                if (gamepad.GetButton("LB"))
                {
                    if (VoiceVolume > 0)
                    {
                        VoiceVolume--;
                    }

                    PlayerPrefs.SetFloat("VoiceVolume", VoiceVolume);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
                else if (gamepad.GetButton("RB"))
                {
                    if (VoiceVolume < 100)
                    {
                        VoiceVolume++;
                    }

                    PlayerPrefs.SetFloat("VoiceVolume", VoiceVolume);
                    UpdateTextAndApplySettings();
                    PlayerPrefs.Save();
                }
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 30
0
 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
 {
 }
    /// <summary>
    ///  Do actions based on current active scene.
    /// </summary>
    private void SwitchSettings()
    {
        switch (CurrentSelection)
        {
        case "MenuType":
            if (gamepad.GetButtonDown("RB"))
            {
                if (_MenuType < MenuType.WINDOW)
                {
                    _MenuType++;
                }
                else
                {
                    _MenuType = 0;
                }
                PlayerPrefs.SetInt("MenuType", (int)_MenuType);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            else if (gamepad.GetButtonDown("LB"))
            {
                if (_MenuType > MenuType.RADIAL)
                {
                    _MenuType--;
                }
                else
                {
                    _MenuType = MenuType.WINDOW;;
                }
                UpdateTextAndApplySettings();
                PlayerPrefs.SetInt("MenuType", (int)_MenuType);
                PlayerPrefs.Save();
            }
            break;

        case "WindowMode":
            if (gamepad.GetButtonDown("RB"))
            {
                if (_WindowMode < WindowMode.WINDOWED)
                {
                    _WindowMode++;
                }
                else
                {
                    _WindowMode = 0;
                }
                PlayerPrefs.SetInt("WindowMode", (int)_WindowMode);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            else if (gamepad.GetButtonDown("LB"))
            {
                if (_WindowMode > WindowMode.FULLSCREEN)
                {
                    _WindowMode--;
                }
                else
                {
                    _WindowMode = WindowMode.WINDOWED;
                }
                PlayerPrefs.SetInt("WindowMode", (int)_WindowMode);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            break;

        case "Resolution":
            if (gamepad.GetButtonDown("RB"))
            {
                PlayerPrefs.SetInt("Resolution", (int)_Resolution);
                PlayerPrefs.Save();
            }
            else if (gamepad.GetButtonDown("LB"))
            {
                PlayerPrefs.SetInt("Resolution", (int)_Resolution);
                PlayerPrefs.Save();
            }
            break;

        case "AspectRatio":
            if (gamepad.GetButtonDown("RB"))
            {
                if (_AspectRatio < AspectRatio.FIVE_FOUR)
                {
                    _AspectRatio++;
                }
                else
                {
                    _AspectRatio = AspectRatio.SIXTEEN_NINE;
                }
                PlayerPrefs.SetInt("AspectRatio", (int)_AspectRatio);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            else if (gamepad.GetButtonDown("LB"))
            {
                if (_AspectRatio > AspectRatio.SIXTEEN_NINE)
                {
                    _AspectRatio--;
                }
                else
                {
                    _AspectRatio = AspectRatio.FIVE_FOUR;
                }
                PlayerPrefs.SetInt("AspectRatio", (int)_AspectRatio);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            break;

        case "VSync":
            if (gamepad.GetButtonDown("RB"))
            {
                if (VSync == 0)
                {
                    VSync = 1;
                }
                else if (VSync == 1)
                {
                    VSync = 0;
                }
                PlayerPrefs.SetInt("VSync", VSync);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            else if (gamepad.GetButtonDown("LB"))
            {
                if (VSync == 0)
                {
                    VSync = 1;
                }
                else if (VSync == 1)
                {
                    VSync = 0;
                }
                PlayerPrefs.SetInt("VSync", VSync);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            break;

        case "TextureQuality":
            if (gamepad.GetButtonDown("RB"))
            {
                if (_TextureQuality < TextureQuality.ULTRA)
                {
                    _TextureQuality++;
                }
                else
                {
                    _TextureQuality = 0;
                }
                PlayerPrefs.SetInt("TextureQuality", (int)_TextureQuality);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            else if (gamepad.GetButtonDown("LB"))
            {
                if (_TextureQuality > TextureQuality.VERY_LOW)
                {
                    _TextureQuality--;
                }
                else
                {
                    _TextureQuality = TextureQuality.ULTRA;
                }
                PlayerPrefs.SetInt("TextureQuality", (int)_TextureQuality);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            break;

        case "MasterVolume":
            if (gamepad.GetButton("LB"))
            {
                if (MasterVolume > 0)
                {
                    MasterVolume--;
                }
                PlayerPrefs.SetFloat("MasterVolume", MasterVolume);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            else if (gamepad.GetButton("RB"))
            {
                if (MasterVolume < 100)
                {
                    MasterVolume++;
                }
                PlayerPrefs.SetFloat("MasterVolume", MasterVolume);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            break;

        case "MusicVolume":
            if (gamepad.GetButton("LB"))
            {
                if (MusicVolume > 0)
                {
                    MusicVolume--;
                }
                PlayerPrefs.SetFloat("MusicVolume", MusicVolume);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            else if (gamepad.GetButton("RB"))
            {
                if (MusicVolume < 100)
                {
                    MusicVolume++;
                }
                PlayerPrefs.SetFloat("MusicVolume", MusicVolume);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            break;

        case "SFXVolume":
            if (gamepad.GetButton("LB"))
            {
                if (EffectsVolume > 0)
                {
                    EffectsVolume--;
                }

                PlayerPrefs.SetFloat("SFXVolume", EffectsVolume);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            else if (gamepad.GetButton("RB"))
            {
                if (EffectsVolume < 100)
                {
                    EffectsVolume++;
                }

                PlayerPrefs.SetFloat("SFXVolume", EffectsVolume);
                UpdateTextAndApplySettings();
                PlayerPrefs.Save();
            }
            break;

        default:
            break;
        }
    }
Ejemplo n.º 32
0
 public void ShowWindow(Character pc, WindowMode mode = WindowMode.DISPLAY, int slotID = 0, DetailsWindow child = null)
 {
     _pc = pc;
     cursorPos = 0;
     _windowmode = mode;
     _slotID = slotID;
     _child = child;
     pack = _pc.Backpack.Items;
     if (mode == WindowMode.DISPLAY)
     {
         _title = Game.Lang[StringName.BACKPACK_WND_TITLE];
     }
     else if (mode == WindowMode.DROP)
     {
         _title = Game.Lang[StringName.BACKPACK_WND_TITLE_DROP];
     }
     else
     {
         _title = Game.Lang[StringName.BACKPACK_WND_TITLE_EQUIP];
         SlotType st = EquipmentSlot.GetSlotType(_slotID);
         pack = _pc.Backpack.GetItemsBySlot(st);
     }
     base.drawWindow();
     drawText();
     windowLoop();
 }
 public PXRedirectToBoardRequiredException(string baseBoardUrl, KeyValuePair <string, string>[] parameters, WindowMode windowMode = WindowMode.NewWindow, bool supressFrameset = true)
     : base(BuildUrl(baseBoardUrl, parameters), windowMode, supressFrameset, null)
 {
 }
Ejemplo n.º 34
0
        public PlatformWindow(Size requestWindowSize, WindowMode windowMode, int batchSize, bool DisableWindowsDPIScaling, bool lockMouseWindow, bool disableWindowsRenderThread)
        {
#if DEBUG
            windowMode = WindowMode.Windowed;
#endif
            Console.WriteLine("Using SDL 2 with OpenGL renderer");

            // Lock the Window/Surface properties until initialization is complete
            lock (syncObject)
            {
                windowSize = requestWindowSize;

                // Disable legacy scaling on Windows
                if (Platform.CurrentPlatform == PlatformType.Windows && !DisableWindowsDPIScaling)
                {
                    SetProcessDPIAware();
                }

                SDL.SDL_Init(SDL.SDL_INIT_NOPARACHUTE | SDL.SDL_INIT_VIDEO);
                SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1);
                SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_RED_SIZE, 8);
                SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_GREEN_SIZE, 8);
                SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_BLUE_SIZE, 8);
                SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_ALPHA_SIZE, 0);

                SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, 4);                 // OpenGL 3+

                SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 4);
                SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, Convert.ToInt32(SDL.SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_CORE));                 // нужно для RenderDoc


                SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_FLAGS, Convert.ToInt32(SDL.SDL_GLcontext.SDL_GL_CONTEXT_DEBUG_FLAG));



                SDL.SDL_DisplayMode display;
                SDL.SDL_GetCurrentDisplayMode(0, out display);

                Console.WriteLine("Desktop resolution: {0}x{1}", display.w, display.h);
                if (windowSize.Width == 0 && windowSize.Height == 0)
                {
                    Console.WriteLine("No custom resolution provided, using desktop resolution");
                    windowSize = new Size(display.w, display.h);
                }

                Console.WriteLine("Using resolution: {0}x{1}", windowSize.Width, windowSize.Height);

                var windowFlags = SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL | SDL.SDL_WindowFlags.SDL_WINDOW_ALLOW_HIGHDPI;

                // HiDPI doesn't work properly on OSX with (legacy) fullscreen mode
                if (Platform.CurrentPlatform == PlatformType.OSX && windowMode == WindowMode.Fullscreen)
                {
                    SDL.SDL_SetHint(SDL.SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1");
                }

                window = SDL.SDL_CreateWindow("OpenRA", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED,
                                              windowSize.Width, windowSize.Height, windowFlags);

                // Work around an issue in macOS's GL backend where the window remains permanently black
                // (if dark mode is enabled) unless we drain the event queue before initializing GL
                if (Platform.CurrentPlatform == PlatformType.OSX)
                {
                    SDL.SDL_Event e;
                    while (SDL.SDL_PollEvent(out e) != 0)
                    {
                        // We can safely ignore all mouse/keyboard events and window size changes
                        // (these will be caught in the window setup below), but do need to process focus
                        if (e.type == SDL.SDL_EventType.SDL_WINDOWEVENT)
                        {
                            switch (e.window.windowEvent)
                            {
                                //case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                                //	Game.HasInputFocus = false;
                                //	break;

                                //case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                                //	Game.HasInputFocus = true;
                                //	break;
                            }
                        }
                    }
                }

                surfaceSize = windowSize;
                windowScale = 1;

                // Enable high resolution rendering for Retina displays
                if (Platform.CurrentPlatform == PlatformType.OSX)
                {
                    // OSX defines the window size in "points", with a device-dependent number of pixels per point.
                    // The window scale is simply the ratio of GL pixels / window points.
                    int width, height;

                    SDL.SDL_GL_GetDrawableSize(Window, out width, out height);
                    surfaceSize = new Size(width, height);
                    windowScale = width * 1f / windowSize.Width;
                }
                else if (Platform.CurrentPlatform == PlatformType.Windows)
                {
                    float ddpi, hdpi, vdpi;
                    if (!DisableWindowsDPIScaling && SDL.SDL_GetDisplayDPI(0, out ddpi, out hdpi, out vdpi) == 0)
                    {
                        windowScale = ddpi / 96;
                        windowSize  = new Size((int)(surfaceSize.Width / windowScale), (int)(surfaceSize.Height / windowScale));
                    }
                }
                else
                {
                    float scale         = 1;
                    var   scaleVariable = Environment.GetEnvironmentVariable("OPENRA_DISPLAY_SCALE");
                    if (scaleVariable != null && float.TryParse(scaleVariable, out scale))
                    {
                        windowScale = scale;
                        windowSize  = new Size((int)(surfaceSize.Width / windowScale), (int)(surfaceSize.Height / windowScale));
                    }
                }

                Console.WriteLine("Using window scale {0:F2}", windowScale);

                if (lockMouseWindow)
                {
                    GrabWindowMouseFocus();
                }
                else
                {
                    ReleaseWindowMouseFocus();
                }

                if (windowMode == WindowMode.Fullscreen)
                {
                    SDL.SDL_SetWindowFullscreen(Window, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN);

                    // Fullscreen mode on OSX will ignore the configured display resolution
                    // and instead always picks an arbitrary scaled resolution choice that may
                    // not match the window size, leading to graphical and input issues.
                    // We work around this by force disabling HiDPI and resetting the window and
                    // surface sizes to match the size that is forced by SDL.
                    // This is usually not what the player wants, but is the best we can consistently do.
                    if (Platform.CurrentPlatform == PlatformType.OSX)
                    {
                        int width, height;
                        SDL.SDL_GetWindowSize(Window, out width, out height);
                        windowSize  = surfaceSize = new Size(width, height);
                        windowScale = 1;
                    }
                }
                else if (windowMode == WindowMode.PseudoFullscreen)
                {
                    // Work around a visual glitch in OSX: the window is offset
                    // partially offscreen if the dock is at the left of the screen
                    if (Platform.CurrentPlatform == PlatformType.OSX)
                    {
                        SDL.SDL_SetWindowPosition(Window, 0, 0);
                    }

                    SDL.SDL_SetWindowFullscreen(Window, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP);
                    SDL.SDL_SetHint(SDL.SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
                }
            }

            // Run graphics rendering on a dedicated thread.
            // The calling thread will then have more time to process other tasks, since rendering happens in parallel.
            // If the calling thread is the main game thread, this means it can run more logic and render ticks.
            // This is disabled on Windows because it breaks the ability to minimize/restore the window from the taskbar for reasons that we dont understand.
            var threadedRenderer = Platform.CurrentPlatform != PlatformType.Windows || !disableWindowsRenderThread;
            if (!threadedRenderer)
            {
                var ctx = new GraphicsContext(this);
                ctx.InitializeOpenGL();
                context = ctx;
            }
            else
            {
                //context = new ThreadedGraphicsContext(new GraphicsContext(this), batchSize);

                SDL.SDL_SetModState(SDL.SDL_Keymod.KMOD_NONE);
            }
            input = new Sdl2Input();
        }
Ejemplo n.º 35
0
        partial void InitProjSpecific(XDocument doc)
        {
            if (doc == null)
            {
                GraphicsWidth  = 1024;
                GraphicsHeight = 678;

                MasterServerUrl = "";

                SelectedContentPackage = ContentPackage.list.Any() ? ContentPackage.list[0] : new ContentPackage("");

                JobNamePreferences = new List <string>();
                foreach (JobPrefab job in JobPrefab.List)
                {
                    JobNamePreferences.Add(job.Name);
                }
                return;
            }

            XElement graphicsMode = doc.Root.Element("graphicsmode");

            GraphicsWidth  = graphicsMode.GetAttributeInt("width", 0);
            GraphicsHeight = graphicsMode.GetAttributeInt("height", 0);
            VSyncEnabled   = graphicsMode.GetAttributeBool("vsync", true);

            if (GraphicsWidth == 0 || GraphicsHeight == 0)
            {
                GraphicsWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                GraphicsHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            }

            //FullScreenEnabled = ToolBox.GetAttributeBool(graphicsMode, "fullscreen", true);

            var windowModeStr = graphicsMode.GetAttributeString("displaymode", "Fullscreen");

            if (!Enum.TryParse <WindowMode>(windowModeStr, out windowMode))
            {
                windowMode = WindowMode.Fullscreen;
            }

            SoundVolume = doc.Root.GetAttributeFloat("soundvolume", 1.0f);
            MusicVolume = doc.Root.GetAttributeFloat("musicvolume", 0.3f);

            EnableSplashScreen = doc.Root.GetAttributeBool("enablesplashscreen", true);

            keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
            keyMapping[(int)InputType.Up]    = new KeyOrMouse(Keys.W);
            keyMapping[(int)InputType.Down]  = new KeyOrMouse(Keys.S);
            keyMapping[(int)InputType.Left]  = new KeyOrMouse(Keys.A);
            keyMapping[(int)InputType.Right] = new KeyOrMouse(Keys.D);
            keyMapping[(int)InputType.Run]   = new KeyOrMouse(Keys.LeftShift);


            keyMapping[(int)InputType.Chat]       = new KeyOrMouse(Keys.Tab);
            keyMapping[(int)InputType.CrewOrders] = new KeyOrMouse(Keys.C);

            keyMapping[(int)InputType.Select] = new KeyOrMouse(Keys.E);

            keyMapping[(int)InputType.Use] = new KeyOrMouse(0);
            keyMapping[(int)InputType.Aim] = new KeyOrMouse(1);

            foreach (XElement subElement in doc.Root.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "keymapping":
                    foreach (XAttribute attribute in subElement.Attributes())
                    {
                        InputType inputType;
                        if (Enum.TryParse(attribute.Name.ToString(), true, out inputType))
                        {
                            int mouseButton;
                            if (int.TryParse(attribute.Value.ToString(), out mouseButton))
                            {
                                keyMapping[(int)inputType] = new KeyOrMouse(mouseButton);
                            }
                            else
                            {
                                Keys key;
                                if (Enum.TryParse(attribute.Value.ToString(), true, out key))
                                {
                                    keyMapping[(int)inputType] = new KeyOrMouse(key);
                                }
                            }
                        }
                    }
                    break;

                case "gameplay":
                    JobNamePreferences = new List <string>();
                    foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
                    {
                        JobNamePreferences.Add(ele.GetAttributeString("name", ""));
                    }
                    break;
                }
            }

            foreach (InputType inputType in Enum.GetValues(typeof(InputType)))
            {
                if (keyMapping[(int)inputType] == null)
                {
                    DebugConsole.ThrowError("Key binding for the input type \"" + inputType + " not set!");
                    keyMapping[(int)inputType] = new KeyOrMouse(Keys.D1);
                }
            }


            UnsavedSettings = false;
        }
Ejemplo n.º 36
0
		public IGraphicsDevice Create(Size size, WindowMode windowMode)
		{
			Console.WriteLine("Using Cg renderer");
			return new GraphicsDevice(size, windowMode);
		}
Ejemplo n.º 37
0
 public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
 {
     Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
     _windowSize2D     = windowSize;
     _windowPosition2D = windowPosition;
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Update the system control buttons in the window frame
        /// </summary>
        /// <param name="winMode">Window mode</param>
        private void UpdateWindowFrame(WindowMode winMode)
        {
            switch (winMode)
            {
            // Only close button should be visible if the mode is CanClose/PaneCanClose
            case WindowMode.CanClose:
            case WindowMode.PaneCanClose:
                if (minimizeButton != null)
                {
                    minimizeButton.Visibility = Visibility.Collapsed;
                }
                if (maximizeButton != null)
                {
                    maximizeButton.Visibility = Visibility.Collapsed;
                }
                if (restoreButton != null)
                {
                    restoreButton.Visibility = Visibility.Collapsed;
                }
                break;

            // Only minimize and close buttons should be visible if the mode is Pane/CanMinimize
            case WindowMode.Pane:
            case WindowMode.CanMinimize:
            default:
                if (minimizeButton != null)
                {
                    minimizeButton.Visibility = Visibility.Visible;
                    Grid.SetColumn(minimizeButton, 2);
                }
                if (maximizeButton != null)
                {
                    maximizeButton.Visibility = Visibility.Collapsed;
                }
                if (restoreButton != null)
                {
                    restoreButton.Visibility = Visibility.Collapsed;
                }
                break;

            // All buttons - minimize, maximize and close will be visible if the mode is CanMaximize
            case WindowMode.CanMaximize:
                if (minimizeButton != null)
                {
                    minimizeButton.Visibility = Visibility.Visible;
                    Grid.SetColumn(minimizeButton, 1);
                }
                if (maximizeButton != null)
                {
                    maximizeButton.Visibility = Visibility.Visible;
                }
                break;

            // All buttons - minimize, maximize and close will be hidden if the mode is CanMaximize
            case WindowMode.ChildWindow:
                if (minimizeButton != null)
                {
                    minimizeButton.Visibility = Visibility.Collapsed;
                }
                if (maximizeButton != null)
                {
                    maximizeButton.Visibility = Visibility.Collapsed;
                }
                if (restoreButton != null)
                {
                    restoreButton.Visibility = Visibility.Collapsed;
                }
                if (closeButton != null)
                {
                    closeButton.Visibility = Visibility.Collapsed;
                }
                break;
            }

            // If the mode is Pane/PaneCanClose then the window should be in maximized state
            if ((WindowFrameMode == WindowMode.Pane) || (WindowFrameMode == WindowMode.PaneCanClose))
            {
                SystemCommands.MaximizeWindow(this);
            }
        }
Ejemplo n.º 39
0
 public IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int batchSize, int videoDisplay, GLProfile profile)
 {
     return(new Sdl2PlatformWindow(size, windowMode, scaleModifier, batchSize, videoDisplay, profile));
 }
Ejemplo n.º 40
0
 /// <summary>
 /// The constructor with a stylesheet and window mode.
 /// </summary>
 /// <param name="styleSheet">The styleSheet url.</param>
 /// <param name="windowMode">The windowMode.</param>
 /// <since_tizen> 3 </since_tizen>
 public NUIApplication(string styleSheet, WindowMode windowMode) : base(new NUICoreBackend(styleSheet, windowMode))
 {
     Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
 }
Ejemplo n.º 41
0
 public IGraphicsDevice Create(Size size, WindowMode windowMode)
 {
     Console.WriteLine("Using SDL 2 with OpenGL renderer");
     return new Sdl2GraphicsDevice(size, windowMode);
 }
Ejemplo n.º 42
0
        /// <summary>
        /// ウィンドウ名と画像の表示モードを指定して初期化
        /// </summary>
        /// <param name="name">ウィンドウの識別に用いられるウィンドウ名で,ウィンドウのタイトルバ ーに表示される.</param>
        /// <param name="flags">ウィンドウのフラグ</param>
#else
        /// <summary>
        /// Creates a window
        /// </summary>
        /// <param name="name">Name of the window which is used as window identifier and appears in the window caption. </param>
        /// <param name="flags">Flags of the window. Currently the only supported flag is WindowMode.AutoSize. 
        /// If it is set, window size is automatically adjusted to fit the displayed image (see cvShowImage), while user can not change the window size manually. </param>
#endif
        public CvWindow(string name, WindowMode flags)
            : this(name, flags, null)
        {
        }
Ejemplo n.º 43
0
 public NullGraphicsDevice(Size size, WindowMode window)
 {
     Console.WriteLine("Using Null renderer");
     WindowSize = size;
 }
Ejemplo n.º 44
0
        /// <summary>
        /// 適当なウィンドウ名で、画像の表示モードを指定して初期化
        /// </summary>
        /// <param name="flags">ウィンドウのフラグ</param>
        /// <param name="image">ウィンドウに表示する画像</param>
#else
        /// <summary>
        /// Creates a window with a specified image and flag
        /// </summary>
        /// <param name="flags">Flags of the window. Currently the only supported flag is WindowMode.AutoSize. 
        /// If it is set, window size is automatically adjusted to fit the displayed image (see cvShowImage), while user can not change the window size manually. </param>
        /// <param name="image"></param>
#endif
        public CvWindow(WindowMode flags, CvArr image)
            : this(DefaultName(), flags, image)
        {
        }
Ejemplo n.º 45
0
 public static int OpenWindow(int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, WindowMode mode)
 {
     return(GlfwDelegates.glfwOpenWindow(width, height, redbits, greenbits, bluebits, alphabits, depthbits, stencilbits, (int)mode));
 }
Ejemplo n.º 46
0
 public IGraphicsDevice Create(Size size, WindowMode windowMode)
 {
     return(new NullGraphicsDevice(size, windowMode));
 }
Ejemplo n.º 47
0
 public static extern int cvNamedWindow([MarshalAs(UnmanagedType.LPStr)] string name, WindowMode flags);
Ejemplo n.º 48
0
        public static IntPtr InitializeSdlGl(ref Size size, WindowMode window, string[] requiredExtensions)
        {
            Sdl.SDL_Init(Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_RED_SIZE, 8);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_GREEN_SIZE, 8);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_BLUE_SIZE, 8);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_ALPHA_SIZE, 0);

            int windowFlags = 0;

            switch (window)
            {
            case WindowMode.Fullscreen:
                windowFlags |= Sdl.SDL_FULLSCREEN;
                break;

            case WindowMode.PseudoFullscreen:
                windowFlags |= Sdl.SDL_NOFRAME;
                Environment.SetEnvironmentVariable("SDL_VIDEO_WINDOW_POS", "0,0");
                break;

            case WindowMode.Windowed:
                Environment.SetEnvironmentVariable("SDL_VIDEO_CENTERED", "1");
                break;

            default:
                break;
            }

            var info = (Sdl.SDL_VideoInfo)Marshal.PtrToStructure(
                Sdl.SDL_GetVideoInfo(), typeof(Sdl.SDL_VideoInfo));

            Console.WriteLine("Desktop resolution: {0}x{1}",
                              info.current_w, info.current_h);

            if (size.Width == 0 && size.Height == 0)
            {
                Console.WriteLine("No custom resolution provided, using desktop resolution");
                size = new Size(info.current_w, info.current_h);
            }

            Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height);

            var surf = Sdl.SDL_SetVideoMode(size.Width, size.Height, 0, Sdl.SDL_OPENGL | windowFlags);

            if (surf == IntPtr.Zero)
            {
                Console.WriteLine("Failed to set video mode.");
            }

            Sdl.SDL_WM_SetCaption("OpenRA", "OpenRA");
            Sdl.SDL_ShowCursor(0);
            Sdl.SDL_EnableUNICODE(1);
            Sdl.SDL_EnableKeyRepeat(Sdl.SDL_DEFAULT_REPEAT_DELAY, Sdl.SDL_DEFAULT_REPEAT_INTERVAL);

            ErrorHandler.CheckGlError();

            var extensions = Gl.glGetString(Gl.GL_EXTENSIONS);

            if (extensions == null)
            {
                Console.WriteLine("Failed to fetch GL_EXTENSIONS, this is bad.");
            }

            var missingExtensions = requiredExtensions.Where(r => !extensions.Contains(r)).ToArray();

            if (missingExtensions.Any())
            {
                ErrorHandler.WriteGraphicsLog("Unsupported GPU: Missing extensions: {0}"
                                              .F(missingExtensions.JoinWith(",")));
                throw new InvalidProgramException("Unsupported GPU. See graphics.log for details.");
            }

            return(surf);
        }
Ejemplo n.º 49
0
        /// <summary>
        /// ウィンドウ名と画像の表示モードと始めから表示しておく画像を指定して初期化
        /// </summary>
        /// <param name="name">ウィンドウの識別に用いられるウィンドウ名で,ウィンドウのタイトルバ ーに表示される.</param>
        /// <param name="flags">ウィンドウのフラグ</param>
        /// <param name="image">ウィンドウに表示する画像</param>
#else
        /// <summary>
        /// Creates a window
        /// </summary>
        /// <param name="name">Name of the window which is used as window identifier and appears in the window caption. </param>
        /// <param name="flags">Flags of the window. Currently the only supported flag is WindowMode.AutoSize. 
        /// If it is set, window size is automatically adjusted to fit the displayed image (see cvShowImage), while user can not change the window size manually. </param>
        /// <param name="image">Image to be shown.</param>
#endif
        public CvWindow(string name, WindowMode flags, CvArr image)
        {
            if (name == null)
            {
                throw new ArgumentNullException();
            }
            this.name = name;
            int status = NativeMethods.cvNamedWindow(name, flags);
            if (status == 0)
            {
                throw new OpenCvSharpException("Failed to create CvWindow");
            }
            this.image = image;
            ShowImage(image);
            trackbars = new Dictionary<string, CvTrackbar>();
            if (!Windows.ContainsKey(name))
            {
                Windows.Add(name, this);
            }
            callbackHandle = null;
        }
Ejemplo n.º 50
0
		public ViewGcodeBasic(PrintItemWrapper printItem, Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape, WindowMode windowMode)
		{
			this.viewerVolume = viewerVolume;
			this.bedShape = bedShape;
			this.bedCenter = bedCenter;
			this.windowMode = windowMode;
			this.printItem = printItem;

			if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
			{
				sliderWidth = 20;
			}
			else
			{
				sliderWidth = 10;
			}

			CreateAndAddChildren();

			SliceSettingsWidget.RegisterForSettingsChange("bed_size", RecreateBedAndPartPosition, ref unregisterEvents);
			SliceSettingsWidget.RegisterForSettingsChange("print_center", RecreateBedAndPartPosition, ref unregisterEvents);
			SliceSettingsWidget.RegisterForSettingsChange("build_height", RecreateBedAndPartPosition, ref unregisterEvents);
			SliceSettingsWidget.RegisterForSettingsChange("bed_shape", RecreateBedAndPartPosition, ref unregisterEvents);
			SliceSettingsWidget.RegisterForSettingsChange("center_part_on_bed", RecreateBedAndPartPosition, ref unregisterEvents);

			SliceSettingsWidget.RegisterForSettingsChange("extruder_offset", Clear3DGCode, ref unregisterEvents);
			ApplicationController.Instance.ReloadAdvancedControlsPanelTrigger.RegisterEvent(RecreateBedAndPartPosition, ref unregisterEvents);

			ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(RecreateBedAndPartPosition, ref unregisterEvents);
		}
Ejemplo n.º 51
0
		public ViewGcodeBasic(PrintItemWrapper printItem, Vector3 viewerVolume, Vector2 bedCenter, BedShape bedShape, WindowMode windowMode)
		{
			this.viewerVolume = viewerVolume;
			this.bedShape = bedShape;
			this.bedCenter = bedCenter;
			this.windowMode = windowMode;
			this.printItem = printItem;

			if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
			{
				sliderWidth = 20;
			}
			else
			{
				sliderWidth = 10;
			}

			CreateAndAddChildren();

			SliceSettingsWidget.SettingChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents);
			ApplicationController.Instance.AdvancedControlsPanelReloading.RegisterEvent((s, e) => ClearGCode(), ref unregisterEvents);

			ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(CheckSettingChanged, ref unregisterEvents);
		}
Ejemplo n.º 52
0
        public Sdl2GraphicsDevice(Size windowSize, WindowMode windowMode)
        {
            size = windowSize;

            SDL.SDL_Init(SDL.SDL_INIT_NOPARACHUTE | SDL.SDL_INIT_VIDEO);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_RED_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_GREEN_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_BLUE_SIZE, 8);
            SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_ALPHA_SIZE, 0);

            var windowFlags = SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL;

            if (windowMode == WindowMode.Fullscreen)
            {
                windowFlags |= SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN;
            }
            else if (windowMode == WindowMode.PseudoFullscreen)
            {
                windowFlags |= SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP;
                Environment.SetEnvironmentVariable("SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS", "0");
            }

            SDL.SDL_DisplayMode display;
            SDL.SDL_GetCurrentDisplayMode(0, out display);

            Console.WriteLine("Desktop resolution: {0}x{1}", display.w, display.h);
            if (size.Width == 0 && size.Height == 0)
            {
                Console.WriteLine("No custom resolution provided, using desktop resolution");
                size = new Size(display.w, display.h);
            }

            Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height);

            window = SDL.SDL_CreateWindow("OpenRA", SDL.SDL_WINDOWPOS_CENTERED, SDL.SDL_WINDOWPOS_CENTERED, size.Width, size.Height, windowFlags);

            SDL.SDL_ShowCursor(0);
            SDL.SDL_GL_CreateContext(window);
            ErrorHandler.CheckGlError();

            var extensions = Gl.glGetString(Gl.GL_EXTENSIONS);

            if (extensions == null)
            {
                Console.WriteLine("Failed to fetch GL_EXTENSIONS, this is bad.");
            }

            var missingExtensions = requiredExtensions.Where(r => !extensions.Contains(r)).ToArray();

            if (missingExtensions.Any())
            {
                ErrorHandler.WriteGraphicsLog("Unsupported GPU: Missing extensions: {0}".F(missingExtensions.JoinWith(",")));
                throw new InvalidProgramException("Unsupported GPU. See graphics.log for details.");
            }

            Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
            ErrorHandler.CheckGlError();
            Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
            ErrorHandler.CheckGlError();

            SDL.SDL_SetModState(0);
            input = new Sdl2Input();
        }
Ejemplo n.º 53
0
 private void windowModeChanged(WindowMode newMode) => UpdateWindowMode(newMode);
Ejemplo n.º 54
0
        public Sdl2PlatformWindow(Size requestEffectiveWindowSize, WindowMode windowMode,
                                  float scaleModifier, int batchSize, int videoDisplay, GLProfile requestProfile, bool enableLegacyGL)
        {
            // Lock the Window/Surface properties until initialization is complete
            lock (syncObject)
            {
                this.scaleModifier = scaleModifier;

                // Disable legacy scaling on Windows
                if (Platform.CurrentPlatform == PlatformType.Windows)
                {
                    SetProcessDPIAware();
                }

                // Decide which OpenGL profile to use.
                // Prefer standard GL over GLES provided by the native driver
                var testProfiles = new List <GLProfile> {
                    GLProfile.ANGLE, GLProfile.Modern, GLProfile.Embedded
                };
                if (enableLegacyGL)
                {
                    testProfiles.Add(GLProfile.Legacy);
                }

                supportedProfiles = testProfiles
                                    .Where(CanCreateGLWindow)
                                    .ToArray();

                if (!supportedProfiles.Any())
                {
                    throw new InvalidOperationException("No supported OpenGL profiles were found.");
                }

                profile = supportedProfiles.Contains(requestProfile) ? requestProfile : supportedProfiles.First();

                // Note: This must be called after the CanCreateGLWindow checks above,
                // which needs to create and destroy its own SDL contexts as a workaround for specific buggy drivers
                SDL.SDL_Init(SDL.SDL_INIT_VIDEO);
                SetSDLAttributes(profile);

                Console.WriteLine("Using SDL 2 with OpenGL ({0}) renderer", profile);
                if (videoDisplay < 0 || videoDisplay >= DisplayCount)
                {
                    videoDisplay = 0;
                }

                SDL.SDL_GetCurrentDisplayMode(videoDisplay, out var display);

                // Windows and Linux define window sizes in native pixel units.
                // Query the display/dpi scale so we can convert our requested effective size to pixels.
                // This is not necessary on macOS, which defines window sizes in effective units ("points").
                if (Platform.CurrentPlatform == PlatformType.Windows)
                {
                    // Launch the game with OPENRA_DISPLAY_SCALE to force a specific scaling factor
                    // Otherwise fall back to Windows's DPI configuration
                    var scaleVariable = Environment.GetEnvironmentVariable("OPENRA_DISPLAY_SCALE");
                    if (scaleVariable == null || !float.TryParse(scaleVariable, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out windowScale) || windowScale <= 0)
                    {
                        if (SDL.SDL_GetDisplayDPI(videoDisplay, out var ddpi, out _, out _) == 0)
                        {
                            windowScale = ddpi / 96;
                        }
                    }
                }
                else if (Platform.CurrentPlatform == PlatformType.Linux)
                {
                    // Launch the game with OPENRA_DISPLAY_SCALE to force a specific scaling factor
                    // Otherwise fall back to GDK_SCALE or parsing the x11 DPI configuration
                    var scaleVariable = Environment.GetEnvironmentVariable("OPENRA_DISPLAY_SCALE") ?? Environment.GetEnvironmentVariable("GDK_SCALE");
                    if (scaleVariable == null || !float.TryParse(scaleVariable, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out windowScale) || windowScale <= 0)
                    {
                        // Attempt to automatically detect DPI
                        try
                        {
                            var psi = new ProcessStartInfo("/usr/bin/xrdb", "-query");
                            psi.UseShellExecute        = false;
                            psi.RedirectStandardOutput = true;
                            var p     = Process.Start(psi);
                            var lines = p.StandardOutput.ReadToEnd().Split('\n');

                            foreach (var line in lines)
                            {
                                if (line.StartsWith("Xft.dpi") && int.TryParse(line.Substring(8), out var dpi))
                                {
                                    windowScale = dpi / 96f;
                                }
                            }
                        }
                        catch { }
                    }
                }

                Console.WriteLine("Desktop resolution: {0}x{1}", display.w, display.h);
                if (requestEffectiveWindowSize.Width == 0 && requestEffectiveWindowSize.Height == 0)
                {
                    Console.WriteLine("No custom resolution provided, using desktop resolution");
                    surfaceSize = windowSize = new Size(display.w, display.h);
                }
                else
                {
                    surfaceSize = windowSize = new Size((int)(requestEffectiveWindowSize.Width * windowScale), (int)(requestEffectiveWindowSize.Height * windowScale));
                }

                Console.WriteLine("Using resolution: {0}x{1}", windowSize.Width, windowSize.Height);

                var windowFlags = SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL | SDL.SDL_WindowFlags.SDL_WINDOW_ALLOW_HIGHDPI;

                // HiDPI doesn't work properly on OSX with (legacy) fullscreen mode
                if (Platform.CurrentPlatform == PlatformType.OSX && windowMode == WindowMode.Fullscreen)
                {
                    SDL.SDL_SetHint(SDL.SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1");
                }

                window = SDL.SDL_CreateWindow("OpenRA", SDL.SDL_WINDOWPOS_CENTERED_DISPLAY(videoDisplay), SDL.SDL_WINDOWPOS_CENTERED_DISPLAY(videoDisplay),
                                              windowSize.Width, windowSize.Height, windowFlags);

                // Work around an issue in macOS's GL backend where the window remains permanently black
                // (if dark mode is enabled) unless we drain the event queue before initializing GL
                if (Platform.CurrentPlatform == PlatformType.OSX)
                {
                    while (SDL.SDL_PollEvent(out var e) != 0)
                    {
                        // We can safely ignore all mouse/keyboard events and window size changes
                        // (these will be caught in the window setup below), but do need to process focus
                        if (e.type == SDL.SDL_EventType.SDL_WINDOWEVENT)
                        {
                            switch (e.window.windowEvent)
                            {
                            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_LOST:
                                HasInputFocus = false;
                                break;

                            case SDL.SDL_WindowEventID.SDL_WINDOWEVENT_FOCUS_GAINED:
                                HasInputFocus = true;
                                break;
                            }
                        }
                    }
                }

                // Enable high resolution rendering for Retina displays
                if (Platform.CurrentPlatform == PlatformType.OSX)
                {
                    // OSX defines the window size in "points", with a device-dependent number of pixels per point.
                    // The window scale is simply the ratio of GL pixels / window points.
                    SDL.SDL_GL_GetDrawableSize(Window, out var width, out var height);
                    surfaceSize = new Size(width, height);
                    windowScale = width * 1f / windowSize.Width;
                }
                else
                {
                    windowSize = new Size((int)(surfaceSize.Width / windowScale), (int)(surfaceSize.Height / windowScale));
                }

                Console.WriteLine("Using window scale {0:F2}", windowScale);

                if (Game.Settings.Game.LockMouseWindow)
                {
                    GrabWindowMouseFocus();
                }
                else
                {
                    ReleaseWindowMouseFocus();
                }

                if (windowMode == WindowMode.Fullscreen)
                {
                    SDL.SDL_SetWindowFullscreen(Window, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN);

                    // Fullscreen mode on OSX will ignore the configured display resolution
                    // and instead always picks an arbitrary scaled resolution choice that may
                    // not match the window size, leading to graphical and input issues.
                    // We work around this by force disabling HiDPI and resetting the window and
                    // surface sizes to match the size that is forced by SDL.
                    // This is usually not what the player wants, but is the best we can consistently do.
                    if (Platform.CurrentPlatform == PlatformType.OSX)
                    {
                        SDL.SDL_GetWindowSize(Window, out var width, out var height);
                        windowSize  = surfaceSize = new Size(width, height);
                        windowScale = 1;
                    }
                }
                else if (windowMode == WindowMode.PseudoFullscreen)
                {
                    SDL.SDL_SetWindowFullscreen(Window, (uint)SDL.SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP);
                    SDL.SDL_SetHint(SDL.SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
                }
            }

            // Run graphics rendering on a dedicated thread.
            // The calling thread will then have more time to process other tasks, since rendering happens in parallel.
            // If the calling thread is the main game thread, this means it can run more logic and render ticks.
            // This is disabled on Windows because it breaks the ability to minimize/restore the window from the taskbar for reasons that we dont understand.
            var threadedRenderer = Platform.CurrentPlatform != PlatformType.Windows || !Game.Settings.Graphics.DisableWindowsRenderThread;

            if (!threadedRenderer)
            {
                var ctx = new Sdl2GraphicsContext(this);
                ctx.InitializeOpenGL();
                context = ctx;
            }
            else
            {
                context = new ThreadedGraphicsContext(new Sdl2GraphicsContext(this), batchSize);
            }

            context.SetVSyncEnabled(Game.Settings.Graphics.VSync);

            SDL.SDL_SetModState(SDL.SDL_Keymod.KMOD_NONE);
            input = new Sdl2Input();
        }
Ejemplo n.º 55
0
        IntPtr InitializeSdlGl(ref Size size, WindowMode window, string[] requiredExtensions)
        {
            Sdl.SDL_Init(Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_RED_SIZE, 8);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_GREEN_SIZE, 8);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_BLUE_SIZE, 8);
            Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_ALPHA_SIZE, 0);

            int windowFlags = 0;
            switch (window)
            {
            case WindowMode.Fullscreen:
                windowFlags |= Sdl.SDL_FULLSCREEN;
                break;
            case WindowMode.PseudoFullscreen:
                windowFlags |= Sdl.SDL_NOFRAME;
                Environment.SetEnvironmentVariable("SDL_VIDEO_WINDOW_POS", "0,0");
                break;
            case WindowMode.Windowed:
                Environment.SetEnvironmentVariable("SDL_VIDEO_CENTERED", "1");
                break;
            default:
                break;
            }

            var info = (Sdl.SDL_VideoInfo)Marshal.PtrToStructure(
                Sdl.SDL_GetVideoInfo(), typeof(Sdl.SDL_VideoInfo));
            Console.WriteLine("Desktop resolution: {0}x{1}",
                info.current_w, info.current_h);

            if (size.Width == 0 && size.Height == 0)
            {
                Console.WriteLine("No custom resolution provided, using desktop resolution");
                size = new Size(info.current_w, info.current_h);
            }

            Console.WriteLine("Using resolution: {0}x{1}", size.Width, size.Height);

            var surf = Sdl.SDL_SetVideoMode(size.Width, size.Height, 0, Sdl.SDL_OPENGL | windowFlags);
            if (surf == IntPtr.Zero)
                Console.WriteLine("Failed to set video mode.");

            Sdl.SDL_WM_SetCaption("OpenRA", "OpenRA");
            Sdl.SDL_ShowCursor(0);
            Sdl.SDL_EnableUNICODE(1);
            Sdl.SDL_EnableKeyRepeat(Sdl.SDL_DEFAULT_REPEAT_DELAY, Sdl.SDL_DEFAULT_REPEAT_INTERVAL);

            ErrorHandler.CheckGlError();

            var extensions = Gl.glGetString(Gl.GL_EXTENSIONS);
            if (extensions == null)
                Console.WriteLine("Failed to fetch GL_EXTENSIONS, this is bad.");

            var missingExtensions = requiredExtensions.Where(r => !extensions.Contains(r)).ToArray();

            if (missingExtensions.Any())
            {
                ErrorHandler.WriteGraphicsLog("Unsupported GPU: Missing extensions: {0}"
                    .F(missingExtensions.JoinWith(",")));
                throw new InvalidProgramException("Unsupported GPU. See graphics.log for details.");
            }

            return surf;
        }
Ejemplo n.º 56
0
        static IGraphicsDevice CreateDevice(Assembly rendererDll, int width, int height, WindowMode window)
        {
            foreach (RendererAttribute r in rendererDll.GetCustomAttributes(typeof(RendererAttribute), false))
            {
                var factory = (IDeviceFactory)r.Type.GetConstructor(Type.EmptyTypes).Invoke(null);
                return(factory.Create(new Size(width, height), window));
            }

            throw new InvalidOperationException("Renderer DLL is missing RendererAttribute to tell us what type to use!");
        }
Ejemplo n.º 57
0
		public IGraphicsDevice CreateGraphics(Size size, WindowMode windowMode)
		{
			return new NullGraphicsDevice(size, windowMode);
		}
Ejemplo n.º 58
0
        /// <summary>
        /// ウィンドウ名と画像の表示モードを指定して初期化
        /// </summary>
        /// <param name="name">ウィンドウの識別に用いられるウィンドウ名で,ウィンドウのタイトルバ ーに表示される.</param>
        /// <param name="flags">ウィンドウのフラグ</param>
#else
        /// <summary>
        /// Creates a window
        /// </summary>
        /// <param name="name">Name of the window which is used as window identifier and appears in the window caption. </param>
        /// <param name="flags">Flags of the window. Currently the only supported flag is WindowMode.AutoSize.
        /// If it is set, window size is automatically adjusted to fit the displayed image (see cvShowImage), while user can not change the window size manually. </param>
#endif
        public Window(string name, WindowMode flags)
            : this(name, flags, null)
        {
        }
Ejemplo n.º 59
0
		public View3DWidget(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, Vector2 bedCenter, MeshViewerWidget.BedShape bedShape, WindowMode windowType, AutoRotate autoRotate, OpenMode openMode = OpenMode.Viewing)
		{
			this.openMode = openMode;
			this.windowType = windowType;
			allowAutoRotate = (autoRotate == AutoRotate.Enabled);
			autoRotating = allowAutoRotate;
			MeshGroupExtraData = new List<PlatingMeshGroupData>();
			MeshGroupExtraData.Add(new PlatingMeshGroupData());

			this.printItemWrapper = printItemWrapper;

			FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
			mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

			FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
			centerPartPreviewAndControls.Name = "centerPartPreviewAndControls";
			centerPartPreviewAndControls.AnchorAll();

			GuiWidget viewArea = new GuiWidget();
			viewArea.AnchorAll();
			{
				meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "Press 'Add' to select an item.".Localize());

				PutOemImageOnBed();

				meshViewerWidget.AnchorAll();
			}
			viewArea.AddChild(meshViewerWidget);

			centerPartPreviewAndControls.AddChild(viewArea);
			mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);

			FlowLayoutWidget buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);
			buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight;
			buttonBottomPanel.Padding = new BorderDouble(3, 3);
			buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			buttonRightPanel = CreateRightButtonPanel(viewerVolume.y);
			buttonRightPanel.Name = "buttonRightPanel";
			buttonRightPanel.Visible = false;

			CreateOptionsContent();

			// add in the plater tools
			{
				FlowLayoutWidget editToolBar = new FlowLayoutWidget();

				string progressFindPartsLabel = "Entering Editor".Localize();
				string progressFindPartsLabelFull = "{0}:".FormatWith(progressFindPartsLabel);

				processingProgressControl = new ProgressControl(progressFindPartsLabelFull, ActiveTheme.Instance.PrimaryTextColor, ActiveTheme.Instance.PrimaryAccentColor);
				processingProgressControl.VAnchor = Agg.UI.VAnchor.ParentCenter;
				editToolBar.AddChild(processingProgressControl);
				editToolBar.VAnchor |= Agg.UI.VAnchor.ParentCenter;
				processingProgressControl.Visible = false;

				// If the window is embeded (in the center pannel) and there is no item loaded then don't show the add button
				enterEditButtonsContainer = new FlowLayoutWidget();
				{
					Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
					addButton.ToolTipText = "Insert an .stl, .amf or .zip file".Localize();
					addButton.Margin = new BorderDouble(right: 0);
					enterEditButtonsContainer.AddChild(addButton);
					addButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							DoAddFileAfterCreatingEditData = true;
							EnterEditAndCreateSelectionData();
						});
					};
					if (printItemWrapper != null 
						&& printItemWrapper.PrintItem.ReadOnly)
					{
						addButton.Enabled = false;
					}

					Button enterEdittingButton = textImageButtonFactory.Generate("Edit".Localize(), "icon_edit_32x32.png");
					enterEdittingButton.Margin = new BorderDouble(right: 4);
					enterEdittingButton.Click += (sender, e) =>
					{
						EnterEditAndCreateSelectionData();
					};
					
					if (printItemWrapper != null 
						&& printItemWrapper.PrintItem.ReadOnly)
					{
						enterEdittingButton.Enabled = false;
					}

					Button exportButton = textImageButtonFactory.Generate("Export...".Localize());
					if (printItemWrapper != null && 
						(printItemWrapper.PrintItem.Protected || printItemWrapper.PrintItem.ReadOnly))
					{
						exportButton.Enabled = false;
					}

					exportButton.Margin = new BorderDouble(right: 10);
					exportButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							OpenExportWindow();
						});
					};

					enterEditButtonsContainer.AddChild(enterEdittingButton);
					enterEditButtonsContainer.AddChild(exportButton);
				}
				editToolBar.AddChild(enterEditButtonsContainer);

				doEdittingButtonsContainer = new FlowLayoutWidget();
				doEdittingButtonsContainer.Visible = false;

				{
					Button addButton = textImageButtonFactory.Generate("Insert".Localize(), "icon_insert_32x32.png");
					addButton.Margin = new BorderDouble(right: 10);
					doEdittingButtonsContainer.AddChild(addButton);
					addButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							FileDialog.OpenFileDialog(
								new OpenFileDialogParams(ApplicationSettings.OpenDesignFileParams, multiSelect: true),
								(openParams) =>
								{
									LoadAndAddPartsToPlate(openParams.FileNames);
								});
						});
					};

					GuiWidget separator = new GuiWidget(1, 2);
					separator.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separator.Margin = new BorderDouble(4, 2);
					separator.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separator);

					Button ungroupButton = textImageButtonFactory.Generate("Ungroup".Localize());
					doEdittingButtonsContainer.AddChild(ungroupButton);
					ungroupButton.Click += (sender, e) =>
					{
						UngroupSelectedMeshGroup();
					};

					Button groupButton = textImageButtonFactory.Generate("Group".Localize());
					doEdittingButtonsContainer.AddChild(groupButton);
					groupButton.Click += (sender, e) =>
					{
						GroupSelectedMeshs();
					};

					Button alignButton = textImageButtonFactory.Generate("Align".Localize());
					doEdittingButtonsContainer.AddChild(alignButton);
					alignButton.Click += (sender, e) =>
					{
						AlignToSelectedMeshGroup();
					};

					Button arrangeButton = textImageButtonFactory.Generate("Arrange".Localize());
					doEdittingButtonsContainer.AddChild(arrangeButton);
					arrangeButton.Click += (sender, e) =>
					{
						AutoArrangePartsInBackground();
					};

					GuiWidget separatorTwo = new GuiWidget(1, 2);
					separatorTwo.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separatorTwo.Margin = new BorderDouble(4, 2);
					separatorTwo.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separatorTwo);

					Button copyButton = textImageButtonFactory.Generate("Copy".Localize());
					doEdittingButtonsContainer.AddChild(copyButton);
					copyButton.Click += (sender, e) =>
					{
						MakeCopyOfGroup();
					};

					Button deleteButton = textImageButtonFactory.Generate("Remove".Localize());
					doEdittingButtonsContainer.AddChild(deleteButton);
					deleteButton.Click += (sender, e) =>
					{
						DeleteSelectedMesh();
					};

					GuiWidget separatorThree = new GuiWidget(1, 2);
					separatorThree.BackgroundColor = ActiveTheme.Instance.PrimaryTextColor;
					separatorThree.Margin = new BorderDouble(4, 1);
					separatorThree.VAnchor = VAnchor.ParentBottomTop;
					doEdittingButtonsContainer.AddChild(separatorThree);

					Button leaveEditModeButton = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true);
					leaveEditModeButton.Click += (sender, e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							if (saveButtons.Visible)
							{
								StyledMessageBox.ShowMessageBox(ExitEditingAndSaveIfRequired, "Would you like to save your changes before exiting the editor?", "Save Changes", StyledMessageBox.MessageType.YES_NO);
							}
							else
							{
								if (partHasBeenEdited)
								{
									ExitEditingAndSaveIfRequired(false);
								}
								else
								{
									SwitchStateToNotEditing();
								}
							}
						});
					};
					doEdittingButtonsContainer.AddChild(leaveEditModeButton);

					// put in the save button
					AddSaveAndSaveAs(doEdittingButtonsContainer);
				}

				KeyDown += (sender, e) =>
				{
					KeyEventArgs keyEvent = e as KeyEventArgs;
					if (keyEvent != null && !keyEvent.Handled)
					{
						if (keyEvent.KeyCode == Keys.Delete || keyEvent.KeyCode == Keys.Back)
						{
							DeleteSelectedMesh();
						}

						if (keyEvent.KeyCode == Keys.Escape)
						{
							if (meshSelectInfo.downOnPart)
							{
								meshSelectInfo.downOnPart = false;

								ScaleRotateTranslate translated = SelectedMeshGroupTransform;
								translated.translation = transformOnMouseDown;
								SelectedMeshGroupTransform = translated;

								Invalidate();
							}
						}
					}
				};

				editToolBar.AddChild(doEdittingButtonsContainer);
				buttonBottomPanel.AddChild(editToolBar);
			}

			GuiWidget buttonRightPanelHolder = new GuiWidget(HAnchor.FitToChildren, VAnchor.ParentBottomTop);
			buttonRightPanelHolder.Name = "buttonRightPanelHolder";
			centerPartPreviewAndControls.AddChild(buttonRightPanelHolder);
			buttonRightPanelHolder.AddChild(buttonRightPanel);

			viewControls3D = new ViewControls3D(meshViewerWidget);

			buttonRightPanelDisabledCover = new Cover(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
			buttonRightPanelDisabledCover.BackgroundColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryBackgroundColor, 150);
			buttonRightPanelHolder.AddChild(buttonRightPanelDisabledCover);

			viewControls3D.PartSelectVisible = false;
			LockEditControls();

			GuiWidget leftRightSpacer = new GuiWidget();
			leftRightSpacer.HAnchor = HAnchor.ParentLeftRight;
			buttonBottomPanel.AddChild(leftRightSpacer);

			if (windowType == WindowMode.StandAlone)
			{
				Button closeButton = textImageButtonFactory.Generate("Close".Localize());
				buttonBottomPanel.AddChild(closeButton);
				closeButton.Click += (sender, e) =>
				{
					CloseOnIdle();
				};
			}

			mainContainerTopToBottom.AddChild(buttonBottomPanel);

			this.AddChild(mainContainerTopToBottom);
			this.AnchorAll();

			meshViewerWidget.TrackballTumbleWidget.TransformState = TrackBallController.MouseDownType.Rotation;
			AddChild(viewControls3D);

			AddHandlers();

			UiThread.RunOnIdle(AutoSpin);

			if (printItemWrapper == null && windowType == WindowMode.Embeded)
			{
				enterEditButtonsContainer.Visible = false;
			}

			if (windowType == WindowMode.Embeded)
			{
				PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(SetEditControlsBasedOnPrinterState, ref unregisterEvents);
				if (windowType == WindowMode.Embeded)
				{
					// make sure we lock the controls if we are printing or paused
					switch (PrinterConnectionAndCommunication.Instance.CommunicationState)
					{
						case PrinterConnectionAndCommunication.CommunicationStates.Printing:
						case PrinterConnectionAndCommunication.CommunicationStates.Paused:
							LockEditControls();
							break;
					}
				}
			}

			ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);

			upArrow = new UpArrow3D(this);
			heightDisplay = new HeightValueDisplay(this);
			heightDisplay.Visible = false;
			meshViewerWidget.interactionVolumes.Add(upArrow);

			// make sure the colors are set correctl
			ThemeChanged(this, null);

			saveButtons.VisibleChanged += (sender, e) =>
			{
				partHasBeenEdited = true;
			};
		}
Ejemplo n.º 60
0
        /// <summary>
        /// 適当なウィンドウ名で、画像の表示モードを指定して初期化
        /// </summary>
        /// <param name="flags">ウィンドウのフラグ</param>
        /// <param name="image">ウィンドウに表示する画像</param>
#else
        /// <summary>
        /// Creates a window with a specified image and flag
        /// </summary>
        /// <param name="flags">Flags of the window. Currently the only supported flag is WindowMode.AutoSize.
        /// If it is set, window size is automatically adjusted to fit the displayed image (see cvShowImage), while user can not change the window size manually. </param>
        /// <param name="image"></param>
#endif
        public Window(WindowMode flags, Mat image)
            : this(DefaultName(), flags, image)
        {
        }