示例#1
0
        public GameWindowArgs(GameWindowArgs args)
        {
            CreateWindow = args.CreateWindow;

            WindowWidth  = args.WindowWidth;
            WindowHeight = args.WindowHeight;

            WindowTitle = args.WindowTitle;
            WindowStyle = args.WindowStyle;

            WaitForWindow = args.WaitForWindow;
            WindowPointer = args.WindowPointer;
        }
示例#2
0
        // Constructor(s)
        internal GameWindow(GameWindowArgs args)
        {
            // Window (Create a new /or/ Render to existing)
            if (args.CreateWindow)
            {
                // Create window
                _window = new ExposedWindow(new VideoMode(args.WindowWidth, args.WindowHeight),
                                            args.WindowTitle,
                                            args.WindowStyle);
                _window.SetFocus();

                // Focus on click
                MouseButtonPressed += new EventHandler <SFMLMouseButtonEventArgs>(delegate
                {
                    if (!_focused)
                    {
                        _window.SetFocus();
                    }
                });
            }
            else
            {
                // Render to existing
                _window = new ExposedWindow(args.WindowPointer);
            }

            // Window is focused (so set focus to true)
            _focused = true;

            // Set window settings
            _window.SetVerticalSyncEnabled(false);
            _window.SetFramerateLimit(0u);
            _window.SetActive(true);

            // Set up EventHandlers
            _gainedFocus += new EventHandler(delegate { _focused = true; });
            _lostFocus   += new EventHandler(delegate { _focused = false; });
            _shutWindow  += new EventHandler <EventArgs>(delegate { _open = false; });

            // Apply EventHandlers to window
            _window.GainedFocus += _gainedFocus;
            _window.LostFocus   += _lostFocus;
            _window.Shut        += _shutWindow;
        }