Ejemplo n.º 1
0
 public void OpenDatabase()
 {
     if (database == null)
     {
         database = new Database(SongInfoLoader.GetAbsolutePath("../" + sqlitePath));
     }
 }
Ejemplo n.º 2
0
 public void Save()
 {
     using (var stream = File.Open(SongInfoLoader.GetAbsolutePath(path), FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) {
         var writer = new BinaryWriter(stream);
         writer.Write(presets.Count);
         foreach (var kv in presets)
         {
             writer.Write(kv.Key);
             if (kv.Value == null)
             {
                 writer.Write(-1);
                 continue;
             }
             writer.Write(kv.Value.Length);
             writer.Write(kv.Value);
         }
         writer.Write(oldIndex);
     }
 }
Ejemplo n.º 3
0
    void Start()
    {
        var file = new FileInfo(SongInfoLoader.GetAbsolutePath(path));

        if (file.Exists)
        {
            using (var stream = file.OpenRead()) {
                var reader       = new BinaryReader(stream);
                int presetsCount = reader.ReadInt32();
                for (int i = 0; i < presetsCount; i++)
                {
                    var presetName = reader.ReadString();
                    int dataLength = reader.ReadInt32();
                    presets[presetName] = dataLength == -1 ? null : reader.ReadBytes(dataLength);
                    presetsDisplay.options.Add(new Dropdown.OptionData(presetName));
                }
                oldIndex = reader.ReadInt32();
            }
        }
        if (presets.Count == 0)
        {
            oldIndex = 0;
            presets.Add("Default", null);
            presetsDisplay.options.Add(new Dropdown.OptionData("Default"));
            if (OnReset != null)
            {
                OnReset.Invoke();
            }
        }
        if (oldIndex >= 0)
        {
            presetsDisplay.value = oldIndex;
            SelectionChanged();
        }
        initialized = true;
    }