Beispiel #1
0
        public IAsyncOperation <ROMData> LoadROMAsync(ROMEntry entry)
        {
            IStorageFile           file          = entry.File;
            String                 fileExtension = this.GetFileExtension(file).ToLower();
            Func <Task <ROMData> > helper        = async() =>
            {
                ROMData romData = new ROMData();
                if (fileExtension == "zip")
                {
                    var zipData = await this.GetBytesFromZipFileAsync(file, this.romFileExtensions);

                    romData.data          = zipData.Bytes;
                    romData.fileExtension = zipData.ROMExtension;
                }
                else
                {
                    romData.data = await this.GetBytesFromFileAsync(file);

                    romData.fileExtension = this.GetFileExtension(file);
                }

                romData.file = file;
                romData.size = (uint)romData.data.Length;

                if (this.currentROM != null)
                {
                    this.currentROM.CheatCache = null;
                }
                this.currentROM = entry;

                return(romData);
            };

            return(helper().AsAsyncOperation <ROMData>());
        }
Beispiel #2
0
        private static string generateTileId(ROMEntry entry)
        {
            string        name = entry.Name;
            StringBuilder sb   = new StringBuilder();

            for (int i = 0; i < name.Length; i++)
            {
                char c = name[i];
                if ((c >= 'a' && c <= 'z') ||
                    (c >= 'A' && c <= 'Z') ||
                    (c >= '0' && c <= '9') ||
                    (c == '.'))
                {
                    sb.Append(c);
                }
                else if (c == ' ')
                {
                    sb.Append('_');
                }
            }
#if DEBUG
            System.Diagnostics.Debug.WriteLine("Tile ID: " + sb.ToString());
#endif
            return(sb.ToString());
        }
Beispiel #3
0
        public IAsyncAction RefreshROMListAsync()
        {
            Func <Task> helper = async() =>
            {
                this.romList.Clear();

                var fileQuery = this.romDirectory.CreateFileQueryWithOptions(
                    new Windows.Storage.Search.QueryOptions(
                        Windows.Storage.Search.CommonFileQuery.DefaultQuery,
                        this.romFileExtensions
                        )
                    );

                IReadOnlyList <StorageFile> files = await fileQuery.GetFilesAsync();

                foreach (StorageFile file in files)
                {
                    var entry = new ROMEntry();
                    entry.File          = file;
                    entry.DatabaseEntry = ROMDatabase.Current.GetOrCreateEntry(entry.Name);

                    this.romList.Add(entry);
                }

                this.NotifyPropertyChanged("ROMList");
            };

            return(helper().AsAsyncAction());
        }
Beispiel #4
0
        public IAsyncAction UnpinTile(ROMEntry entry)
        {
            Func <Task> helper = async() =>
            {
            };

            return(helper().AsAsyncAction());
        }
Beispiel #5
0
        public IAsyncOperation <bool> PinTile(ROMEntry entry)
        {
            Func <Task <bool> > helper = async() =>
            {
                var snapshotPath = StorageManager.Current.GetSnapshotPath(entry.File.Name);

                SecondaryTile tile = new SecondaryTile(/*entry.Name, "123", arguments, new Uri("ms-appx:///Assets/defaultSnapshotGBA.png"), TileSize.Square150x150 | TileSize.Wide310x150 | TileSize.Square70x70*/);
                tile.TileId         = generateTileId(entry);
                tile.Arguments      = generateTileArguments(entry);
                tile.DisplayName    = generateDisplayName(entry);
                tile.RoamingEnabled = false;
                tile.TileOptions    = TileOptions.ShowNameOnLogo | TileOptions.ShowNameOnWideLogo;
                tile.VisualElements.Square150x150Logo = new Uri("ms-appx:///Assets/defaultSnapshotGBA.png");

                return(await tile.RequestCreateAsync());
            };

            return(helper().AsAsyncOperation());
        }
Beispiel #6
0
        internal void LoadSnapshotImage(ROMEntry entry)
        {
#pragma warning disable CS4014
            this.services.MessageService.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
#pragma warning restore CS4014
            {
                var path = this.replaceExtension(entry.Name, ".png");
                var file = await this.romDirectory.TryGetItemAsync(path);
                if (file == null)
                {
                    // try again later maybe
                    entry.ResetImageLoading();
                    return;
                }

                var fs  = await((IStorageFile)file).OpenAsync(FileAccessMode.Read);
                var img = new BitmapImage();
                img.SetSource(fs);

                this.snapshotMap[path] = img;

                entry.SnapshotImage = path;
            });
        }
Beispiel #7
0
 private static string generateTileArguments(ROMEntry entry)
 {
     return("launch-rom:" + entry.Name);
 }
Beispiel #8
0
 private static string generateDisplayName(ROMEntry entry)
 {
     return(entry.Name);
 }
Beispiel #9
0
 public bool HasPinnedTile(ROMEntry entry)
 {
     return(false);
 }
Beispiel #10
0
 public bool HasTilePinned(ROMEntry entry)
 {
     return(false);
 }