예제 #1
0
        private async Task Init()
        {
            object tmp;

            PhoneApplicationService.Current.State.TryGetValue("parameter", out tmp);

            if (tmp == null)
            {
                //go back because there is no information about the rom entry
                if (this.NavigationService.CanGoBack)
                {
                    this.NavigationService.GoBack();
                }
                return;
            }

            this.romEntry = tmp as ROMDBEntry;
            this.game     = romEntry.DisplayName;
            PhoneApplicationService.Current.State.Remove("parameter");
            this.gameNameLabel.Text   = game;
            this.txtSearchString.Text = romEntry.DisplayName;

            try
            {
                this.cheatCodes = await FileHandler.LoadCheatCodes(this.romEntry);
            }
            catch (Exception) { }

            this.RefreshCheatList();
        }
예제 #2
0
        private async void Init()
        {
            object tmp;

            PhoneApplicationService.Current.State.TryGetValue("parameter", out tmp);
            this.romEntry = tmp as ROMDBEntry;
            this.game     = romEntry.DisplayName;
            PhoneApplicationService.Current.State.Remove("parameter");
            this.gameNameLabel.Text = game;

            try
            {
                this.cheatCodes = await FileHandler.LoadCheatCodes(this.romEntry);
            }
            catch (Exception) { }

            this.RefreshCheatList();
        }
예제 #3
0
        async void loadstateButton_Click(object sender, EventArgs e)
        {
            if (!App.IsTrial)
            {
                if (EmulatorSettings.Current.HideLoadConfirmationDialogs)
                {
                    ROMDatabase db     = ROMDatabase.Current;
                    var         entry  = db.GetROM(this.m_d3dBackground.LoadadROMFile.Name);
                    var         cheats = await FileHandler.LoadCheatCodes(entry);

                    this.m_d3dBackground.LoadCheatsOnROMLoad(cheats);

                    this.m_d3dBackground.LoadState();
                }
                else
                {
                    this.ShowLoadDialog();
                }
            }
            else
            {
                this.ShowBuyDialog();
            }
        }
예제 #4
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"];
            }
        }
예제 #5
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"];
            }
        }
예제 #6
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);
        }
예제 #7
0
        protected override async void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            CameraButtons.ShutterKeyPressed     += CameraButtons_ShutterKeyPressed;
            CameraButtons.ShutterKeyHalfPressed += CameraButtons_ShutterKeyHalfPressed;
            CameraButtons.ShutterKeyReleased    += CameraButtons_ShutterKeyReleased;

            object param = null;

            PhoneApplicationService.Current.State.TryGetValue("parameter", out param);
            LoadROMParameter romInfo = param as LoadROMParameter;

            PhoneApplicationService.Current.State.Remove("parameter");

            ROMDatabase db = ROMDatabase.Current;

            if (initialized && this.m_d3dBackground.IsROMLoaded() && romInfo == 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 (romInfo != null)
            {
                if (this.initialized)
                {
                    if (this.m_d3dBackground.LoadadROMFile.Name.Equals(romInfo.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(romInfo.file.Name);
                        var cheats = await FileHandler.LoadCheatCodes(entry);

                        this.m_d3dBackground.LoadCheatsOnROMLoad(cheats);

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

            base.OnNavigatedTo(e);
        }