Esempio n. 1
0
        public ROMDBEntry GetROMFromSRAMName(string savestateName)
        {
            if (!context.DatabaseExists())
            {
                throw new InvalidOperationException("Database does not exist.");
            }
            String name = savestateName.Substring(0, savestateName.Length - 4).ToLower();

            ROMDBEntry entry = this.context.ROMTable
                               .Where(r => (r.FileName.ToLower().EndsWith(".gb") && r.FileName.Substring(0, r.FileName.Length - 3).ToLower().Equals(name)) ||
                                      ((r.FileName.ToLower().EndsWith(".gba") || (r.FileName.ToLower().EndsWith(".gbc"))) && r.FileName.Substring(0, r.FileName.Length - 4).ToLower().Equals(name)))
                               .FirstOrDefault();

            if (entry != null)
            {
                return(entry);
            }
            else
            {
                //check display name
                return(this.context.ROMTable
                       .Where(r => (r.DisplayName.ToLower().Equals(name)))
                       .FirstOrDefault());
            }
        }
Esempio n. 2
0
 public static async Task FindExistingSavestatesForNewROM(ROMDBEntry entry)
 {
     ROMDatabase db = ROMDatabase.Current;
     StorageFolder localFolder = ApplicationData.Current.LocalFolder;
     StorageFolder romFolder = await localFolder.GetFolderAsync(ROM_DIRECTORY);
     StorageFolder saveFolder = await romFolder.GetFolderAsync(SAVE_DIRECTORY);
     IReadOnlyList<StorageFile> saves = await saveFolder.GetFilesAsync();
     // Savestates zuordnen
     foreach (var save in saves)
     {
         if (save.Name.Substring(0, save.Name.Length - 2).Equals(entry.DisplayName + ".0"))
         {
             // Savestate gehoert zu ROM
             String number = save.Name.Substring(save.Name.Length - 2);
             int slot = int.Parse(number);
             SavestateEntry ssEntry = new SavestateEntry()
             {
                 ROM = entry,
                 Savetime = save.DateCreated.DateTime,
                 Slot = slot,
                 FileName = save.Name
             };
             db.Add(ssEntry);
         }
     }
 }
Esempio n. 3
0
        public ROMDBEntry GetROM(string fileName)
        {
            if (!context.DatabaseExists())
            {
                throw new InvalidOperationException("Database does not exist.");
            }


            fileName = fileName.ToLower();

            //first try file name
            ROMDBEntry entry = this.context.ROMTable
                               .Where(f => f.FileName.ToLower().Equals(fileName))
                               .FirstOrDefault();

            //then try display name



            if (entry == null)
            {
                ROMDBEntry[] entries = this.context.ROMTable.ToArray();
                foreach (ROMDBEntry anentry in entries)
                {
                    if (Regex.Replace(anentry.DisplayName, @"[^\w\s]+", "").ToLower().Equals(fileName))
                    {
                        entry = anentry;
                    }
                }
            }



            return(entry);
        }
Esempio n. 4
0
 public void Add(ROMDBEntry entry)
 {
     if (!context.DatabaseExists())
     {
         throw new InvalidOperationException("Database does not exist.");
     }
     context.ROMTable.InsertOnSubmit(entry);
     context.SubmitChanges();
 }
 public void Add(ROMDBEntry entry)
 {
     if (!context.DatabaseExists())
     {
         throw new InvalidOperationException("Database does not exist.");
     }
     context.ROMTable.InsertOnSubmit(entry);
     context.SubmitChanges();
 }
Esempio n. 6
0
        public ContextPage()
        {
            InitializeComponent();

            this.entry = PhoneApplicationService.Current.State["parameter"] as ROMDBEntry;
            PhoneApplicationService.Current.State.Remove("parameter");

            this.titleBox.Text = this.entry.DisplayName;
        }
        public ROMDBEntry GetROM(string fileName)
        {
            if (!context.DatabaseExists())
            {
                throw new InvalidOperationException("Database does not exist.");
            }
            fileName = fileName.ToLower();
            ROMDBEntry entry = this.context.ROMTable
                               .Where(f => f.FileName.ToLower().Equals(fileName))
                               .FirstOrDefault();

            return(entry);
        }
        public void RemoveROM(string fileName)
        {
            ROMDBEntry entry = this.GetROM(fileName);

            if (entry != null)
            {
                this.context.SavestateTable.DeleteAllOnSubmit(
                    this.context.SavestateTable
                    .Where(s => (s.ROM == entry))
                    .ToArray()
                    );
                this.context.ROMTable.DeleteOnSubmit(entry);
            }
        }
Esempio n. 9
0
 public static ROMDBEntry InsertNewDBEntry(string fileName)
 {
     ROMDatabase db = ROMDatabase.Current;
     string displayName = fileName.Substring(0, fileName.Length - 4);
     ROMDBEntry entry = new ROMDBEntry()
     {
         DisplayName = displayName,
         FileName = fileName,
         LastPlayed = DEFAULT_DATETIME,
         SnapshotURI = DEFAULT_SNAPSHOT
     };
     db.Add(entry);
     return entry;
 }
Esempio n. 10
0
        public RenamePage()
        {
            InitializeComponent();

            object tmpObject;
            PhoneApplicationService.Current.State.TryGetValue("parameter", out tmpObject);
            PhoneApplicationService.Current.State.Remove("parameter");
            this.entry = tmpObject as Database.ROMDBEntry;
            PhoneApplicationService.Current.State.TryGetValue("parameter2", out tmpObject);
            PhoneApplicationService.Current.State.Remove("parameter2");
            this.db = tmpObject as Database.ROMDatabase;

            this.nameBox.Text = this.entry.DisplayName;
            #if GBC
            appnameLabel.Text = AppResources.ApplicationTitle2;
            #endif
        }
Esempio n. 11
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();
        }
Esempio n. 12
0
        public RenamePage()
        {
            InitializeComponent();

            object tmpObject;

            PhoneApplicationService.Current.State.TryGetValue("parameter", out tmpObject);
            PhoneApplicationService.Current.State.Remove("parameter");
            this.entry = tmpObject as Database.ROMDBEntry;
            PhoneApplicationService.Current.State.TryGetValue("parameter2", out tmpObject);
            PhoneApplicationService.Current.State.Remove("parameter2");
            this.db = tmpObject as Database.ROMDatabase;


            this.nameBox.Text = this.entry.DisplayName;
#if GBC
            SystemTray.GetProgressIndicator(this).Text = AppResources.ApplicationTitle2;
#endif
        }
Esempio n. 13
0
        public ManageSavestatePage()
        {
            InitializeComponent();


            db = ROMDatabase.Current;

            object tmp;
            PhoneApplicationService.Current.State.TryGetValue("parameter", out tmp);
            this.romEntry = tmp as ROMDBEntry;
            PhoneApplicationService.Current.State.Remove("parameter");

            titleLabel.Text = this.romEntry.DisplayName;

            CreateAppBar();

            var savestates = db.GetSavestatesForROM(this.romEntry);

            this.stateList.ItemsSource = savestates;
        }
 public IEnumerable <SavestateEntry> GetSavestatesForROM(ROMDBEntry entry)
 {
     return(this.context.SavestateTable
            .Where(s => s.ROM == entry)
            .OrderBy(s => s.Slot));
 }
Esempio n. 15
0
        private async Task StartROM(ROMDBEntry entry)
        {
            LoadROMParameter param = await FileHandler.GetROMFileToPlayAsync(entry.FileName);

            entry.LastPlayed = DateTime.Now;
            this.db.CommitChanges();

            PhoneApplicationService.Current.State["parameter"] = param;
            this.NavigationService.Navigate(new Uri("/EmulatorPage.xaml", UriKind.Relative));
        }
Esempio n. 16
0
 public IEnumerable<SavestateEntry> GetSavestatesForROM(ROMDBEntry entry)
 {
     return this.context.SavestateTable
         .Where(s => s.ROM == entry)
         .OrderBy(s => s.Slot);
 }
Esempio n. 17
0
        public static void CreateROMTile(ROMDBEntry re)
        {
            FlipTileData data = CreateFlipTileData(re);

            ShellTile.Create(new Uri("/MainPage.xaml?" + ROM_URI_STRING + "=" + re.FileName, UriKind.Relative), data, true);
        }
Esempio n. 18
0
        internal static async void DeleteSRAMFile(ROMDBEntry re)
        {
            string sramName = re.FileName.Substring(0, re.FileName.LastIndexOf('.')) + ".srm";

            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            StorageFolder romFolder = await localFolder.GetFolderAsync(ROM_DIRECTORY);
            StorageFolder saveFolder = await romFolder.GetFolderAsync(SAVE_DIRECTORY);
            try
            {
                IStorageFile file = await saveFolder.GetFileAsync(sramName);
                await file.DeleteAsync();
            }
            catch (Exception) { }
        }
Esempio n. 19
0
 public static async Task DeleteROMAsync(ROMDBEntry rom)
 {
     ROMDatabase db = ROMDatabase.Current;
     String fileName = rom.FileName;
     StorageFolder folder = await ApplicationData.Current.LocalFolder.GetFolderAsync(ROM_DIRECTORY);
     StorageFile file = await folder.GetFileAsync(fileName);
     DeleteROMTile(file.Name);
     await file.DeleteAsync(StorageDeleteOption.PermanentDelete);
     db.RemoveROM(file.Name);
     db.CommitChanges();
 }
Esempio n. 20
0
 private static FlipTileData CreateFlipTileData(ROMDBEntry re)
 {
     FlipTileData data = new FlipTileData();
     data.Title = re.DisplayName;
     if (re.SnapshotURI.Equals(FileHandler.DEFAULT_SNAPSHOT))
     {
         data.SmallBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileSmall.png", UriKind.Relative);
         data.BackgroundImage = new Uri("Assets/Tiles/tileIcon.png", UriKind.Relative);
         data.WideBackgroundImage = new Uri("Assets/Tiles/tileIconLarge.png", UriKind.Relative);
     }
     else
     {
         data.SmallBackgroundImage = new Uri("isostore:/" + re.SnapshotURI, UriKind.Absolute);
         data.BackgroundImage = new Uri("isostore:/" + re.SnapshotURI, UriKind.Absolute);
         data.WideBackgroundImage = new Uri("isostore:/" + re.SnapshotURI, UriKind.Absolute);
     }
     return data;
 }