Ejemplo n.º 1
0
 public override void InitApp(XNAContext context, GL gl)
 {
     if (m_process == null)
     {
         m_process = new LProcess(this, context._width, context._height);
     }
     m_process.Load(gl);
     Printf("initApp");
 }
Ejemplo n.º 2
0
 public Screen()
 {
     LSystem.AUTO_REPAINT = true;
     Screen.StaticCurrentSceen = this;
     this.runnables = new List<Runnable>(1);
     this.handler = LSystem.screenProcess;
     this.width = LSystem.screenRect.width;
     this.height = LSystem.screenRect.height;
     this.halfWidth = width / 2;
     this.halfHeight = height / 2;
     this.fristOrder = DRAW_USER_PAINT();
     this.secondOrder = DRAW_SPRITE_PAINT();
     this.lastOrder = DRAW_DESKTOP_PAINT();
     this.fristPaintFlag = true;
     this.secondPaintFlag = true;
     this.lastPaintFlag = true;
 }
Ejemplo n.º 3
0
 public override void CreateApp(GL gl, int width, int height)
 {
     if (LSystem.screenRect != null)
     {
         LSystem.screenRect.SetBounds(0, 0, width, height);
     }
     else
     {
         LSystem.screenRect = new RectBox(0, 0, width, height);
     }
     if (m_process == null)
     {
         m_process = new LProcess(this, width, height);
     }
     m_process.Load(gl);
     LSystem.screenProcess = m_process;
 }
Ejemplo n.º 4
0
        public void Initialization(bool l,
                bool f, LMode m)
        {
            log.I("GPU surface");

            this.landscape = l;
            this.fullScreen = f;
            this.mode = m;

            if (landscape == false)
            {
                if (LSystem.MAX_SCREEN_HEIGHT > LSystem.MAX_SCREEN_WIDTH)
                {
                    int tmp_height = LSystem.MAX_SCREEN_HEIGHT;
                    LSystem.MAX_SCREEN_HEIGHT = LSystem.MAX_SCREEN_WIDTH;
                    LSystem.MAX_SCREEN_WIDTH = tmp_height;
                }
            }

            this.CheckDisplayMode();

            RectBox d = GetScreenDimension();

            LSystem.SCREEN_LANDSCAPE = landscape;

            this.maxWidth = (int)d.GetWidth();
            this.maxHeight = (int)d.GetHeight();

            if (landscape && (d.GetWidth() > d.GetHeight()))
            {
                maxWidth = (int)d.GetWidth();
                maxHeight = (int)d.GetHeight();
            }
            else if (landscape && (d.GetWidth() < d.GetHeight()))
            {
                maxHeight = (int)d.GetWidth();
                maxWidth = (int)d.GetHeight();
            }
            else if (!landscape && (d.GetWidth() < d.GetHeight()))
            {
                maxWidth = (int)d.GetWidth();
                maxHeight = (int)d.GetHeight();
            }
            else if (!landscape && (d.GetWidth() > d.GetHeight()))
            {
                maxHeight = (int)d.GetWidth();
                maxWidth = (int)d.GetHeight();
            }

            if (mode != LMode.Max)
            {
                if (landscape)
                {
                    this.width = LSystem.MAX_SCREEN_WIDTH;
                    this.height = LSystem.MAX_SCREEN_HEIGHT;
                }
                else
                {
                    this.width = LSystem.MAX_SCREEN_HEIGHT;
                    this.height = LSystem.MAX_SCREEN_WIDTH;
                }
            }
            else
            {
                if (landscape)
                {
                    this.width = maxWidth >= LSystem.MAX_SCREEN_WIDTH ? LSystem.MAX_SCREEN_WIDTH
                            : maxWidth;
                    this.height = maxHeight >= LSystem.MAX_SCREEN_HEIGHT ? LSystem.MAX_SCREEN_HEIGHT
                            : maxHeight;
                }
                else
                {
                    this.width = maxWidth >= LSystem.MAX_SCREEN_HEIGHT ? LSystem.MAX_SCREEN_HEIGHT
                            : maxWidth;
                    this.height = maxHeight >= LSystem.MAX_SCREEN_WIDTH ? LSystem.MAX_SCREEN_WIDTH
                            : maxHeight;
                }
            }

            if (mode == LMode.Fill)
            {

                LSystem.scaleWidth = ((float)maxWidth) / width;
                LSystem.scaleHeight = ((float)maxHeight) / height;

            }
            else if (mode == LMode.FitFill)
            {

                RectBox res = GraphicsUtils.FitLimitSize(width, height,
                        maxWidth, maxHeight);
                maxWidth = res.width;
                maxHeight = res.height;
                LSystem.scaleWidth = ((float)maxWidth) / width;
                LSystem.scaleHeight = ((float)maxHeight) / height;

            }
            else if (mode == LMode.Ratio)
            {

                maxWidth = MeasureSpec.GetSize(maxWidth);
                maxHeight = MeasureSpec.GetSize(maxHeight);

                float userAspect = (float)width / (float)height;
                float realAspect = (float)maxWidth / (float)maxHeight;

                if (realAspect < userAspect)
                {
                    maxHeight = MathUtils.Round(maxWidth / userAspect);
                }
                else
                {
                    maxWidth = MathUtils.Round(maxHeight * userAspect);
                }

                LSystem.scaleWidth = ((float)maxWidth) / width;
                LSystem.scaleHeight = ((float)maxHeight) / height;

            }
            else if (mode == LMode.MaxRatio)
            {

                maxWidth = MeasureSpec.GetSize(maxWidth);
                maxHeight = MeasureSpec.GetSize(maxHeight);

                float userAspect = (float)width / (float)height;
                float realAspect = (float)maxWidth / (float)maxHeight;

                if ((realAspect < 1 && userAspect > 1)
                        || (realAspect > 1 && userAspect < 1))
                {
                    userAspect = (float)height / (float)width;
                }

                if (realAspect < userAspect)
                {
                    maxHeight = MathUtils.Round(maxWidth / userAspect);
                }
                else
                {
                    maxWidth = MathUtils.Round(maxHeight * userAspect);
                }

                LSystem.scaleWidth = ((float)maxWidth) / width;
                LSystem.scaleHeight = ((float)maxHeight) / height;

            }
            else
            {
                LSystem.scaleWidth = 1;
                LSystem.scaleHeight = 1;
            }

            LSystem.screenRect = new RectBox(0, 0, width, height);

            graphics.PreferredBackBufferFormat = displayMode.Format;
            graphics.PreferredBackBufferWidth = maxWidth;
            graphics.PreferredBackBufferHeight = maxHeight;

            if (landscape)
            {
               graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;
            }
            else
            {
                graphics.SupportedOrientations = DisplayOrientation.Portrait;
            }

            //������Ⱦ����ʾ��ͬ��
            graphics.SynchronizeWithVerticalRetrace = true;
            graphics.PreferMultiSampling = true;

            #if WINDOWS
            graphics.IsFullScreen = false;
            IsMouseVisible = true;
            #elif XBOX || WINDOWS_PHONE
            //ȫ��
            graphics.IsFullScreen = true;
            #endif

            graphics.ApplyChanges();

            base.IsFixedTimeStep = false;

            isFPS = false;

            if (maxFrames <= 0)
            {
                SetFPS(LSystem.DEFAULT_MAX_FPS);
            }

            SetSleepTime(1);

            LSystem.screenActivity = this;
            LSystem.screenProcess = (process = new LProcess(this, width, height));

            StringBuilder sbr = new StringBuilder();
            sbr.Append("Mode:").Append(mode);
            log.I(sbr.ToString());
            sbr.Clear();
            sbr.Append("Width:").Append(width).Append(",Height:" + height);
            log.I(sbr.ToString());
            sbr.Clear();
            sbr.Append("MaxWidth:").Append(maxWidth)
                    .Append(",MaxHeight:" + maxHeight);
            log.I(sbr.ToString());
            sbr.Clear();
            sbr.Append("Scale:").Append(IsScale());
            log.I(sbr.ToString());
        }
Ejemplo n.º 5
0
 public _LoadingScreen(LProcess p, Screen s)
 {
     this.process = p;
     this.screen = s;
 }
Ejemplo n.º 6
0
 public _LoadingScreen(LProcess p, Screen s)
     : base("ProcessThread")
 {
     this.process = p;
     this.screen = s;
 }
Ejemplo n.º 7
0
 public Screen()
 {
     LSystem.AUTO_REPAINT = true;
     Screen.StaticCurrentSceen = this;
     this.log = LogFactory.GetInstance(GetType());
     this.runnables = new List<Runnable>(1);
     this.handler = LSystem.screenProcess;
     this.width = LSystem.screenRect.width;
     this.height = LSystem.screenRect.height;
     this.halfWidth = width / 2;
     this.halfHeight = height / 2;
     this.fristOrder = DRAW_USER;
     this.secondOrder = DRAW_SPRITE;
     this.lastOrder = DRAW_DESKTOP;
     this.fristPaintFlag = true;
     this.secondPaintFlag = true;
     this.lastPaintFlag = true;
     this.SetFPS(GetMaxFPS());
 }
Ejemplo n.º 8
0
        public void OnSensorChanged(LProcess.AccelerometerState e)
        {
            if (isLock || isClose || !isLoad)
            {
                return;
            }

            lock (this)
            {

                long curTime = JavaRuntime.CurrentTimeMillis();

                if ((curTime - lastUpdate) > 30)
                {

                    long diffTime = (curTime - lastUpdate);

                    lastUpdate = curTime;
                    currentX = e.Acceleration.X;
                    currentY = e.Acceleration.Y;
                    currentZ = e.Acceleration.Z;

                    currenForce = Math.Abs(currentX + currentY + currentZ - lastX
                            - lastY - lastZ)
                            / diffTime * 10000;

                    if (currenForce > 500)
                    {
                        OnShakeChanged(currenForce);
                    }

                    float absx = Math.Abs(currentX);
                    float absy = Math.Abs(currentY);
                    float absz = Math.Abs(currentZ);

                    if (LSystem.SCREEN_LANDSCAPE)
                    {

                        // PS:横屏时上下朝向非常容易同左右混淆,暂未发现有效的解决方案(不是无法区分,
                        // 而是横屏操作游戏时用户难以保持水平,而一晃就是【左摇右摆】……) ,所以现阶段横屏只取左右
                        double type = Math.Atan(currentY / currentZ);
                        if (type <= -accelOffset)
                        {
                            if (landscapeUpdate > -accelOffset)
                            {
                                direction = SensorDirection.LEFT;
                            }
                        }
                        else if (type >= accelOffset)
                        {
                            if (landscapeUpdate < accelOffset)
                            {
                                direction = SensorDirection.RIGHT;
                            }
                        }
                        else
                        {
                            if (landscapeUpdate <= -accelOffset)
                            {
                                direction = SensorDirection.LEFT;
                            }
                            else if (landscapeUpdate >= accelOffset)
                            {
                                direction = SensorDirection.RIGHT;
                            }
                        }
                        landscapeUpdate = type;

                    }
                    else
                    {
                        if (absx > absy && absx > absz)
                        {
                            if (currentX > accelOffset)
                            {
                                direction = SensorDirection.LEFT;

                            }
                            else
                            {
                                direction = SensorDirection.RIGHT;
                            }
                        }
                        else if (absz > absx && absz > absy)
                        {
                            if (currentY < -accelOffset)
                            {
                                direction = SensorDirection.DOWN;
                            }
                            else
                            {
                                direction = SensorDirection.UP;
                            }
                        }
                    }
                    lastX = currentX;
                    lastY = currentY;
                    lastZ = currentZ;

                    if (isGravityToKey)
                    {
                        GravityToKey(direction);
                    }

                    OnDirection(direction, currentX, currentY, currentZ);
                }

            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// ����XNA��Դж�غ���(��ֹ����)
 /// </summary>
 public void OnNavigatedFrom(NavigationEventArgs e)
 {
     if (process != null)
     {
         process.End();
         process.OnDestroy();
     }
     if (useXNAListener)
     {
         sl_listener.UnloadContent(GamePage);
     }
     XNA_UnloadContent();
     TargetElapsedTime.Stop();
     try
     {
         SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(false);
         this.Destory();
     }
     catch
     {
     }
     if (process != null)
     {
         process = null;
     }
 }
Ejemplo n.º 10
0
        public void Initialization(bool l,
                bool f, LMode m)
        {
            log.I("GPU surface");

            this.landscape = l;
            this.fullScreen = f;
            this.mode = m;

            if (landscape == false)
            {
                if (LSystem.MAX_SCREEN_HEIGHT > LSystem.MAX_SCREEN_WIDTH)
                {
                    int tmp_height = LSystem.MAX_SCREEN_HEIGHT;
                    LSystem.MAX_SCREEN_HEIGHT = LSystem.MAX_SCREEN_WIDTH;
                    LSystem.MAX_SCREEN_WIDTH = tmp_height;
                }
            }

            this.CheckDisplayMode();

            RectBox d = GetScreenDimension();

            LSystem.SCREEN_LANDSCAPE = landscape;

            this.maxWidth = (int)d.GetWidth();
            this.maxHeight = (int)d.GetHeight();

            if (landscape && (d.GetWidth() > d.GetHeight()))
            {
                maxWidth = (int)d.GetWidth();
                maxHeight = (int)d.GetHeight();
            }
            else if (landscape && (d.GetWidth() < d.GetHeight()))
            {
                maxHeight = (int)d.GetWidth();
                maxWidth = (int)d.GetHeight();
            }
            else if (!landscape && (d.GetWidth() < d.GetHeight()))
            {
                maxWidth = (int)d.GetWidth();
                maxHeight = (int)d.GetHeight();
            }
            else if (!landscape && (d.GetWidth() > d.GetHeight()))
            {
                maxHeight = (int)d.GetWidth();
                maxWidth = (int)d.GetHeight();
            }

            if (mode != LMode.Max)
            {
                if (landscape)
                {
                    this.width = LSystem.MAX_SCREEN_WIDTH;
                    this.height = LSystem.MAX_SCREEN_HEIGHT;
                }
                else
                {
                    this.width = LSystem.MAX_SCREEN_HEIGHT;
                    this.height = LSystem.MAX_SCREEN_WIDTH;
                }
            }
            else
            {
                if (landscape)
                {
                    this.width = maxWidth >= LSystem.MAX_SCREEN_WIDTH ? LSystem.MAX_SCREEN_WIDTH
                            : maxWidth;
                    this.height = maxHeight >= LSystem.MAX_SCREEN_HEIGHT ? LSystem.MAX_SCREEN_HEIGHT
                            : maxHeight;
                }
                else
                {
                    this.width = maxWidth >= LSystem.MAX_SCREEN_HEIGHT ? LSystem.MAX_SCREEN_HEIGHT
                            : maxWidth;
                    this.height = maxHeight >= LSystem.MAX_SCREEN_WIDTH ? LSystem.MAX_SCREEN_WIDTH
                            : maxHeight;
                }
            }

            if (mode == LMode.Fill)
            {

                LSystem.scaleWidth = ((float)maxWidth) / width;
                LSystem.scaleHeight = ((float)maxHeight) / height;

            }
            else if (mode == LMode.FitFill)
            {

                RectBox res = GraphicsUtils.FitLimitSize(width, height,
                        maxWidth, maxHeight);
                maxWidth = res.width;
                maxHeight = res.height;
                LSystem.scaleWidth = ((float)maxWidth) / width;
                LSystem.scaleHeight = ((float)maxHeight) / height;

            }
            else if (mode == LMode.Ratio)
            {

                maxWidth = MeasureSpec.GetSize(maxWidth);
                maxHeight = MeasureSpec.GetSize(maxHeight);

                float userAspect = (float)width / (float)height;
                float realAspect = (float)maxWidth / (float)maxHeight;

                if (realAspect < userAspect)
                {
                    maxHeight = MathUtils.Round(maxWidth / userAspect);
                }
                else
                {
                    maxWidth = MathUtils.Round(maxHeight * userAspect);
                }

                LSystem.scaleWidth = ((float)maxWidth) / width;
                LSystem.scaleHeight = ((float)maxHeight) / height;

            }
            else if (mode == LMode.MaxRatio)
            {

                maxWidth = MeasureSpec.GetSize(maxWidth);
                maxHeight = MeasureSpec.GetSize(maxHeight);

                float userAspect = (float)width / (float)height;
                float realAspect = (float)maxWidth / (float)maxHeight;

                if ((realAspect < 1 && userAspect > 1)
                        || (realAspect > 1 && userAspect < 1))
                {
                    userAspect = (float)height / (float)width;
                }

                if (realAspect < userAspect)
                {
                    maxHeight = MathUtils.Round(maxWidth / userAspect);
                }
                else
                {
                    maxWidth = MathUtils.Round(maxHeight * userAspect);
                }

                LSystem.scaleWidth = ((float)maxWidth) / width;
                LSystem.scaleHeight = ((float)maxHeight) / height;

            }
            else
            {
                LSystem.scaleWidth = 1;
                LSystem.scaleHeight = 1;
            }

            if (landscape)
            {
                GamePage.Orientation = Microsoft.Phone.Controls.PageOrientation.Landscape | Microsoft.Phone.Controls.PageOrientation.LandscapeLeft | Microsoft.Phone.Controls.PageOrientation.LandscapeRight;
                GamePage.SupportedOrientations = Microsoft.Phone.Controls.SupportedPageOrientation.Landscape;
            }
            else
            {
                GamePage.Orientation = Microsoft.Phone.Controls.PageOrientation.Portrait | Microsoft.Phone.Controls.PageOrientation.PortraitDown | Microsoft.Phone.Controls.PageOrientation.PortraitUp;
                GamePage.SupportedOrientations = Microsoft.Phone.Controls.SupportedPageOrientation.Portrait;
            }

            LSystem.screenRect = new RectBox(0, 0, width, height);

            graphics.PreferredBackBufferFormat = displayMode.Format;
            graphics.PreferredBackBufferWidth = maxWidth;
            graphics.PreferredBackBufferHeight = maxHeight;

            if (GamePage != null)
            {
                UIElementRenderer = new UIElementRenderer(GamePage, maxWidth, maxHeight);
            }

            //������Ⱦ����ʾ��ͬ��
            graphics.SynchronizeWithVerticalRetrace = true;

            graphics.ApplyChanges();

            isFPS = false;

            if (maxFrames <= 0)
            {
                SetFPS(LSystem.DEFAULT_MAX_FPS);
            }

            LSystem.screenActivity = this;
            LSystem.screenProcess = (process = new LProcess(this, width, height));

            StringBuilder sbr = new StringBuilder();
            sbr.Append("Mode:").Append(mode);
            log.I(sbr.ToString());
            sbr.Clear();
            sbr.Append("Width:").Append(width).Append(",Height:" + height);
            log.I(sbr.ToString());
            sbr.Clear();
            sbr.Append("MaxWidth:").Append(maxWidth)
                    .Append(",MaxHeight:" + maxHeight);
            log.I(sbr.ToString());
            sbr.Clear();
            sbr.Append("Scale:").Append(IsScale());
            log.I(sbr.ToString());

            if (GamePage != null)
            {
                GamePage.Background = null;
                GamePage.Foreground = null;
                GamePage.Style = null;
                GamePage.AllowDrop = false;
                GamePage.Visibility = System.Windows.Visibility.Collapsed;
                /*System.Windows.Interop.Settings settings = new System.Windows.Interop.Settings();
                settings.EnableFrameRateCounter = true;
                settings.EnableCacheVisualization = true;
                settings.EnableRedrawRegions = true;
                settings.MaxFrameRate = maxFrames;
                System.Windows.Media.BitmapCache cache = new System.Windows.Media.BitmapCache();
                cache.RenderAtScale = 1;
                GamePage.CacheMode = cache;*/
                GamePage.Opacity = 1f;
            }
        }