예제 #1
0
        public Window(WindowOptions options)
        {
            if (Application.MainWindow != null)
            {
                throw new Lime.Exception("Attempt to set Application.MainWindow twice");
            }
            Application.MainWindow = this;
            Active     = true;
            fpsCounter = new FPSCounter();
            input      = new Input();

            UnityApplicationDelegate.Instance.Updating += delta => {
                Input.Refresh();
                RaiseUpdating(delta);
                AudioSystem.Update();
                Input.TextInput = null;
                Input.CopyKeysState();
                if (LastSize != ClientSize)
                {
                    RaiseResized(false);
                    LastSize = ClientSize;
                }
            };
            UnityApplicationDelegate.Instance.Rendering += () => {
                RaiseRendering();
                fpsCounter.Refresh();
            };
            UnityApplicationDelegate.Instance.Destroying += () => {
                RaiseClosed();
            };
        }
예제 #2
0
        public Window(WindowOptions options)
        {
            if (Application.MainWindow != null)
            {
                throw new Lime.Exception("Attempt to set Application.MainWindow twice");
            }
            Application.MainWindow = this;
            Active     = true;
            fpsCounter = new FPSCounter();
            ActivityDelegate.Instance.Paused += activity => {
                Active = false;
                RaiseDeactivated();
            };
            ActivityDelegate.Instance.Resumed += activity => {
                Active = true;
                RaiseActivated();
            };
            ActivityDelegate.Instance.GameView.Resize += (sender, e) => {
                RaiseResized(((ResizeEventArgs)e).DeviceRotated);
            };
            ActivityDelegate.Instance.GameView.RenderFrame += (sender, e) => {
                RaiseRendering();
                fpsCounter.Refresh();
            };
            ActivityDelegate.Instance.GameView.UpdateFrame += (sender, e) => {
                RaiseUpdating((float)e.Time);
            };

            PixelScale = Resources.System.DisplayMetrics.Density;
        }
예제 #3
0
        public Window(WindowOptions options)
        {
            if (Application.MainWindow != null)
            {
                throw new Lime.Exception("Attempt to set Application.MainWindow twice");
            }
            Application.MainWindow = this;
            Input          = new WindowInput(this);
            Active         = true;
            AsyncRendering = options.AsyncRendering;
            fpsCounter     = new FPSCounter();
            ActivityDelegate.Instance.Paused += activity => {
                Active = false;
                RaiseDeactivated();
            };
            ActivityDelegate.Instance.Resumed += activity => {
                Active = true;
                RaiseActivated();
            };
            ActivityDelegate.Instance.GameView.Resize += (sender, e) => {
                RaiseResized(((ResizeEventArgs)e).DeviceRotated);
            };

            PixelScale = Resources.System.DisplayMetrics.Density;

            if (AsyncRendering)
            {
                renderThread = new Thread(RenderLoop);
                renderThread.IsBackground = true;
                renderThread.Start();
            }

            Application.WindowUnderMouse = this;

            var  ccb           = new ChoreographerCallback();
            long prevFrameTime = Java.Lang.JavaSystem.NanoTime();

            ccb.OnFrame += frameTimeNanos => {
                var delta = (float)((frameTimeNanos - prevFrameTime) / 1000000000d);
                prevFrameTime = frameTimeNanos;
                if (Active && ActivityDelegate.Instance.GameView.IsSurfaceCreated)
                {
                    fpsCounter.Refresh();
                    Update(delta);
                    if (AsyncRendering)
                    {
                        renderCompleted.WaitOne();
                        renderCompleted.Reset();
                        RaiseSync();
                        renderReady.Set();
                    }
                    else
                    {
                        RaiseSync();
                        Render();
                    }
                }
            };
            Choreographer.Instance.PostFrameCallback(ccb);
        }
예제 #4
0
 public Window(WindowOptions options)
 {
     fpsCounter = new FPSCounter();
     CreateNativeWindow(options);
     if (Application.MainWindow == null)
     {
         Application.MainWindow = this;
     }
     Application.Windows.Add(this);
     Input      = new WindowInput(this);
     ClientSize = options.ClientSize;
     Title      = options.Title;
     if (options.Visible)
     {
         Visible = true;
     }
     if (options.Centered)
     {
         Center();
     }
     if (options.Type == WindowType.ToolTip)
     {
         window.Level = NSWindowLevel.Floating;
     }
     stopwatch = new Stopwatch();
     stopwatch.Start();
 }
예제 #5
0
 public Window(WindowOptions options)
 {
     Input      = new Input();
     fpsCounter = new FPSCounter();
     CreateNativeWindow(options);
     if (Application.MainWindow == null)
     {
         Application.MainWindow = this;
     }
     Application.Windows.Add(this);
     ClientSize = options.ClientSize;
     Title      = options.Title;
     if (options.Visible)
     {
         Visible = true;
     }
     if (options.Centered)
     {
         Center();
     }
     stopwatch = new Stopwatch();
     stopwatch.Start();
 }