private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            // Set window bounds in dips
            m_d3dBackground.WindowBounds = new Windows.Foundation.Size(
                (float)Application.Current.Host.Content.ActualWidth,
                (float)Application.Current.Host.Content.ActualHeight
                );

            // Set native resolution in pixels
            m_d3dBackground.NativeResolution = new Windows.Foundation.Size(
                (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                );

            // Set render resolution to the full native resolution
            m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution;

            // Hook-up native component to DrawingSurface
            if (m_d3dContentProvider == null)
            {
                m_d3dContentProvider = m_d3dBackground.CreateContentProvider();
            }
            // Hook-up native component to DrawingSurfaceBackgroundGrid
            DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dContentProvider);
            DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dBackground);
        }
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_d3dInterop == null)
            {
                PageOrientation     pageOrientation    = (PageOrientation)GetValue(OrientationProperty);
                DisplayOrientations displayOrientation = ConvertToNativeOrientation(pageOrientation);

                m_d3dInterop = new Direct3DInterop(displayOrientation);

                // Set WindowBounds to size of DrawingSurface
                m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
                    (float)Application.Current.Host.Content.ActualWidth,
                    (float)Application.Current.Host.Content.ActualHeight
                    );

                // Hook-up native component to DrawingSurfaceBackgroundGrid
                DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop);

                // Hook-up Cocos2d-x delegates
                m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent);
                m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent);
                m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox);
                m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL);
            }
        }
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            // Set window bounds in dips
            m_d3dBackground.WindowBounds = new Windows.Foundation.Size(
                (float)Application.Current.Host.Content.ActualWidth,
                (float)Application.Current.Host.Content.ActualHeight
                );

            // Set native resolution in pixels
            m_d3dBackground.NativeResolution = new Windows.Foundation.Size(
                (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                );

            // Set render resolution to the full native resolution
            m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution;

            // Hook-up native component to DrawingSurfaceBackgroundGrid
            DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dBackground.CreateContentProvider());
            DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dBackground);

            string orientation_str = null;

            NavigationContext.QueryString.TryGetValue("orientation", out orientation_str);
            orientation = int.Parse(orientation_str);

            if (orientation_str != null)
            {
                this.m_d3dBackground.ChangeOrientation(orientation);
            }
        }
Beispiel #4
0
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_d3dInterop == null)
            {
                m_d3dInterop = new Direct3DInterop();

                // Set WindowBounds to size of DrawingSurface
                m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
                    (float)Application.Current.Host.Content.ActualWidth,
                    (float)Application.Current.Host.Content.ActualHeight
                    );

                // Hook-up native component to DrawingSurfaceBackgroundGrid
                DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop);

                // Set the preferred device orientation
                m_d3dInterop.WindowOrientation = DisplayOrientations.Landscape;

                // Hook-up Cocos2d-x delegates
                m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent);
                m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent);
                m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox);
            }
        }
Beispiel #5
0
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_d3dBackground == null)
            {
                m_d3dBackground = new Direct3DBackground();

                // Définir les limites de la fenêtre en pixels indépendants du périphérique
                m_d3dBackground.WindowBounds = new Windows.Foundation.Size(
                    (float)Application.Current.Host.Content.ActualWidth,
                    (float)Application.Current.Host.Content.ActualHeight
                    );

                // Définir la résolution native en pixels
                m_d3dBackground.NativeResolution = new Windows.Foundation.Size(
                    (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                    (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                    );

                // Définir la résolution de rendu sur la résolution native complète
                m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution;

                // Raccorder le composant natif à DrawingSurfaceBackgroundGrid
                DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dBackground.CreateContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dBackground);
            }
        }
Beispiel #6
0
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (_background == null)
            {
                _background = new Direct3DBackground();
                _background.DeviceRotation = _rot;

                // Set window bounds in dips
                _background.WindowBounds = new Windows.Foundation.Size(
                    (float)Application.Current.Host.Content.ActualWidth,
                    (float)Application.Current.Host.Content.ActualHeight
                    );

                // Set native resolution in pixels
                _background.NativeResolution = new Windows.Foundation.Size(
                    (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                    (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                    );

                // Set render resolution to the full native resolution
                _background.RenderResolution = _background.NativeResolution;

                // Hook-up native component to DrawingSurfaceBackgroundGrid
                DrawingSurfaceBackground.SetBackgroundContentProvider(_background.CreateContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(_background);

                _background.PostToUIThread   = PostToUIThread;
                _background.ActivateKeyboard = ActivateKeyboard;
            }
        }
        public void Dispose()
        {
            if (isDisposed == false)
            {
                Interop.ConnectEvent    -= m_d3dInterop_ConnectEvent;
                Interop.DisconnectEvent -= m_d3dInterop_DisconnectEvent;
                isDisposed = true;
                restoreActions.PerformAction(item => item());

                try
                {
                    DrawingSurfaceBackground.SetBackgroundContentProvider(null);
                    DrawingSurfaceBackground.SetBackgroundManipulationHandler(null);
                }
                catch (Exception e)
                {
                    e.Log("SetBackgroundContentProvider");
                }


                while (sprites.Any())
                {
                    sprites.First().Dispose();
                }
                Interop = null;
            }
        }
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_unityStartedLoading)
            {
                _unityStartedLoading = true;

                UnityApp.SetLoadedCallback(() => { Dispatcher.BeginInvoke(Unity_Loaded); });

                int    physicalWidth, physicalHeight;
                object physicalResolution;

                var content      = Application.Current.Host.Content;
                var nativeWidth  = (int)Math.Floor(content.ActualWidth * content.ScaleFactor / 100.0 + 0.5);
                var nativeHeight = (int)Math.Floor(content.ActualHeight * content.ScaleFactor / 100.0 + 0.5);

                if (DeviceExtendedProperties.TryGetValue("PhysicalScreenResolution", out physicalResolution))
                {
                    var resolution = (System.Windows.Size)physicalResolution;

                    physicalWidth  = (int)resolution.Width;
                    physicalHeight = (int)resolution.Height;
                }
                else
                {
                    physicalWidth  = nativeWidth;
                    physicalHeight = nativeHeight;
                }

                UnityApp.SetNativeResolution(nativeWidth, nativeHeight);
                UnityApp.SetRenderResolution(physicalWidth, physicalHeight);
                UnityPlayer.UnityApp.SetOrientation((int)Orientation);

                DrawingSurfaceBackground.SetBackgroundContentProvider(UnityApp.GetBackgroundContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(UnityApp.GetManipulationHandler());
                if (isShowAds == 1)
                {
                    bannerAd = new AdView
                    {
                        Format   = AdFormats.Banner,
                        AdUnitID = "ca-app-pub-6844968633010430/8322003504"
                    };

                    bannerAd.FailedToReceiveAd += OnFailedToReceiveAd;
                    bannerAd.ReceivedAd        += OnReceivedAd;
                    AdRequest adRequest = new AdRequest();
                    //adRequest.ForceTesting = true;//here rem here
                    adGridAdmob.Children.Add(bannerAd);
                    bannerAd.LoadAd(adRequest);//hinh nh cai nay thua. Can kiem tra lai
                    // toanstt_Refresh_admob();
                }
            }
        }
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_d3dInterop == null)
            {
                PageOrientation     pageOrientation = (PageOrientation)GetValue(OrientationProperty);
                DisplayOrientations displayOrientation;

                switch (pageOrientation)
                {
                case PageOrientation.Portrait:
                case PageOrientation.PortraitUp:
                    displayOrientation = DisplayOrientations.Portrait;
                    break;

                case PageOrientation.PortraitDown:
                    displayOrientation = DisplayOrientations.PortraitFlipped;
                    break;

                case PageOrientation.Landscape:
                case PageOrientation.LandscapeLeft:
                    displayOrientation = DisplayOrientations.Landscape;
                    break;

                case PageOrientation.LandscapeRight:
                    displayOrientation = DisplayOrientations.LandscapeFlipped;
                    break;

                default:
                    displayOrientation = DisplayOrientations.Landscape;
                    break;
                }
                m_d3dInterop = new Direct3DInterop(displayOrientation);

                // Set WindowBounds to size of DrawingSurface
                m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
                    (float)Application.Current.Host.Content.ActualWidth,
                    (float)Application.Current.Host.Content.ActualHeight
                    );

                // Hook-up native component to DrawingSurfaceBackgroundGrid
                DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop);

                // Hook-up Cocos2d-x delegates
                m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent);
                m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent);
                m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox);
                m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL);
            }
        }
Beispiel #10
0
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (d3dBackground == null)
            {
                d3dBackground = new Direct3DBackground();

                d3dBackground.NativeResolution = new Windows.Foundation.Size(
                    (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                    (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                    );
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(d3dBackground);
                DrawingSurfaceBackground.SetBackgroundContentProvider(d3dBackground.CreateContentProvider());
            }
        }
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_unityStartedLoading)
            {
                _unityStartedLoading = true;

                UnityApp.SetLoadedCallback(() => { Dispatcher.BeginInvoke(Unity_Loaded); });

                var content = Application.Current.Host.Content;
                var width   = (int)Math.Floor(content.ActualWidth * content.ScaleFactor / 100.0 + 0.5);
                var height  = (int)Math.Floor(content.ActualHeight * content.ScaleFactor / 100.0 + 0.5);

                UnityApp.SetNativeResolution(width, height);
                UnityApp.SetRenderResolution(width, height);
                UnityPlayer.UnityApp.SetOrientation((int)Orientation);

                DrawingSurfaceBackground.SetBackgroundContentProvider(UnityApp.GetBackgroundContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(UnityApp.GetManipulationHandler());
            }
        }
Beispiel #12
0
        /*
         * private void DrawingSurface_Loaded(object sender, RoutedEventArgs e)
         * {
         *  if (m_d3dInterop == null)
         *  {
         *      m_d3dInterop = new Direct3DInterop();
         *
         *
         *      // Задание границ окна в аппаратно-независимых пикселях (DIP)
         *      m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
         *          (float)DrawingSurface.ActualWidth,
         *          (float)DrawingSurface.ActualHeight
         *          );
         *
         *      // Задание собственного разрешения в пикселях
         *      m_d3dInterop.NativeResolution = new Windows.Foundation.Size(
         *          (float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
         *          (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
         *          );
         *
         *      // Задание для разрешения отрисовки значения полного собственного разрешения
         *      m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution;
         *
         *      // Присоединение собственного компонента к DrawingSurface
         *      DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider());
         *      DrawingSurface.SetManipulationHandler(m_d3dInterop);
         *  }
         * }
         */
        private void DrawingSurfaceBackground_Loaded()
        {
            if (m_d3dInterop == null)
            {
                m_d3dInterop = new Direct3DInterop();

                // Set native resolution in pixels
                m_d3dInterop.NativeResolution = new Windows.Foundation.Size(
                    (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                    (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                    );

                // Set render resolution to the full native resolution
                m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution;


                // Hook-up native component to DrawingSurfaceBackgroundGrid
                DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateBackgroundContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop);
                m_d3dInterop.WindowOrientation = DisplayOrientations.Portrait;
            }
        }
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_unityStartedLoading)
            {
                _unityStartedLoading = true;

                //UnityApp.SetLoadedCallback(() => { Dispatcher.BeginInvoke(Unity_Loaded); });

                var content      = Application.Current.Host.Content;
                var nativeWidth  = (int)Math.Floor(content.ActualWidth * content.ScaleFactor / 100.0 + 0.5);
                var nativeHeight = (int)Math.Floor(content.ActualHeight * content.ScaleFactor / 100.0 + 0.5);

                var    physicalWidth  = nativeWidth;
                var    physicalHeight = nativeHeight;
                object physicalResolution;

                if (DeviceExtendedProperties.TryGetValue("PhysicalScreenResolution", out physicalResolution))
                {
                    var resolution    = (System.Windows.Size)physicalResolution;
                    var nativeScale   = content.ActualHeight / content.ActualWidth;
                    var physicalScale = resolution.Height / resolution.Width;
                    // don't use physical resolution for devices that don't have hardware buttons (e.g. Lumia 630)
                    if (Math.Abs(nativeScale - physicalScale) < 0.01)
                    {
                        physicalWidth  = (int)resolution.Width;
                        physicalHeight = (int)resolution.Height;
                    }
                }

                UnityApp.SetNativeResolution(nativeWidth, nativeHeight);
                UnityApp.SetRenderResolution(physicalWidth, physicalHeight);
                UnityApp.SetOrientation((int)Orientation);

                DrawingSurfaceBackground.SetBackgroundContentProvider(UnityApp.GetBackgroundContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(UnityApp.GetManipulationHandler());
            }
        }
Beispiel #14
0
        private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (!_unityStartedLoading)
            {
                _unityStartedLoading = true;

                UnityApp.SetLoadedCallback(() => { Dispatcher.BeginInvoke(Unity_Loaded); });

                int    physicalWidth, physicalHeight;
                object physicalResolution;

                var content      = Application.Current.Host.Content;
                var nativeWidth  = (int)Math.Floor(content.ActualWidth * content.ScaleFactor / 100.0 + 0.5);
                var nativeHeight = (int)Math.Floor(content.ActualHeight * content.ScaleFactor / 100.0 + 0.5);

                if (DeviceExtendedProperties.TryGetValue("PhysicalScreenResolution", out physicalResolution))
                {
                    var resolution = (System.Windows.Size)physicalResolution;

                    physicalWidth  = (int)resolution.Width;
                    physicalHeight = (int)resolution.Height;
                }
                else
                {
                    physicalWidth  = nativeWidth;
                    physicalHeight = nativeHeight;
                }

                UnityApp.SetNativeResolution(nativeWidth, nativeHeight);
                UnityApp.SetRenderResolution(physicalWidth, physicalHeight);
                UnityPlayer.UnityApp.SetOrientation((int)Orientation);

                DrawingSurfaceBackground.SetBackgroundContentProvider(UnityApp.GetBackgroundContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(UnityApp.GetManipulationHandler());
            }
        }
Beispiel #15
0
        private async void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            // Set window bounds in dips
            m_d3dBackground.WindowBounds = new Windows.Foundation.Size(
                (float)Application.Current.Host.Content.ActualWidth,
                (float)Application.Current.Host.Content.ActualHeight
                );

            // Set native resolution in pixels
            m_d3dBackground.NativeResolution = new Windows.Foundation.Size(
                (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                );

            // Set render resolution to the full native resolution
            m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution;

            // Hook-up native component to DrawingSurfaceBackgroundGrid
            DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dBackground.CreateContentProvider());
            DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dBackground);

            this.initialized = true;

            ROMDatabase db = ROMDatabase.Current;

            if (ROMLoaded && this.cache == null)
            {
                var entry  = db.GetROM(this.m_d3dBackground.LoadadROMFile.Name);
                var cheats = await FileHandler.LoadCheatCodes(entry);

                this.m_d3dBackground.LoadCheats(cheats);

                this.m_d3dBackground.UnpauseEmulation();
            }
            else if (this.cache != null && this.cache.file != null && this.cache.folder != null)
            {
                if (ROMLoaded && this.m_d3dBackground.LoadadROMFile.Name.Equals(this.cache.file.Name))
                {
                    var entry  = db.GetROM(this.m_d3dBackground.LoadadROMFile.Name);
                    var cheats = await FileHandler.LoadCheatCodes(entry);

                    this.m_d3dBackground.LoadCheats(cheats);

                    this.m_d3dBackground.UnpauseEmulation();
                }
                else
                {
                    var entry  = db.GetROM(this.cache.file.Name);
                    var cheats = await FileHandler.LoadCheatCodes(entry);

                    this.m_d3dBackground.LoadCheatsOnROMLoad(cheats);

                    // Load new ROM
                    this.m_d3dBackground.LoadROMAsync(this.cache.file, this.cache.folder);
                    if (EmulatorSettings.Current.SelectLastState)
                    {
                        RestoreLastSavestate(this.cache.file.Name);
                    }
                    ROMLoaded = true;
                }
            }

            int orientation = 0;

            switch (this.Orientation)
            {
            case PageOrientation.LandscapeLeft:
            case PageOrientation.Landscape:
                orientation = 0;
                break;

            case PageOrientation.LandscapeRight:
                orientation = 1;
                break;

            case PageOrientation.PortraitUp:
            case PageOrientation.Portrait:
                orientation = 2;
                break;
            }
            this.m_d3dBackground.ChangeOrientation(orientation);
        }
Beispiel #16
0
        private async void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_d3dBackground == null)
            {
                this.m_d3dBackground = new Direct3DBackground();

                this.m_d3dBackground.SetContinueNotifier(this.ContinueEmulation);
                this.m_d3dBackground.SnapshotAvailable = FileHandler.CaptureSnapshot;
                this.m_d3dBackground.SavestateCreated  = FileHandler.CreateSavestate;
                this.m_d3dBackground.SavestateSelected = this.savestateSelected;
                Direct3DBackground.WrongCheatVersion   = this.wrongCheatVersion;
                Direct3DBackground.ToggleTurboMode     = this.ToggleTurboMode;

                this.InitAppBar();

                // Set window bounds in dips
                m_d3dBackground.WindowBounds = new Windows.Foundation.Size(
                    (float)Application.Current.Host.Content.ActualWidth,
                    (float)Application.Current.Host.Content.ActualHeight
                    );

                // Set native resolution in pixels
                m_d3dBackground.NativeResolution = new Windows.Foundation.Size(
                    (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                    (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                    );

                // Set render resolution to the full native resolution
                m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution;

                // Hook-up native component to DrawingSurfaceBackgroundGrid
                DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dBackground.CreateContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dBackground);
            }

            //this.initialized = true;

            ROMDatabase db = ROMDatabase.Current;

            //if (ROMLoaded && this.cache == null)  //this never happens so just get rid of it
            //{
            //    var entry = db.GetROM(this.m_d3dBackground.LoadadROMFile.Name);
            //    var cheats = await FileHandler.LoadCheatCodes(entry);
            //    this.m_d3dBackground.LoadCheats(cheats);

            //    this.m_d3dBackground.UnpauseEmulation();
            //}


            if (EmulatorPage.cache != null && EmulatorPage.cache.file != null && EmulatorPage.cache.folder != null) // a safeguard to make sure we have enough info to load ROM
                                                                                                                    //this is all null if returned from tombstone
            {
                if (ROMLoaded && this.m_d3dBackground.LoadadROMFile.Name.Equals(EmulatorPage.cache.file.Name))      //name match, we are resuming to current game
                {
                    var entry  = db.GetROM(this.m_d3dBackground.LoadadROMFile.Name);
                    var cheats = await FileHandler.LoadCheatCodes(entry);

                    this.m_d3dBackground.LoadCheats(cheats);

                    //this.m_d3dBackground.UnpauseEmulation();
                }
                else  //name does not match or ROM is not loaded, we are loading a new rom
                {
                    var entry  = db.GetROM(EmulatorPage.cache.file.Name);
                    var cheats = await FileHandler.LoadCheatCodes(entry);

                    this.m_d3dBackground.LoadCheatsOnROMLoad(cheats);

                    // Load new ROM

                    await this.m_d3dBackground.LoadROMAsync(EmulatorPage.cache.file, EmulatorPage.cache.folder);

                    //if (EmulatorSettings.Current.SelectLastState)
                    {
                        RestoreLastSavestate(EmulatorPage.cache.file.Name);
                    }

                    ROMLoaded = true;
                }


                int orientation = 0;
                switch (this.Orientation)
                {
                case PageOrientation.LandscapeLeft:
                case PageOrientation.Landscape:
                    orientation = 0;
                    break;

                case PageOrientation.LandscapeRight:
                    orientation = 1;
                    break;

                case PageOrientation.PortraitUp:
                case PageOrientation.Portrait:
                    orientation = 2;
                    break;
                }
                this.m_d3dBackground.ChangeOrientation(orientation);
            }

            //set app bar color in case returning from setting page
            if (ApplicationBar != null)
            {
                ApplicationBar.BackgroundColor = (Color)App.Current.Resources["CustomChromeColor"];
                ApplicationBar.ForegroundColor = (Color)App.Current.Resources["CustomForegroundColor"];
            }
        }
Beispiel #17
0
        private async void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_d3dBackground == null)
            {
                this.m_d3dBackground = new LinkDirect3DBackground();

                this.m_d3dBackground.SetContinueNotifier(this.ContinueEmulation);
                this.m_d3dBackground.SnapshotAvailable = FileHandler.CaptureSnapshot;
                this.m_d3dBackground.SavestateCreated  = FileHandler.CreateSavestate;
                this.m_d3dBackground.SavestateSelected = this.savestateSelected;
                this.InitAppBar();

                // Set window bounds in dips
                m_d3dBackground.WindowBounds = new Windows.Foundation.Size(
                    (float)Application.Current.Host.Content.ActualWidth,
                    (float)Application.Current.Host.Content.ActualHeight
                    );

                // Set native resolution in pixels
                m_d3dBackground.NativeResolution = new Windows.Foundation.Size(
                    (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f),
                    (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)
                    );

                // Set render resolution to the full native resolution
                m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution;

                // Hook-up native component to DrawingSurfaceBackgroundGrid
                DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dBackground.CreateContentProvider());
                DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dBackground);

                this.initialized = true;

                ROMDatabase db = ROMDatabase.Current;

                //if (ROMLoaded && this.cache == null)
                //{
                //    var entry = db.GetROM(this.m_d3dBackground.LoadadROMFile.Name);
                //    var cheats = await FileHandler.LoadCheatCodes(entry);
                //    this.m_d3dBackground.LoadCheats(cheats);

                //    this.m_d3dBackground.UnpauseEmulation();
                //}
                //else if (this.cache != null && this.cache.file != null && this.cache.folder != null)
                //{
                //    if (ROMLoaded && this.m_d3dBackground.LoadadROMFile.Name.Equals(this.cache.file.Name))
                //    {
                //        var entry = db.GetROM(this.m_d3dBackground.LoadadROMFile.Name);
                //        var cheats = await FileHandler.LoadCheatCodes(entry);
                //        this.m_d3dBackground.LoadCheats(cheats);

                //        this.m_d3dBackground.UnpauseEmulation();
                //    }
                //    else
                //    {
                //load first ROM
                var entry  = db.GetROM(this.cache.file.Name);
                var cheats = await FileHandler.LoadCheatCodes(entry);

                this.m_d3dBackground.LoadCheatsOnROMLoad(cheats);


                this.m_d3dBackground.LoadROMAsync(this.cache.file, this.cache.folder);
                if (EmulatorSettings.Current.SelectLastState)
                {
                    RestoreLastSavestate(this.cache.file.Name);
                }


                // Load second ROM
                entry  = db.GetROM(this.cache2.file.Name);
                cheats = await FileHandler.LoadCheatCodes(entry);

                this.m_d3dBackground.LoadCheatsOnROMLoad(cheats);


                this.m_d3dBackground.LoadROMAsync(this.cache.file, this.cache.folder);
                if (EmulatorSettings.Current.SelectLastState)
                {
                    RestoreLastSavestate(this.cache.file.Name);
                }

                ROMLoaded = true;
                //    }
                //}

                int orientation = 0;
                switch (this.Orientation)
                {
                case PageOrientation.LandscapeLeft:
                case PageOrientation.Landscape:
                    orientation = 0;
                    break;

                case PageOrientation.LandscapeRight:
                    orientation = 1;
                    break;

                case PageOrientation.PortraitUp:
                case PageOrientation.Portrait:
                    orientation = 2;
                    break;
                }
                this.m_d3dBackground.ChangeOrientation(orientation);
            }

            //set app bar color in case returning from setting page
            if (ApplicationBar != null)
            {
                ApplicationBar.BackgroundColor = (Color)App.Current.Resources["CustomChromeColor"];
                ApplicationBar.ForegroundColor = (Color)App.Current.Resources["CustomForegroundColor"];
            }
        }