Esempio n. 1
0
        private async void ShowSelectionBrowserCoroutine(DataFileTypes type)
        {
            UIBlocking.Instance.Block();

            FileBrowser.SetFilters(showAllFilesFilter: true, new FileBrowser.Filter(type.ToString(), type.FileExtensionWithPeriod()));
            FileBrowser.SetDefaultFilter(type.FileExtensionWithPeriod());

            var initialDirectory = GetFilePath(type);

            initialDirectory = string.IsNullOrEmpty(initialDirectory) ? Environment.GetFolderPath(Environment.SpecialFolder.Desktop) : Path.GetDirectoryName(initialDirectory);

            await FileBrowser.WaitForLoadDialog(
                folderMode : false,
                initialPath : initialDirectory,
                title : $"Choose {type} file",
                loadButtonText : "Load");

            if (FileBrowser.Success)
            {
                var path = FileBrowser.Result;

                UpdateFilePath(type, filePath: path, loadFile: true);
            }

            UIBlocking.Instance.Unblock();
        }
Esempio n. 2
0
        private void LoadFile(DataFileTypes type)
        {
            switch (type)
            {
            case DataFileTypes.Maps:
                MapsLoading.Instance.LoadFile();
                break;

            case DataFileTypes.Shapes:
                ShapesLoading.Instance.LoadFile();
                break;

            case DataFileTypes.Physics:
                Debug.LogWarning("Physics loading not yet supported.");
                break;

            case DataFileTypes.Sounds:
                Debug.LogWarning("Sounds loading not yet supported.");
                break;

            case DataFileTypes.Images:
                Debug.LogWarning("Images loading not yet supported.");
                break;
            }
        }
Esempio n. 3
0
        public void CreateReader(DataFileTypes fType, Type expectedType)
        {
            IDataFileReader reader = DataReaderFactory.CreateReader(fType);

            Assert.NotNull(reader);
            Assert.IsType(expectedType, reader);
        }
 private void OnPathUpdated(DataFileTypes type, string newPath)
 {
     if (type == dataFileType)
     {
         RefreshPath(newPath);
     }
 }
Esempio n. 5
0
        public void UnloadFile(DataFileTypes type)
        {
            switch (type)
            {
            case DataFileTypes.Maps:
                MapsLoading.Instance.UnloadFile();
                break;

            case DataFileTypes.Shapes:
                ShapesLoading.Instance.UnloadFile();
                break;

            case DataFileTypes.Physics:
                Debug.LogWarning("Physics unloading not yet supported.");
                break;

            case DataFileTypes.Sounds:
                Debug.LogWarning("Sounds unloading not yet supported.");
                break;

            case DataFileTypes.Images:
                Debug.LogWarning("Images unloading not yet supported.");
                break;
            }

            UpdateFilePath(type, filePath: string.Empty, loadFile: false);
        }
 public DataFileFacade(DataFileTypes _dataFileType)
 {
     mDataFileType   = _dataFileType;
     mNewDataFileDAO = new NewDataFileDAO();
     mOldDataFileDAO = new OldDataFileDAO();
     //getChannelsBoundleDelegate =
     //    new GetChannelsBoundle(mNewDataFileDAO.getChannels);
     setDAOType(mDataFileType);
 }
Esempio n. 7
0
        /// <summary>
        /// Creates the reader.
        /// </summary>
        /// <param name="fileType">Type of the file.</param>
        /// <returns></returns>
        public static IDataFileReader CreateReader(DataFileTypes fileType)
        {
            IDataFileReader reader = null;

            switch (fileType)
            {
                case DataFileTypes._XLS:
                    throw new NotImplementedException("Excel 2003 is not currently supported.");
                    break;
                case DataFileTypes._XLSX:
                    throw new NotImplementedException("Excel 2007 is not currently supported.");
                    break;
                case DataFileTypes._CSV:
                    throw new NotImplementedException("CSV is not currently supported.");
                    break;
            }

            return reader;
        }
Esempio n. 8
0
        public static IFrameFileWriter CreateWriter(DataFileTypes fileTypes)
        {
            IFrameFileWriter writer = null;

            switch (fileTypes)
            {
                case DataFileTypes._CSV:
                    writer = new Writers.Data.Csv.BasicFrameToCsvWriter();
                    break;
                case DataFileTypes._XLS:
                    throw new NotImplementedException("Writing to Excel 2003 files is not yet supported.");
                    break;
                case DataFileTypes._XLSX:
                    throw new NotImplementedException("Writing to Excel 2007 files is not yet supported.");
                    break;
            }

            return writer;
        }
Esempio n. 9
0
        public void UpdateFilePath(DataFileTypes type, string filePath, bool loadFile)
        {
            PlayerPrefs.SetString(GetPlayerPrefsKey(type), filePath);

            OnPathChanged_Sender?.Invoke(type, filePath);

            if (loadFile)
            {
                try
                {
                    LoadFile(type); // TODO: add an arg to auto-load the first level (for saving)
                }
                catch (Exception exception)
                {
                    Debug.LogError($"Attempt to load file at path \"{filePath}\" failed with exception: {exception}");

                    UnloadFile(type);
                }
            }
        }
        public void setDAOType(DataFileTypes _dataFileType)
        {
            mDataFileType = _dataFileType;
            switch (mDataFileType)
            {
            case DataFileTypes.NewDataFile:
            {
                getChannelsBoundleDelegate =
                    new GetChannelsBoundle(mNewDataFileDAO.getChannels);
                break;
            }

            case DataFileTypes.OldDataFile:
            {
                getChannelsBoundleDelegate =
                    new GetChannelsBoundle(mOldDataFileDAO.getChannels);
                break;
            }
            }
        }
        public static string FileExtension(this DataFileTypes type)
        {
            switch (type)
            {
            case DataFileTypes.Maps:
                return("sceA");

            case DataFileTypes.Shapes:
                return("shpA");

            case DataFileTypes.Sounds:
                return("sndA");

            case DataFileTypes.Physics:
                return("phyA");

            case DataFileTypes.Images:
                return("imgA");

            default:
                return("*");
            }
        }
Esempio n. 12
0
 public string GetFilePath(DataFileTypes type)
 {
     return(PlayerPrefs.GetString(GetPlayerPrefsKey(type), string.Empty));
 }
Esempio n. 13
0
 public void ShowSelectionBrowser(DataFileTypes type)
 {
     ShowSelectionBrowserCoroutine(type);
 }
Esempio n. 14
0
 public void CreateReader_Not_Implemented(DataFileTypes fType)
 {
     IDataFileReader reader = null;
     var ex = Assert.Throws<NotImplementedException>(() => reader = DataReaderFactory.CreateReader(fType));
 }
Esempio n. 15
0
 private string GetPlayerPrefsKey(DataFileTypes type)
 {
     return(string.Concat(playerPrefsPrefix, type));
 }
 public DataFileFacade2(DataFileTypes _dataFileType)
 {
     setDAOType(_dataFileType);
     // mNewDataFileDAO = new NewDataFileDAO();
     // mOldDataFileDAO = new OldDataFileDAO();
 }
 public void setDAOType(DataFileTypes _dataFileType)
 {
     mDataFileType = _dataFileType;
 }
Esempio n. 18
0
 private DataFileTypesCaption(DataFileTypes fileType, string caption, string tooltip)
 {
     _fileType = fileType;
     _caption = caption;
     _tooltip = tooltip;
 }
 public static string FileExtensionWithPeriod(this DataFileTypes type)
 {
     return(string.Concat(".", type.FileExtension()));
 }
Esempio n. 20
0
 public void CreateWriter_Not_Implemented_Formats(DataFileTypes fileType)
 {
     IFrameFileWriter writer = null;
     var ex = Assert.Throws<NotImplementedException>(() => writer = DataWriterFactory.CreateWriter(fileType));
 }
Esempio n. 21
0
 public void CreateWriter_By_DataFileTypes_Enum(DataFileTypes fileType, Type expectedType)
 {
     IFrameFileWriter writer = DataWriterFactory.CreateWriter(fileType);
     Assert.NotNull(writer);
     Assert.IsType(expectedType, writer);
 }