Example #1
0
    void Start()
    {
        string[] textTracks = trackSource.ToString().Split('\n');

        for (int i = 0; i < numOfTracks; i++)
        {
            tracks[i] = Instantiate(trackBasePrefab, new Vector3(0, 0, 0), Quaternion.identity, transform);
            tracks[i].transform.localPosition = new Vector3(tracksSpread * i, 0, 0);
            TrackBase baseTrack = tracks[i].GetComponent <TrackBase>();
            baseTrack.mesh.GetComponent <MeshRenderer>().material = trackMaterials[i];
            baseTrack.length = trackLength;
        }

        for (int i = 0; i < textTracks.Length; i++)
        {
            string[] s = textTracks[i].Split(' ');
            noteTimeCodes[i] = s[0];
            noteTypes[i]     = s[1];
        }

        hitArea.transform.localScale    = new Vector3(tracksSpread * textTracks.Length, 1, 1);
        hitArea.transform.localPosition = new Vector3((textTracks.Length - 1) * tracksSpread / 2, 0, 0);

        lastTime  = 0f;
        startTime = Time.fixedTime;
        audioTrack.Play();
    }
        public void AddPlayableTrack(TrackBase source)
        {
            PlayableTrackInfo playable = new PlayableTrackInfo();

            playable.Title  = source.MetaData.Title.Value;
            playable.Artist = source.MetaData.AlbumArtists.JoinedValue;

            playable.IsPlayableOffline = source.PlayableOffline;
            playable.IsPlayableOnline  = source.PlayableOnline;

            if (source.PlayableOffline)
            {
                playable.OfflinePlayer = source.SupportedMediaPlayers;
            }
            else
            {
                playable.OnlinePlayer = source.SupportedMediaPlayers;
            }

            if (source is TrackVirtual && source.PlayableOnline)
            {
                TrackVirtual sourceVirtual = source as TrackVirtual;
                playable.SpotifyURI        = sourceVirtual.SpotifyURI;
                playable.PlaytimeInSeconds = 10; // TODO
            }
            else if (source is TrackLocal && source.PlayableOffline)
            {
                TrackLocal sourceLocal = source as TrackLocal;
                playable.FilePath          = sourceLocal.MusicFileProperties.Path;
                playable.PlaytimeInSeconds = sourceLocal.MusicFileProperties.Duration;
            }

            tracks.Add(playable);
        }
Example #3
0
    private static TrackBase Deserialize(string json)
    {
        TrackBase track = null;

#if UNITY_2019
        string version = UnityEngine.JsonUtility
                         .FromJson <TrackBase>(json).version;
        switch (version)
        {
        case TrackV1.kVersion:
            track = UnityEngine.JsonUtility
                    .FromJson <TrackV1>(json);
            break;

        case Track.kVersion:
            track = UnityEngine.JsonUtility
                    .FromJson <Track>(json);
            break;

        default:
            throw new Exception($"Unknown version: {version}");
        }
#else
        return(null);
#endif
        track.InitAfterDeserialize();
        return(track);
    }
Example #4
0
        public static TrackBase CopyTrack(TrackBase source)
        {
            TrackBase target = null;

            if (source is TrackVirtual)
            {
                TrackVirtual sourceVirtual = source as TrackVirtual;
                target = new TrackVirtual(sourceVirtual.MetaData, sourceVirtual.IsOnlyMetaData)
                {
                    SpotifyID  = sourceVirtual.SpotifyID,
                    SpotifyURI = sourceVirtual.SpotifyURI
                };
            }
            else if (source is TrackLocal)
            {
                TrackLocal sourceLocal = source as TrackLocal;
                target = new TrackLocal(sourceLocal.MusicFileProperties, sourceLocal.MetaData, sourceLocal.MetaDataExtended)
                {
                    MatchCandidates          = sourceLocal.MatchCandidates,
                    ActiveCandidateMBTrackID = sourceLocal.ActiveCandidateMBTrackID
                };
            }

            target.PlayableOffline       = source.PlayableOffline;
            target.PlayableOnline        = source.PlayableOnline;
            target.SupportedMediaPlayers = source.SupportedMediaPlayers;

            return(target);
        }
Example #5
0
        //
        //
        //
        //

        public static void delete_script_data(TrackBase t)
        {
            //if(t.type != TSIGNAL)
            //  return;
            //if(t._interpreterData) {
            //  InterpreterData interp = (InterpreterData)t._interpreterData;
            // Globals.delete(interp);
            //}
            //t._interpreterData = 0;
        }
Example #6
0
        public void DeleteTrack(TrackBase trk)
        {
            int i = Find(trk);

            if (i < 0)
            {
                return;
            }
            DeleteAt(i);
        }
Example #7
0
 public void DeleteTrack(TrackBase track)
 {
     Requires.NotNull(track);
     Requires.PropertyNotNegative(track, "TrackId");
     using (var context = DataContext.Instance())
     {
         var rep = context.GetRepository <TrackBase>();
         rep.Delete(track);
     }
 }
Example #8
0
 public RailItem(TrackBase track, Point pos, Guid layer)
 {
     this.DebugIndex = globalDebugIndex++;
     //this.Id = Guid.NewGuid();
     this.TrackId    = track.Id;
     this.Track      = track;
     this.Position   = pos;
     this.Angle      = 0.0;
     this.Layer      = layer;
     this.DockPoints = track.DockPoints.Select(dp => new RailDockPoint(this, dp)).ToList();
 }
Example #9
0
 public void UpdateTrack(TrackBase track, int userId)
 {
     Requires.NotNull(track);
     Requires.PropertyNotNegative(track, "TrackId");
     track.LastModifiedByUserID = userId;
     track.LastModifiedOnDate   = DateTime.Now;
     using (var context = DataContext.Instance())
     {
         var rep = context.GetRepository <TrackBase>();
         rep.Update(track);
     }
 }
Example #10
0
        public void Insert(TrackBase trk, int f)
        {
            //int i;

            //Add(trk, f);	    // just to make space
            //for(i = _size - 1; i > 0; --i) {
            //  _ptr[i] = _ptr[i - 1];
            //  _flags[i] = _flags[i - 1];
            //}
            //_ptr[0] = trk;
            //_flags[0] = f;
            //ComputeLength();
        }
Example #11
0
        int Find(TrackBase trk)
        {
            int i;

            for (i = 0; i < _size; ++i)
            {
                if (_ptr[i] == trk)
                {
                    return(i);
                }
            }
            return(-1);
        }
Example #12
0
 public int AddTrack(ref TrackBase track, int userId)
 {
     Requires.NotNull(track);
     track.CreatedByUserID      = userId;
     track.CreatedOnDate        = DateTime.Now;
     track.LastModifiedByUserID = userId;
     track.LastModifiedOnDate   = DateTime.Now;
     using (var context = DataContext.Instance())
     {
         var rep = context.GetRepository <TrackBase>();
         rep.Insert(track);
     }
     return(track.TrackId);
 }
Example #13
0
 public void Add(TrackBase e, int flag)
 {
     //if(_size >= _maxelem) {
     //  _maxelem += 10;
     //  if(_ptr) {
     //    _ptr = (TrackBase**)realloc(_ptr, _maxelem * sizeof(TrackBase*));
     //    _flags = (string)realloc(_flags, _maxelem * sizeof(char));
     //  } else {
     //    _ptr = (TrackBase**)malloc(_maxelem * sizeof(TrackBase*));
     //    _flags = (string)malloc(_maxelem * sizeof(char));
     //  }
     //}
     //_flags[_size] = flag;
     //_ptr[_size++] = e;
 }
Example #14
0
        public ActionResult Edit(TrackBase track)
        {
            var previousRecord = _repository.GetTrack(track.ConferenceId, track.TrackId);

            if (previousRecord == null)
            {
                _repository.AddTrack(ref track, User.UserID);
            }
            else
            {
                track.CreatedOnDate   = previousRecord.CreatedOnDate;
                track.CreatedByUserID = previousRecord.CreatedByUserID;
                _repository.UpdateTrack(track, User.UserID);
            }
            return(ReturnRoute(track.ConferenceId, View("View", _repository.GetTrack(track.ConferenceId, track.TrackId))));
        }
Example #15
0
    void Start()
    {
        textTracks = trackSource.ToString().Replace(" ", "").Split('\n');

        for (int i = 0; i < textTracks.Length; i++)
        {
            tracks[i] = Instantiate(trackBasePrefab, new Vector3(0, 0, 0), Quaternion.identity, transform);
            tracks[i].transform.localPosition = new Vector3(tracksSpread * i, 0, 0);
            TrackBase baseTrack = tracks[i].GetComponent <TrackBase>();
            baseTrack.mesh.GetComponent <MeshRenderer>().material = trackMaterials[i];
            baseTrack.length = trackLength;
        }

        lastIndex = startIndex;

        InvokeRepeating("AddKey", 60f / speed, 60f / speed);

        hitArea.transform.localScale    = new Vector3(tracksSpread * textTracks.Length, 1, 1);
        hitArea.transform.localPosition = new Vector3((textTracks.Length - 1) * tracksSpread / 2, 0, 0);
    }
Example #16
0
        public static TrackViewModel Create(TrackTypeViewModel trackTypeViewModel, TrackBase track)
        {
            string typeName = track.GetType().Name;

            return(typeName switch
            {
                nameof(TrackStraight) => new TrackStraightViewModel(trackTypeViewModel, (TrackStraight)track),
                nameof(TrackCurved) => new TrackCurvedViewModel(trackTypeViewModel, (TrackCurved)track),
                nameof(TrackCrossing) => new TrackCrossingViewModel(trackTypeViewModel, (TrackCrossing)track),
                nameof(TrackEndPiece) => new TrackEndPieceViewModel(trackTypeViewModel, (TrackEndPiece)track),
                nameof(TrackFlex) => new TrackFlexViewModel(trackTypeViewModel, (TrackFlex)track),

                nameof(TrackTurnout) => new TrackTurnoutViewModel(trackTypeViewModel, (TrackTurnout)track),
                nameof(TrackCurvedTurnout) => new TrackCurvedTurnoutViewModel(trackTypeViewModel, (TrackCurvedTurnout)track),
                nameof(TrackDoubleSlipSwitch) => new TrackDoubleSlipSwitchViewModel(trackTypeViewModel, (TrackDoubleSlipSwitch)track),
                nameof(TrackDoubleCrossover) => new TrackDoubleCrossoverViewModel(trackTypeViewModel, (TrackDoubleCrossover)track),

                nameof(TrackTable) => new TrackTableViewModel(trackTypeViewModel, (TrackTable)track),

                nameof(TrackGroup) => new TrackGroupViewModel(trackTypeViewModel, (TrackGroup)track),
                _ => null
            });
        public MainPageOfPlayer()
        {
            InitializeComponent();

            if (!InternetChecker.ConnectionAvailable("https://www.google.by/"))
            {
                ErrorForm erForm = new ErrorForm("Отсутствует соединение с интернетом. Часть функционала программы недоступна. Попробуйте позже.");
                erForm.ShowDialog();
                buttonVK.Visible               = false;
                vkCom.Visible                  = false;
                buttonLoginVk.Visible          = false;
                imageSoundCloud.Visible        = false;
                soundCloud.Visible             = false;
                buttonSearchSoundCloud.Visible = false;
            }

            if (Settings.Default.red == 0 && Settings.Default.green == 0 && Settings.Default.blue == 0)
            {
                CustomColor.maincolor = CustomColor.defaultcolor;
            }
            else
            {
                CustomColor.maincolor = Color.FromArgb(Settings.Default.red, Settings.Default.green, Settings.Default.blue);
            }

            BassClass.InitBass(BassClass.HZ);
            openFileDialog1.Filter            = TrackBase.GetInputFormats();
            ButtonAdd.Image                   = CustomColor.FillShape(Properties.Resources.add);
            buttonDelete.Image                = CustomColor.FillShape(Properties.Resources.delete);
            ButtonPlay.Image                  = CustomColor.FillShape(Properties.Resources.Circled_Play_100px);
            ButtonStop.Image                  = CustomColor.FillShape(Properties.Resources.stop1);
            ButtonPause.Image                 = CustomColor.FillShape(Properties.Resources.pause1);
            ButtonSkipLeft.Image              = CustomColor.FillShape(Properties.Resources.SkipLeft);
            ButtonSkipRight.Image             = CustomColor.FillShape(Properties.Resources.SkipRight);
            ButtonSettings.Image              = CustomColor.FillShape(Properties.Resources.settings);
            ButtonSettings.Image              = CustomColor.FillShape(Properties.Resources.settings);
            buttonVK.Image                    = CustomColor.ColoredObject(Properties.Resources.VK_com_100px, Color.FromArgb(80, 114, 153));
            buttonLogoutVk.Image              = CustomColor.ColoredObject(Properties.Resources.logout, Color.FromArgb(80, 114, 153));
            buttonMute.Image                  = CustomColor.FillShape(Properties.Resources.yes_audio);
            streamTrackBar.UseCustomBackColor = true;
            streamTrackBar.UseCustomForeColor = true;
            streamTrackBar.ForeColor          = CustomColor.defaultcolor;

            playlist.Size               = new Size(1088, 609);
            playlist.Location           = new Point(52, 47);
            searchTextBox.Visible       = false;
            buttonSearchStartVK.Visible = false;
            buttonDelete.Visible        = true;
            buttonDownload.Visible      = false;

            soundCloud.Location             = new Point(46, 224);
            imageSoundCloud.Location        = new Point(4, 226);
            buttonSearchSoundCloud.Location = new Point(0, 271);
            if (!VkAuthLog.GetAuth())
            {
                buttonLogoutVk.Visible = false;
            }

            vkCom.Font     = new Font("Phenomena", 16.25F);
            vkCom.Location = new Point(46, 133);

            buttonDownload.Image = CustomColor.FillShape(Properties.Resources.Download);

            if (Settings.Default.path == "" || Settings.Default.path == null)
            {
                Settings.Default.path = TrackBase.AppPath;
            }
        }
Example #18
0
 public void Add(TrackBase e, trkdir flag)
 {
     Add(e, flag);
 }
 public TrackShoud()
 {
     _lineWayUpSide     = new SideOfTrackSelector(true, true, false, false);
     _lineToLeftWaySide = new SideOfTrackSelector(true, false, true, false);
     _sut = new CommonTrack(_lineWayUpSide, _lineToLeftWaySide);
 }
Example #20
0
 public TrackViewModel(TrackTypeViewModel trackTypeViewModel, TrackBase trackBase)
 {
     this.Track = trackBase;
     this.trackTypeViewModel = trackTypeViewModel;
 }
Example #21
0
    protected void Refresh()
    {
        // Remove all objects from grid, except for templates.
        for (int i = 0; i < trackGrid.transform.childCount; i++)
        {
            GameObject o = trackGrid.transform.GetChild(i).gameObject;
            if (o == trackCardTemplate)
            {
                continue;
            }
            if (o == errorCardTemplate)
            {
                continue;
            }
            if (o == newTrackCard)
            {
                continue;
            }
            Destroy(o);
        }

        // Build and sort the list of all tracks.
        List <TrackInFolder> allTracks = new List <TrackInFolder>();
        List <ErrorInFolder> allErrors = new List <ErrorInFolder>();

        foreach (string dir in Directory.EnumerateDirectories(
                     Paths.GetTrackFolder()))
        {
            // Is there a track?
            string possibleTrackFile = Path.Combine(
                dir, Paths.kTrackFilename);
            if (!File.Exists(possibleTrackFile))
            {
                continue;
            }

            // Attempt to load track.
            TrackBase trackBase = null;
            bool      upgraded  = false;
            try
            {
                trackBase = TrackBase.LoadFromFile(possibleTrackFile);
                if (trackBase is TrackV1)
                {
                    // Attempt upgrade.
                    trackBase = (trackBase as TrackV1).Upgrade();
                    upgraded  = true;
                }
            }
            catch (Exception e)
            {
                allErrors.Add(new ErrorInFolder()
                {
                    trackFile = possibleTrackFile,
                    message   = e.Message
                });
                continue;
            }

            allTracks.Add(new TrackInFolder()
            {
                folder   = dir,
                track    = trackBase as Track,
                upgraded = upgraded
            });
        }

        allTracks.Sort((TrackInFolder t1, TrackInFolder t2) =>
        {
            return(string.Compare(t1.track.trackMetadata.title,
                                  t2.track.trackMetadata.title));
        });

        // Instantiate track cards.
        cardToTrack = new Dictionary <GameObject, TrackInFolder>();
        cardToError = new Dictionary <GameObject, string>();
        GameObject firstCard = null;

        foreach (TrackInFolder trackInFolder in allTracks)
        {
            GameObject card = Instantiate(trackCardTemplate,
                                          trackGrid.transform);
            card.name = "Track Card";
            card.GetComponent <TrackCard>().Initialize(
                trackInFolder.folder,
                trackInFolder.track.trackMetadata);
            card.SetActive(true);

            // Record mapping.
            cardToTrack.Add(card, trackInFolder);

            if (trackInFolder.upgraded &&
                ShowUpgradeNoticeOnOutdatedTracks())
            {
                // Bind click event.
                card.GetComponent <Button>().onClick
                .AddListener(() =>
                {
                    OnClickCardWithUpgradeNotice(card);
                });
            }
            else
            {
                // Bind click event.
                card.GetComponent <Button>().onClick
                .AddListener(() =>
                {
                    OnClickCard(card);
                });
            }

            if (firstCard == null)
            {
                firstCard = card;
            }
        }

        // Instantiate error cards.
        foreach (ErrorInFolder error in allErrors)
        {
            GameObject card    = null;
            string     message = $"An error occurred when loading {error.trackFile}:\n\n{error.message}";

            // Instantiate card.
            card = Instantiate(errorCardTemplate,
                               trackGrid.transform);
            card.name = "Error Card";
            card.SetActive(true);

            // Record mapping.
            cardToError.Add(card, message);

            // Bind click event.
            card.GetComponent <Button>().onClick.AddListener(() =>
            {
                OnClickErrorCard(card);
            });

            if (firstCard == null)
            {
                firstCard = card;
            }
        }

        if (ShowNewTrackCard())
        {
            newTrackCard.transform.SetAsLastSibling();
            newTrackCard.SetActive(true);
            newTrackCard.GetComponent <Button>().onClick
            .RemoveAllListeners();
            newTrackCard.GetComponent <Button>().onClick
            .AddListener(() =>
            {
                OnClickNewTrackCard();
            });

            if (firstCard == null)
            {
                firstCard = newTrackCard;
            }
        }

        EventSystem.current.SetSelectedGameObject(firstCard);
        noTrackText.SetActive(firstCard == null);
    }
Example #22
0
    protected void Refresh()
    {
        // Remove all objects from grid, except for templates.
        for (int i = 0; i < trackGrid.transform.childCount; i++)
        {
            GameObject o = trackGrid.transform.GetChild(i).gameObject;
            if (o == trackCardTemplate)
            {
                continue;
            }
            if (o == errorCardTemplate)
            {
                continue;
            }
            if (o == newTrackCard)
            {
                continue;
            }
            Destroy(o);
        }

        // Rebuild track list.
        cardToTrack = new Dictionary <GameObject, TrackInFolder>();
        cardToError = new Dictionary <GameObject, string>();
        GameObject firstCard = null;

        foreach (string dir in Directory.EnumerateDirectories(
                     Paths.GetTrackFolder()))
        {
            // Is there a track?
            string possibleTrackFile = $"{dir}\\{Paths.kTrackFilename}";
            if (!File.Exists(possibleTrackFile))
            {
                continue;
            }

            // Attempt to load track.
            TrackBase trackBase = null;
            string    error     = null;
            bool      upgraded  = false;
            try
            {
                trackBase = TrackBase.LoadFromFile(possibleTrackFile);
                if (trackBase is TrackV1)
                {
                    // Attempt upgrade.
                    trackBase = (trackBase as TrackV1).Upgrade();
                    upgraded  = true;
                }
                if (!(trackBase is Track))
                {
                    error = "The track was created in an old version and is no longer supported.";
                }
            }
            catch (Exception e)
            {
                error = e.Message;
            }

            GameObject card = null;
            if (error == null)
            {
                Track track = trackBase as Track;

                // Instantiate card.
                card = Instantiate(trackCardTemplate,
                                   trackGrid.transform);
                card.name = "Track Card";
                card.SetActive(true);
                card.GetComponent <TrackCard>().Initialize(
                    dir, track.trackMetadata);

                // Record mapping.
                cardToTrack.Add(card, new TrackInFolder()
                {
                    folder = dir,
                    track  = track
                });

                if (upgraded && ShowUpgradeNoticeOnOutdatedTracks())
                {
                    // Bind click event.
                    card.GetComponent <Button>().onClick
                    .AddListener(() =>
                    {
                        OnClickCardWithUpgradeNotice(card);
                    });
                }
                else
                {
                    // Bind click event.
                    card.GetComponent <Button>().onClick
                    .AddListener(() =>
                    {
                        OnClickCard(card);
                    });
                }
            }
            else
            {
                error = $"An error occurred when loading {possibleTrackFile}:\n\n"
                        + error;

                // Instantiate card.
                card = Instantiate(errorCardTemplate,
                                   trackGrid.transform);
                card.name = "Error Card";
                card.SetActive(true);

                // Record mapping.
                cardToError.Add(card, error);

                // Bind click event.
                card.GetComponent <Button>().onClick.AddListener(() =>
                {
                    OnClickErrorCard(card);
                });
            }

            if (firstCard == null)
            {
                firstCard = card;
            }
        }

        if (ShowNewTrackCard())
        {
            newTrackCard.transform.SetAsLastSibling();
            newTrackCard.SetActive(true);
            newTrackCard.GetComponent <Button>().onClick
            .RemoveAllListeners();
            newTrackCard.GetComponent <Button>().onClick
            .AddListener(() =>
            {
                OnClickNewTrackCard();
            });

            if (firstCard == null)
            {
                firstCard = newTrackCard;
            }
        }

        EventSystem.current.SetSelectedGameObject(firstCard);
        noTrackText.SetActive(firstCard == null);
    }
 /// <summary>
 /// Update an Track
 /// </summary>
 /// <remarks>
 /// Updates an existing Track in the asset
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group within the Azure subscription.
 /// </param>
 /// <param name='accountName'>
 /// The Media Services account name.
 /// </param>
 /// <param name='assetName'>
 /// The Asset name.
 /// </param>
 /// <param name='trackName'>
 /// The Asset Track name.
 /// </param>
 /// <param name='track'>
 /// Detailed information about a track in the asset.
 /// </param>
 public static AssetTrack BeginUpdate(this ITracksOperations operations, string resourceGroupName, string accountName, string assetName, string trackName, TrackBase track = default(TrackBase))
 {
     return(operations.BeginUpdateAsync(resourceGroupName, accountName, assetName, trackName, track).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Update an Track
 /// </summary>
 /// <remarks>
 /// Updates an existing Track in the asset
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group within the Azure subscription.
 /// </param>
 /// <param name='accountName'>
 /// The Media Services account name.
 /// </param>
 /// <param name='assetName'>
 /// The Asset name.
 /// </param>
 /// <param name='trackName'>
 /// The Asset Track name.
 /// </param>
 /// <param name='track'>
 /// Detailed information about a track in the asset.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <AssetTrack> BeginUpdateAsync(this ITracksOperations operations, string resourceGroupName, string accountName, string assetName, string trackName, TrackBase track = default(TrackBase), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, accountName, assetName, trackName, track, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }